diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index a3981cac7c..a0e8244d50 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -3618,7 +3618,9 @@ void Simulation::UpdateParticles(int start, int end) s = 0; else if (parts[i].ctype==PT_TUNG) { - if (pt>=3695.0) + // TUNG does its own melting in its update function, so HighTemperatureTransition is not LAVA so it won't be handled by the code for HighTemperatureTransition==PT_LAVA below + // However, the threshold is stored in HighTemperature to allow it to be changed from Lua + if (pt>=elements[parts[i].ctype].HighTemperature) s = 0; } else if (elements[parts[i].ctype].HighTemperatureTransition == PT_LAVA) diff --git a/src/simulation/elements/LAVA.cpp b/src/simulation/elements/LAVA.cpp index b52c61ec1a..e617071ef9 100644 --- a/src/simulation/elements/LAVA.cpp +++ b/src/simulation/elements/LAVA.cpp @@ -37,7 +37,7 @@ Element_LAVA::Element_LAVA() LowPressureTransition = NT; HighPressure = IPH; HighPressureTransition = NT; - LowTemperature = 3695.0f;// Highest temperature at which any type of lava can solidify + LowTemperature = MAX_TEMP;// check for lava solidification at all temperatures LowTemperatureTransition = ST; HighTemperature = ITH; HighTemperatureTransition = NT; diff --git a/src/simulation/elements/TUNG.cpp b/src/simulation/elements/TUNG.cpp index 370e29f36b..64a43d2e00 100644 --- a/src/simulation/elements/TUNG.cpp +++ b/src/simulation/elements/TUNG.cpp @@ -40,22 +40,20 @@ Element_TUNG::Element_TUNG() HighPressureTransition = NT; LowTemperature = ITL; LowTemperatureTransition = NT; - HighTemperature = ITH; + HighTemperature = 3695.0f;// TUNG melts in its update function instead of in the normal way, but store the threshold here so that it can be changed from Lua HighTemperatureTransition = NT; - /*HighTemperature = 3895.0f; - HighTemperatureTransition = PT_LAVA;*/ Update = &Element_TUNG::update; Graphics = &Element_TUNG::graphics; } -#define MELTING_POINT 3695.0 - //#TPT-Directive ElementHeader Element_TUNG static int update(UPDATE_FUNC_ARGS) int Element_TUNG::update(UPDATE_FUNC_ARGS) { bool splode = false; + const float MELTING_POINT = sim->elements[PT_TUNG].HighTemperature; + if(parts[i].temp > 2400.0) { int r, rx, ry; @@ -90,7 +88,7 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS) } if(splode) { - parts[i].temp = MELTING_POINT + (rand()%600) + 200; + parts[i].temp = restrict_flt(MELTING_POINT + (rand()%600) + 200, MIN_TEMP, MAX_TEMP); } parts[i].vx += (rand()%100)-50; parts[i].vy += (rand()%100)-50; @@ -111,6 +109,7 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS) //#TPT-Directive ElementHeader Element_TUNG static int graphics(GRAPHICS_FUNC_ARGS) int Element_TUNG::graphics(GRAPHICS_FUNC_ARGS) { + const float MELTING_POINT = ren->sim->elements[PT_TUNG].HighTemperature; double startTemp = (MELTING_POINT - 1500.0); double tempOver = (((cpart->temp - startTemp)/1500.0)*M_PI) - (M_PI/2.0); if(tempOver > -(M_PI/2.0))