summaryrefslogtreecommitdiff
path: root/src/simulation/elements/DSTW.cpp
diff options
context:
space:
mode:
authorcracker64 <cracker642@gmail.com>2013-02-27 05:11:23 (GMT)
committer cracker64 <cracker642@gmail.com>2013-02-27 05:11:23 (GMT)
commit27e3e1251837f5d64e835068d5f5bd5b67b95921 (patch)
treeaf6383f7df96485633c91ebcfbe6318ee927403f /src/simulation/elements/DSTW.cpp
parenta62467c74e9391dd2a9173cfa167d32eceed506b (diff)
downloadpowder-27e3e1251837f5d64e835068d5f5bd5b67b95921.zip
powder-27e3e1251837f5d64e835068d5f5bd5b67b95921.tar.gz
Small optimizations number 2.
Diffstat (limited to 'src/simulation/elements/DSTW.cpp')
-rw-r--r--src/simulation/elements/DSTW.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/simulation/elements/DSTW.cpp b/src/simulation/elements/DSTW.cpp
index 8b16107..970dbb2 100644
--- a/src/simulation/elements/DSTW.cpp
+++ b/src/simulation/elements/DSTW.cpp
@@ -49,7 +49,7 @@ Element_DSTW::Element_DSTW()
//#TPT-Directive ElementHeader Element_DSTW static int update(UPDATE_FUNC_ARGS)
int Element_DSTW::update(UPDATE_FUNC_ARGS)
{
- int r, rx, ry;
+ int r, rx, ry, rt;
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))
@@ -57,36 +57,37 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)==PT_SALT && 1>(rand()%250))
+ rt = r&0xFF;
+ if (rt==PT_SALT && !(rand()%250))
{
sim->part_change_type(i,x,y,PT_SLTW);
// on average, convert 3 DSTW to SLTW before SALT turns into SLTW
- if (rand()%3==0)
+ if (!rand()%3)
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
}
- if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && 1>(rand()%500))
+ if ((rt==PT_WATR||rt==PT_SLTW) && !(rand()%500))
{
sim->part_change_type(i,x,y,PT_WATR);
}
- if ((r&0xFF)==PT_SLTW && 1>(rand()%10000))
+ if (rt==PT_SLTW && !(rand()%10000))
{
sim->part_change_type(i,x,y,PT_SLTW);
}
- if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>12.0f) && 1>(rand()%500))
+ if ((rt==PT_RBDM||rt==PT_LRBD) && (sim->legacy_enable||parts[i].temp>12.0f) && !(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
}
- if ((r&0xFF)==PT_FIRE){
+ if (rt==PT_FIRE){
sim->kill_part(r>>8);
- if(1>(rand()%150)){
- sim->kill_part(i);
- return 1;
- }
+ if(!(rand()%150)){
+ sim->kill_part(i);
+ return 1;
+ }
}
}
return 0;
}
-Element_DSTW::~Element_DSTW() {} \ No newline at end of file
+Element_DSTW::~Element_DSTW() {}