From 3a738846a3e0c59ed02805f11f93678ae42a946e Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 16 Mar 2013 13:23:19 -0400 Subject: add identifier constants based on the display name to the lua api diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 33e10d2..79c79a1 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1141,6 +1141,13 @@ void LuaScriptInterface::initElementsAPI() { lua_pushinteger(l, i); lua_setfield(l, elementsAPI, luacon_sim->elements[i].Identifier); + char realIdentifier[20]; + sprintf(realIdentifier, "DEFAULT_PT_%s", luacon_sim->elements[i].Name); + if (i != 0 && i != PT_NBHL && i != PT_NWHL && strcmp(luacon_sim->elements[i].Identifier, realIdentifier)) + { + lua_pushinteger(l, i); + lua_setfield(l, elementsAPI, realIdentifier); + } } } } diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index f037252..d59ac51 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -3016,7 +3016,7 @@ int Simulation::create_part(int p, int x, int y, int tv) case PT_PLSM: parts[i].life = rand()%150+50; break; - case PT_HFLM: + case PT_CFLM: parts[i].life = rand()%150+50; break; case PT_LAVA: @@ -3678,7 +3678,7 @@ void Simulation::update_particles_i(int start, int inc) (bmap[y/CELL][x/CELL]==WL_DESTROYALL) || (bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && elements[t].Falldown!=2) || (bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && elements[t].Falldown!=1) || - (bmap[y/CELL][x/CELL]==WL_ALLOWGAS && !(elements[t].Properties&TYPE_GAS)) || //&& elements[t].Falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) || + (bmap[y/CELL][x/CELL]==WL_ALLOWGAS && !(elements[t].Properties&TYPE_GAS)) || //&& elements[t].Falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_CFLM) || (bmap[y/CELL][x/CELL]==WL_ALLOWENERGY && !(elements[t].Properties&TYPE_ENERGY)) || (bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) || (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2) && (t!=PT_FIGH))) @@ -4038,7 +4038,7 @@ void Simulation::update_particles_i(int start, int inc) if (elements[t].State==ST_GAS&&elements[parts[i].type].State!=ST_GAS) pv[y/CELL][x/CELL] += 0.50f; part_change_type(i,x,y,t); - if (t==PT_FIRE||t==PT_PLSM||t==PT_HFLM) + if (t==PT_FIRE||t==PT_PLSM||t==PT_CFLM) parts[i].life = rand()%50+120; if (t==PT_LAVA) { if (parts[i].ctype==PT_BRMT) parts[i].ctype = PT_BMTL; diff --git a/src/simulation/elements/ANAR.cpp b/src/simulation/elements/ANAR.cpp index fa9130e..16d619d 100644 --- a/src/simulation/elements/ANAR.cpp +++ b/src/simulation/elements/ANAR.cpp @@ -60,9 +60,9 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_HFLM && !(rand()%7)) + if ((r&0xFF)==PT_CFLM && !(rand()%7)) { - sim->part_change_type(i,x,y,PT_HFLM); + sim->part_change_type(i,x,y,PT_CFLM); parts[i].life = rand()%150+50; parts[r>>8].temp = parts[i].temp = 0; sim->pv[y/CELL][x/CELL] -= 0.5; diff --git a/src/simulation/elements/C5.cpp b/src/simulation/elements/C5.cpp index 0141991..98d9bf0 100644 --- a/src/simulation/elements/C5.cpp +++ b/src/simulation/elements/C5.cpp @@ -57,11 +57,11 @@ int Element_C5::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100 && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10)) || (r&0xFF)==PT_HFLM) + if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100 && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10)) || (r&0xFF)==PT_CFLM) { if (!(rand()%6)) { - sim->part_change_type(i,x,y,PT_HFLM); + sim->part_change_type(i,x,y,PT_CFLM); parts[r>>8].temp = parts[i].temp = 0; parts[i].life = rand()%150+50; sim->pv[y/CELL][x/CELL] += 1.5; diff --git a/src/simulation/elements/CFLM.cpp b/src/simulation/elements/CFLM.cpp new file mode 100644 index 0000000..d19f9f0 --- /dev/null +++ b/src/simulation/elements/CFLM.cpp @@ -0,0 +1,75 @@ +#include "simulation/Elements.h" +extern "C" +{ + #include "hmap.h" +} + +//#TPT-Directive ElementClass Element_CFLM PT_CFLM 68 +Element_CFLM::Element_CFLM() +{ + Identifier = "DEFAULT_PT_HFLM"; + Name = "CFLM"; + Colour = PIXPACK(0x8080FF); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.9f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.97f; + Loss = 0.20f; + Collision = 0.0f; + Gravity = -0.1f; + Diffusion = 0.00f; + HotAir = 0.0005f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 2; + + Temperature = 0.0f; + HeatConduct = 88; + Description = "Sub-zero flame."; + + State = ST_LIQUID; + Properties = TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = &Element_CFLM::graphics; +} + +//#TPT-Directive ElementHeader Element_CFLM static int graphics(GRAPHICS_FUNC_ARGS) +int Element_CFLM::graphics(GRAPHICS_FUNC_ARGS) + +{ + int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + *colr = (unsigned char)hflm_data[caddress]; + *colg = (unsigned char)hflm_data[caddress+1]; + *colb = (unsigned char)hflm_data[caddress+2]; + + *firea = 255; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + + *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel + *pixel_mode |= FIRE_ADD; + //Returning 0 means dynamic, do not cache + return 0; +} + + +Element_CFLM::~Element_CFLM() {} \ No newline at end of file diff --git a/src/simulation/elements/HFLM.cpp b/src/simulation/elements/HFLM.cpp deleted file mode 100644 index 1c39a2c..0000000 --- a/src/simulation/elements/HFLM.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "simulation/Elements.h" -extern "C" -{ - #include "hmap.h" -} - -//#TPT-Directive ElementClass Element_HFLM PT_HFLM 68 -Element_HFLM::Element_HFLM() -{ - Identifier = "DEFAULT_PT_HFLM"; - Name = "CFLM"; - Colour = PIXPACK(0x8080FF); - MenuVisible = 1; - MenuSection = SC_EXPLOSIVE; - Enabled = 1; - - Advection = 0.9f; - AirDrag = 0.04f * CFDS; - AirLoss = 0.97f; - Loss = 0.20f; - Collision = 0.0f; - Gravity = -0.1f; - Diffusion = 0.00f; - HotAir = 0.0005f * CFDS; - Falldown = 1; - - Flammable = 0; - Explosive = 0; - Meltable = 0; - Hardness = 1; - - Weight = 2; - - Temperature = 0.0f; - HeatConduct = 88; - Description = "Sub-zero flame."; - - State = ST_LIQUID; - Properties = TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL; - - LowPressure = IPL; - LowPressureTransition = NT; - HighPressure = IPH; - HighPressureTransition = NT; - LowTemperature = ITL; - LowTemperatureTransition = NT; - HighTemperature = ITH; - HighTemperatureTransition = NT; - - Update = NULL; - Graphics = &Element_HFLM::graphics; -} - -//#TPT-Directive ElementHeader Element_HFLM static int graphics(GRAPHICS_FUNC_ARGS) -int Element_HFLM::graphics(GRAPHICS_FUNC_ARGS) - -{ - int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - *colr = (unsigned char)hflm_data[caddress]; - *colg = (unsigned char)hflm_data[caddress+1]; - *colb = (unsigned char)hflm_data[caddress+2]; - - *firea = 255; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel - *pixel_mode |= FIRE_ADD; - //Returning 0 means dynamic, do not cache - return 0; -} - - -Element_HFLM::~Element_HFLM() {} \ No newline at end of file -- cgit v0.9.2-21-gd62e