From 2b8fa926eb8badc2f7e6716e4bdcdb2456216b8f Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 6 Apr 2022 23:57:32 +0200 Subject: Replaced c-style casts of derived classes with dynamic_cast --- StarsEx/StarServer.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'StarsEx') diff --git a/StarsEx/StarServer.cpp b/StarsEx/StarServer.cpp index 29e9470..b9ba942 100644 --- a/StarsEx/StarServer.cpp +++ b/StarsEx/StarServer.cpp @@ -207,10 +207,8 @@ StarServer::SetGameMode(int m) Print(" game_mode = MENU_MODE\n"); paused = true; - Sim* sim = (Sim*) world; - - if (sim) - sim->UnloadMission(); + if (auto sim = dynamic_cast(world)) + sim->UnloadMission(); } game_mode = m; @@ -224,8 +222,7 @@ StarServer::CreateWorld() // create world if (!world) { - Sim* sim = new Sim(nullptr); - world = sim; + world = new Sim(nullptr); Print(" World Created.\n"); } } @@ -239,9 +236,7 @@ StarServer::InstantiateMission() current_mission = Campaign::GetCampaign()->GetMission(); } - Sim* sim = (Sim*) world; - - if (sim) { + if (auto sim = dynamic_cast(world)) { sim->UnloadMission(); if (current_mission) { -- cgit v1.1