From 70ffbbbbf96d414b031ce195cf4ff6392b9a7d22 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sun, 1 May 2016 01:47:29 +0200 Subject: [PATCH] hookthrough shortcut now works for game and front --- src/game/editor/editor.h | 12 +++++------ src/game/editor/layer_game.cpp | 36 ++++++++++++++++----------------- src/game/editor/layer_tiles.cpp | 35 ++++++++++++++++---------------- 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index dfbf70fbc..f2175c6dd 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -507,8 +507,8 @@ public: CLayerTiles(int w, int h); ~CLayerTiles(); - virtual CTile GetTile(int x, int y, bool force=false); - virtual void SetTile(int x, int y, CTile tile, bool force=false); + virtual CTile GetTile(int x, int y); + virtual void SetTile(int x, int y, CTile tile); virtual void Resize(int NewW, int NewH); virtual void Shift(int Direction); @@ -593,8 +593,8 @@ public: CLayerGame(int w, int h); ~CLayerGame(); - virtual CTile GetTile(int x, int y, bool force=false); - virtual void SetTile(int x, int y, CTile tile, bool force=false); + virtual CTile GetTile(int x, int y); + virtual void SetTile(int x, int y, CTile tile); virtual int RenderProperties(CUIRect *pToolbox); }; @@ -1088,8 +1088,8 @@ public: virtual void Resize(int NewW, int NewH); virtual void Shift(int Direction); - virtual CTile GetTile(int x, int y, bool force=false); - virtual void SetTile(int x, int y, CTile tile, bool force=false); + virtual CTile GetTile(int x, int y); + virtual void SetTile(int x, int y, CTile tile); virtual void BrushDraw(CLayer *pBrush, float wx, float wy); }; diff --git a/src/game/editor/layer_game.cpp b/src/game/editor/layer_game.cpp index 092ca70e4..1116c7e55 100644 --- a/src/game/editor/layer_game.cpp +++ b/src/game/editor/layer_game.cpp @@ -14,40 +14,38 @@ CLayerGame::~CLayerGame() { } -CTile CLayerGame::GetTile(int x, int y, bool force) +CTile CLayerGame::GetTile(int x, int y) { - if(!force && m_pEditor->m_Map.m_pFrontLayer && GetTile(x, y, true).m_Index == TILE_NOHOOK && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) - { - CTile throughcut = {TILE_THROUGH_CUT, 0, 0, 0}; - return throughcut; + if(m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y).m_Index == TILE_THROUGH_CUT) { + CTile through_cut = {TILE_THROUGH_CUT}; + return through_cut; } else { - return m_pTiles[y*m_Width+x]; + return CLayerTiles::GetTile(x, y); } } -void CLayerGame::SetTile(int x, int y, CTile tile, bool force) +void CLayerGame::SetTile(int x, int y, CTile tile) { - if(!force && tile.m_Index == TILE_THROUGH_CUT) { + if(tile.m_Index == TILE_THROUGH_CUT) { if(!m_pEditor->m_Map.m_pFrontLayer) { CLayer *l = new CLayerFront(m_Width, m_Height); m_pEditor->m_Map.MakeFrontLayer(l); m_pEditor->m_Map.m_lGroups[m_pEditor->m_SelectedGroup]->AddLayer(l); } - CTile nohook = {TILE_NOHOOK, 0, 0, 0}; - SetTile(x, y, nohook, true); - CTile throughcut = {TILE_THROUGH_CUT, 0, 0, 0}; - m_pEditor->m_Map.m_pFrontLayer->SetTile(x, y, throughcut, true); + CTile nohook = {TILE_NOHOOK}; + CLayerTiles::SetTile(x, y, nohook); + CTile through_cut = {TILE_THROUGH_CUT}; + m_pEditor->m_Map.m_pFrontLayer->CLayerTiles::SetTile(x, y, through_cut); } else { - if(!force && m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) { - CTile air = {TILE_AIR, 0, 0, 0}; - m_pEditor->m_Map.m_pFrontLayer->SetTile(x, y, air, true); + if(m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y).m_Index == TILE_THROUGH_CUT) { + CTile air = {TILE_AIR}; + m_pEditor->m_Map.m_pFrontLayer->CLayerTiles::SetTile(x, y, air); } - // set normal game tile if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidGameTile(tile.m_Index)) { - m_pTiles[y*m_Width+x] = tile; + CLayerTiles::SetTile(x, y, tile); } else { - CTile air = {TILE_AIR, 0, 0, 0}; - SetTile(x, y, air); + CTile air = {TILE_AIR}; + CLayerTiles::SetTile(x, y, air); } } } diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index 645be026a..da52943dd 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -46,12 +46,12 @@ CLayerTiles::~CLayerTiles() delete [] m_pTiles; } -CTile CLayerTiles::GetTile(int x, int y, bool force) +CTile CLayerTiles::GetTile(int x, int y) { return m_pTiles[y*m_Width+x]; } -void CLayerTiles::SetTile(int x, int y, CTile tile, bool force) +void CLayerTiles::SetTile(int x, int y, CTile tile) { m_pTiles[y*m_Width+x] = tile; } @@ -1300,26 +1300,25 @@ CLayerFront::CLayerFront(int w, int h) m_Front = 1; } -CTile CLayerFront::GetTile(int x, int y, bool force) +CTile CLayerFront::GetTile(int x, int y) { - if(!force && GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) { - CTile air = {TILE_AIR, 0, 0, 0}; - return air; - } else { - return m_pTiles[y*m_Width+x]; - } + return CLayerTiles::GetTile(x, y); } -void CLayerFront::SetTile(int x, int y, CTile tile, bool force) +void CLayerFront::SetTile(int x, int y, CTile tile) { - if(force || (GetTile(x, y, true).m_Index != TILE_THROUGH_CUT && tile.m_Index != TILE_THROUGH_CUT)) { - // set normal front tile - if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidFrontTile(tile.m_Index)) { - m_pTiles[y*m_Width+x] = tile; - } else { - CTile air = {TILE_AIR, 0, 0, 0}; - SetTile(x, y, air); - } + if(tile.m_Index == TILE_THROUGH_CUT) { + CTile nohook = {TILE_NOHOOK}; + m_pEditor->m_Map.m_pGameLayer->CLayerTiles::SetTile(x, y, nohook); + } else if(tile.m_Index == TILE_AIR && CLayerTiles::GetTile(x, y).m_Index == TILE_THROUGH_CUT) { + CTile air = {TILE_AIR}; + m_pEditor->m_Map.m_pGameLayer->CLayerTiles::SetTile(x, y, air); + } + if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidFrontTile(tile.m_Index)) { + CLayerTiles::SetTile(x, y, tile); + } else { + CTile air = {TILE_AIR}; + CLayerTiles::SetTile(x, y, air); } }