mirror of https://github.com/OpenTTD/OpenTTD
(svn r17544) -Fix [FS#3202]: [NoAI] Crash when doing commands in the 'global' scope
parent
4dfef325ce
commit
227824f753
|
@ -135,21 +135,30 @@ AIInstance::AIInstance(AIInfo *info) :
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load and execute the script for this AI */
|
try {
|
||||||
const char *main_script = info->GetMainScript();
|
AIObject::SetAllowDoCommand(false);
|
||||||
if (strcmp(main_script, "%_dummy") == 0) {
|
/* Load and execute the script for this AI */
|
||||||
extern void AI_CreateAIDummy(HSQUIRRELVM vm);
|
const char *main_script = info->GetMainScript();
|
||||||
AI_CreateAIDummy(this->engine->GetVM());
|
if (strcmp(main_script, "%_dummy") == 0) {
|
||||||
} else if (!this->engine->LoadScript(main_script)) {
|
extern void AI_CreateAIDummy(HSQUIRRELVM vm);
|
||||||
this->Died();
|
AI_CreateAIDummy(this->engine->GetVM());
|
||||||
return;
|
} else if (!this->engine->LoadScript(main_script)) {
|
||||||
}
|
this->Died();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the main-class */
|
/* Create the main-class */
|
||||||
this->instance = MallocT<SQObject>(1);
|
this->instance = MallocT<SQObject>(1);
|
||||||
if (!this->engine->CreateClassInstance(info->GetInstanceName(), this->controller, this->instance)) {
|
if (!this->engine->CreateClassInstance(info->GetInstanceName(), this->controller, this->instance)) {
|
||||||
|
this->Died();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AIObject::SetAllowDoCommand(true);
|
||||||
|
} catch (AI_FatalError e) {
|
||||||
|
this->is_dead = true;
|
||||||
|
this->engine->ThrowError(e.GetErrorMessage());
|
||||||
|
this->engine->ResumeError();
|
||||||
this->Died();
|
this->Died();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue