summaryrefslogtreecommitdiff
path: root/src/simulation/elements
diff options
context:
space:
mode:
authorcracker64 <cracker642@gmail.com>2013-02-27 22:20:05 (GMT)
committer cracker64 <cracker642@gmail.com>2013-02-27 22:20:05 (GMT)
commit08d1a68ce091b6ba53788224fd1bda92c1895ca6 (patch)
tree09593de4276750ce9abf203edb08741947ba7ab6 /src/simulation/elements
parent3d2e59415003c51c0b6dbe764003cc2012ba9ca7 (diff)
downloadpowder-08d1a68ce091b6ba53788224fd1bda92c1895ca6.zip
powder-08d1a68ce091b6ba53788224fd1bda92c1895ca6.tar.gz
More fixes.
Diffstat (limited to 'src/simulation/elements')
-rw-r--r--src/simulation/elements/BCLN.cpp15
-rw-r--r--src/simulation/elements/CLNE.cpp15
-rw-r--r--src/simulation/elements/DEUT.cpp4
-rw-r--r--src/simulation/elements/GPMP.cpp9
-rw-r--r--src/simulation/elements/HSWC.cpp9
-rw-r--r--src/simulation/elements/LIGH.cpp134
-rw-r--r--src/simulation/elements/MERC.cpp2
-rw-r--r--src/simulation/elements/NBLE.cpp22
-rw-r--r--src/simulation/elements/NEUT.cpp39
-rw-r--r--src/simulation/elements/O2.cpp54
-rw-r--r--src/simulation/elements/PBCN.cpp53
-rw-r--r--src/simulation/elements/PCLN.cpp39
-rw-r--r--src/simulation/elements/PHOT.cpp10
-rw-r--r--src/simulation/elements/PIPE.cpp16
14 files changed, 190 insertions, 231 deletions
diff --git a/src/simulation/elements/BCLN.cpp b/src/simulation/elements/BCLN.cpp
index 80a5d44..a617620 100644
--- a/src/simulation/elements/BCLN.cpp
+++ b/src/simulation/elements/BCLN.cpp
@@ -59,7 +59,7 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS)
}
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
{
- 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)
@@ -69,13 +69,14 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
- (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM &&
- (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 &&
- (r&0xFF)<PT_NUM)
+ rt = r&0xFF;
+ if (rt!=PT_CLNE && rt!=PT_PCLN &&
+ rt!=PT_BCLN && rt!=PT_STKM &&
+ rt!=PT_PBCN && rt!=PT_STKM2 &&
+ rt<PT_NUM)
{
- parts[i].ctype = r&0xFF;
- if ((r&0xFF)==PT_LIFE || (r&0xFF)==PT_LAVA)
+ parts[i].ctype = rt;
+ if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[r>>8].ctype;
}
}
diff --git a/src/simulation/elements/CLNE.cpp b/src/simulation/elements/CLNE.cpp
index 6ffe4f1..f0a9c44 100644
--- a/src/simulation/elements/CLNE.cpp
+++ b/src/simulation/elements/CLNE.cpp
@@ -51,7 +51,7 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS)
{
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
{
- 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)
@@ -61,13 +61,14 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
- (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM &&
- (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 &&
- (r&0xFF)<PT_NUM)
+ rt = r&0xFF;
+ if (rt!=PT_CLNE && rt!=PT_PCLN &&
+ rt!=PT_BCLN && rt!=PT_STKM &&
+ rt!=PT_PBCN && rt!=PT_STKM2 &&
+ rt<PT_NUM)
{
- parts[i].ctype = r&0xFF;
- if ((r&0xFF)==PT_LIFE || (r&0xFF)==PT_LAVA)
+ parts[i].ctype = rt;
+ if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[r>>8].ctype;
}
}
diff --git a/src/simulation/elements/DEUT.cpp b/src/simulation/elements/DEUT.cpp
index b8209e4..98f27a5 100644
--- a/src/simulation/elements/DEUT.cpp
+++ b/src/simulation/elements/DEUT.cpp
@@ -66,7 +66,7 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r || (parts[i].life >=maxlife))
continue;
- if ((r&0xFF)==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1)
+ if ((r&0xFF)==PT_DEUT&& !(rand()%3))
{
if ((parts[i].life + parts[r>>8].life + 1) <= maxlife)
{
@@ -146,4 +146,4 @@ int Element_DEUT::graphics(GRAPHICS_FUNC_ARGS)
}
-Element_DEUT::~Element_DEUT() {} \ No newline at end of file
+Element_DEUT::~Element_DEUT() {}
diff --git a/src/simulation/elements/GPMP.cpp b/src/simulation/elements/GPMP.cpp
index 24f180a..d22934e 100644
--- a/src/simulation/elements/GPMP.cpp
+++ b/src/simulation/elements/GPMP.cpp
@@ -50,9 +50,12 @@ Element_GPMP::Element_GPMP()
int Element_GPMP::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
- if (parts[i].life!=10 && parts[i].life>0)
- parts[i].life--;
- else if (parts[i].life==10)
+ if (parts[i].life!=10)
+ {
+ if (parts[i].life>0)
+ parts[i].life--;
+ }
+ else
{
if (parts[i].temp>=256.0+273.15)
parts[i].temp=256.0+273.15;
diff --git a/src/simulation/elements/HSWC.cpp b/src/simulation/elements/HSWC.cpp
index 81484d6..1b3200d 100644
--- a/src/simulation/elements/HSWC.cpp
+++ b/src/simulation/elements/HSWC.cpp
@@ -50,9 +50,12 @@ Element_HSWC::Element_HSWC()
int Element_HSWC::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
- if (parts[i].life!=10 && parts[i].life>0)
- parts[i].life--;
- else if (parts[i].life==10)
+ if (parts[i].life!=10)
+ {
+ if (parts[i].life>0)
+ parts[i].life--;
+ }
+ else
{
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
diff --git a/src/simulation/elements/LIGH.cpp b/src/simulation/elements/LIGH.cpp
index d280fc1..23f815a 100644
--- a/src/simulation/elements/LIGH.cpp
+++ b/src/simulation/elements/LIGH.cpp
@@ -101,39 +101,40 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
}
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 (rt!=PT_CLNE&&rt!=PT_THDR&&rt!=PT_DMND&&rt!=PT_FIRE)
{
if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0)
{
sim->create_part(r>>8,x+rx,y+ry,PT_SPRK);
}
- 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 (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;
- if (rand()%3==0)
+ if (rt==PT_DEUT || rt==PT_PLUT) // start nuclear reactions
{
- sim->part_change_type(r>>8,x+rx,y+ry,PT_NEUT);
- parts[r>>8].life = rand()%480+480;
- parts[r>>8].vx=rand()%10-5;
- parts[r>>8].vy=rand()%10-5;
+ parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful, MIN_TEMP, MAX_TEMP);
+ sim->pv[y/CELL][x/CELL] +=powderful/35;
+ if (!(rand()%3))
+ {
+ sim->part_change_type(r>>8,x+rx,y+ry,PT_NEUT);
+ parts[r>>8].life = rand()%480+480;
+ parts[r>>8].vx=rand()%10-5;
+ parts[r>>8].vy=rand()%10-5;
+ }
}
- }
- if (rt==PT_COAL || rt==PT_BCOL) // ignite coal
- {
- if (parts[r>>8].life>100) {
- parts[r>>8].life = 99;
+ else if (rt==PT_COAL || rt==PT_BCOL) // ignite coal
+ {
+ if (parts[r>>8].life>100) {
+ parts[r>>8].life = 99;
+ }
+ }
+ else if ((rt==PT_STKM && sim->player.elem!=PT_LIGH) || (rt==PT_STKM2 && sim->player2.elem!=PT_LIGH))
+ {
+ parts[r>>8].life-=powderful/100;
}
+ 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.3, MIN_TEMP, MAX_TEMP);
}
- if (sim->elements[r&0xFF].HeatConduct)
+ else
parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP);
- if ((rt==PT_STKM && sim->player.elem!=PT_LIGH) || (rt==PT_STKM2 && sim->player2.elem!=PT_LIGH))
- {
- parts[r>>8].life-=powderful/100;
- }
+
}
}
if (parts[i].tmp2==3)
@@ -141,28 +142,21 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
parts[i].tmp2=0;
return 1;
}
-
- if (parts[i].tmp2==-1)
+ else if (parts[i].tmp2<=-1)
{
sim->kill_part(i);
return 1;
}
- if (parts[i].tmp2<=0 || parts[i].life<=1)
+ else if (parts[i].tmp2<=0 || parts[i].life<=1)
{
if (parts[i].tmp2>0)
parts[i].tmp2=0;
parts[i].tmp2--;
return 1;
}
- if (parts[i].tmp2<=-2)
- {
- sim->kill_part(i);
- return 1;
- }
-
- angle2=-1;
- pNear = LIGH_nearest_part(sim, i, parts[i].life*2.5);
+ //Completely broken and laggy function, possible can be fixed later
+ /*pNear = LIGH_nearest_part(sim, i, parts[i].life*2.5);
if (pNear!=-1)
{
int t=parts[pNear].type;
@@ -196,59 +190,21 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
}
}
else pNear=-1;
- }
+ }*/
//if (parts[i].tmp2==1/* || near!=-1*/)
//angle=0;//parts[i].tmp-30+rand()%60;
- angle = parts[i].tmp-30+rand()%60;
- if (angle<0)
- angle+=360;
- if (angle>=360)
- angle-=360;
- if (parts[i].tmp2==2 && pNear==-1)
- {
- angle2=angle+100-rand()%200;
- if (angle2<0)
- angle2+=360;
- if (angle2>=360)
- angle-=360;
- }
-
- multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1));
+ angle = (parts[i].tmp-30+rand()%60)%360;
+ multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1));
rx=cos(angle*M_PI/180)*multipler;
ry=-sin(angle*M_PI/180)*multipler;
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle, 0);
-
- if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
+ if (parts[i].tmp2==2)// && pNear==-1)
{
- r = pmap[y+ry][x+rx];
- if ((r&0xFF)==PT_LIGH)
- {
- parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+60);
- parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2);
- parts[r>>8].tmp=angle;
- parts[r>>8].temp=parts[i].temp;
- }
- }
-
- if (angle2!=-1)
- {
- multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1));
+ angle2= ((int)angle+100-rand()%200)%360;
rx=cos(angle2*M_PI/180)*multipler;
ry=-sin(angle2*M_PI/180)*multipler;
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle2, 0);
-
- if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
- {
- r = pmap[y+ry][x+rx];
- if ((r&0xFF)==PT_LIGH)
- {
- parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+40);
- parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2);
- parts[r>>8].tmp=angle;
- parts[r>>8].temp=parts[i].temp;
- }
- }
}
parts[i].tmp2=-1;
@@ -297,16 +253,24 @@ int Element_LIGH::contact_part(Simulation * sim, int i, int tp)
return -1;
}
-//#TPT-Directive ElementHeader Element_LIGH static bool create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2)
-bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2)
+//#TPT-Directive ElementHeader Element_LIGH static bool create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2, bool last)
+bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp, int life, int tmp, int tmp2, bool last)
{
int p = sim->create_part(-1, x, y,c);
if (p != -1)
{
- sim->parts[p].life = life;
sim->parts[p].temp = temp;
sim->parts[p].tmp = tmp;
- sim->parts[p].tmp2 = tmp2;
+ if (last)
+ {
+ sim->parts[p].tmp2=1+(rand()%200>tmp2*tmp2/10+60);
+ sim->parts[p].life=(int)(life/1.5-rand()%2);
+ }
+ else
+ {
+ sim->parts[p].life = life;
+ sim->parts[p].tmp2 = tmp2;
+ }
}
else if (x >= 0 && x < XRES && y >= 0 && y < YRES)
{
@@ -348,9 +312,9 @@ void Element_LIGH::create_line_par(Simulation * sim, int x1, int y1, int x2, int
{
bool ret;
if (reverseXY)
- ret = create_LIGH(sim, y, x, c, temp, life, tmp, tmp2);
+ ret = create_LIGH(sim, y, x, c, temp, life, tmp, tmp2,x==x2);
else
- ret = create_LIGH(sim, x, y, c, temp, life, tmp, tmp2);
+ ret = create_LIGH(sim, x, y, c, temp, life, tmp, tmp2,x==x2);
if (ret)
return;
@@ -368,9 +332,9 @@ void Element_LIGH::create_line_par(Simulation * sim, int x1, int y1, int x2, int
{
bool ret;
if (reverseXY)
- ret = create_LIGH(sim, y, x, c, temp, life, tmp, tmp2);
+ ret = create_LIGH(sim, y, x, c, temp, life, tmp, tmp2,x==x2);
else
- ret = create_LIGH(sim, x, y, c, temp, life, tmp, tmp2);
+ ret = create_LIGH(sim, x, y, c, temp, life, tmp, tmp2,x==x2);
if (ret)
return;
diff --git a/src/simulation/elements/MERC.cpp b/src/simulation/elements/MERC.cpp
index 655a8b9..57c6481 100644
--- a/src/simulation/elements/MERC.cpp
+++ b/src/simulation/elements/MERC.cpp
@@ -62,7 +62,7 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r || (parts[i].tmp >=maxtmp))
continue;
- if ((r&0xFF)==PT_MERC&&33>=rand()/(RAND_MAX/100)+1)
+ if ((r&0xFF)==PT_MERC&& !(rand()%3))
{
if ((parts[i].tmp + parts[r>>8].tmp + 1) <= maxtmp)
{
diff --git a/src/simulation/elements/NBLE.cpp b/src/simulation/elements/NBLE.cpp
index 3093d45..dedd4d6 100644
--- a/src/simulation/elements/NBLE.cpp
+++ b/src/simulation/elements/NBLE.cpp
@@ -53,41 +53,41 @@ int Element_NBLE::update(UPDATE_FUNC_ARGS)
if (parts[i].temp > 5273.15 && sim->pv[y/CELL][x/CELL] > 100.0f)
{
parts[i].tmp = 1;
- if (rand()%5 < 1)
+ if (!(rand()%5))
{
- int j;
- float temp = parts[i].temp;
- sim->create_part(i,x,y,PT_CO2);
+ int j;
+ float temp = parts[i].temp;
+ sim->create_part(i,x,y,PT_CO2);
- j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT);
+ j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT);
if (j != -1)
parts[j].temp = temp;
- if (!(rand()%25))
+ if (!(rand()%25))
{
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC);
if (j != -1)
parts[j].temp = temp;
}
- j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT);
+ j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT);
if (j != -1)
{
parts[j].ctype = 0xF800000;
parts[j].temp = temp;
}
- j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PLSM);
+ j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PLSM);
if (j != -1)
{
parts[j].temp = temp;
parts[j].tmp |= 4;
}
- parts[i].temp = temp+1750+rand()%500;
- sim->pv[y/CELL][x/CELL] += 50;
+ parts[i].temp = temp+1750+rand()%500;
+ sim->pv[y/CELL][x/CELL] += 50;
}
}
return 0;
}
-Element_NBLE::~Element_NBLE() {} \ No newline at end of file
+Element_NBLE::~Element_NBLE() {}
diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp
index 4641370..31c990b 100644
--- a/src/simulation/elements/NEUT.cpp
+++ b/src/simulation/elements/NEUT.cpp
@@ -58,14 +58,15 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW)
+ rt = r&0xFF;
+ if (rt==PT_WATR || rt==PT_ICEI || rt==PT_SNOW)
{
parts[i].vx *= 0.995;
parts[i].vy *= 0.995;
}
- if ((r&0xFF)==PT_PLUT && pressureFactor>(rand()%1000))
+ if (rt==PT_PLUT && pressureFactor>(rand()%1000))
{
- if (33>rand()%100)
+ if (!(rand()%3))
{
sim->create_part(r>>8, x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN);
parts[r>>8].temp = MAX_TEMP;
@@ -84,13 +85,13 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
}
#ifdef SDEUT
- else if ((r&0xFF)==PT_DEUT && (pressureFactor+1+(parts[r>>8].life/100))>(rand()%1000))
+ else if (rt==PT_DEUT && (pressureFactor+1+(parts[r>>8].life/100))>(rand()%1000))
{
create_n_parts(sim, parts[r>>8].life, x+rx, y+ry, parts[i].vx, parts[i].vy, restrict_flt(parts[r>>8].temp + parts[r>>8].life*500, MIN_TEMP, MAX_TEMP), PT_NEUT);
sim->kill_part(r>>8);
}
#else
- else if ((r&0xFF)==PT_DEUT && (pressureFactor+1)>(rand()%1000))
+ else if (rt==PT_DEUT && (pressureFactor+1)>(rand()%1000))
{
create_part(r>>8, x+rx, y+ry, PT_NEUT);
parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
@@ -105,36 +106,36 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
sim.kill_part(r>>8);
}
#endif
- else if ((r&0xFF)==PT_GUNP && 15>(rand()%1000))
+ else if (rt==PT_GUNP && 3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DUST);
- else if ((r&0xFF)==PT_DYST && 15>(rand()%1000))
+ else if (rt==PT_DYST && 3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_YEST);
- else if ((r&0xFF)==PT_YEST)
+ else if (rt==PT_YEST)
sim->part_change_type(r>>8,x+rx,y+ry,PT_DYST);
- else if ((r&0xFF)==PT_WATR && 15>(rand()%100))
+ else if (rt==PT_WATR && 3>(rand()%20))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DSTW);
- else if ((r&0xFF)==PT_PLEX && 15>(rand()%1000))
+ else if (rt==PT_PLEX && 3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_GOO);
- else if ((r&0xFF)==PT_NITR && 15>(rand()%1000))
+ else if (rt==PT_NITR && 3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DESL);
- else if ((r&0xFF)==PT_PLNT && 5>(rand()%100))
+ else if (rt==PT_PLNT && !(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_WOOD);
- else if ((r&0xFF)==PT_DESL && 15>(rand()%1000))
+ else if (rt==PT_DESL && 3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_GAS);
- else if ((r&0xFF)==PT_COAL && 5>(rand()%100))
+ else if (rt==PT_COAL && !(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_WOOD);
- else if ((r&0xFF)==PT_DUST && 5>(rand()%100))
+ else if (rt==PT_DUST && !(rand()%20))
sim->part_change_type(r>>8, x+rx, y+ry, PT_FWRK);
- else if ((r&0xFF)==PT_FWRK && 5>(rand()%100))
+ else if (rt==PT_FWRK && !(rand()%20))
parts[r>>8].ctype = PT_DUST;
- else if ((r&0xFF)==PT_ACID && 5>(rand()%100))
+ else if (rt==PT_ACID && !(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_ISOZ);
- else if ((r&0xFF)==PT_TTAN && 5>(rand()%100))
+ else if (rt==PT_TTAN && !(rand()%20))
{
sim->kill_part(i);
return 1;
}
- else if ((r&0xFF)==PT_EXOT && 5>(rand()%100))
+ else if (rt==PT_EXOT && 5>(rand()%100))
parts[r>>8].life = 1500;
/*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM &&
(elements[parts[r>>8].type-1].menusection==SC_LIQUID||
diff --git a/src/simulation/elements/O2.cpp b/src/simulation/elements/O2.cpp
index 20bd902..d446834 100644
--- a/src/simulation/elements/O2.cpp
+++ b/src/simulation/elements/O2.cpp
@@ -50,51 +50,53 @@ Element_O2::Element_O2()
int Element_O2::update(UPDATE_FUNC_ARGS)
{
int r,rx,ry;
- for (rx=-2; rx<3; rx++)
- for (ry=-2; ry<3; 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;
+ for (rx=-2; rx<3; rx++)
+ for (ry=-2; ry<3; 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_FIRE)
- {
- parts[r>>8].temp+=(rand()/(RAND_MAX/100));
- if(parts[r>>8].tmp&0x01)
+ if ((r&0xFF)==PT_FIRE)
+ {
+ parts[r>>8].temp+=(rand()%100);
+ if(parts[r>>8].tmp&0x01)
parts[r>>8].temp=3473;
- parts[r>>8].tmp |= 2;
- }
- if ((r&0xFF)==PT_FIRE || ((r&0xFF)==PT_PLSM && !(parts[r>>8].tmp&4)))
- {
- sim->create_part(i,x,y,PT_FIRE);
- parts[i].temp+=(rand()/(RAND_MAX/100));
- parts[i].tmp |= 2;
- }
+ parts[r>>8].tmp |= 2;
+ sim->create_part(i,x,y,PT_FIRE);
+ parts[i].temp+=(rand()%100);
+ parts[i].tmp |= 2;
}
+ else if ((r&0xFF)==PT_PLSM && !(parts[r>>8].tmp&4))
+ {
+ sim->create_part(i,x,y,PT_FIRE);
+ parts[i].temp+=(rand()%100);
+ parts[i].tmp |= 2;
+ }
+ }
if (parts[i].temp > 9973.15 && sim->pv[y/CELL][x/CELL] > 250.0f && abs(sim->gravx[((y/CELL)*(XRES/CELL))+(x/CELL)]) + abs(sim->gravy[((y/CELL)*(XRES/CELL))+(x/CELL)]) > 20)
{
- if (rand()%5 < 1)
+ if (!(rand()%5))
{
int j;
sim->create_part(i,x,y,PT_BRMT);
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT);
if (j != -1)
- parts[j].temp = 15000;
+ parts[j].temp = MAX_TEMP;
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT);
if (j != -1)
- parts[j].temp = 15000;
+ parts[j].temp = MAX_TEMP;
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PLSM);
if (j != -1)
{
- parts[j].temp = 15000;
+ parts[j].temp = MAX_TEMP;
parts[j].tmp |= 4;
}
-
- parts[i].temp = 15000;
- sim->pv[y/CELL][x/CELL] += 300;
+ parts[i].temp = MAX_TEMP;
+ sim->pv[y/CELL][x/CELL] = 256;
}
}
return 0;
diff --git a/src/simulation/elements/PBCN.cpp b/src/simulation/elements/PBCN.cpp
index e3bc7ce..bbc9e45 100644
--- a/src/simulation/elements/PBCN.cpp
+++ b/src/simulation/elements/PBCN.cpp
@@ -48,10 +48,8 @@ Element_PBCN::Element_PBCN()
//#TPT-Directive ElementHeader Element_PBCN static int update(UPDATE_FUNC_ARGS)
int Element_PBCN::update(UPDATE_FUNC_ARGS)
- {
- int r, rx, ry;
- if (parts[i].life>0 && parts[i].life!=10)
- parts[i].life--;
+{
+ int r, rx, ry, rt;
if (!parts[i].tmp2 && sim->pv[y/CELL][x/CELL]>4.0f)
parts[i].tmp2 = rand()%40+80;
if (parts[i].tmp2)
@@ -75,20 +73,25 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
- (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK &&
- (r&0xFF)!=PT_NSCN && (r&0xFF)!=PT_PSCN &&
- (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 &&
- (r&0xFF)!=PT_PBCN && (r&0xFF)<PT_NUM)
+ rt = r&0xFF;
+ if (rt!=PT_CLNE && rt!=PT_PCLN &&
+ rt!=PT_BCLN && rt!=PT_SPRK &&
+ rt!=PT_NSCN && rt!=PT_PSCN &&
+ rt!=PT_STKM && rt!=PT_STKM2 &&
+ rt!=PT_PBCN && rt<PT_NUM)
{
- parts[i].ctype = r&0xFF;
- if ((r&0xFF)==PT_LIFE || (r&0xFF)==PT_LAVA)
+ parts[i].ctype = rt;
+ if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[r>>8].ctype;
}
}
- if (parts[i].life==10)
+ if (parts[i].life!=10)
+ {
+ if (parts[i].life>0)
+ parts[i].life--;
+ }
+ else
{
-
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
@@ -105,16 +108,14 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
}
}
}
- if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10) {
+ if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10)
+ {
if (parts[i].ctype==PT_PHOT) {//create photons a different way
for (rx=-1; rx<2; rx++)
- {
for (ry = -1; ry < 2; ry++)
- {
if (rx || ry)
{
- int r = sim->create_part(-1, x + rx, y + ry,
- parts[i].ctype);
+ int r = sim->create_part(-1, x + rx, y + ry,parts[i].ctype);
if (r != -1)
{
parts[r].vx = rx * 3;
@@ -126,20 +127,16 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
}
}
}
- }
- }
}
- else if (parts[i].ctype==PT_LIFE) {//create life a different way
- for (rx=-1; rx<2; rx++) {
- for (ry=-1; ry<2; ry++) {
+ else if (parts[i].ctype==PT_LIFE)//create life a different way
+ for (rx=-1; rx<2; rx++)
+ for (ry=-1; ry<2; ry++)
sim->create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8));
- }
- }
- }
- else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
+
+ else if (parts[i].ctype!=PT_LIGH || !(rand()%30))
{
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
- if (np>=0)
+ if (np>-1)
{
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
parts[np].ctype = parts[i].tmp;
diff --git a/src/simulation/elements/PCLN.cpp b/src/simulation/elements/PCLN.cpp
index 7e6b3d7..926b232 100644
--- a/src/simulation/elements/PCLN.cpp
+++ b/src/simulation/elements/PCLN.cpp
@@ -49,7 +49,7 @@ Element_PCLN::Element_PCLN()
//#TPT-Directive ElementHeader Element_PCLN static int update(UPDATE_FUNC_ARGS)
int Element_PCLN::update(UPDATE_FUNC_ARGS)
{
- int r, rx, ry;
+ int r, rx, ry, rt;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
for (rx=-2; rx<3; rx++)
@@ -66,7 +66,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
else if (parts[r>>8].ctype==PT_NSCN)
parts[i].life = 9;
}
- if ((r&0xFF)==PT_PCLN)
+ else if ((r&0xFF)==PT_PCLN)
{
if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
parts[i].life = 9;
@@ -84,27 +84,26 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
- (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK &&
- (r&0xFF)!=PT_NSCN && (r&0xFF)!=PT_PSCN &&
- (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 &&
- (r&0xFF)!=PT_PBCN && (r&0xFF)<PT_NUM)
+ rt = r&0xFF;
+ if (rt!=PT_CLNE && rt!=PT_PCLN &&
+ rt!=PT_BCLN && rt!=PT_SPRK &&
+ rt!=PT_NSCN && rt!=PT_PSCN &&
+ rt!=PT_STKM && rt!=PT_STKM2 &&
+ rt!=PT_PBCN && rt<PT_NUM)
{
- parts[i].ctype = r&0xFF;
- if ((r&0xFF)==PT_LIFE || (r&0xFF)==PT_LAVA)
+ parts[i].ctype = rt;
+ if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[r>>8].ctype;
}
}
- if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10) {
+ if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10)
+ {
if (parts[i].ctype==PT_PHOT) {//create photons a different way
for (rx=-1; rx<2; rx++)
- {
for (ry = -1; ry < 2; ry++)
- {
if (rx || ry)
{
- int r = sim->create_part(-1, x + rx, y + ry,
- parts[i].ctype);
+ int r = sim->create_part(-1, x + rx, y + ry, parts[i].ctype);
if (r != -1)
{
parts[r].vx = rx * 3;
@@ -116,16 +115,12 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
}
}
}
- }
- }
}
- else if (parts[i].ctype==PT_LIFE) {//create life a different way
- for (rx=-1; rx<2; rx++) {
- for (ry=-1; ry<2; ry++) {
+ else if (parts[i].ctype==PT_LIFE)//create life a different way
+ for (rx=-1; rx<2; rx++)
+ for (ry=-1; ry<2; ry++)
sim->create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8));
- }
- }
- }
+
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
{
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp
index ac8c5c8..2c6c81f 100644
--- a/src/simulation/elements/PHOT.cpp
+++ b/src/simulation/elements/PHOT.cpp
@@ -58,14 +58,14 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
return 1;
}
if (parts[i].temp > 506)
- if (1>rand()%10) Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
+ if (!(rand()%10)) Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
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_ISOZ && 5>(rand()%2000))
+ if ((r&0xFF)==PT_ISOZ && !(rand()%400))
{
parts[i].vx *= 0.90;
parts[i].vy *= 0.90;
@@ -76,7 +76,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
parts[r>>8].vy = rr*sinf(rrr);
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
}
- if ((r&0xFF)==PT_ISZS && 5>(rand()%2000))
+ if ((r&0xFF)==PT_ISZS && !(rand()%400))
{
parts[i].vx *= 0.90;
parts[i].vy *= 0.90;
@@ -89,7 +89,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
}
}
r = pmap[y][x];
- if((r&0xFF) == PT_QRTZ && r)// && parts[i].ctype==0x3FFFFFFF)
+ if((r&0xFF) == PT_QRTZ)// && parts[i].ctype==0x3FFFFFFF)
{
float a = (rand()%360)*3.14159f/180.0f;
parts[i].vx = 3.0f*cosf(a);
@@ -138,4 +138,4 @@ int Element_PHOT::graphics(GRAPHICS_FUNC_ARGS)
}
-Element_PHOT::~Element_PHOT() {} \ No newline at end of file
+Element_PHOT::~Element_PHOT() {}
diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp
index 3d631a1..80f6ba2 100644
--- a/src/simulation/elements/PIPE.cpp
+++ b/src/simulation/elements/PIPE.cpp
@@ -216,21 +216,13 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
{
if (parts[i].temp<272.15)//manual pipe colors
{
- if (parts[i].temp>173.25&&parts[i].temp<273.15)
- {
+ if (parts[i].temp>173.25)
parts[i].ctype = 2;
- parts[i].life = 0;
- }
- if (parts[i].temp>73.25&&parts[i].temp<=173.15)
- {
+ else if (parts[i].temp>73.25)
parts[i].ctype = 3;
- parts[i].life = 0;
- }
- if (parts[i].temp>=0&&parts[i].temp<=73.15)
- {
+ else if (parts[i].temp>=0)
parts[i].ctype = 4;
- parts[i].life = 0;
- }
+ parts[i].life = 0;
}
else
{