summaryrefslogtreecommitdiff
path: root/src/simulation/elements/FUSE.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/FUSE.cpp
parenta62467c74e9391dd2a9173cfa167d32eceed506b (diff)
downloadpowder-27e3e1251837f5d64e835068d5f5bd5b67b95921.zip
powder-27e3e1251837f5d64e835068d5f5bd5b67b95921.tar.gz
Small optimizations number 2.
Diffstat (limited to 'src/simulation/elements/FUSE.cpp')
-rw-r--r--src/simulation/elements/FUSE.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/simulation/elements/FUSE.cpp b/src/simulation/elements/FUSE.cpp
index 946e86b..5e9c95d 100644
--- a/src/simulation/elements/FUSE.cpp
+++ b/src/simulation/elements/FUSE.cpp
@@ -52,25 +52,26 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS)
int r, rx, ry;
if (parts[i].life<=0) {
r = sim->create_part(i, x, y, PT_PLSM);
- if (r!=-1)
+ if (r>-1)
parts[r].life = 50;
return 1;
} else if (parts[i].life < 40) {
parts[i].life--;
- if ((rand()%100)==0) {
- r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM);
- if (r!=-1)
+ if (!(rand()%100)) {
+ r = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_PLSM);
+ if (r>-1)
parts[r].life = 50;
}
}
- if ((sim->pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40)
+ if ((sim->pv[y/CELL][x/CELL] > 2.7f) && parts[i].tmp>40)
parts[i].tmp=39;
- else if (parts[i].tmp<40&&parts[i].tmp>0)
- parts[i].tmp--;
else if (parts[i].tmp<=0) {
sim->create_part(i, x, y, PT_FSEP);
return 1;
}
+ else if (parts[i].tmp<40)
+ parts[i].tmp--;
+
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))
@@ -78,15 +79,14 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20)))
+ if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && parts[i].life>40 && !(rand()%20)))
{
- if (parts[i].life>40) {
- parts[i].life = 39;
- }
+ parts[i].life = 39;
+
}
}
return 0;
}
-Element_FUSE::~Element_FUSE() {} \ No newline at end of file
+Element_FUSE::~Element_FUSE() {}