summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2012-10-05 00:16:57 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-10-05 15:33:54 (GMT)
commitd159467b63b930958930f252b208ecb7e959ad97 (patch)
tree72c3a3934b8826c951ec6b55236c7bc6bff4a6cf /src/simulation
parentf19f393e227e9158aced5ecd73dcb621e8d84569 (diff)
downloadpowder-d159467b63b930958930f252b208ecb7e959ad97.zip
powder-d159467b63b930958930f252b208ecb7e959ad97.tar.gz
LOLZ and LOVE work again
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/Simulation.cpp96
-rw-r--r--src/simulation/Simulation.h7
-rw-r--r--src/simulation/elements/LOLZ.cpp8
-rw-r--r--src/simulation/elements/LOVE.cpp8
4 files changed, 105 insertions, 14 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index be114e1..b054cda 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -3273,6 +3273,77 @@ void Simulation::update_particles_i(int start, int inc)
}
}
+ if (ISLOVE || ISLOLZ) //LOVE and LOLZ element handling
+ {
+ int nx, nnx, ny, nny, r, rt;
+ ISLOVE = 0;
+ ISLOLZ = 0;
+ for (ny=0; ny<YRES-4; ny++)
+ {
+ for (nx=0; nx<XRES-4; nx++)
+ {
+ r=pmap[ny][nx];
+ if (!r)
+ {
+ continue;
+ }
+ else if ((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&(parts[r>>8].type==PT_LOVE||parts[r>>8].type==PT_LOLZ))
+ kill_part(r>>8);
+ else if (parts[r>>8].type==PT_LOVE)
+ {
+ love[nx/9][ny/9] = 1;
+ }
+ else if (parts[r>>8].type==PT_LOLZ)
+ {
+ lolz[nx/9][ny/9] = 1;
+ }
+ }
+ }
+ for (nx=9; nx<=XRES-18; nx++)
+ {
+ for (ny=9; ny<=YRES-7; ny++)
+ {
+ if (love[nx/9][ny/9]==1)
+ {
+ for ( nnx=0; nnx<9; nnx++)
+ for ( nny=0; nny<9; nny++)
+ {
+ if (ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
+ {
+ rt=pmap[ny+nny][nx+nnx];
+ if (!rt&&loverule[nnx][nny]==1)
+ create_part(-1,nx+nnx,ny+nny,PT_LOVE);
+ else if (!rt)
+ continue;
+ else if (parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0)
+ kill_part(rt>>8);
+ }
+ }
+ }
+ love[nx/9][ny/9]=0;
+ if (lolz[nx/9][ny/9]==1)
+ {
+ for ( nnx=0; nnx<9; nnx++)
+ for ( nny=0; nny<9; nny++)
+ {
+ if (ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
+ {
+ rt=pmap[ny+nny][nx+nnx];
+ if (!rt&&lolzrule[nny][nnx]==1)
+ create_part(-1,nx+nnx,ny+nny,PT_LOLZ);
+ else if (!rt)
+ continue;
+ else if (parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0)
+ kill_part(rt>>8);
+
+ }
+ }
+ }
+ lolz[nx/9][ny/9]=0;
+ }
+ }
+ }
+
//wire!
if(elementCount[PT_WIRE] > 0)
{
@@ -4676,4 +4747,29 @@ Simulation::Simulation():
clear_sim();
grav->gravity_mask();
+
+ int loverule[9][9] =
+ {
+ {0,0,1,1,0,0,0,0,0},
+ {0,1,0,0,1,1,0,0,0},
+ {1,0,0,0,0,0,1,0,0},
+ {1,0,0,0,0,0,0,1,0},
+ {0,1,0,0,0,0,0,0,1},
+ {1,0,0,0,0,0,0,1,0},
+ {1,0,0,0,0,0,1,0,0},
+ {0,1,0,0,1,1,0,0,0},
+ {0,0,1,1,0,0,0,0,0},
+ };
+ int lolzrule[9][9] =
+ {
+ {0,0,0,0,0,0,0,0,0},
+ {1,0,0,0,0,0,1,0,0},
+ {1,0,0,0,0,0,1,0,0},
+ {1,0,0,1,1,0,0,1,0},
+ {1,0,1,0,0,1,0,1,0},
+ {1,0,1,0,0,1,0,1,0},
+ {0,1,0,1,1,0,0,1,0},
+ {0,1,0,0,0,0,0,1,0},
+ {0,1,0,0,0,0,0,1,0},
+ };
}
diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h
index ba9fa1a..98c5025 100644
--- a/src/simulation/Simulation.h
+++ b/src/simulation/Simulation.h
@@ -117,6 +117,12 @@ public:
int pretty_powder;
int sandcolour;
int sandcolour_frame;
+ static int loverule[9][9];
+ bool ISLOVE;
+ int love[XRES/9][YRES/9];
+ static int lolzrule[9][9];
+ bool ISLOLZ;
+ int lolz[XRES/9][YRES/9];
int Load(GameSave * save);
int Load(int x, int y, GameSave * save);
@@ -204,6 +210,7 @@ public:
Simulation();
~Simulation();
};
+
//#endif
#endif /* SIMULATION_H_ */
diff --git a/src/simulation/elements/LOLZ.cpp b/src/simulation/elements/LOLZ.cpp
index 6feae3f..4ab9c61 100644
--- a/src/simulation/elements/LOLZ.cpp
+++ b/src/simulation/elements/LOLZ.cpp
@@ -49,13 +49,7 @@ Element_LOLZ::Element_LOLZ()
//#TPT-Directive ElementHeader Element_LOLZ static int update(UPDATE_FUNC_ARGS)
int Element_LOLZ::update(UPDATE_FUNC_ARGS)
{
- /*int t = parts[i].type;
- if (t==PT_LOVE)
- ISLOVE=1;
- else if (t==PT_LOLZ)
- ISLOLZ=1;
- else if (t==PT_GRAV)
- ISGRAV=1;*/
+ sim->ISLOLZ = true;
return 0;
}
diff --git a/src/simulation/elements/LOVE.cpp b/src/simulation/elements/LOVE.cpp
index 28a20b7..e15cea2 100644
--- a/src/simulation/elements/LOVE.cpp
+++ b/src/simulation/elements/LOVE.cpp
@@ -49,13 +49,7 @@ Element_LOVE::Element_LOVE()
//#TPT-Directive ElementHeader Element_LOVE static int update(UPDATE_FUNC_ARGS)
int Element_LOVE::update(UPDATE_FUNC_ARGS)
{
- /*int t = parts[i].type;
- if (t==PT_LOVE)
- ISLOVE=1;
- else if (t==PT_LOLZ)
- ISLOLZ=1;
- else if (t==PT_GRAV)
- ISGRAV=1;*/
+ sim->ISLOVE = true;
return 0;
}