Fix array underrun when searching for highest used object

This commit is contained in:
Kp 2012-12-02 23:47:41 +00:00
parent a8f8bb3682
commit caaf44e358
2 changed files with 24 additions and 2 deletions

View file

@ -994,7 +994,18 @@ void obj_free(int objnum)
Assert(num_objects >= 0);
if (objnum == Highest_object_index)
while (Objects[--Highest_object_index].type == OBJ_NONE);
{
int o = Highest_object_index;
for (;;)
{
--o;
if (Objects[o].type != OBJ_NONE)
break;
if (o == 0)
break;
}
Highest_object_index = o;
}
}
//-----------------------------------------------------------------------------

View file

@ -1147,7 +1147,18 @@ void obj_free(int objnum)
Assert(num_objects >= 0);
if (objnum == Highest_object_index)
while (Objects[--Highest_object_index].type == OBJ_NONE);
{
int o = Highest_object_index;
for (;;)
{
--o;
if (Objects[o].type != OBJ_NONE)
break;
if (o == 0)
break;
}
Highest_object_index = o;
}
}
//-----------------------------------------------------------------------------