]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_user.c
Cleaned up alot more memory leaks. (still get 720 leaks just running demo1.dem)
[xonotic/darkplaces.git] / sv_user.c
index a2057f07beded4e88396bf693660579562d71e98..7015dd5011f4b35539296d0df1e9be79bea43710 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -630,7 +630,7 @@ void SV_ReadClientMove (usercmd_t *move)
                        angle[i] = MSG_ReadAngle8i();
                else if (sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3)
                        angle[i] = MSG_ReadAngle32f();
-               else if (sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5)
+               else if (sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5 || sv.protocol == PROTOCOL_DARKPLACES6)
                        angle[i] = MSG_ReadAngle16i();
                if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
        }
@@ -653,7 +653,10 @@ void SV_ReadClientMove (usercmd_t *move)
        }
 
        // read buttons
-       bits = MSG_ReadByte ();
+       if (sv.protocol == PROTOCOL_DARKPLACES6)
+               bits = MSG_ReadLong ();
+       else
+               bits = MSG_ReadByte ();
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
        host_client->edict->v->button0 = bits & 1;
        host_client->edict->v->button2 = (bits & 2)>>1;
@@ -664,11 +667,59 @@ void SV_ReadClientMove (usercmd_t *move)
        if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button6))) val->_float = ((bits >> 5) & 1);
        if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button7))) val->_float = ((bits >> 6) & 1);
        if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button8))) val->_float = ((bits >> 7) & 1);
+       if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_buttonuse))) val->_float = ((bits >> 8) & 1);
+       if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_buttonchat))) val->_float = ((bits >> 9) & 1);
+       if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_cursor_active))) val->_float = ((bits >> 10) & 1);
 
        i = MSG_ReadByte ();
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
        if (i)
                host_client->edict->v->impulse = i;
+
+       // PRYDON_CLIENTCURSOR
+       if (sv.protocol == PROTOCOL_DARKPLACES6)
+       {
+               // 30 bytes
+               move->cursor_screen[0] = MSG_ReadShort() * (1.0f / 32767.0f);
+               move->cursor_screen[1] = MSG_ReadShort() * (1.0f / 32767.0f);
+               move->cursor_start[0] = MSG_ReadFloat();
+               move->cursor_start[1] = MSG_ReadFloat();
+               move->cursor_start[2] = MSG_ReadFloat();
+               move->cursor_impact[0] = MSG_ReadFloat();
+               move->cursor_impact[1] = MSG_ReadFloat();
+               move->cursor_impact[2] = MSG_ReadFloat();
+               move->cursor_entitynumber = (unsigned short)MSG_ReadShort();
+               if (move->cursor_entitynumber >= sv.max_edicts)
+               {
+                       Con_DPrintf("SV_ReadClientMessage: client send bad cursor_entitynumber\n");
+                       move->cursor_entitynumber = 0;
+               }
+               // as requested by FrikaC, cursor_trace_ent is reset to world if the
+               // entity is free at time of receipt
+               if (EDICT_NUM(move->cursor_entitynumber)->e->free)
+                       move->cursor_entitynumber = 0;
+               if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
+       }
+       if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_cursor_screen))) VectorCopy(move->cursor_screen, val->vector);
+       if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_start))) VectorCopy(move->cursor_start, val->vector);
+       if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_endpos))) VectorCopy(move->cursor_impact, val->vector);
+       if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_ent))) val->edict = EDICT_TO_PROG(EDICT_NUM(move->cursor_entitynumber));
+}
+
+void SV_FrameLost(int framenum)
+{
+       if (host_client->entitydatabase5)
+               EntityFrame5_LostFrame(host_client->entitydatabase5, framenum, host_client - svs.clients + 1);
+}
+
+void SV_FrameAck(int framenum)
+{
+       if (host_client->entitydatabase)
+               EntityFrame_AckFrame(host_client->entitydatabase, framenum);
+       else if (host_client->entitydatabase4)
+               EntityFrame4_AckFrame(host_client->entitydatabase4, framenum, true);
+       else if (host_client->entitydatabase5)
+               EntityFrame5_AckFrame(host_client->entitydatabase5, framenum);
 }
 
 /*
@@ -742,6 +793,8 @@ void SV_ReadClientMessage(void)
                         || strncasecmp(s, "ban", 3) == 0
                         || strncasecmp(s, "pmodel", 6) == 0
                         || strncasecmp(s, "rate", 4) == 0
+                        || strncasecmp(s, "playermodel", 11) == 0
+                        || strncasecmp(s, "playerskin", 10) == 0
                         || (gamemode == GAME_NEHAHRA && (strncasecmp(s, "max", 3) == 0 || strncasecmp(s, "monster", 7) == 0 || strncasecmp(s, "scrag", 5) == 0 || strncasecmp(s, "gimme", 5) == 0 || strncasecmp(s, "wraith", 6) == 0))
                         || (gamemode != GAME_NEHAHRA && (strncasecmp(s, "god", 3) == 0 || strncasecmp(s, "notarget", 8) == 0 || strncasecmp(s, "fly", 3) == 0 || strncasecmp(s, "give", 4) == 0 || strncasecmp(s, "noclip", 6) == 0)))
                                Cmd_ExecuteString (s, src_client);
@@ -757,18 +810,20 @@ void SV_ReadClientMessage(void)
                        SV_ReadClientMove (&host_client->cmd);
                        break;
 
-               case clc_ackentities:
+               case clc_ackframe:
                        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
                        num = MSG_ReadLong();
                        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
                        if (developer_networkentities.integer >= 1)
-                               Con_Printf("recv clc_ackentities %i\n", num);
-                       if (host_client->entitydatabase)
-                               EntityFrame_AckFrame(host_client->entitydatabase, num);
-                       else if (host_client->entitydatabase4)
-                               EntityFrame4_AckFrame(host_client->entitydatabase4, num, true);
-                       else if (host_client->entitydatabase5)
-                               EntityFrame5_AckFrame(host_client->entitydatabase5, num, host_client - svs.clients + 1);
+                               Con_Printf("recv clc_ackframe %i\n", num);
+                       if (host_client->latestframenum < num)
+                       {
+                               int i;
+                               for (i = host_client->latestframenum + 1;i < num;i++)
+                                       SV_FrameLost(i);
+                               SV_FrameAck(num);
+                               host_client->latestframenum = num;
+                       }
                        break;
                }
        }