From da7d107f60f2e07ac6d859dbc562473ddaf321fe Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 18 Jul 2013 18:54:09 -0400 Subject: [PATCH] remove specific delete for walls, doesn't work very well and it conflicts with specific delete for elements Also prevent wall replace mode, could never do anything because walls already replace everything --- src/cat/LuaScriptInterface.cpp | 12 ++++-------- src/gui/game/GameView.cpp | 3 ++- src/gui/game/Tool.cpp | 2 +- src/simulation/Simulation.cpp | 35 +++++++++++++--------------------- src/simulation/Simulation.h | 8 ++++---- 5 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index b1169f421..4bea8edc5 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1047,11 +1047,10 @@ int LuaScriptInterface::simulation_createWalls(lua_State * l) int rx = luaL_optint(l,3,0); int ry = luaL_optint(l,4,0); int c = luaL_optint(l,5,8); - int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); - int ret = luacon_sim->CreateWalls(x, y, rx, ry, c, NULL, flags); + int ret = luacon_sim->CreateWalls(x, y, rx, ry, c, NULL); lua_pushinteger(l, ret); return 1; } @@ -1065,11 +1064,10 @@ int LuaScriptInterface::simulation_createWallLine(lua_State * l) int rx = luaL_optint(l,5,0); int ry = luaL_optint(l,6,0); int c = luaL_optint(l,7,8); - int flags = luaL_optint(l,8,luacon_sim->replaceModeFlags); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); - luacon_sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, NULL, flags); + luacon_sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, NULL); return 0; } @@ -1080,11 +1078,10 @@ int LuaScriptInterface::simulation_createWallBox(lua_State * l) int x2 = luaL_optint(l,3,-1); int y2 = luaL_optint(l,4,-1); int c = luaL_optint(l,5,8); - int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); - luacon_sim->CreateWallBox(x1, y1, x2, y2, c, flags); + luacon_sim->CreateWallBox(x1, y1, x2, y2, c); return 0; } @@ -1094,10 +1091,9 @@ int LuaScriptInterface::simulation_floodWalls(lua_State * l) int y = luaL_optint(l,2,-1); int c = luaL_optint(l,3,8); int bm = luaL_optint(l,4,-1); - int flags = luaL_optint(l,5,luacon_sim->replaceModeFlags); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); - int ret = luacon_sim->FloodWalls(x, y, c, bm, flags); + int ret = luacon_sim->FloodWalls(x, y, c, bm); lua_pushinteger(l, ret); return 1; } diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 4abceacd3..f1b04501c 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -519,7 +519,8 @@ public: { ToolButton *sender = (ToolButton*)sender_; if (v->CtrlBehaviour() && v->AltBehaviour() && !v->ShiftBehaviour()) - sender->SetSelectionState(3); + if (tool->GetIdentifier().find("DEFAULT_PT_") != tool->GetIdentifier().npos) + sender->SetSelectionState(3); if(sender->GetSelectionState() >= 0 && sender->GetSelectionState() <= 3) v->c->SetActiveTool(sender->GetSelectionState(), tool); } diff --git a/src/gui/game/Tool.cpp b/src/gui/game/Tool.cpp index fb3f7ed58..b0def6c79 100644 --- a/src/gui/game/Tool.cpp +++ b/src/gui/game/Tool.cpp @@ -87,7 +87,7 @@ void WallTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui newFanVelX *= strength; float newFanVelY = (position2.Y-position1.Y)*0.005f; newFanVelY *= strength; - sim->FloodWalls(position1.X, position1.Y, WL_FLOODHELPER, WL_FAN, 0); + sim->FloodWalls(position1.X, position1.Y, WL_FLOODHELPER, WL_FAN); for (int j = 0; j < YRES/CELL; j++) for (int i = 0; i < XRES/CELL; i++) if (sim->bmap[j][i] == WL_FLOODHELPER) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index d598b3015..678247de9 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1038,17 +1038,13 @@ void Simulation::ToolBox(int x1, int y1, int x2, int y2, int tool, float strengt Tool(i, j, tool, strength); } -int Simulation::CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBrush, int flags) +int Simulation::CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBrush) { if(cBrush) { rx = cBrush->GetRadius().X; ry = cBrush->GetRadius().Y; } - if (wall == WL_ERASE) - wall = 0; - if (flags == -1) - flags = replaceModeFlags; ry = ry/CELL; rx = rx/CELL; @@ -1062,9 +1058,6 @@ int Simulation::CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBru { if (wallX >= 0 && wallX < XRES/CELL && wallY >= 0 && wallY < YRES/CELL) { - if ((flags&SPECIFIC_DELETE) && wall != WL_FLOODHELPER && wall == replaceModeSelected) - wall = 0; - if (wall == WL_FAN) { fvx[wallY][wallX] = 0.0f; @@ -1091,7 +1084,7 @@ int Simulation::CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBru return 1; } -void Simulation::CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int wall, Brush * cBrush, int flags) +void Simulation::CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int wall, Brush * cBrush) { int x, y, dx, dy, sy; bool reverseXY = abs(y2-y1) > abs(x2-x1); @@ -1125,9 +1118,9 @@ void Simulation::CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, for (x=x1; x<=x2; x++) { if (reverseXY) - CreateWalls(y, x, rx, ry, wall, cBrush, flags); + CreateWalls(y, x, rx, ry, wall, cBrush); else - CreateWalls(x, y, rx, ry, wall, cBrush, flags); + CreateWalls(x, y, rx, ry, wall, cBrush); e += de; if (e >= 0.5f) { @@ -1135,16 +1128,16 @@ void Simulation::CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, if (!(rx+ry) && ((y1=y2))) { if (reverseXY) - CreateWalls(y, x, rx, ry, wall, cBrush, flags); + CreateWalls(y, x, rx, ry, wall, cBrush); else - CreateWalls(x, y, rx, ry, wall, cBrush, flags); + CreateWalls(x, y, rx, ry, wall, cBrush); } e -= 1.0f; } } } -void Simulation::CreateWallBox(int x1, int y1, int x2, int y2, int wall, int flags) +void Simulation::CreateWallBox(int x1, int y1, int x2, int y2, int wall) { int i, j; if (x1>x2) @@ -1161,10 +1154,10 @@ void Simulation::CreateWallBox(int x1, int y1, int x2, int y2, int wall, int fla } for (j=y1; j<=y2; j++) for (i=x1; i<=x2; i++) - CreateWalls(i, j, 0, 0, wall, NULL, flags); + CreateWalls(i, j, 0, 0, wall, NULL); } -int Simulation::FloodWalls(int x, int y, int wall, int bm, int flags) +int Simulation::FloodWalls(int x, int y, int wall, int bm) { int x1, x2, dy = CELL; if (bm==-1) @@ -1177,8 +1170,6 @@ int Simulation::FloodWalls(int x, int y, int wall, int bm, int flags) } else bm = 0; - if (flags == -1) - flags = replaceModeFlags; } if (bmap[y/CELL][x/CELL]!=bm) @@ -1206,19 +1197,19 @@ int Simulation::FloodWalls(int x, int y, int wall, int bm, int flags) // fill span for (x=x1; x<=x2; x++) { - if (!CreateWalls(x, y, 0, 0, wall, NULL, flags)) + if (!CreateWalls(x, y, 0, 0, wall, NULL)) return 0; } // fill children if (y>=CELL) for (x=x1; x<=x2; x++) if (bmap[(y-dy)/CELL][x/CELL]==bm) - if (!FloodWalls(x, y-dy, wall, bm, flags)) + if (!FloodWalls(x, y-dy, wall, bm)) return 0; if (y