summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-20 12:41:03 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-20 12:41:03 (GMT)
commit7fc8d5f388039da885b3432cdfe7d5b7f4ace07c (patch)
tree333f10265dbcbe06f8ef218c553789585ba065ff /src/simulation
parent9ecc29d24c335f46277193b1f54c95e8da9ce17c (diff)
downloadpowder-7fc8d5f388039da885b3432cdfe7d5b7f4ace07c.zip
powder-7fc8d5f388039da885b3432cdfe7d5b7f4ace07c.tar.gz
Add missing legacy update function
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/Simulation.cpp4
-rw-r--r--src/simulation/elements/Element.cpp117
-rw-r--r--src/simulation/elements/Element.h1
3 files changed, 120 insertions, 2 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index ba24893..d9da206 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -3851,8 +3851,8 @@ void Simulation::update_particles_i(int start, int inc)
y = (int)(parts[i].y+0.5f);
}
#endif
- //if (legacy_enable)//if heat sim is off
- //update_legacy_all(this, i,x,y,surround_space,nt, parts, pmap); //TODO:pop
+ if(legacy_enable)//if heat sim is off
+ Element::legacyUpdate(this, i,x,y,surround_space,nt, parts, pmap);
killed:
if (parts[i].type == PT_NONE)//if its dead, skip to next particle
diff --git a/src/simulation/elements/Element.cpp b/src/simulation/elements/Element.cpp
index ff2918a..4ec33a6 100644
--- a/src/simulation/elements/Element.cpp
+++ b/src/simulation/elements/Element.cpp
@@ -48,6 +48,123 @@ Element::Element():
{
}
+int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
+ int r, rx, ry, rt;
+ int t = parts[i].type;
+ if (t==PT_WTRV) {
+ 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)
+ continue;
+ if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000))
+ {
+ sim->part_change_type(i,x,y,PT_WATR);
+ sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR);
+ }
+ if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000))
+ {
+ sim->part_change_type(i,x,y,PT_WATR);
+ if (1>(rand()%1000))
+ sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR);
+ }
+ }
+ }
+ else if (t==PT_WATR) {
+ 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)
+ continue;
+ if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
+ {
+ sim->part_change_type(i,x,y,PT_WTRV);
+ }
+ }
+ }
+ else if (t==PT_SLTW) {
+ 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)
+ continue;
+ if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
+ {
+ if (rand()%4==0) sim->part_change_type(i,x,y,PT_SALT);
+ else sim->part_change_type(i,x,y,PT_WTRV);
+ }
+ }
+ }
+ else if (t==PT_DSTW) {
+ 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)
+ continue;
+ if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
+ {
+ sim->part_change_type(i,x,y,PT_WTRV);
+ }
+ }
+ }
+ else if (t==PT_ICEI) {
+ 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)
+ continue;
+ if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
+ {
+ sim->part_change_type(i,x,y,PT_ICEI);
+ sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI);
+ }
+ }
+ }
+ else if (t==PT_SNOW) {
+ 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)
+ continue;
+ if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
+ {
+ sim->part_change_type(i,x,y,PT_ICEI);
+ sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI);
+ }
+ if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000))
+ sim->part_change_type(i,x,y,PT_WATR);
+ }
+ }
+ if (t==PT_WTRV && sim->pv[y/CELL][x/CELL]>4.0f)
+ sim->part_change_type(i,x,y,PT_DSTW);
+ if (t==PT_OIL && sim->pv[y/CELL][x/CELL]<-6.0f)
+ sim->part_change_type(i,x,y,PT_GAS);
+ if (t==PT_GAS && sim->pv[y/CELL][x/CELL]>6.0f)
+ sim->part_change_type(i,x,y,PT_OIL);
+ if (t==PT_DESL && sim->pv[y/CELL][x/CELL]>12.0f)
+ {
+ sim->part_change_type(i,x,y,PT_FIRE);
+ parts[i].life = rand()%50+120;
+ }
+ return 0;
+}
+
int Element::defaultGraphics(GRAPHICS_FUNC_ARGS)
{
int t = cpart->type;
diff --git a/src/simulation/elements/Element.h b/src/simulation/elements/Element.h
index 65e3898..72b6c2b 100644
--- a/src/simulation/elements/Element.h
+++ b/src/simulation/elements/Element.h
@@ -53,6 +53,7 @@ public:
Element();
virtual ~Element() {}
static int defaultGraphics(GRAPHICS_FUNC_ARGS);
+ static int legacyUpdate(UPDATE_FUNC_ARGS);
};
#endif