Mercurial > hg > openttd
changeset 13047:30208da44525 draft
(svn r17545) -Fix [FS#3202]: [NoAI] AIs had 'infinite' time when running code from the global scope
author | rubidium <rubidium@openttd.org> |
---|---|
date | Tue, 15 Sep 2009 16:18:10 +0000 |
parents | a02317f15b22 |
children | f9399c64435f |
files | src/ai/ai_instance.cpp src/script/squirrel.cpp |
diffstat | 2 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -142,7 +142,8 @@ 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; }
--- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -473,7 +473,7 @@ /* 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; }