From 06b2631f8dc03693eb64c197ee97686a66372b58 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 4 Jun 2017 12:56:25 -0400 Subject: [PATCH] rename E180 to HEAC (rapid heat conductor), now affects photons, code formatting --- src/simulation/Elements.h | 2 - src/simulation/elements/180.cpp | 93 -------------------------- src/simulation/elements/HEAC.cpp | 109 +++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 95 deletions(-) delete mode 100644 src/simulation/elements/180.cpp create mode 100644 src/simulation/elements/HEAC.cpp diff --git a/src/simulation/Elements.h b/src/simulation/Elements.h index 36075aa5e4..b3dcbf3da3 100644 --- a/src/simulation/Elements.h +++ b/src/simulation/Elements.h @@ -48,8 +48,6 @@ #define BOUNDS_CHECK true -#define REAL_BOUNDS_CHECK(x, y) (x >= 0 && x < XRES && y >= 0 && x < YRES) - #define OLD_PT_WIND 147 //#define PT_NUM 161 diff --git a/src/simulation/elements/180.cpp b/src/simulation/elements/180.cpp deleted file mode 100644 index 0b62c680f7..0000000000 --- a/src/simulation/elements/180.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "simulation/Elements.h" -#include "simulation/Air.h" -//#TPT-Directive ElementClass Element_E180 PT_E180 180 -Element_E180::Element_E180() -{ - Identifier = "DEFAULT_PT_E180"; - Name = "E180"; - Colour = PIXPACK(0xCB6351); - MenuVisible = 1; - MenuSection = SC_SOLIDS; -#if (defined(DEBUG) || defined(SNAPSHOT)) && MOD_ID == 0 - Enabled = 1; -#else - Enabled = 0; -#endif - - Advection = 0.0f; - AirDrag = 0.00f * CFDS; - AirLoss = 0.90f; - Loss = 0.00f; - Collision = 0.0f; - Gravity = 0.0f; - Diffusion = 0.00f; - HotAir = 0.000f * CFDS; - Falldown = 0; - - Flammable = 0; - Explosive = 0; - Meltable = 1; - Hardness = 50; - - Weight = 100; - - Temperature = R_TEMP+0.0f +273.15f; - HeatConduct = 251; - Description = "Experimental element, high thermal conductivity"; - - Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW|PROP_LIFE_DEC; - - LowPressure = IPL; - LowPressureTransition = NT; - HighPressure = IPH; - HighPressureTransition = NT; - LowTemperature = ITL; - LowTemperatureTransition = NT; - HighTemperature = 1356.15f; - HighTemperatureTransition = PT_LAVA; - - Update = &Element_E180::update; -} - -//#TPT-Directive ElementHeader Element_E180 static int update(UPDATE_FUNC_ARGS) -int Element_E180::update(UPDATE_FUNC_ARGS) -{ - const int rad = 4; - int rx, ry, rry, rrx, r, count = 0; - float tempAgg = 0; - for (rx=-1; rx<2; rx++) { - for (ry=-1; ry<2; ry++) { - rry = ry * rad; - rrx = rx * rad; - if (REAL_BOUNDS_CHECK(x+rrx, y+rry)) { - r = pmap[y+rry][x+rrx]; - if(r && (sim->elements[r&0xFF].HeatConduct > 0 || (r&0xFF) == PT_E180)) { - count++; - tempAgg += parts[r>>8].temp; - } - } - } - } - - if(count > 0) { - parts[i].temp = tempAgg/count; - - for (rx=-1; rx<2; rx++) { - for (ry=-1; ry<2; ry++) { - rry = ry * rad; - rrx = rx * rad; - if (REAL_BOUNDS_CHECK(x+rrx, y+rry)) { - r = pmap[y+rry][x+rrx]; - if(r && (sim->elements[r&0xFF].HeatConduct > 0 || (r&0xFF) == PT_E180)) { - parts[r>>8].temp = parts[i].temp; - } - } - } - } - } - - return 0; -} - - -Element_E180::~Element_E180() {} diff --git a/src/simulation/elements/HEAC.cpp b/src/simulation/elements/HEAC.cpp new file mode 100644 index 0000000000..25714e8700 --- /dev/null +++ b/src/simulation/elements/HEAC.cpp @@ -0,0 +1,109 @@ +#include "simulation/Elements.h" +#include "simulation/Air.h" +//#TPT-Directive ElementClass Element_HEAC PT_HEAC 180 +Element_HEAC::Element_HEAC() +{ + Identifier = "DEFAULT_PT_HEAC"; + Name = "HEAC"; + Colour = PIXPACK(0xCB6351); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 50; + + Weight = 100; + + Temperature = R_TEMP+273.15f; + HeatConduct = 251; + Description = "Rapid heat conductor"; + + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_HEAC::update; +} + +//#TPT-Directive ElementHeader Element_HEAC static int update(UPDATE_FUNC_ARGS) +int Element_HEAC::update(UPDATE_FUNC_ARGS) +{ + const int rad = 4; + int rry, rrx, r, count = 0; + float tempAgg = 0; + for (int rx = -1; rx <= 1; rx++) + { + for (int ry = -1; ry <= 1; ry++) + { + rry = ry * rad; + rrx = rx * rad; + if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES) + { + r = pmap[y+rry][x+rrx]; + if (r && sim->elements[r&0xFF].HeatConduct > 0) + { + count++; + tempAgg += parts[r>>8].temp; + } + r = sim->photons[y+rry][x+rrx]; + if (r && sim->elements[r&0xFF].HeatConduct > 0) + { + count++; + tempAgg += parts[r>>8].temp; + } + } + } + } + + if (count > 0) + { + parts[i].temp = tempAgg/count; + + for (int rx = -1; rx <= 1; rx++) + { + for (int ry = -1; ry <= 1; ry++) + { + rry = ry * rad; + rrx = rx * rad; + if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES) + { + r = pmap[y+rry][x+rrx]; + if (r && sim->elements[r&0xFF].HeatConduct > 0) + { + parts[r>>8].temp = parts[i].temp; + } + r = sim->photons[y+rry][x+rrx]; + if (r && sim->elements[r&0xFF].HeatConduct > 0) + { + parts[r>>8].temp = parts[i].temp; + } + } + } + } + } + + return 0; +} + + +Element_HEAC::~Element_HEAC() {}