mirror of https://bitbucket.org/CPMADevs/cnq3
fixed new demo player not always writing to all entities in a snapshot
This commit is contained in:
parent
b36fce3234
commit
15bea75d06
|
@ -244,7 +244,7 @@ static void MB_GrowTo( memoryBuffer_t* mb, int numBytes )
|
||||||
if (mb->data && mb->capacity < numBytes) {
|
if (mb->data && mb->capacity < numBytes) {
|
||||||
byte* const oldData = mb->data;
|
byte* const oldData = mb->data;
|
||||||
numBytes = max(numBytes, mb->capacity * 2);
|
numBytes = max(numBytes, mb->capacity * 2);
|
||||||
mb->data = (byte*)malloc(numBytes);
|
mb->data = (byte*)calloc(numBytes, 1);
|
||||||
if (!mb->data) {
|
if (!mb->data) {
|
||||||
Drop("Ran out of memory");
|
Drop("Ran out of memory");
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ static void MB_GrowTo( memoryBuffer_t* mb, int numBytes )
|
||||||
Com_Memcpy(mb->data, oldData, mb->position);
|
Com_Memcpy(mb->data, oldData, mb->position);
|
||||||
free(oldData);
|
free(oldData);
|
||||||
} else if (!mb->data) {
|
} else if (!mb->data) {
|
||||||
mb->data = (byte*)malloc(numBytes);
|
mb->data = (byte*)calloc(numBytes, 1);
|
||||||
if (!mb->data) {
|
if (!mb->data) {
|
||||||
Drop("Ran out of memory");
|
Drop("Ran out of memory");
|
||||||
}
|
}
|
||||||
|
@ -631,6 +631,9 @@ static void ParseSnapshot()
|
||||||
|
|
||||||
// update our custom snapshot data structure
|
// update our custom snapshot data structure
|
||||||
ndpSnapshot_t* const currNDPSnap = parser.currSnap;
|
ndpSnapshot_t* const currNDPSnap = parser.currSnap;
|
||||||
|
for (int i = 0; i < MAX_GENTITIES; ++i) {
|
||||||
|
currNDPSnap->entities[i].number = MAX_GENTITIES - 1;
|
||||||
|
}
|
||||||
for (int i = 0; i < newSnap->numEntities; ++i) {
|
for (int i = 0; i < newSnap->numEntities; ++i) {
|
||||||
const int index = (newSnap->parseEntitiesNum + i) & (MAX_PARSE_ENTITIES - 1);
|
const int index = (newSnap->parseEntitiesNum + i) & (MAX_PARSE_ENTITIES - 1);
|
||||||
const entityState_t* const ent = &parser.entities[index];
|
const entityState_t* const ent = &parser.entities[index];
|
||||||
|
@ -896,8 +899,11 @@ static void ReadNextSnapshot()
|
||||||
}
|
}
|
||||||
qbool entSet[MAX_GENTITIES];
|
qbool entSet[MAX_GENTITIES];
|
||||||
Com_Memset(entSet, 0, sizeof(entSet));
|
Com_Memset(entSet, 0, sizeof(entSet));
|
||||||
|
int prevIndex = -1;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const int index = MSG_ReadBits(&inMsg, GENTITYNUM_BITS);
|
const int index = MSG_ReadBits(&inMsg, GENTITYNUM_BITS);
|
||||||
|
Q_assert(index > prevIndex);
|
||||||
|
prevIndex = index;
|
||||||
if (index == MAX_GENTITIES - 1) {
|
if (index == MAX_GENTITIES - 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -911,7 +917,7 @@ static void ReadNextSnapshot()
|
||||||
}
|
}
|
||||||
if (!isFullSnap) {
|
if (!isFullSnap) {
|
||||||
// copy over old valid entities and mark missing ones as invalid
|
// copy over old valid entities and mark missing ones as invalid
|
||||||
for (int i = 0; i < MAX_GENTITIES; ++i) {
|
for (int i = 0; i < MAX_GENTITIES - 1; ++i) {
|
||||||
if (entSet[i]) {
|
if (entSet[i]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue