Fix off-by-one issue in sim.parts, fixes #678

This commit is contained in:
jacob1
2019-09-15 15:37:51 -04:00
parent 66ef37e778
commit 28d5345bf9

View File

@@ -1893,11 +1893,9 @@ int PartsClosure(lua_State * l)
int i = lua_tointeger(l, lua_upvalueindex(1)); int i = lua_tointeger(l, lua_upvalueindex(1));
do do
{ {
if(i>=NPART) if (++i >= NPART)
return 0; return 0;
else } while (!luacon_sim->parts[i].type);
i++;
} while(!luacon_sim->parts[i].type);
lua_pushnumber(l, i); lua_pushnumber(l, i);
lua_replace(l, lua_upvalueindex(1)); lua_replace(l, lua_upvalueindex(1));
lua_pushnumber(l, i); lua_pushnumber(l, i);