Skip to content

Commit

Permalink
Allow TUNG melting point to be changed from Lua
Browse files Browse the repository at this point in the history
Also set lava LowTemperature threshold to MAX_TEMP, to simplify changing melting points from Lua.
  • Loading branch information
jacksonmj committed Feb 23, 2015
1 parent b06af53 commit d71a0d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/simulation/Simulation.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/LAVA.cpp
Expand Up @@ -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;
Expand Down
11 changes: 5 additions & 6 deletions src/simulation/elements/TUNG.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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))
Expand Down

0 comments on commit d71a0d9

Please sign in to comment.