Merge pull request #1346 from melex750/dev-cbot-fix-delete
Fix CBOT script hanging at delete()pyro-refactor
commit
d7ec891ab8
|
@ -734,6 +734,9 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
CScript* script = static_cast<CScript*>(user);
|
||||||
|
bool deleteSelf = (obj == script->m_object);
|
||||||
|
|
||||||
if ( exploType != DestructionType::NoEffect && obj->Implements(ObjectInterfaceType::Destroyable) )
|
if ( exploType != DestructionType::NoEffect && obj->Implements(ObjectInterfaceType::Destroyable) )
|
||||||
{
|
{
|
||||||
dynamic_cast<CDestroyableObject*>(obj)->DestroyObject(static_cast<DestructionType>(exploType));
|
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);
|
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
|
return true;
|
||||||
// using delete(this.id)
|
|
||||||
// See issue #925
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static CBotTypResult compileSearch(CBotVar* &var, void* user, CBotTypResult returnValue)
|
static CBotTypResult compileSearch(CBotVar* &var, void* user, CBotTypResult returnValue)
|
||||||
|
|
Loading…
Reference in New Issue