From d159467b63b930958930f252b208ecb7e959ad97 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 4 Oct 2012 20:16:57 -0400 Subject: [PATCH] LOLZ and LOVE work again --- src/simulation/Simulation.cpp | 96 ++++++++++++++++++++++++++++++++ src/simulation/Simulation.h | 7 +++ src/simulation/elements/LOLZ.cpp | 8 +-- src/simulation/elements/LOVE.cpp | 8 +-- 4 files changed, 105 insertions(+), 14 deletions(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index be114e1a6..b054cda74 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; nyYRES-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=0&&nx+nnx>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=0&&nx+nnx>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 ba9fa1ae3..98c5025c8 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 6feae3f8c..4ab9c6188 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 28a20b7f5..e15cea29a 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; }