Fix elem.allocate corrupting LSI when running out of IDs

The can_move bits weren't guarded by newID != -1.
This commit is contained in:
Tamás Bálint Misius 2021-07-14 07:29:50 +02:00
parent e80dc7b114
commit a463180e2a
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -2821,14 +2821,14 @@ int LuaScriptInterface::elements_allocate(lua_State * l)
lua_pushinteger(l, newID);
lua_setfield(l, -2, identifier.c_str());
lua_pop(l, 1);
}
for (auto elem = 0; elem < PT_NUM; ++elem)
{
luacon_ci->custom_can_move[elem][newID] = 0;
luacon_ci->custom_can_move[newID][elem] = 0;
for (auto elem = 0; elem < PT_NUM; ++elem)
{
luacon_ci->custom_can_move[elem][newID] = 0;
luacon_ci->custom_can_move[newID][elem] = 0;
}
luacon_ci->custom_init_can_move();
}
luacon_ci->custom_init_can_move();
lua_pushinteger(l, newID);
return 1;