Ver código fonte

Merge pull request #1451 from Azaezel/alpha41/cleanerCleanups

isobject and obj.delete safties
Brian Roberts 5 meses atrás
pai
commit
b095134df8
2 arquivos alterados com 12 adições e 1 exclusões
  1. 9 1
      Engine/source/console/sim.cpp
  2. 3 0
      Engine/source/console/simObject.cpp

+ 9 - 1
Engine/source/console/sim.cpp

@@ -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(

+ 3 - 0
Engine/source/console/simObject.cpp

@@ -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();
 }