|
|
@ -602,6 +602,7 @@ void AIInstance::Save()
|
|
|
|
/* We don't want to be interrupted during the save function. */
|
|
|
|
/* We don't want to be interrupted during the save function. */
|
|
|
|
bool backup_allow = AIObject::GetAllowDoCommand();
|
|
|
|
bool backup_allow = AIObject::GetAllowDoCommand();
|
|
|
|
AIObject::SetAllowDoCommand(false);
|
|
|
|
AIObject::SetAllowDoCommand(false);
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (!this->engine->CallMethod(*this->instance, "Save", &savedata)) {
|
|
|
|
if (!this->engine->CallMethod(*this->instance, "Save", &savedata)) {
|
|
|
|
/* The script crashed in the Save function. We can't kill
|
|
|
|
/* The script crashed in the Save function. We can't kill
|
|
|
|
* it here, but do so in the next AI tick. */
|
|
|
|
* it here, but do so in the next AI tick. */
|
|
|
@ -609,6 +610,19 @@ void AIInstance::Save()
|
|
|
|
this->engine->CrashOccurred();
|
|
|
|
this->engine->CrashOccurred();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (AI_FatalError e) {
|
|
|
|
|
|
|
|
/* If we don't mark the AI as dead here cleaning up the squirrel
|
|
|
|
|
|
|
|
* stack could throw AI_FatalError again. */
|
|
|
|
|
|
|
|
this->is_dead = true;
|
|
|
|
|
|
|
|
this->engine->ThrowError(e.GetErrorMessage());
|
|
|
|
|
|
|
|
this->engine->ResumeError();
|
|
|
|
|
|
|
|
SaveEmpty();
|
|
|
|
|
|
|
|
/* We can't kill the AI here, so mark it as crashed (not dead) and
|
|
|
|
|
|
|
|
* kill it in the next AI tick. */
|
|
|
|
|
|
|
|
this->is_dead = false;
|
|
|
|
|
|
|
|
this->engine->CrashOccured();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
AIObject::SetAllowDoCommand(backup_allow);
|
|
|
|
AIObject::SetAllowDoCommand(backup_allow);
|
|
|
|
|
|
|
|
|
|
|
|
if (!sq_istable(savedata)) {
|
|
|
|
if (!sq_istable(savedata)) {
|
|
|
|