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,10 +1893,8 @@ int PartsClosure(lua_State * l)
int i = lua_tointeger(l, lua_upvalueindex(1));
do
{
if(i>=NPART)
if (++i >= NPART)
return 0;
else
i++;
} while (!luacon_sim->parts[i].type);
lua_pushnumber(l, i);
lua_replace(l, lua_upvalueindex(1));