diff --git a/d1x-rebirth/main/object.c b/d1x-rebirth/main/object.c index 5685b6d46..0e5db9b9c 100644 --- a/d1x-rebirth/main/object.c +++ b/d1x-rebirth/main/object.c @@ -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; + } } //----------------------------------------------------------------------------- diff --git a/d2x-rebirth/main/object.c b/d2x-rebirth/main/object.c index 27c9ba181..ef04195d0 100644 --- a/d2x-rebirth/main/object.c +++ b/d2x-rebirth/main/object.c @@ -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; + } } //-----------------------------------------------------------------------------