From 4ff1dc0bc345940eaee4e17a889cb4ff032eb75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Mon, 11 Feb 2019 21:58:39 +0100 Subject: [PATCH] Fix a few more random PMAPBITS issues --- src/gui/game/GameView.cpp | 6 +++--- src/gui/game/SampleTool.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 95be9dd29..873971d40 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -715,7 +715,7 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender) if (!active->GetIdentifier().Contains("_PT_")) ren->findingElement = 0; else - ren->findingElement = sender->GetActiveTool(0)->GetToolID()%256; + ren->findingElement = sender->GetActiveTool(0)->GetToolID() & ((1 << PMAPBITS) - 1); } } @@ -1509,10 +1509,10 @@ void GameView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, if (ctrl) { Tool *active = c->GetActiveTool(0); - if (!active->GetIdentifier().Contains("_PT_") || ren->findingElement == active->GetToolID()%256) + if (!active->GetIdentifier().Contains("_PT_") || (ren->findingElement == (active->GetToolID() & ((1 << PMAPBITS) - 1)))) ren->findingElement = 0; else - ren->findingElement = active->GetToolID()%256; + ren->findingElement = active->GetToolID() & ((1 << PMAPBITS) - 1); } else c->FrameStep(); diff --git a/src/gui/game/SampleTool.cpp b/src/gui/game/SampleTool.cpp index ca58d686b..d104af614 100644 --- a/src/gui/game/SampleTool.cpp +++ b/src/gui/game/SampleTool.cpp @@ -54,7 +54,7 @@ void SampleTool::Draw(Simulation * sim, Brush * brush, ui::Point position) for(std::vector::iterator iter = elementTools.begin(), end = elementTools.end(); iter != end; ++iter) { Tool * elementTool = *iter; - if(elementTool && elementTool->GetToolID()/256 == particleCtype) + if(elementTool && (elementTool->GetToolID() >> PMAPBITS) == particleCtype) gameModel->SetActiveTool(0, elementTool); } }