summaryrefslogtreecommitdiff
path: root/src/simulation/elements/CO2.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/CO2.cpp
parenta62467c74e9391dd2a9173cfa167d32eceed506b (diff)
downloadpowder-27e3e1251837f5d64e835068d5f5bd5b67b95921.zip
powder-27e3e1251837f5d64e835068d5f5bd5b67b95921.tar.gz
Small optimizations number 2.
Diffstat (limited to 'src/simulation/elements/CO2.cpp')
-rw-r--r--src/simulation/elements/CO2.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/simulation/elements/CO2.cpp b/src/simulation/elements/CO2.cpp
index 49614fb..c4e6a9a 100644
--- a/src/simulation/elements/CO2.cpp
+++ b/src/simulation/elements/CO2.cpp
@@ -55,47 +55,48 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
- if (parts[i].ctype==5 && 20>(rand()%40000))
- {
- if (sim->create_part(-1, x+rx, y+ry, PT_WATR)>=0)
- parts[i].ctype = 0;
- }
- if ((r>>8)>=NPART || !r)
+ if (!r)
continue;
if ((r&0xFF)==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;
+ }
}
- if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%250))
+ if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%250))
{
sim->part_change_type(r>>8, x+rx, y+ry, PT_CBNW);
if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet
sim->create_part(i, x, y, PT_WATR);
else
+ {
sim->kill_part(i);
+ return 1;
+ }
}
}
+ if (parts[i].ctype==5 && !(rand()%83))
+ {
+ if (sim->create_part(-1, x+rx, y+ry, PT_WATR)>=0)
+ parts[i].ctype = 0;
+ }
if (parts[i].temp > 9773.15 && sim->pv[y/CELL][x/CELL] > 200.0f)
{
- if (rand()%5 < 1)
+ if (!(rand()%5))
{
int j;
sim->create_part(i,x,y,PT_O2);
-
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;
if (!(rand()%50))
{
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC);
if (j != -1)
- parts[j].temp = 15000;
+ parts[j].temp = MAX_TEMP;
}
-
- parts[i].temp = 15000;
+ parts[i].temp = MAX_TEMP;
sim->pv[y/CELL][x/CELL] += 100;
}
}