Permalink
Browse files

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

  • Loading branch information...
jacob1 committed Aug 25, 2014
1 parent b20db5f commit 2140beb9ccf0e414f8fa92328333d062e5e10942
Showing with 6 additions and 1 deletion.
  1. +1 −1 src/graphics/Renderer.cpp
  2. +5 −0 src/simulation/elements/SOAP.cpp
@@ -1365,7 +1365,7 @@ void Renderer::render_parts()
{
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);
}
}
@@ -104,6 +104,11 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
{
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 only connected on one side

0 comments on commit 2140beb

Please sign in to comment.