diff options
author | zuu <zuu@openttd.org> | 2012-09-21 19:58:18 +0000 |
---|---|---|
committer | zuu <zuu@openttd.org> | 2012-09-21 19:58:18 +0000 |
commit | f3f4c562ff0625df99782af09725391d0f1c0a8a (patch) | |
tree | 6c456062b1bf0217a16fc19e4e21f9d505baabec /src/ai/ai_core.cpp | |
parent | 2e1936b11cfb64f08b43e454a402b6ada276a67a (diff) | |
download | openttd-f3f4c562ff0625df99782af09725391d0f1c0a8a.tar.xz |
(svn r24537) -Feature: Scripts can be suspended even if the game is still progressing, thus break-on-log now works also for Game Scripts.
Diffstat (limited to 'src/ai/ai_core.cpp')
-rw-r--r-- | src/ai/ai_core.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
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<CompanyByte> cur_company(_current_company, company, FILE_LINE); + Company::Get(company)->ai_instance->Pause(); + + cur_company.Restore(); +} + +/* static */ void AI::Unpause(CompanyID company) +{ + Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE); + Company::Get(company)->ai_instance->Unpause(); + cur_company.Restore(); +} + +/* static */ bool AI::IsPaused(CompanyID company) +{ Backup<CompanyByte> 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() |