make sure soap doesn't crash when messed with in the console

This commit is contained in:
jacob1 2014-08-25 19:05:32 -04:00
parent b20db5fb8a
commit 2140beb9cc
2 changed files with 6 additions and 1 deletions

View File

@ -1365,7 +1365,7 @@ void Renderer::render_parts()
{ {
if (t==PT_SOAP) if (t==PT_SOAP)
{ {
if ((parts[i].ctype&7) == 7) if ((parts[i].ctype&7) == 7 && parts[i].tmp >= 0 && parts[i].tmp < NPART && parts[i].tmp2 >= 0 && parts[i].tmp2 < NPART)
draw_line(nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), colr, colg, colb, cola); draw_line(nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), colr, colg, colb, cola);
} }
} }

View File

@ -104,6 +104,11 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
{ {
if (parts[i].temp>FREEZING) if (parts[i].temp>FREEZING)
{ {
if (parts[i].tmp < 0 || parts[i].tmp >= NPART || parts[i].tmp2 < 0 || parts[i].tmp2 >= NPART)
{
parts[i].tmp = parts[i].tmp2 = parts[i].ctype = 0;
return 0;
}
if (parts[i].life<=0) if (parts[i].life<=0)
{ {
//if only connected on one side //if only connected on one side