From e823c209faf2084dca8aacc73d8b223b955f27f9 Mon Sep 17 00:00:00 2001 From: DavivaD Date: Thu, 2 Aug 2018 17:21:31 +0200 Subject: [PATCH] Fix crash while loading mod and blank settings menu while paused game --- src/app/pathman.cpp | 30 ++++++++++++++++++++++++------ src/level/robotmain.cpp | 4 +++- src/level/robotmain.h | 1 + src/ui/maindialog.cpp | 1 + src/ui/mainui.cpp | 2 +- src/ui/screen/screen_setup.cpp | 1 - 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/app/pathman.cpp b/src/app/pathman.cpp index 26eebdf8..9656d3eb 100644 --- a/src/app/pathman.cpp +++ b/src/app/pathman.cpp @@ -77,11 +77,11 @@ void CPathManager::AddMod(const std::string &modPath) if (ON == std::string::npos) { GetLogger()->Info("Loading mod: '%s'\n", modPath.c_str()); - m_mods.push_back(modPath); + CResourceManager::AddLocation(modPath, true); } else { - GetLogger()->Info("Found Excluded mod: '%s'\n", modPath.c_str()); + GetLogger()->Info("Found excluded mod: '%s'\n", modPath.c_str()); } } @@ -171,15 +171,33 @@ void CPathManager::InitPaths() GetLogger()->Trace("Searching for mods in '%s'...\n", modAutoloadDir.c_str()); for (const std::string& modPath : FindModsInDir(modAutoloadDir)) { - GetLogger()->Info("Autoloading mod: '%s'\n", modPath.c_str()); - CResourceManager::AddLocation(modPath); + std::string::size_type ON; + ON = modPath.find('~'); + if (ON == std::string::npos) + { + GetLogger()->Info("Autoloading mod: '%s'\n", modPath.c_str()); + CResourceManager::AddLocation(modPath); + } + else + { + GetLogger()->Info("Found excluded mod: '%s'\n", modPath.c_str()); + } } } for (const std::string& modPath : m_mods) { - GetLogger()->Info("Loading mod: '%s'\n", modPath.c_str()); - CResourceManager::AddLocation(modPath); + std::string::size_type ON; + ON = modPath.find('~'); + if (ON == std::string::npos) + { + GetLogger()->Info("Loading mod: '%s'\n", modPath.c_str()); + CResourceManager::AddLocation(modPath); + } + else + { + GetLogger()->Info("Found excluded mod: '%s'\n", modPath.c_str()); + } } CResourceManager::SetSaveLocation(m_savePath); diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 14e26f9e..14397feb 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -327,6 +327,7 @@ std::string PhaseToString(Phase phase) if (phase == PHASE_SETUPps) return "PHASE_SETUPps"; if (phase == PHASE_SETUPcs) return "PHASE_SETUPcs"; if (phase == PHASE_SETUPss) return "PHASE_SETUPss"; + if (phase == PHASE_SETUPms) return "PHASE_SETUPms"; if (phase == PHASE_WRITEs) return "PHASE_WRITEs"; if (phase == PHASE_READ) return "PHASE_READ"; if (phase == PHASE_READs) return "PHASE_READs"; @@ -339,7 +340,7 @@ std::string PhaseToString(Phase phase) bool IsInSimulationConfigPhase(Phase phase) { - return (phase >= PHASE_SETUPds && phase <= PHASE_SETUPss) || phase == PHASE_READs || phase == PHASE_WRITEs; + return (phase >= PHASE_SETUPds && phase <= PHASE_SETUPms) || phase == PHASE_READs || phase == PHASE_WRITEs; } bool IsPhaseWithWorld(Phase phase) @@ -3865,6 +3866,7 @@ void CRobotMain::ChangeColor() m_phase != PHASE_SETUPps && m_phase != PHASE_SETUPcs && m_phase != PHASE_SETUPss && + m_phase != PHASE_SETUPms && m_phase != PHASE_WIN && m_phase != PHASE_LOST && m_phase != PHASE_APPERANCE ) return; diff --git a/src/level/robotmain.h b/src/level/robotmain.h index 68768beb..cd3345e4 100644 --- a/src/level/robotmain.h +++ b/src/level/robotmain.h @@ -67,6 +67,7 @@ enum Phase PHASE_SETUPps, PHASE_SETUPcs, PHASE_SETUPss, + PHASE_SETUPms, PHASE_WRITEs, PHASE_READ, PHASE_READs, diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 01d87dc2..395a875e 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -107,6 +107,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( CScreenSetup::GetTab() == PHASE_SETUPp ) m_main->ChangePhase(PHASE_SETUPps); if ( CScreenSetup::GetTab() == PHASE_SETUPc ) m_main->ChangePhase(PHASE_SETUPcs); if ( CScreenSetup::GetTab() == PHASE_SETUPs ) m_main->ChangePhase(PHASE_SETUPss); + if ( CScreenSetup::GetTab() == PHASE_SETUPm ) m_main->ChangePhase(PHASE_SETUPss); } if ( pressedButton == EVENT_INTERFACE_WRITE ) diff --git a/src/ui/mainui.cpp b/src/ui/mainui.cpp index 7e63a7db..1ca364bc 100644 --- a/src/ui/mainui.cpp +++ b/src/ui/mainui.cpp @@ -192,7 +192,7 @@ void CMainUserInterface::ChangePhase(Phase phase) screenSetup->SetActive(); m_currentScreen = screenSetup; } - if (m_phase >= PHASE_SETUPds && m_phase <= PHASE_SETUPss) + if (m_phase >= PHASE_SETUPds && m_phase <= PHASE_SETUPms) { CScreenSetup* screenSetup = GetSetupScreen(static_cast(m_phase - PHASE_SETUPds + PHASE_SETUPd)); screenSetup->SetInSimulation(true); diff --git a/src/ui/screen/screen_setup.cpp b/src/ui/screen/screen_setup.cpp index e9c36a71..3dbc0836 100644 --- a/src/ui/screen/screen_setup.cpp +++ b/src/ui/screen/screen_setup.cpp @@ -240,7 +240,6 @@ bool CScreenSetup::EventProcess(const Event &event) return false; case EVENT_INTERFACE_SETUPm: - m_main->ChangePhase(PHASE_SETUPm); return false; default: