diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 418e4ba86..5715a09c0 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.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); } } diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp index e18ad284a..c88314302 100644 --- a/src/simulation/elements/SOAP.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -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