diff --git a/rehlds/engine/cmodel.cpp b/rehlds/engine/cmodel.cpp index 21d6ae4..8bd9edf 100644 --- a/rehlds/engine/cmodel.cpp +++ b/rehlds/engine/cmodel.cpp @@ -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; } diff --git a/rehlds/engine/model.cpp b/rehlds/engine/model.cpp index c6283fc..d8796b5 100644 --- a/rehlds/engine/model.cpp +++ b/rehlds/engine/model.cpp @@ -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++)