safeguard FloodParts and kill_part (#717)
This commit is contained in:
parent
49963980e6
commit
dda7747688
@ -1355,6 +1355,10 @@ int LuaScriptInterface::simulation_floodParts(lua_State * l)
|
|||||||
int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID());
|
int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID());
|
||||||
int cm = luaL_optint(l,4,-1);
|
int cm = luaL_optint(l,4,-1);
|
||||||
int flags = luaL_optint(l,5,luacon_sim->replaceModeFlags);
|
int flags = luaL_optint(l,5,luacon_sim->replaceModeFlags);
|
||||||
|
|
||||||
|
if (x < CELL || x >= XRES-CELL || y < CELL || y >= YRES-CELL)
|
||||||
|
return luaL_error(l, "coordinates out of range (%d,%d)", x, y);
|
||||||
|
|
||||||
int ret = luacon_sim->FloodParts(x, y, c, cm, flags);
|
int ret = luacon_sim->FloodParts(x, y, c, cm, flags);
|
||||||
lua_pushinteger(l, ret);
|
lua_pushinteger(l, ret);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1900,6 +1900,7 @@ int Simulation::FloodParts(int x, int y, int fullc, int cm, int flags)
|
|||||||
return 1;
|
return 1;
|
||||||
else if (x < 0 || x >= XRES || y < 0 || y >= YRES)
|
else if (x < 0 || x >= XRES || y < 0 || y >= YRES)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
{
|
{
|
||||||
cm = TYP(pmap[y][x]);
|
cm = TYP(pmap[y][x]);
|
||||||
@ -1918,6 +1919,7 @@ int Simulation::FloodParts(int x, int y, int fullc, int cm, int flags)
|
|||||||
else
|
else
|
||||||
cm = 0;
|
cm = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != 0 && IsWallBlocking(x, y, c))
|
if (c != 0 && IsWallBlocking(x, y, c))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -3036,6 +3038,9 @@ int Simulation::get_normal_interp(int pt, float x0, float y0, float dx, float dy
|
|||||||
|
|
||||||
void Simulation::kill_part(int i)//kills particle number i
|
void Simulation::kill_part(int i)//kills particle number i
|
||||||
{
|
{
|
||||||
|
if (i < 0 || i >= NPART)
|
||||||
|
return;
|
||||||
|
|
||||||
int x = (int)(parts[i].x + 0.5f);
|
int x = (int)(parts[i].x + 0.5f);
|
||||||
int y = (int)(parts[i].y + 0.5f);
|
int y = (int)(parts[i].y + 0.5f);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user