Merge pull request #1451 from Azaezel/alpha41/cleanerCleanups

isobject and obj.delete safties
This commit is contained in:
Brian Roberts 2025-04-29 20:25:39 -05:00 committed by GitHub
commit b095134df8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -102,7 +102,15 @@ DefineEngineFunction( isObject, bool, (const char * objectName), ,"isObject(obje
if (!String::compare(objectName, "0") || !String::compare(objectName, ""))
return false;
else
return (Sim::findObject(objectName) != NULL);
{
SimObject* obj= Sim::findObject(objectName);
if (obj)
{
if (!obj->isProperlyAdded() || obj->isRemoved())
obj = NULL;
}
return obj != NULL;
}
}
ConsoleDocFragment _spawnObject1(

View file

@ -3296,6 +3296,9 @@ DefineEngineMethod( SimObject, getGroup, SimGroup*, (),,
DefineEngineMethod( SimObject, delete, void, (),,
"Delete and remove the object." )
{
if (!object->isProperlyAdded() || object->isRemoved())
return;
object->deleteObject();
}