mirror of https://github.com/OpenTTD/OpenTTD.git
Fix #11585: Crash when cleaning AI/GS with nested AsyncMode.
Do not throw sanity check when in_shutdown is true. This is also applied to ExecMode and TestMode as they follow the same pattern.
This commit is contained in:
parent
47dd04d16c
commit
bbf3028f89
|
@ -48,8 +48,8 @@ ScriptAsyncMode::ScriptAsyncMode(HSQUIRRELVM vm)
|
||||||
void ScriptAsyncMode::FinalRelease()
|
void ScriptAsyncMode::FinalRelease()
|
||||||
{
|
{
|
||||||
if (this->GetDoCommandAsyncModeInstance() != this) {
|
if (this->GetDoCommandAsyncModeInstance() != this) {
|
||||||
/* Ignore this error if the script already died. */
|
/* Ignore this error if the script is not alive. */
|
||||||
if (!ScriptObject::GetActiveInstance()->IsDead()) {
|
if (ScriptObject::GetActiveInstance()->IsAlive()) {
|
||||||
throw Script_FatalError("Asyncmode object was removed while it was not the latest *Mode object created.");
|
throw Script_FatalError("Asyncmode object was removed while it was not the latest *Mode object created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ ScriptExecMode::ScriptExecMode()
|
||||||
void ScriptExecMode::FinalRelease()
|
void ScriptExecMode::FinalRelease()
|
||||||
{
|
{
|
||||||
if (this->GetDoCommandModeInstance() != this) {
|
if (this->GetDoCommandModeInstance() != this) {
|
||||||
/* Ignore this error if the script already died. */
|
/* Ignore this error if the script is not alive. */
|
||||||
if (!ScriptObject::GetActiveInstance()->IsDead()) {
|
if (ScriptObject::GetActiveInstance()->IsAlive()) {
|
||||||
throw Script_FatalError("ScriptExecMode object was removed while it was not the latest *Mode object created.");
|
throw Script_FatalError("ScriptExecMode object was removed while it was not the latest *Mode object created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ ScriptTestMode::ScriptTestMode()
|
||||||
void ScriptTestMode::FinalRelease()
|
void ScriptTestMode::FinalRelease()
|
||||||
{
|
{
|
||||||
if (this->GetDoCommandModeInstance() != this) {
|
if (this->GetDoCommandModeInstance() != this) {
|
||||||
/* Ignore this error if the script already died. */
|
/* Ignore this error if the script is not alive. */
|
||||||
if (!ScriptObject::GetActiveInstance()->IsDead()) {
|
if (ScriptObject::GetActiveInstance()->IsAlive()) {
|
||||||
throw Script_FatalError("Testmode object was removed while it was not the latest *Mode object created.");
|
throw Script_FatalError("Testmode object was removed while it was not the latest *Mode object created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,6 +152,11 @@ public:
|
||||||
*/
|
*/
|
||||||
inline bool IsDead() const { return this->is_dead; }
|
inline bool IsDead() const { return this->is_dead; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether the script is alive.
|
||||||
|
*/
|
||||||
|
inline bool IsAlive() const { return !this->IsDead() && !this->in_shutdown; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call the script Save function and save all data in the savegame.
|
* Call the script Save function and save all data in the savegame.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue