summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_instance.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index 9e4b56ddc..384f2b4be 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -135,21 +135,30 @@ AIInstance::AIInstance(AIInfo *info) :
return;
}
- /* Load and execute the script for this AI */
- const char *main_script = info->GetMainScript();
- if (strcmp(main_script, "%_dummy") == 0) {
- extern void AI_CreateAIDummy(HSQUIRRELVM vm);
- AI_CreateAIDummy(this->engine->GetVM());
- } else if (!this->engine->LoadScript(main_script)) {
- this->Died();
- return;
- }
+ try {
+ AIObject::SetAllowDoCommand(false);
+ /* Load and execute the script for this AI */
+ const char *main_script = info->GetMainScript();
+ if (strcmp(main_script, "%_dummy") == 0) {
+ extern void AI_CreateAIDummy(HSQUIRRELVM vm);
+ AI_CreateAIDummy(this->engine->GetVM());
+ } else if (!this->engine->LoadScript(main_script)) {
+ this->Died();
+ return;
+ }
- /* Create the main-class */
- this->instance = MallocT<SQObject>(1);
- if (!this->engine->CreateClassInstance(info->GetInstanceName(), this->controller, this->instance)) {
+ /* Create the main-class */
+ this->instance = MallocT<SQObject>(1);
+ 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();
- return;
}
}