Fix a few more random PMAPBITS issues

This commit is contained in:
Tamás Bálint Misius 2019-02-11 21:58:39 +01:00 committed by jacob1
parent 240bb3bd92
commit 4ff1dc0bc3
2 changed files with 4 additions and 4 deletions

View File

@ -715,7 +715,7 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender)
if (!active->GetIdentifier().Contains("_PT_")) if (!active->GetIdentifier().Contains("_PT_"))
ren->findingElement = 0; ren->findingElement = 0;
else 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) if (ctrl)
{ {
Tool *active = c->GetActiveTool(0); 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; ren->findingElement = 0;
else else
ren->findingElement = active->GetToolID()%256; ren->findingElement = active->GetToolID() & ((1 << PMAPBITS) - 1);
} }
else else
c->FrameStep(); c->FrameStep();

View File

@ -54,7 +54,7 @@ void SampleTool::Draw(Simulation * sim, Brush * brush, ui::Point position)
for(std::vector<Tool*>::iterator iter = elementTools.begin(), end = elementTools.end(); iter != end; ++iter) for(std::vector<Tool*>::iterator iter = elementTools.begin(), end = elementTools.end(); iter != end; ++iter)
{ {
Tool * elementTool = *iter; Tool * elementTool = *iter;
if(elementTool && elementTool->GetToolID()/256 == particleCtype) if(elementTool && (elementTool->GetToolID() >> PMAPBITS) == particleCtype)
gameModel->SetActiveTool(0, elementTool); gameModel->SetActiveTool(0, elementTool);
} }
} }