summaryrefslogtreecommitdiff
path: root/src/simulation/elements/DLAY.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/DLAY.cpp
parenta62467c74e9391dd2a9173cfa167d32eceed506b (diff)
downloadpowder-27e3e1251837f5d64e835068d5f5bd5b67b95921.zip
powder-27e3e1251837f5d64e835068d5f5bd5b67b95921.tar.gz
Small optimizations number 2.
Diffstat (limited to 'src/simulation/elements/DLAY.cpp')
-rw-r--r--src/simulation/elements/DLAY.cpp57
1 files changed, 26 insertions, 31 deletions
diff --git a/src/simulation/elements/DLAY.cpp b/src/simulation/elements/DLAY.cpp
index e69c202..1bce999 100644
--- a/src/simulation/elements/DLAY.cpp
+++ b/src/simulation/elements/DLAY.cpp
@@ -53,44 +53,39 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS)
oldl = parts[i].life;
if (parts[i].life>0)
parts[i].life--;
- //if (parts[i].life==1)
- //{
- if (parts[i].temp>=MAX_TEMP+273.15f)
- parts[i].temp = MAX_TEMP+273.15f;
if (parts[i].temp<= 1.0f+273.15f)
parts[i].temp = 1.0f+273.15f;
-
- 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))
+ 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 || sim->parts_avg(r>>8, i,PT_INSL)==PT_INSL)
+ continue;
+ if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life>0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN)
{
- r = pmap[y+ry][x+rx];
- if (!r || sim->parts_avg(r>>8, i,PT_INSL)==PT_INSL)
- continue;
- if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life>0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN)
- {
- parts[i].life = (int)(parts[i].temp-273.15);
- }
- else if ((r&0xFF)==PT_DLAY)
+ parts[i].life = (int)(parts[i].temp-273.15);
+ }
+ else if ((r&0xFF)==PT_DLAY)
+ {
+ if(!parts[i].life && parts[r>>8].life)
{
- if(!parts[i].life && parts[r>>8].life)
- {
- parts[i].life = parts[r>>8].life;
- if((r>>8)>i) //If the other particle hasn't been life updated
- parts[i].life--;
- }
- else if(parts[i].life && !parts[r>>8].life)
- {
- parts[r>>8].life = parts[i].life;
- if((r>>8)>i) //If the other particle hasn't been life updated
- parts[r>>8].life++;
- }
+ parts[i].life = parts[r>>8].life;
+ if((r>>8)>i) //If the other particle hasn't been life updated
+ parts[i].life--;
}
- else if((r&0xFF)==PT_NSCN && oldl==1)
+ else if(parts[i].life && !parts[r>>8].life)
{
- sim->create_part(-1, x+rx, y+ry, PT_SPRK);
+ parts[r>>8].life = parts[i].life;
+ if((r>>8)>i) //If the other particle hasn't been life updated
+ parts[r>>8].life++;
}
}
+ else if((r&0xFF)==PT_NSCN && oldl==1)
+ {
+ sim->create_part(-1, x+rx, y+ry, PT_SPRK);
+ }
+ }
//}
return 0;
}
@@ -108,4 +103,4 @@ int Element_DLAY::graphics(GRAPHICS_FUNC_ARGS)
}
-Element_DLAY::~Element_DLAY() {} \ No newline at end of file
+Element_DLAY::~Element_DLAY() {}