summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 20:56:50 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 20:56:50 +0000
commit83f2785f54de1c31267c5586464c97fb39f95b5a (patch)
treede073b47921321433fc0945bd63bc9c07d4a1f33 /src/script/api
parentcbe43abe5db481568ccf988dbe994f43a985efbd (diff)
downloadopenttd-83f2785f54de1c31267c5586464c97fb39f95b5a.tar.xz
(svn r23611) -Add: run the begin of the script already while generating, and don't sleep on DoCommand while doing so
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/script_object.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp
index 1dd431d80..d9a432b44 100644
--- a/src/script/api/script_object.cpp
+++ b/src/script/api/script_object.cpp
@@ -15,6 +15,7 @@
#include "../../company_func.h"
#include "../../network/network.h"
#include "../../tunnelbridge.h"
+#include "../../genworld.h"
#include "../script_storage.hpp"
#include "../script_instance.hpp"
@@ -233,7 +234,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
#endif
/* Try to perform the command. */
- CommandCost res = ::DoCommandPInternal(tile, p1, p2, cmd, _networking ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : NULL, text, false, estimate_only);
+ CommandCost res = ::DoCommandPInternal(tile, p1, p2, cmd, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : NULL, text, false, estimate_only);
/* We failed; set the error and bail out */
if (res.Failed()) {
@@ -254,7 +255,11 @@ ScriptObject::ActiveInstance::~ActiveInstance()
SetLastCost(res.GetCost());
SetLastCommandRes(true);
- if (_networking) {
+ if (_generating_world) {
+ IncreaseDoCommandCosts(res.GetCost());
+ if (callback != NULL) callback(GetActiveInstance());
+ return true;
+ } else if (_networking) {
/* Suspend the AI till the command is really executed. */
throw Script_Suspend(-(int)GetDoCommandDelay(), callback);
} else {