]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Kill csqcentityglobalhistory.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 6 Jan 2014 09:48:43 +0000 (09:48 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 6 Jan 2014 09:48:43 +0000 (09:48 +0000)
From: Rudolf Polzer <divverent@xonotic.org>

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12037 d7cf8633-e32d-0410-b094-e92efae38249

protocol.c
server.h
sv_main.c

index 7120e5460d2f5cf3f77c3281c08636f3f69aea91..64f42dea7101463db47a12fdb453af46290984f8 100644 (file)
                Con_Printf("sent entity update of size %u for %d classname %s flags %d\n", (msg->cursize - entityprofiling_startsize), num, PRVM_serveredictstring(ed, classname) ? PRVM_GetString(prog, PRVM_serveredictstring(ed, classname)) : "(no classname)", flags); \
        }
 
-// CSQC entity scope values.
-#define SCOPE_IGNORE 0
-#define SCOPE_REMOVE 1
-#define SCOPE_UPDATE 2
+// CSQC entity scope values. Bitflags!
+#define SCOPE_WANTREMOVE 1  // Set if a remove has been scheduled. Has priority over WANTUPDATE.
+#define SCOPE_WANTUPDATE 2  // Set if an update has been scheduled.
+#define SCOPE_WANTSEND (SCOPE_WANTREMOVE | SCOPE_WANTUPDATE)
+#define SCOPE_EXISTED_ONCE 4
 
 // this is 88 bytes (must match entity_state_t in protocol.h)
 entity_state_t defaultstate =
@@ -284,14 +285,14 @@ static void EntityFrameCSQC_LostAllFrames(client_t *client)
        n = client->csqcnumedicts;
        for(i = 0; i < n; ++i)
        {
-               if(client->csqcentityglobalhistory[i])
+               if(client->csqcentityscope[i] & SCOPE_EXISTED_ONCE)
                {
                        ed = prog->edicts + i;
                        if (PRVM_serveredictfunction(ed, SendEntity))
                                client->csqcentitysendflags[i] |= 0xFFFFFF; // FULL RESEND
                        else // if it was ever sent to that client as a CSQC entity
                        {
-                               client->csqcentityscope[i] = SCOPE_REMOVE;
+                               client->csqcentityscope[i] |= SCOPE_WANTREMOVE;
                                client->csqcentitysendflags[i] |= 0xFFFFFF;
                        }
                }
@@ -403,7 +404,7 @@ void EntityFrameCSQC_LostFrame(client_t *client, int framenum)
                {
                        // a remove got lost, then either send a remove or - if it was
                        // recreated later - a FULL update to make totally sure
-                       client->csqcentityscope[i] = SCOPE_REMOVE;
+                       client->csqcentityscope[i] |= SCOPE_WANTREMOVE;
                        client->csqcentitysendflags[i] = 0xFFFFFF;
                }
                else
@@ -466,18 +467,21 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
                end = *n;
                for (;number < end;number++)
                {
-                       if (client->csqcentityscope[number] != SCOPE_IGNORE)
+                       if (client->csqcentityscope[number] & SCOPE_WANTSEND)
                        {
-                               client->csqcentityscope[number] = SCOPE_REMOVE;
+                               client->csqcentityscope[number] |= SCOPE_WANTREMOVE;
                                client->csqcentitysendflags[number] = 0xFFFFFF;
                        }
                }
                ed = prog->edicts + number;
                if (PRVM_serveredictfunction(ed, SendEntity))
-                       client->csqcentityscope[number] = SCOPE_UPDATE;
-               else if (client->csqcentityscope[number] != SCOPE_IGNORE)
                {
-                       client->csqcentityscope[number] = SCOPE_REMOVE;
+                       client->csqcentityscope[number] &= ~SCOPE_WANTREMOVE;
+                       client->csqcentityscope[number] |= SCOPE_WANTUPDATE;
+               }
+               else if (client->csqcentityscope[number] & SCOPE_WANTSEND)
+               {
+                       client->csqcentityscope[number] |= SCOPE_WANTREMOVE;
                        client->csqcentitysendflags[number] = 0xFFFFFF;
                }
                number++;
@@ -485,9 +489,9 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
        end = client->csqcnumedicts;
        for (;number < end;number++)
        {
-               if (client->csqcentityscope[number] != SCOPE_IGNORE)
+               if (client->csqcentityscope[number] & SCOPE_WANTSEND)
                {
-                       client->csqcentityscope[number] = SCOPE_REMOVE;
+                       client->csqcentityscope[number] |= SCOPE_WANTREMOVE;
                        client->csqcentitysendflags[number] = 0xFFFFFF;
                }
        }
@@ -497,7 +501,7 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
        end = client->csqcnumedicts;
        for (number = 1;number < end;number++)
        {
-               if (client->csqcentityscope[number] == SCOPE_IGNORE)
+               if (!(client->csqcentityscope[number] & SCOPE_WANTSEND))
                        continue;
                sendflags = client->csqcentitysendflags[number];
                if (!sendflags)
@@ -505,8 +509,7 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
                if(db->num >= NUM_CSQCENTITIES_PER_FRAME)
                        break;
                ed = prog->edicts + number;
-               // entity scope is either update (2) or remove (1)
-               if (client->csqcentityscope[number] == SCOPE_REMOVE)
+               if (client->csqcentityscope[number] & SCOPE_WANTREMOVE)
                {
                        // write a remove message
                        // first write the message identifier if needed
@@ -520,12 +523,12 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
                        {
                                ENTITYSIZEPROFILING_START(msg, number, 0);
                                MSG_WriteShort(msg, (unsigned short)number | 0x8000);
-                               client->csqcentityscope[number] = SCOPE_IGNORE;
+                               client->csqcentityscope[number] &= ~SCOPE_WANTSEND;
                                client->csqcentitysendflags[number] = 0xFFFFFF; // resend completely if it becomes active again
                                db->entno[db->num] = number;
                                db->sendflags[db->num] = -1;
                                db->num += 1;
-                               client->csqcentityglobalhistory[number] = 1;
+                               client->csqcentityscope[number] |= SCOPE_EXISTED_ONCE;
                                ENTITYSIZEPROFILING_END(msg, number, 0);
                        }
                        if (msg->cursize + 17 >= maxsize)
@@ -536,7 +539,6 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
                        // write an update
                        // save the cursize value in case we overflow and have to rollback
                        int oldcursize = msg->cursize;
-                       client->csqcentityscope[number] = SCOPE_REMOVE;
                        if (PRVM_serveredictfunction(ed, SendEntity))
                        {
                                if(!sectionstarted)
@@ -561,12 +563,12 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
                                                        if(!sectionstarted)
                                                                MSG_WriteByte(msg, svc_csqcentities);
                                                        MSG_WriteShort(msg, (unsigned short)number | 0x8000);
-                                                       client->csqcentityscope[number] = SCOPE_IGNORE;
+                                                       client->csqcentityscope[number] &= ~SCOPE_WANTSEND;
                                                        client->csqcentitysendflags[number] = 0xFFFFFF; // resend completely if it becomes active again
                                                        db->entno[db->num] = number;
                                                        db->sendflags[db->num] = -1;
                                                        db->num += 1;
-                                                       client->csqcentityglobalhistory[number] = 1;
+                                                       client->csqcentityscope[number] |= SCOPE_EXISTED_ONCE;
                                                        // and take note that we have begun the svc_csqcentities
                                                        // section of the packet
                                                        sectionstarted = 1;
@@ -584,7 +586,7 @@ qboolean EntityFrameCSQC_WriteFrame (sizebuf_t *msg, int maxsize, int numnumbers
                                                db->entno[db->num] = number;
                                                db->sendflags[db->num] = sendflags;
                                                db->num += 1;
-                                               client->csqcentityglobalhistory[number] = 1;
+                                               client->csqcentityscope[number] |= SCOPE_EXISTED_ONCE;
                                                // and take note that we have begun the svc_csqcentities
                                                // section of the packet
                                                sectionstarted = 1;
index 0dfaf0342255f5ba4f567576026d81f17b85849e..e277e75e9d7008e1d8f52eb945f01b78a0975ced 100644 (file)
--- a/server.h
+++ b/server.h
@@ -263,7 +263,6 @@ typedef struct client_s
        unsigned int csqcentitysendflags[MAX_EDICTS];
 
 #define NUM_CSQCENTITYDB_FRAMES 256
-       unsigned char csqcentityglobalhistory[MAX_EDICTS]; // set to 1 if the entity was ever csqc networked to the client, and never reset back to 0
        csqcentityframedb_t csqcentityframehistory[NUM_CSQCENTITYDB_FRAMES];
        int csqcentityframehistory_next;
        int csqcentityframe_lastreset;
index 84a4d8c3fbf98e1687221b46dafb2992d15a57a5..d89c2dded52cd6465194b9e483c02755558596b8 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -914,7 +914,6 @@ void SV_SendServerinfo (client_t *client)
        {
                client->csqcentityscope[i] = 0;
                client->csqcentitysendflags[i] = 0xFFFFFF;
-               client->csqcentityglobalhistory[i] = 0;
        }
        for (i = 0;i < NUM_CSQCENTITYDB_FRAMES;i++)
        {