diff options
author | rubidium <rubidium@openttd.org> | 2009-09-15 16:18:10 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-09-15 16:18:10 +0000 |
commit | f2487381ce266241952b3e0d8f796740d405f0ea (patch) | |
tree | 61cc32e12afcb28fdf54ffa04864667cd4acce91 /src | |
parent | 227824f753d7149d53aa47fafd6292459a24afa0 (diff) | |
download | openttd-f2487381ce266241952b3e0d8f796740d405f0ea.tar.xz |
(svn r17545) -Fix [FS#3202]: [NoAI] AIs had 'infinite' time when running code from the global scope
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/ai_instance.cpp | 3 | ||||
-rw-r--r-- | src/script/squirrel.cpp | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index 384f2b4be..1405f6226 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -142,7 +142,8 @@ AIInstance::AIInstance(AIInfo *info) : if (strcmp(main_script, "%_dummy") == 0) { extern void AI_CreateAIDummy(HSQUIRRELVM vm); AI_CreateAIDummy(this->engine->GetVM()); - } else if (!this->engine->LoadScript(main_script)) { + } else if (!this->engine->LoadScript(main_script) || this->engine->IsSuspended()) { + if (this->engine->IsSuspended()) AILog::Error("This AI took too long to load script. AI is not started."); this->Died(); return; } diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index c9010cfcd..67a927bbe 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -473,7 +473,7 @@ static SQInteger _io_file_read(SQUserPointer file, SQUserPointer buf, SQInteger /* Load and run the script */ if (SQ_SUCCEEDED(LoadFile(vm, script, SQTrue))) { sq_push(vm, -2); - if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue))) { + if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue, 100000))) { sq_pop(vm, 1); return true; } |