summaryrefslogtreecommitdiff
path: root/src/simulation/elements/EXOT.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/EXOT.cpp
parenta62467c74e9391dd2a9173cfa167d32eceed506b (diff)
downloadpowder-27e3e1251837f5d64e835068d5f5bd5b67b95921.zip
powder-27e3e1251837f5d64e835068d5f5bd5b67b95921.tar.gz
Small optimizations number 2.
Diffstat (limited to 'src/simulation/elements/EXOT.cpp')
-rw-r--r--src/simulation/elements/EXOT.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/simulation/elements/EXOT.cpp b/src/simulation/elements/EXOT.cpp
index 03eca2f..8cf0161 100644
--- a/src/simulation/elements/EXOT.cpp
+++ b/src/simulation/elements/EXOT.cpp
@@ -48,42 +48,36 @@ Element_EXOT::Element_EXOT()
//#TPT-Directive ElementHeader Element_EXOT static int update(UPDATE_FUNC_ARGS)
int Element_EXOT::update(UPDATE_FUNC_ARGS) {
- int r, rt, rx, ry, nb, rrx, rry, trade, tym, t;
- t = parts[i].type;
+ int r, rt, rx, ry, nb, rrx, rry, trade, tym;
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
- if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
+ if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry)) {
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF) == PT_WARP)
+ rt = r&0xFF;
+ if (rt == PT_WARP)
{
- if (parts[r>>8].tmp2>2000)
- if (1>rand()%100)
- {
- parts[i].tmp2 += 100;
- }
+ if (parts[r>>8].tmp2>2000 && !(rand()%100))
+ {
+ parts[i].tmp2 += 100;
+ }
}
- else if ((r&0xFF) == PT_EXOT && parts[r>>8].life == 1500 && 1>rand()%1000)
+ else if (rt == PT_EXOT && parts[r>>8].life == 1500 && !(rand()%1000))
parts[i].life = 1500;
- else if ((r&0xFF) == PT_LAVA)
+ else if (rt == PT_LAVA)
{
- if (parts[r>>8].ctype == PT_TTAN && 1>rand()%10)
+ if (parts[r>>8].ctype == PT_TTAN && !(rand()%10))
{
parts[r>>8].ctype = PT_VIBR;
sim->kill_part(i);
return 1;
}
- /*else if (parts[r>>8].ctype == PT_VIBR && 1>rand()%1000)
- {
- sim->kill_part(i);
- return 1;
- }*/
}
if ((parts[i].tmp>245) && (parts[i].life>1000))
- if ((r&0xFF)!=PT_EXOT && (r&0xFF)!=PT_BREC && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_WARP && (r&0xFF)!=PT_NEUT)
+ if (rt!=PT_EXOT && rt!=PT_BREC && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PRTI && rt!=PT_PRTO && rt!=PT_PCLN && rt!=PT_PHOT && rt!=PT_VOID && rt!=PT_NBHL && rt!=PT_WARP && rt!=PT_NEUT)
{
- sim->create_part(i, x, y, parts[r>>8].type);
+ sim->create_part(i, x, y, rt);
return 0;
}
}
@@ -121,7 +115,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)==t && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion
+ if ((r&0xFF)==PT_EXOT && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion
{
tym = parts[i].tmp2 - parts[r>>8].tmp2;
if (tym ==1)