summaryrefslogtreecommitdiff
path: root/src/simulation/elements
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation/elements')
-rw-r--r--src/simulation/elements/DEST.cpp2
-rw-r--r--src/simulation/elements/DSTW.cpp2
-rw-r--r--src/simulation/elements/EMP.cpp2
-rw-r--r--src/simulation/elements/FIRE.cpp4
-rw-r--r--src/simulation/elements/GBMB.cpp4
-rw-r--r--src/simulation/elements/GEL.cpp29
-rw-r--r--src/simulation/elements/GLOW.cpp14
-rw-r--r--src/simulation/elements/GPMP.cpp4
-rw-r--r--src/simulation/elements/GRAV.cpp20
-rw-r--r--src/simulation/elements/H2.cpp27
-rw-r--r--src/simulation/elements/HSWC.cpp6
-rw-r--r--src/simulation/elements/ICEI.cpp10
-rw-r--r--src/simulation/elements/IGNT.cpp11
-rw-r--r--src/simulation/elements/IRON.cpp17
-rw-r--r--src/simulation/elements/ISOZ.cpp4
-rw-r--r--src/simulation/elements/ISZS.cpp4
-rw-r--r--src/simulation/elements/LCRY.cpp96
-rw-r--r--src/simulation/elements/LIGH.cpp28
18 files changed, 139 insertions, 145 deletions
diff --git a/src/simulation/elements/DEST.cpp b/src/simulation/elements/DEST.cpp
index 3036331..73bc5cd 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 970dbb2..6c2c7d2 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 a09ad26..33f9ad3 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 9a9334f..37745ab 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 827f062..1b0ede0 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 5a139db..2b02841 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+rx<XRES && y+ry<YRES && (rx || ry))
{
+ gel=false;
r = pmap[y+ry][x+rx];
if (!r)
continue;
-
+ rt = r&0xFF;
//Desaturation
- if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_FRZW) && parts[i].tmp<100 && 500>rand()%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)<parts[i].tmp)
+ if (rt==PT_GEL && (parts[r>>8].tmp+1)<parts[i].tmp)
{
parts[r>>8].tmp++;
parts[i].tmp--;
+ gel = true;
}
-
- if ((r&0xFF)==PT_SPNG && (parts[r>>8].life+1)<parts[i].tmp)
+ else if (rt==PT_SPNG && (parts[r>>8].life+1)<parts[i].tmp)
{
parts[r>>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 775e188..373fc51 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 3cf51a3..24f180a 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 b913a28..144ba94 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 2b6c31b..b5bfe51 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 0f3c7e7..81484d6 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 3624877..995da9e 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 de26eb7..b1afe92 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 1542da9..b742b30 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<XRES && y+ry<YRES && (rx || ry))
@@ -57,12 +57,13 @@ int Element_IRON::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((((r&0xFF) == PT_SALT && 15>(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 05df489..9f9e9b1 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 b12f34c..3ee82cb 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 7cd4def..2ca5c28 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<XRES && y+ry<YRES && (rx || ry))
- {
- r = pmap[y+ry][x+rx];
- if (!r)
- continue;
- if ((r&0xFF)==PT_LCRY && parts[r>>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;
- }
+ parts[i].life+=2;
+ if(parts[i].life > 10)
+ parts[i].life = 10;
+ 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<XRES && y+ry<YRES && (rx || ry))
+ 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<XRES && y+ry<YRES && (rx || ry))
+ {
+ r = pmap[y+ry][x+rx];
+ if (!r)
+ continue;
+ if ((r&0xFF)==PT_LCRY && parts[r>>8].tmp == check)
{
- r = pmap[y+ry][x+rx];
- if (!r)
- continue;
- if ((r&0xFF)==PT_LCRY && parts[r>>8].tmp == 0)
- {
- parts[r>>8].tmp = 2;
- }
+ parts[r>>8].tmp = setto;
}
- }
+ }
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 a6b77de..d280fc1 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() {}