From f3f4c562ff0625df99782af09725391d0f1c0a8a Mon Sep 17 00:00:00 2001 From: zuu Date: Fri, 21 Sep 2012 19:58:18 +0000 Subject: (svn r24537) -Feature: Scripts can be suspended even if the game is still progressing, thus break-on-log now works also for Game Scripts. --- src/ai/ai_core.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/ai/ai_core.cpp') diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index e2f04622b..ab8510f09 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -112,14 +112,35 @@ DeleteWindowById(WC_AI_SETTINGS, company); } -/* static */ void AI::Suspend(CompanyID company) +/* static */ void AI::Pause(CompanyID company) { - if (_networking && !_network_server) return; + /* The reason why dedicated servers are forbidden to execute this + * command is not because it is unsafe, but because there is no way + * for the server owner to unpause the script again. */ + if (_network_dedicated) return; + + Backup cur_company(_current_company, company, FILE_LINE); + Company::Get(company)->ai_instance->Pause(); + + cur_company.Restore(); +} + +/* static */ void AI::Unpause(CompanyID company) +{ + Backup cur_company(_current_company, company, FILE_LINE); + Company::Get(company)->ai_instance->Unpause(); + cur_company.Restore(); +} + +/* static */ bool AI::IsPaused(CompanyID company) +{ Backup cur_company(_current_company, company, FILE_LINE); - Company::Get(company)->ai_instance->Suspend(); + bool paused = Company::Get(company)->ai_instance->IsPaused(); cur_company.Restore(); + + return paused; } /* static */ void AI::KillAll() -- cgit v1.2.3-54-g00ecf