Added a check to avoid packed from being out of bounds in MSG_PackCoord()

This commit is contained in:
smallmodel committed 2023-08-17 18:24:50 +02:00
1 parent d80e9d80e7
commit a9374f068b
1 file changed
+5 -1
+5 -1
View File
@@ -2157,7 +2157,11 @@ int MSG_PackAlpha(float alpha, int bits)
int MSG_PackCoord(float coord)
{
unsigned int packed = (unsigned int)round(coord * 4.0 + MAX_PACKED_COORD_HALF);
coordstats[packed]++;
if (packed >= MAX_PACKED_COORD) {
Com_DPrintf("Illegal XYZ coordinates for an entity, small information lost in transmission\n");
} else {
coordstats[packed]++;
}
return packed;
}