Fix Lua 'searchBlockmap'

This commit is contained in:
Lactozilla 2024-02-12 16:28:32 -03:00
parent 3087107175
commit a709ff9ecd
2 changed files with 5 additions and 12 deletions

View file

@ -312,17 +312,12 @@ static int lib_searchBlockmap(lua_State *L)
continue; // our thing just found itself, so move on continue; // our thing just found itself, so move on
funcret = lib_searchBlockmap_Objects(L, mobj, itmobj); funcret = lib_searchBlockmap_Objects(L, mobj, itmobj);
if (funcret == 2) { if (funcret == 2 || P_MobjWasRemoved(mobj)) {
lua_pushboolean(L, false);
return 1;
}
else if (funcret == 1)
retval = false;
if (P_MobjWasRemoved(mobj)) {
retval = false; retval = false;
break; break;
} }
else if (funcret == 1)
retval = false;
} }
} }
while (itmobj != NULL); while (itmobj != NULL);

View file

@ -1095,8 +1095,6 @@ bthingit_t *P_NewBlockThingsIterator(int x1, int y1, int x2, int y2)
return NULL; return NULL;
block = GetBlockmapBlock(x1, y1); block = GetBlockmapBlock(x1, y1);
if (!block)
return NULL;
if (freeiters != NULL) if (freeiters != NULL)
{ {
@ -1188,12 +1186,12 @@ mobj_t *P_BlockThingsIteratorNext(bthingit_t *it, boolean centeronly)
if (!it->dynhash) if (!it->dynhash)
{ {
it->dynhashcapacity = 50; it->dynhashcapacity = 50;
Z_Calloc(it->dynhashcapacity * sizeof(it->dynhashcapacity), PU_LEVEL, &it->dynhash); Z_Calloc(it->dynhashcapacity * sizeof(*it->dynhash), PU_LEVEL, &it->dynhash);
} }
if (it->dynhashcount == it->dynhashcapacity) if (it->dynhashcount == it->dynhashcapacity)
{ {
it->dynhashcapacity *= 2; it->dynhashcapacity *= 2;
it->dynhash = Z_Realloc(it->dynhash, it->dynhashcapacity * sizeof(it->dynhashcapacity), PU_LEVEL, &it->dynhash); it->dynhash = Z_Realloc(it->dynhash, it->dynhashcapacity * sizeof(*it->dynhash), PU_LEVEL, &it->dynhash);
} }
i = (int)it->dynhashcount; i = (int)it->dynhashcount;
it->dynhashcount++; it->dynhashcount++;