Created
July 13, 2015 07:09
-
-
Save entdark/e069057377d58b7a2b0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void demoCutParsePacketEntities(msg_t *msg, clSnapshot_t *oldSnap, clSnapshot_t *newSnap, clientActive_t *clCut) { | |
/* The beast that is entity parsing */ | |
int newnum; | |
entityState_t *oldstate, *newstate; | |
int oldindex = 0; | |
int oldnum; | |
newSnap->parseEntitiesNum = clCut->parseEntitiesNum; | |
newSnap->numEntities = 0; | |
newnum = MSG_ReadBits(msg, GENTITYNUM_BITS); | |
while (1) { | |
// read the entity index number | |
if (oldSnap && oldindex < oldSnap->numEntities) { | |
oldstate = &clCut->parseEntities[(oldSnap->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)]; | |
oldnum = oldstate->number; | |
} else { | |
oldstate = 0; | |
oldnum = 99999; | |
} | |
newstate = &clCut->parseEntities[clCut->parseEntitiesNum]; | |
if (!oldstate && (newnum == (MAX_GENTITIES-1))) { | |
break; | |
} else if (oldnum < newnum) { | |
*newstate = *oldstate; | |
oldindex++; | |
} else if (oldnum == newnum) { | |
oldindex++; | |
MSG_ReadDeltaEntity(msg, oldstate, newstate, newnum); | |
newnum = MSG_ReadBits(msg, GENTITYNUM_BITS); | |
} else if (oldnum > newnum) { | |
MSG_ReadDeltaEntity(msg, &clCut->entityBaselines[newnum], newstate, newnum); | |
newnum = MSG_ReadBits(msg, GENTITYNUM_BITS); | |
} | |
if (newstate->number == MAX_GENTITIES-1) | |
continue; | |
clCut->parseEntitiesNum++; | |
clCut->parseEntitiesNum &= (MAX_PARSE_ENTITIES-1); | |
newSnap->numEntities++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment