From 3f99a59cb2e92abbd2a54c19305236b11ad3e6f6 Mon Sep 17 00:00:00 2001 From: moonheart08 Date: Tue, 3 Apr 2018 21:24:38 -0500 Subject: [PATCH] Adds STASIS wall. (#556) --- src/graphics/Renderer.cpp | 8 ++++---- src/simulation/Simulation.cpp | 18 +++++++++++++----- src/simulation/SimulationData.cpp | 1 + src/simulation/SimulationData.h | 3 ++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 21bdce464..cc22710e9 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -589,7 +589,7 @@ VideoBuffer * Renderer::WallIcon(int wallID, int width, int height) newTexture->SetPixel(i, j, 0x80, 0x80, 0x80, 255); } } - else if (wt==WL_EHOLE) + else if (wt==WL_EHOLE || wt==WL_STASIS) { for (j=0; jwtypes[wt].drawstyle) { case 0: - if (wt == WL_EWALL) + if (wt == WL_EWALL || wt == WL_STASIS) { - if (powered) + bool reverse = wt == WL_STASIS; + if ((powered>0) ^ reverse) { for (int j = 0; j < CELL; j++) for (int i =0; i < CELL; i++) @@ -2974,4 +2975,3 @@ Renderer::~Renderer() #endif #undef PIXELMETHODS_CLASS - diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index c2814f144..04b75e77c 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1919,12 +1919,12 @@ void Simulation::orbitalparts_set(int *block1, int *block2, int resblock1[], int inline int Simulation::is_wire(int x, int y) { - return bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE; + return bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE || bmap[y][x]==WL_STASIS; } inline int Simulation::is_wire_off(int x, int y) { - return (bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE) && emap[y][x]<8; + return (bmap[y][x]==WL_DETECT || bmap[y][x]==WL_EWALL || bmap[y][x]==WL_ALLOWLIQUID || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_ALLOWALLELEC || bmap[y][x]==WL_EHOLE || bmap[y][x]==WL_STASIS) && emap[y][x]<8; } // implement __builtin_ctz and __builtin_clz on msvc @@ -3661,11 +3661,18 @@ void Simulation::UpdateParticles(int start, int end) for (i = start; i <= end && i <= parts_lastActiveIndex; i++) if (parts[i].type) { + + t = parts[i].type; x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f); + // Make sure that STASIS'd particles don't tick. + if (bmap[y/CELL][x/CELL] == WL_STASIS && emap[y/CELL][x/CELL]<8) { + continue; + } + //this kills any particle out of the screen, or in a wall where it isn't supposed to go if (x=XRES-CELL || y>=YRES-CELL || (bmap[y/CELL][x/CELL] && @@ -4196,7 +4203,7 @@ void Simulation::UpdateParticles(int start, int end) { if (t!=PT_SPRK) { - if (emap[ny][nx]==12 && !parts[i].life) + if (emap[ny][nx]==12 && !parts[i].life && bmap[ny][nx] != WL_STASIS) { part_change_type(i,x,y,PT_SPRK); parts[i].life = 4; @@ -5064,8 +5071,9 @@ void Simulation::RecalcFreeParticles(bool do_life_dec) elementCount[t]++; unsigned int elem_properties = elements[t].Properties; - if (parts[i].life>0 && (elem_properties&PROP_LIFE_DEC)) + if (parts[i].life>0 && (elem_properties&PROP_LIFE_DEC) && !(bmap[y/CELL][x/CELL] == WL_STASIS && emap[y/CELL][x/CELL]<8)) { + // automatically decrease life parts[i].life--; if (parts[i].life<=0 && (elem_properties&(PROP_LIFE_KILL_DEC|PROP_LIFE_KILL))) @@ -5075,7 +5083,7 @@ void Simulation::RecalcFreeParticles(bool do_life_dec) continue; } } - else if (parts[i].life<=0 && (elem_properties&PROP_LIFE_KILL)) + else if (parts[i].life<=0 && (elem_properties&PROP_LIFE_KILL) && !(bmap[y/CELL][x/CELL] == WL_STASIS && emap[y/CELL][x/CELL]<8)) { // kill if no life kill_part(i); diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp index 3ffdc6fda..67cf6f484 100644 --- a/src/simulation/SimulationData.cpp +++ b/src/simulation/SimulationData.cpp @@ -132,6 +132,7 @@ wall_type * LoadWalls(int & wallCount) {PIXPACK(0xFFAA00), PIXPACK(0xAA5500), 4, Renderer::WallIcon, "ENERGY WALL", "DEFAULT_WL_ENRGY", "Allows energy particles, blocks all other particles."}, {PIXPACK(0xDCDCDC), PIXPACK(0x000000), 1, Renderer::WallIcon, "AIRBLOCK WALL", "DEFAULT_WL_NOAIR", "Allows all particles, but blocks air."}, {PIXPACK(0x808080), PIXPACK(0x000000), 0, Renderer::WallIcon, "ERASEALL", "DEFAULT_WL_ERASEA","Erases walls, particles, and signs."}, + {PIXPACK(0x800080), PIXPACK(0x000000), 0, Renderer::WallIcon, "STASIS WALL", "DEFAULT_WL_STASIS", "Freezes particles inside the wall in place"}, }; wallCount = UI_WALLCOUNT; wall_type * wtypesT = (wall_type*)malloc(UI_WALLCOUNT*sizeof(wall_type)); diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h index 2364dc4c8..471b7d019 100644 --- a/src/simulation/SimulationData.h +++ b/src/simulation/SimulationData.h @@ -57,9 +57,10 @@ #define WL_ALLOWENERGY 15 #define WL_BLOCKAIR 16 #define WL_ERASEALL 17 +#define WL_STASIS 18 #define WL_FLOODHELPER 255 -#define UI_WALLCOUNT 18 +#define UI_WALLCOUNT 19 #define OLD_SPC_AIR 236 #define SPC_AIR 256