From 3a738846a3e0c59ed02805f11f93678ae42a946e Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 16 Mar 2013 13:23:19 -0400 Subject: [PATCH] add identifier constants based on the display name to the lua api --- src/cat/LuaScriptInterface.cpp | 7 +++++++ src/simulation/Simulation.cpp | 6 +++--- src/simulation/elements/ANAR.cpp | 4 ++-- src/simulation/elements/C5.cpp | 4 ++-- src/simulation/elements/{HFLM.cpp => CFLM.cpp} | 12 ++++++------ 5 files changed, 20 insertions(+), 13 deletions(-) rename src/simulation/elements/{HFLM.cpp => CFLM.cpp} (83%) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 33e10d279..79c79a123 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 f0372526c..d59ac51c8 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 fa9130ea0..16d619d63 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 014199147..98d9bf035 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/HFLM.cpp b/src/simulation/elements/CFLM.cpp similarity index 83% rename from src/simulation/elements/HFLM.cpp rename to src/simulation/elements/CFLM.cpp index 1c39a2c57..d19f9f0e9 100644 --- a/src/simulation/elements/HFLM.cpp +++ b/src/simulation/elements/CFLM.cpp @@ -4,8 +4,8 @@ extern "C" #include "hmap.h" } -//#TPT-Directive ElementClass Element_HFLM PT_HFLM 68 -Element_HFLM::Element_HFLM() +//#TPT-Directive ElementClass Element_CFLM PT_CFLM 68 +Element_CFLM::Element_CFLM() { Identifier = "DEFAULT_PT_HFLM"; Name = "CFLM"; @@ -48,11 +48,11 @@ Element_HFLM::Element_HFLM() HighTemperatureTransition = NT; Update = NULL; - Graphics = &Element_HFLM::graphics; + Graphics = &Element_CFLM::graphics; } -//#TPT-Directive ElementHeader Element_HFLM static int graphics(GRAPHICS_FUNC_ARGS) -int Element_HFLM::graphics(GRAPHICS_FUNC_ARGS) +//#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); @@ -72,4 +72,4 @@ int Element_HFLM::graphics(GRAPHICS_FUNC_ARGS) } -Element_HFLM::~Element_HFLM() {} \ No newline at end of file +Element_CFLM::~Element_CFLM() {} \ No newline at end of file