From 3d2e59415003c51c0b6dbe764003cc2012ba9ca7 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Wed, 27 Feb 2013 12:08:10 -0500 Subject: [PATCH] Small modifications part three. --- src/simulation/elements/DEST.cpp | 2 +- src/simulation/elements/DSTW.cpp | 2 +- src/simulation/elements/EMP.cpp | 2 +- src/simulation/elements/FIRE.cpp | 4 +- src/simulation/elements/GBMB.cpp | 4 +- src/simulation/elements/GEL.cpp | 29 +++++----- src/simulation/elements/GLOW.cpp | 14 ++--- src/simulation/elements/GPMP.cpp | 4 +- src/simulation/elements/GRAV.cpp | 20 +------ src/simulation/elements/H2.cpp | 27 +++++---- src/simulation/elements/HSWC.cpp | 6 +- src/simulation/elements/ICEI.cpp | 10 ++-- src/simulation/elements/IGNT.cpp | 11 ++-- src/simulation/elements/IRON.cpp | 17 +++--- src/simulation/elements/ISOZ.cpp | 4 +- src/simulation/elements/ISZS.cpp | 4 +- src/simulation/elements/LCRY.cpp | 98 ++++++++++++++++---------------- src/simulation/elements/LIGH.cpp | 28 ++++++--- 18 files changed, 140 insertions(+), 146 deletions(-) diff --git a/src/simulation/elements/DEST.cpp b/src/simulation/elements/DEST.cpp index 303633155..73bc5cd4f 100644 --- a/src/simulation/elements/DEST.cpp +++ b/src/simulation/elements/DEST.cpp @@ -77,7 +77,7 @@ int Element_DEST::update(UPDATE_FUNC_ARGS) { sim->create_part(r>>8, x+rx, y+ry, PT_PLSM); } - else if (!rand()%3) + else if (!(rand()%3)) { sim->kill_part(r>>8); parts[i].life -= 4*((sim->elements[r&0xFF].Properties&TYPE_SOLID)?3:1); diff --git a/src/simulation/elements/DSTW.cpp b/src/simulation/elements/DSTW.cpp index 970dbb20a..6c2c7d2e3 100644 --- a/src/simulation/elements/DSTW.cpp +++ b/src/simulation/elements/DSTW.cpp @@ -62,7 +62,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS) { sim->part_change_type(i,x,y,PT_SLTW); // on average, convert 3 DSTW to SLTW before SALT turns into SLTW - if (!rand()%3) + if (!(rand()%3)) sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); } if ((rt==PT_WATR||rt==PT_SLTW) && !(rand()%500)) diff --git a/src/simulation/elements/EMP.cpp b/src/simulation/elements/EMP.cpp index a09ad2625..33f9ad384 100644 --- a/src/simulation/elements/EMP.cpp +++ b/src/simulation/elements/EMP.cpp @@ -49,7 +49,7 @@ Element_EMP::Element_EMP() //#TPT-Directive ElementHeader Element_EMP static int update(UPDATE_FUNC_ARGS) int Element_EMP::update(UPDATE_FUNC_ARGS) { - int r,rx,ry,ok=0,t,n,nx,ny; + int r,rx,ry,t,n,nx,ny; if (parts[i].life) return 0; for (rx=-2; rx<3; rx++) diff --git a/src/simulation/elements/FIRE.cpp b/src/simulation/elements/FIRE.cpp index 9a9334fda..37745ab80 100644 --- a/src/simulation/elements/FIRE.cpp +++ b/src/simulation/elements/FIRE.cpp @@ -55,7 +55,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS) sim->part_change_type(i,x,y,PT_NBLE); parts[i].life = 0; } - if (t==PT_FIRE && parts[i].life <=1) + else if (t==PT_FIRE && parts[i].life <=1) { if ((parts[i].tmp&0x3) == 3){ sim->part_change_type(i,x,y,PT_DSTW); @@ -68,7 +68,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS) parts[i].life = rand()%20+250; } } - if (t==PT_PLSM && parts[i].life <=1) + else if (t==PT_PLSM && parts[i].life <=1) { if ((parts[i].tmp&0x3) == 3){ sim->part_change_type(i,x,y,PT_DSTW); diff --git a/src/simulation/elements/GBMB.cpp b/src/simulation/elements/GBMB.cpp index 827f062c9..1b0ede066 100644 --- a/src/simulation/elements/GBMB.cpp +++ b/src/simulation/elements/GBMB.cpp @@ -69,7 +69,7 @@ int Element_GBMB::update(UPDATE_FUNC_ARGS) } if(parts[i].life>20) sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 20; - if(parts[i].life<20 && parts[i].life>=1) + else if(parts[i].life>=1) sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = -80; return 0; } @@ -90,4 +90,4 @@ int Element_GBMB::graphics(GRAPHICS_FUNC_ARGS) } -Element_GBMB::~Element_GBMB() {} \ No newline at end of file +Element_GBMB::~Element_GBMB() {} diff --git a/src/simulation/elements/GEL.cpp b/src/simulation/elements/GEL.cpp index 5a139db65..2b028416a 100644 --- a/src/simulation/elements/GEL.cpp +++ b/src/simulation/elements/GEL.cpp @@ -49,7 +49,8 @@ Element_GEL::Element_GEL() //#TPT-Directive ElementHeader Element_GEL static int update(UPDATE_FUNC_ARGS) int Element_GEL::update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + int r, rx, ry, rt; + bool gel; int absorbChanceDenom; if (parts[i].tmp>100) parts[i].tmp = 100; if (parts[i].tmp<0) parts[i].tmp = 0; @@ -58,22 +59,23 @@ int Element_GEL::update(UPDATE_FUNC_ARGS) for (ry=-2; ry<3; ry++) if (x+rx>=0 && y+ry>0 && x+rxrand()%absorbChanceDenom) + if ((rt==PT_WATR || rt==PT_DSTW || rt==PT_FRZW) && parts[i].tmp<100 && 500>rand()%absorbChanceDenom) { parts[i].tmp++; sim->kill_part(r>>8); } - if (((r&0xFF)==PT_PSTE) && parts[i].tmp<100 && 20>rand()%absorbChanceDenom) + else if ((rt==PT_PSTE) && parts[i].tmp<100 && 20>rand()%absorbChanceDenom) { parts[i].tmp++; sim->create_part(r>>8, x+rx, y+ry, PT_CLST); } - if (((r&0xFF)==PT_SLTW) && parts[i].tmp<100 && 50>rand()%absorbChanceDenom) + else if ((rt==PT_SLTW) && parts[i].tmp<100 && 50>rand()%absorbChanceDenom) { parts[i].tmp++; if (rand()%4) @@ -81,30 +83,25 @@ int Element_GEL::update(UPDATE_FUNC_ARGS) else sim->part_change_type(r>>8, x+rx, y+ry, PT_SALT); } - if (((r&0xFF)==PT_CBNW) && parts[i].tmp<100 && 100>rand()%absorbChanceDenom) + else if ((rt==PT_CBNW) && parts[i].tmp<100 && 100>rand()%absorbChanceDenom) { parts[i].tmp++; sim->part_change_type(r>>8, x+rx, y+ry, PT_CO2); } - if ((r&0xFF)==PT_SPNG && parts[i].tmp<100 && ((parts[r>>8].life+1)>parts[i].tmp)) + else if (rt==PT_SPNG && parts[i].tmp<100 && ((parts[r>>8].life+1)>parts[i].tmp)) { parts[r>>8].life--; parts[i].tmp++; } - - char gel = 0; - if ((r&0xFF)==PT_GEL) - gel = 1; - //Concentration diffusion - if (gel && (parts[r>>8].tmp+1)>8].tmp+1)>8].tmp++; parts[i].tmp--; + gel = true; } - - if ((r&0xFF)==PT_SPNG && (parts[r>>8].life+1)>8].life+1)>8].life++; parts[i].tmp--; @@ -127,7 +124,7 @@ int Element_GEL::update(UPDATE_FUNC_ARGS) dx *= per; dy *= per; parts[i].vx += dx; parts[i].vy += dy; - if ((sim->elements[r&0xFF].Properties&TYPE_PART) || (r&0xFF)==PT_GOO) + if ((sim->elements[r&0xFF].Properties&TYPE_PART) || rt==PT_GOO) { parts[r>>8].vx -= dx; parts[r>>8].vy -= dy; diff --git a/src/simulation/elements/GLOW.cpp b/src/simulation/elements/GLOW.cpp index 775e1881e..373fc51cd 100644 --- a/src/simulation/elements/GLOW.cpp +++ b/src/simulation/elements/GLOW.cpp @@ -57,21 +57,17 @@ int Element_GLOW::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_WATR&&5>(rand()%2000)) + if ((r&0xFF)==PT_WATR && !(rand()%400)) { - parts[i].type = PT_NONE; + sim->kill_part(i); sim->part_change_type(r>>8,x+rx,y+ry,PT_DEUT); parts[r>>8].life = 10; + return 1; } } parts[i].ctype = sim->pv[y/CELL][x/CELL]*16; - parts[i].tmp = abs((int)((sim->vx[y/CELL][x/CELL]+sim->vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f)); - //printf("%f %f\n", parts[i].vx, parts[i].vy); - if (parts[i].type==PT_NONE) { - sim->kill_part(i); - return 1; - } + return 0; } @@ -93,4 +89,4 @@ int Element_GLOW::graphics(GRAPHICS_FUNC_ARGS) } -Element_GLOW::~Element_GLOW() {} \ No newline at end of file +Element_GLOW::~Element_GLOW() {} diff --git a/src/simulation/elements/GPMP.cpp b/src/simulation/elements/GPMP.cpp index 3cf51a38c..24f180a3c 100644 --- a/src/simulation/elements/GPMP.cpp +++ b/src/simulation/elements/GPMP.cpp @@ -50,9 +50,9 @@ Element_GPMP::Element_GPMP() int Element_GPMP::update(UPDATE_FUNC_ARGS) { int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) + if (parts[i].life!=10 && parts[i].life>0) parts[i].life--; - if (parts[i].life==10) + else if (parts[i].life==10) { if (parts[i].temp>=256.0+273.15) parts[i].temp=256.0+273.15; diff --git a/src/simulation/elements/GRAV.cpp b/src/simulation/elements/GRAV.cpp index b913a282d..144ba943a 100644 --- a/src/simulation/elements/GRAV.cpp +++ b/src/simulation/elements/GRAV.cpp @@ -42,25 +42,9 @@ Element_GRAV::Element_GRAV() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_GRAV::update; + Update = NULL; Graphics = &Element_GRAV::graphics; } - -//#TPT-Directive ElementHeader Element_GRAV static int update(UPDATE_FUNC_ARGS) -int Element_GRAV::update(UPDATE_FUNC_ARGS) - { - /*int t = parts[i].type; - if (t==PT_LOVE) - ISLOVE=1; - else if (t==PT_LOLZ) - ISLOLZ=1; - else if (t==PT_GRAV) - ISGRAV=1;*/ - return 0; -} - -int lastIndex; - //#TPT-Directive ElementHeader Element_GRAV static int graphics(GRAPHICS_FUNC_ARGS) int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS) @@ -108,4 +92,4 @@ int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS) } -Element_GRAV::~Element_GRAV() {} \ No newline at end of file +Element_GRAV::~Element_GRAV() {} diff --git a/src/simulation/elements/H2.cpp b/src/simulation/elements/H2.cpp index 2b6c31bad..b5bfe513a 100644 --- a/src/simulation/elements/H2.cpp +++ b/src/simulation/elements/H2.cpp @@ -63,18 +63,25 @@ int Element_H2::update(UPDATE_FUNC_ARGS) sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR); sim->part_change_type(i,x,y,PT_OIL); } - if (parts[r>>8].temp > 2273.15 && sim->pv[y/CELL][x/CELL] > 45.0f) - continue; - if (sim->pv[y/CELL][x/CELL] <= 45.0f) + + if (sim->pv[y/CELL][x/CELL] > 45.0f) + { + if (parts[r>>8].temp > 2273.15) + continue; + } + else { if (rt==PT_FIRE) { parts[r>>8].temp=2473.15; if(parts[r>>8].tmp&0x02) - parts[r>>8].temp=3473; + parts[r>>8].temp=3473; parts[r>>8].tmp |= 1; + sim->create_part(i,x,y,PT_FIRE); + parts[i].temp+=(rand()/(RAND_MAX/100)); + parts[i].tmp |= 1; } - if (rt==PT_FIRE || (rt==PT_PLSM && !(parts[r>>8].tmp&4)) || (rt==PT_LAVA && parts[r>>8].ctype != PT_BMTL)) + else if ((rt==PT_PLSM && !(parts[r>>8].tmp&4)) || (rt==PT_LAVA && parts[r>>8].ctype != PT_BMTL)) { sim->create_part(i,x,y,PT_FIRE); parts[i].temp+=(rand()/(RAND_MAX/100)); @@ -84,30 +91,30 @@ int Element_H2::update(UPDATE_FUNC_ARGS) } if (parts[i].temp > 2273.15 && sim->pv[y/CELL][x/CELL] > 50.0f) { - if (rand()%5 < 1) + if (!(rand()%5)) { int j; float temp = parts[i].temp; sim->create_part(i,x,y,PT_NBLE); j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); - if (j != -1) + if (j>-1) parts[j].temp = temp; if (!(rand()%10)) { j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); - if (j != -1) + if (j>-1) parts[j].temp = temp; } j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); - if (j != -1) + if (j>-1) { parts[j].ctype = 0x7C0000; parts[j].temp = temp; } j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PLSM); - if (j != -1) + if (j>-1) { parts[j].temp = temp; parts[j].tmp |= 4; diff --git a/src/simulation/elements/HSWC.cpp b/src/simulation/elements/HSWC.cpp index 0f3c7e764..81484d66a 100644 --- a/src/simulation/elements/HSWC.cpp +++ b/src/simulation/elements/HSWC.cpp @@ -50,9 +50,9 @@ Element_HSWC::Element_HSWC() int Element_HSWC::update(UPDATE_FUNC_ARGS) { int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) + if (parts[i].life!=10 && parts[i].life>0) parts[i].life--; - if (parts[i].life==10) + else if (parts[i].life==10) { for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) @@ -84,4 +84,4 @@ int Element_HSWC::graphics(GRAPHICS_FUNC_ARGS) } -Element_HSWC::~Element_HSWC() {} \ No newline at end of file +Element_HSWC::~Element_HSWC() {} diff --git a/src/simulation/elements/ICEI.cpp b/src/simulation/elements/ICEI.cpp index 362487725..995da9e3f 100644 --- a/src/simulation/elements/ICEI.cpp +++ b/src/simulation/elements/ICEI.cpp @@ -61,16 +61,18 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && parts[i].temp > sim->elements[PT_SLTW].LowTemperature && 1>(rand()%1000)) + if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%1000)) { sim->part_change_type(i,x,y,PT_SLTW); sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); + goto done; } - if (((r&0xFF)==PT_FRZZ) && (parts[i].ctype=PT_FRZW) && 1>(rand()%1000)) - sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); + else if (((r&0xFF)==PT_FRZZ) && (parts[i].ctype=PT_FRZW) && !(rand()%1000)) + sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); } + done: return 0; } -Element_ICEI::~Element_ICEI() {} \ No newline at end of file +Element_ICEI::~Element_ICEI() {} diff --git a/src/simulation/elements/IGNT.cpp b/src/simulation/elements/IGNT.cpp index de26eb743..b1afe9203 100644 --- a/src/simulation/elements/IGNT.cpp +++ b/src/simulation/elements/IGNT.cpp @@ -49,7 +49,7 @@ Element_IGNT::Element_IGNT() //#TPT-Directive ElementHeader Element_IGNT static int update(UPDATE_FUNC_ARGS) int Element_IGNT::update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + int r, rx, ry, rt; if(parts[i].tmp==0) { for (rx=-1; rx<2; rx++) @@ -59,11 +59,8 @@ int Element_IGNT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) - { - parts[i].tmp = 1; - } - else if ((r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH || ((r&0xFF)==PT_IGNT && parts[r>>8].life==1)) + rt = r&0xFF; + if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_SPRK || rt==PT_LIGH || (rt==PT_IGNT && parts[r>>8].life==1)) { parts[i].tmp = 1; } @@ -92,4 +89,4 @@ int Element_IGNT::update(UPDATE_FUNC_ARGS) } -Element_IGNT::~Element_IGNT() {} \ No newline at end of file +Element_IGNT::~Element_IGNT() {} diff --git a/src/simulation/elements/IRON.cpp b/src/simulation/elements/IRON.cpp index 1542da9e2..b742b3038 100644 --- a/src/simulation/elements/IRON.cpp +++ b/src/simulation/elements/IRON.cpp @@ -49,7 +49,7 @@ Element_IRON::Element_IRON() //#TPT-Directive ElementHeader Element_IRON static int update(UPDATE_FUNC_ARGS) int Element_IRON::update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + int r, rx, ry, rt; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx(rand()/(RAND_MAX/700))) || - ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) || - ((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) || - ((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) || - ((r&0xFF) == PT_LO2))&& - (!(parts[i].life)) + rt = r&0xFF; + if ((!(parts[i].life)) && + ((rt == PT_SALT && !(rand()%47)) || + (rt == PT_SLTW && !(rand()%67)) || + (rt == PT_WATR && !(rand()%1200)) || + (rt == PT_O2 && !(rand()%250)) || + (rt == PT_LO2)) ) { sim->part_change_type(i,x,y,PT_BMTL); @@ -73,4 +74,4 @@ int Element_IRON::update(UPDATE_FUNC_ARGS) } -Element_IRON::~Element_IRON() {} \ No newline at end of file +Element_IRON::~Element_IRON() {} diff --git a/src/simulation/elements/ISOZ.cpp b/src/simulation/elements/ISOZ.cpp index 05df48918..9f9e9b139 100644 --- a/src/simulation/elements/ISOZ.cpp +++ b/src/simulation/elements/ISOZ.cpp @@ -50,7 +50,7 @@ Element_ISOZ::Element_ISOZ() int Element_ISOZ::update(UPDATE_FUNC_ARGS) { // for both ISZS and ISOZ float rr, rrr; - if (1>rand()%200 && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000)) + if (!(rand()%200) && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000)) { sim->create_part(i, x, y, PT_PHOT); rr = (rand()%228+128)/127.0f; @@ -62,4 +62,4 @@ int Element_ISOZ::update(UPDATE_FUNC_ARGS) } -Element_ISOZ::~Element_ISOZ() {} \ No newline at end of file +Element_ISOZ::~Element_ISOZ() {} diff --git a/src/simulation/elements/ISZS.cpp b/src/simulation/elements/ISZS.cpp index b12f34ce5..3ee82cbd8 100644 --- a/src/simulation/elements/ISZS.cpp +++ b/src/simulation/elements/ISZS.cpp @@ -50,7 +50,7 @@ Element_ISZS::Element_ISZS() int Element_ISZS::update(UPDATE_FUNC_ARGS) { // for both ISZS and ISOZ float rr, rrr; - if (1>rand()%200 && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000)) + if (!(rand()%200) && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000)) { sim->create_part(i, x, y, PT_PHOT); rr = (rand()%228+128)/127.0f; @@ -62,4 +62,4 @@ int Element_ISZS::update(UPDATE_FUNC_ARGS) } -Element_ISZS::~Element_ISZS() {} \ No newline at end of file +Element_ISZS::~Element_ISZS() {} diff --git a/src/simulation/elements/LCRY.cpp b/src/simulation/elements/LCRY.cpp index 7cd4def0c..2ca5c285c 100644 --- a/src/simulation/elements/LCRY.cpp +++ b/src/simulation/elements/LCRY.cpp @@ -50,61 +50,59 @@ Element_LCRY::Element_LCRY() int Element_LCRY::update(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if(parts[i].tmp==1 || parts[i].tmp==0) + int r, rx, ry, check, setto; + switch (parts[i].tmp) { - if(parts[i].tmp==1) + case 0: + check=3; + setto=1; + break; + case 1: + check=3; + setto=1; + if(parts[i].life<=0) + parts[i].tmp = 0; + else { - if(parts[i].life<=0) - parts[i].tmp = 0; - else - { - parts[i].life-=2; - if(parts[i].life < 0) - parts[i].life = 0; - parts[i].tmp2 = parts[i].life; - } + parts[i].life-=2; + if(parts[i].life < 0) + parts[i].life = 0; + parts[i].tmp2 = parts[i].life; } - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].tmp == 3) - { - parts[r>>8].tmp = 1; - } - } - } - else if(parts[i].tmp==2 || parts[i].tmp==3) - { - if(parts[i].tmp==2) + break; + case 3: + check=0; + setto=2; + break; + case 2: + check=0; + setto=2; + if(parts[i].life>=10) + parts[i].tmp = 3; + else { - if(parts[i].life>=10) - parts[i].tmp = 3; - else + parts[i].life+=2; + if(parts[i].life > 10) + parts[i].life = 10; + parts[i].tmp2 = parts[i].life; + } + break; + + default: + return 0; + } + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx 10) - parts[i].life = 10; - parts[i].tmp2 = parts[i].life; + r = pmap[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)==PT_LCRY && parts[r>>8].tmp == check) + { + parts[r>>8].tmp = setto; + } } - } - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].tmp == 0) - { - parts[r>>8].tmp = 2; - } - } - } return 0; } @@ -151,4 +149,4 @@ int Element_LCRY::graphics(GRAPHICS_FUNC_ARGS) } -Element_LCRY::~Element_LCRY() {} \ No newline at end of file +Element_LCRY::~Element_LCRY() {} diff --git a/src/simulation/elements/LIGH.cpp b/src/simulation/elements/LIGH.cpp index a6b77de02..d280fc167 100644 --- a/src/simulation/elements/LIGH.cpp +++ b/src/simulation/elements/LIGH.cpp @@ -68,11 +68,11 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) * tmp - angle of lighting, measured in degrees anticlockwise from the positive x direction * */ - int r,rx,ry, multipler, powderful; + int r,rx,ry,rt, multipler, powderful; float angle, angle2=-1; int pNear = 0; powderful = powderful = parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER; - Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); + //Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); if (sim->aheat_enable) { sim->hv[y/CELL][x/CELL]+=powderful/50; @@ -87,9 +87,21 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_TESC) + rt = r&0xFF; + if ((surround_space || sim->elements[rt].Explosive) && + (rt!=PT_SPNG || parts[r>>8].life==0) && + sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) { - if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT) + sim->part_change_type(r>>8,x+rx,y+ry,PT_FIRE); + parts[r>>8].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP); + parts[r>>8].life = rand()%80+180; + parts[r>>8].tmp = parts[r>>8].ctype = 0; + if (sim->elements[rt].Explosive) + sim->pv[y/CELL][x/CELL] += 0.25f * CFDS; + } + if (rt!=PT_LIGH && rt!=PT_TESC) + { + if (rt!=PT_CLNE&&rt!=PT_THDR&&rt!=PT_DMND&&rt!=PT_FIRE&&rt!=PT_NEUT&&rt!=PT_PHOT) { if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0) { @@ -98,7 +110,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) sim->pv[y/CELL][x/CELL] += powderful/400; if (sim->elements[r&0xFF].HeatConduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); } - if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) // start nuclear reactions + if (rt==PT_DEUT || rt==PT_PLUT) // start nuclear reactions { parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful, MIN_TEMP, MAX_TEMP); sim->pv[y/CELL][x/CELL] +=powderful/35; @@ -110,7 +122,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) parts[r>>8].vy=rand()%10-5; } } - if ((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL) // ignite coal + if (rt==PT_COAL || rt==PT_BCOL) // ignite coal { if (parts[r>>8].life>100) { parts[r>>8].life = 99; @@ -118,7 +130,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) } if (sim->elements[r&0xFF].HeatConduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP); - if (((r&0xFF)==PT_STKM && sim->player.elem!=PT_LIGH) || ((r&0xFF)==PT_STKM2 && sim->player2.elem!=PT_LIGH)) + if ((rt==PT_STKM && sim->player.elem!=PT_LIGH) || (rt==PT_STKM2 && sim->player2.elem!=PT_LIGH)) { parts[r>>8].life-=powderful/100; } @@ -386,4 +398,4 @@ int Element_LIGH::graphics(GRAPHICS_FUNC_ARGS) } -Element_LIGH::~Element_LIGH() {} \ No newline at end of file +Element_LIGH::~Element_LIGH() {}