Fix CBOT script hanging at delete()

pyro-refactor
melex750 2020-08-15 09:41:31 -04:00 committed by GitHub
parent 5749fff377
commit 8d5cafecb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -734,6 +734,9 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
}
else
{
CScript* script = static_cast<CScript*>(user);
bool deleteSelf = (obj == script->m_object);
if ( exploType != DestructionType::NoEffect && obj->Implements(ObjectInterfaceType::Destroyable) )
{
dynamic_cast<CDestroyableObject*>(obj)->DestroyObject(static_cast<DestructionType>(exploType));
@ -752,12 +755,13 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
}
CObjectManager::GetInstancePointer()->DeleteObject(obj);
}
// Returning "false" here makes sure the program doesn't try to keep executing
// if the robot just destroyed itself using delete(this.id)
// See issue #925
return !deleteSelf;
}
// Returning "false" here makes sure the program doesn't try to keep executing if the robot just destroyed itself
// using delete(this.id)
// See issue #925
return false;
return true;
}
static CBotTypResult compileSearch(CBotVar* &var, void* user, CBotTypResult returnValue)