diff --git a/src/simulation/elements/RFGL.cpp b/src/simulation/elements/RFGL.cpp index 479204a61..74cb14829 100644 --- a/src/simulation/elements/RFGL.cpp +++ b/src/simulation/elements/RFGL.cpp @@ -27,13 +27,13 @@ Element_RFGL::Element_RFGL() Weight = 10; Temperature = R_TEMP + 273.15f; - HeatConduct = 0; + HeatConduct = 3; Description = "Liquid refrigerant."; Properties = TYPE_LIQUID|PROP_DEADLY; - LowPressure = IPL; - LowPressureTransition = NT; + LowPressure = 2; + LowPressureTransition = PT_RFRG; HighPressure = IPH; HighPressureTransition = NT; LowTemperature = ITL; @@ -41,52 +41,7 @@ Element_RFGL::Element_RFGL() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_RFGL::update; -} - -//#TPT-Directive ElementHeader Element_RFGL static int update(UPDATE_FUNC_ARGS) -int Element_RFGL::update(UPDATE_FUNC_ARGS) -{ - float pressure = sim->pv[y/CELL][x/CELL]; - if (pressure > parts[i].tmp) - parts[i].tmp = (int)pressure; - - if (pressure > -1 && pressure < 15 && parts[i].life > 0) - parts[i].life --; - - if (parts[i].temp >= 363.15f + (pressure * 6.0f)) - sim->part_change_type(i, x, y, PT_RFRG); - - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (BOUNDS_CHECK && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF) == PT_RFGL || (r&0xFF) == PT_RFRG) - { - float avgTemp = (parts[r>>8].temp + parts[i].temp) / 2; - parts[r>>8].temp = avgTemp; - parts[i].temp = avgTemp; - } - else - { - if (pressure > 20 && parts[i].temp > 273.15f + 2.0f - (pressure - 20.0f) && sim->elements[r&0xFF].HeatConduct) - { - parts[r>>8].temp = restrict_flt(parts[r>>8].temp + 80.0f, 0.0f, MAX_TEMP); - parts[i].temp = restrict_flt(parts[i].temp - 80.0f, 0.0f, MAX_TEMP); - } - else if (parts[i].life == 0 && parts[r>>8].temp > 273.15f - 50.0f - (parts[i].tmp - 20.0f) && sim->elements[r&0xFF].HeatConduct) - { - parts[r>>8].temp = restrict_flt(parts[r>>8].temp - 80.0f, 273.15f - 50.0f - (parts[i].tmp - 20.0f), MAX_TEMP); - parts[i].temp = restrict_flt(parts[i].temp + 80.0f, 0.0f, 383.15f); - } - } - } - - return 0; + Update = &Element_RFRG::update; } Element_RFGL::~Element_RFGL() {} diff --git a/src/simulation/elements/RFRG.cpp b/src/simulation/elements/RFRG.cpp index 25163e464..c5741b686 100644 --- a/src/simulation/elements/RFRG.cpp +++ b/src/simulation/elements/RFRG.cpp @@ -28,14 +28,14 @@ Element_RFRG::Element_RFRG() Temperature = R_TEMP + 273.15f; HeatConduct = 3; - Description = "Refrigerant. Liquifies and transfers heat to other particles under pressure."; + Description = "Refrigerant. Heats up and liquifies under pressure."; Properties = TYPE_GAS|PROP_DEADLY; LowPressure = IPL; LowPressureTransition = NT; - HighPressure = IPH; - HighPressureTransition = NT; + HighPressure = 2; + HighPressureTransition = PT_RFGL; LowTemperature = ITL; LowTemperatureTransition = NT; HighTemperature = ITH; @@ -47,16 +47,15 @@ Element_RFRG::Element_RFRG() //#TPT-Directive ElementHeader Element_RFRG static int update(UPDATE_FUNC_ARGS) int Element_RFRG::update(UPDATE_FUNC_ARGS) { - if (sim->pv[y/CELL][x/CELL] > 15) - { - parts[i].temp += (sim->pv[y/CELL][x/CELL] - 15.0f) / 2.0f; - if (parts[i].temp >= 343.15f) - { - sim->part_change_type(i, x, y, PT_RFGL); - parts[i].life = 20; - } - } - + float new_pressure = sim->pv[y/CELL][x/CELL]; + float *old_pressure = (float *)&parts[i].tmp; + + // * 0 bar seems to be pressure value -256 in TPT, see Air.cpp. Also, 1 bar seems to be pressure value 0. + // With those two values we can set up our pressure scale which states that ... the highest pressure + // we can achieve in TPT is 2 bar. That's not particularly realistic, but good enough for TPT. + + parts[i].temp = restrict_flt(parts[i].temp * ((new_pressure + 257.f) / (*old_pressure + 257.f)), 0, MAX_TEMP); + *old_pressure = new_pressure; return 0; }