Selaa lähdekoodia

Adds a onPostAdd callback to simObject so we can do handling AFTER the object and it's children have been added successfully.

Areloch 9 vuotta sitten
vanhempi
commit
86dd8a8cf7

+ 4 - 0
Engine/source/console/compiledEval.cpp

@@ -994,6 +994,7 @@ breakContinue:
                   // This error is usually caused by failing to call Parent::initPersistFields in the class' initPersistFields().
                   // This error is usually caused by failing to call Parent::initPersistFields in the class' initPersistFields().
                   Con::warnf(ConsoleLogEntry::General, "%s: Register object failed for object %s of class %s.", getFileLine(ip), currentNewObject->getName(), currentNewObject->getClassName());
                   Con::warnf(ConsoleLogEntry::General, "%s: Register object failed for object %s of class %s.", getFileLine(ip), currentNewObject->getName(), currentNewObject->getClassName());
                   delete currentNewObject;
                   delete currentNewObject;
+                  currentNewObject = NULL;
                   ip = failJump;
                   ip = failJump;
                   // Prevent stack value corruption
                   // Prevent stack value corruption
                   CSTK.popFrame();
                   CSTK.popFrame();
@@ -1094,6 +1095,9 @@ breakContinue:
 
 
          case OP_FINISH_OBJECT:
          case OP_FINISH_OBJECT:
          {
          {
+            if (currentNewObject)
+               currentNewObject->onPostAdd();
+
             //Assert( objectCreationStackIndex >= 0 );
             //Assert( objectCreationStackIndex >= 0 );
             // Restore the object info from the stack [7/9/2007 Black]
             // Restore the object info from the stack [7/9/2007 Black]
             currentNewObject = objectCreationStack[ --objectCreationStackIndex ].newObject;
             currentNewObject = objectCreationStack[ --objectCreationStackIndex ].newObject;

+ 4 - 0
Engine/source/console/simObject.h

@@ -606,6 +606,10 @@ class SimObject: public ConsoleObject, public TamlCallbacks
       /// Called when the object's name is changed.
       /// Called when the object's name is changed.
       virtual void onNameChange(const char *name);
       virtual void onNameChange(const char *name);
       
       
+      /// Called when the adding of the object to the sim is complete, all sub-objects have been processed as well
+      // This is a special-case function that only really gets used with Entities/BehaviorObjects.
+      virtual void onPostAdd() {}
+
       ///
       ///
       ///  Specifically, these are called by setDataField
       ///  Specifically, these are called by setDataField
       ///  when a static or dynamic field is modified, see
       ///  when a static or dynamic field is modified, see