From 41c0ec09402f920c8b616e3715e98bc3a00f18e1 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 14 Aug 2015 00:21:18 +0200 Subject: [PATCH] Fixed game save being always blocked Also, prevent autosave if saving is blocked --- src/level/robotmain.cpp | 11 ++++++++--- src/level/robotmain.h | 2 +- src/ui/maindialog.cpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index b2885668..49c6fb43 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -77,6 +77,7 @@ #include "object/task/task.h" #include "object/task/taskbuild.h" +#include "object/task/taskmanager.h" #include "object/task/taskmanip.h" #include "physics/physics.h" @@ -2363,8 +2364,11 @@ bool CRobotMain::EventFrame(const Event &event) m_levelCategory == LevelCategory::FreeGame || m_levelCategory == LevelCategory::CustomLevels ) { - m_autosaveLast = m_gameTimeAbsolute; - Autosave(); + if (!IOIsBusy()) + { + m_autosaveLast = m_gameTimeAbsolute; + Autosave(); + } } } @@ -4804,7 +4808,7 @@ char* CRobotMain::GetNewScriptName(ObjectType type, int rank) //! Seeks if an object occupies in a spot, to prevent a backup of the game -bool CRobotMain::IsBusy() +bool CRobotMain::IOIsBusy() { if (CScriptFunctions::m_numberOfOpenFiles > 0) return true; @@ -4812,6 +4816,7 @@ bool CRobotMain::IsBusy() { if (! obj->Implements(ObjectInterfaceType::TaskExecutor)) continue; + if (obj->Implements(ObjectInterfaceType::Programmable) && dynamic_cast(obj)->IsProgram()) continue; // TODO: I'm not sure if this is correct but this is how it worked earlier if (dynamic_cast(obj)->IsForegroundTask()) return true; } return false; diff --git a/src/level/robotmain.h b/src/level/robotmain.h index 681579b0..6aca2286 100644 --- a/src/level/robotmain.h +++ b/src/level/robotmain.h @@ -287,7 +287,7 @@ public: void SelectPlayer(std::string playerName); CPlayerProfile* GetPlayerProfile(); - bool IsBusy(); + bool IOIsBusy(); bool IOWriteScene(std::string filename, std::string filecbot, std::string filescreenshot, char *info); void IOWriteSceneFinished(); CObject* IOReadScene(std::string filename, std::string filecbot); diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 1a99a156..d857ad7e 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -209,7 +209,7 @@ void CMainDialog::StartPauseMenu() pos.y = 0.62f; pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_WRITE); pb->SetState(STATE_SHADOW); - if ( m_main->IsBusy() ) // current task? + if ( m_main->IOIsBusy() ) // current task? { pb->ClearState(STATE_ENABLE); }