diff --git a/apps/opencs/view/render/commands.cpp b/apps/opencs/view/render/commands.cpp index b9b7b12f7..99d8a0da6 100644 --- a/apps/opencs/view/render/commands.cpp +++ b/apps/opencs/view/render/commands.cpp @@ -17,38 +17,28 @@ CSVRender::DrawTerrainSelectionCommand::DrawTerrainSelectionCommand(WorldspaceWi void CSVRender::DrawTerrainSelectionCommand::redo() { - if (mWorldspaceWidget) - { - if (CSVRender::TerrainShapeMode* terrainMode = dynamic_cast (mWorldspaceWidget->getEditMode()) ) - { - terrainMode->getTerrainSelection()->update(); - return; - } - else - { - Log(Debug::Verbose) << "Can't update terrain selection in current EditMode"; - return; - } - } - else - Log(Debug::Verbose) << "Can't update terrain selection, no WorldspaceWidget found!"; + tryUpdate(); } void CSVRender::DrawTerrainSelectionCommand::undo() { - if (mWorldspaceWidget) + tryUpdate(); +} + +void CSVRender::DrawTerrainSelectionCommand::tryUpdate() +{ + if (!mWorldspaceWidget) { - if (CSVRender::TerrainShapeMode* terrainMode = dynamic_cast (mWorldspaceWidget->getEditMode()) ) - { - terrainMode->getTerrainSelection()->update(); - return; - } - else - { - Log(Debug::Verbose) << "Can't undo terrain selection in current EditMode"; - return; - } - } - else Log(Debug::Verbose) << "Can't undo terrain selection, no WorldspaceWidget found!"; + return; + } + + auto terrainMode = dynamic_cast(mWorldspaceWidget->getEditMode()); + if (!terrainMode) + { + Log(Debug::Verbose) << "Can't undo terrain selection in current EditMode"; + return; + } + + terrainMode->getTerrainSelection()->update(); } diff --git a/apps/opencs/view/render/commands.hpp b/apps/opencs/view/render/commands.hpp index 9698010a9..62b7fbfdc 100644 --- a/apps/opencs/view/render/commands.hpp +++ b/apps/opencs/view/render/commands.hpp @@ -34,6 +34,8 @@ namespace CSVRender void redo() override; void undo() override; + + void tryUpdate(); }; }