strlcpy(sv.model_precache[0], "", sizeof(sv.model_precache[0]));
strlcpy(sv.model_precache[1], sv.modelname, sizeof(sv.model_precache[1]));
- for (i = 1;i < sv.worldmodel->brush.numsubmodels;i++)
+ for (i = 1;i < sv.worldmodel->brush.numsubmodels && i+1 < MAX_MODELS;i++)
{
dpsnprintf(sv.model_precache[i+1], sizeof(sv.model_precache[i+1]), "*%i", i);
sv.models[i+1] = Mod_ForName (sv.model_precache[i+1], false, false, sv.modelname);
if (ent->fields.server->solid == SOLID_BSP)
{
int modelindex = (int)ent->fields.server->modelindex;
- if (modelindex < 0 || modelindex > MAX_MODELS)
+ if (modelindex < 0 || modelindex >= MAX_MODELS)
{
Con_Printf("edict %i: SOLID_BSP with invalid modelindex!\n", PRVM_NUM_FOR_EDICT(ent));
modelindex = 0;
return 2;
modelindex = (int)ent->fields.server->modelindex;
- if (modelindex <= 0 || modelindex > MAX_MODELS)
+ if (modelindex <= 0 || modelindex >= MAX_MODELS)
return 3;
model = sv.models[modelindex];
modelindex = (int)ent->fields.server->modelindex;
tag_index = 0;
- if (modelindex <= 0 || modelindex > MAX_MODELS)
+ if (modelindex <= 0 || modelindex >= MAX_MODELS)
Con_DPrintf("gettagindex(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(ent));
else
{
return;
}
i = (int)PRVM_G_FLOAT(OFS_PARM1);
- if (i <= 0 || i > MAX_MODELS)
+ if (i <= 0 || i >= MAX_MODELS)
{
VM_Warning("setmodelindex: invalid modelindex\n");
return;
PRVM_G_INT(OFS_RETURN) = OFS_NULL;
i = (int)PRVM_G_FLOAT(OFS_PARM0);
- if (i <= 0 || i > MAX_MODELS)
+ if (i <= 0 || i >= MAX_MODELS)
{
VM_Warning("modelnameforindex: invalid modelindex\n");
return;