summaryrefslogtreecommitdiff
path: root/src/simulation/elements/PBCN.cpp
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/PBCN.cpp
parent3d2e59415003c51c0b6dbe764003cc2012ba9ca7 (diff)
downloadpowder-08d1a68ce091b6ba53788224fd1bda92c1895ca6.zip
powder-08d1a68ce091b6ba53788224fd1bda92c1895ca6.tar.gz
More fixes.
Diffstat (limited to 'src/simulation/elements/PBCN.cpp')
-rw-r--r--src/simulation/elements/PBCN.cpp53
1 files changed, 25 insertions, 28 deletions
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;