2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Merge pull request #314 from In-line/move_numleafs_check_to_model_load

Move model->numleafs check to Mod_LoadLeafs
This commit is contained in:
theAsmodai 2017-01-21 14:23:09 +03:00 committed by GitHub
commit 47964c847b
2 changed files with 14 additions and 2 deletions

View File

@ -47,15 +47,18 @@ unsigned char *Mod_DecompressVis(unsigned char *in, model_t *model)
{
return mod_novis;
}
#ifdef REHLDS_FIXES
CM_DecompressPVS(in, decompressed, (model->numleafs + 7) / 8);
#else
int row = (model->numleafs + 7) / 8;
// TODO: Move to model loading code
if (row < 0 || row > MODEL_MAX_PVS)
{
Sys_Error(__FUNCTION__ ": oversized model->numleafs: %i", model->numleafs);
}
CM_DecompressPVS(in, decompressed, row);
#endif
return decompressed;
}

View File

@ -1033,7 +1033,16 @@ void Mod_LoadLeafs(lump_t *l)
loadmodel->leafs = out;
loadmodel->numleafs = count;
#ifdef REHLDS_FIXES
{
int row = (loadmodel->numleafs + 7) / 8;
if (row < 0 || row > MODEL_MAX_PVS)
{
Sys_Error(__FUNCTION__ ": oversized loadmodel->numleafs: %i", loadmodel->numleafs);
}
}
#endif
for (i = 0; i < count; i++, in++, out++)
{
for (j = 0; j < 3; j++)