Game Development Community

TGEA 1.7.0 Bug - onStaticModified() changes

by Jeff Faust · in Torque Game Engine Advanced · 04/22/2008 (3:25 pm) · 0 replies

OnStaticModified() is a virtual method of SimObject that is called whenever a static field of an object (or datablock) is assigned a new value. Subclasses of SimObject can override the call as needed.

Between TGEA 1.0.3 and 1.7.0, the method acquired a new argument, as shown here:
// IN TGEA 1.0.3
virtual void onStaticModified(const char* slotName);

// IN TGEA 1.7.0
virtual void onStaticModified(const char* slotName, const char*newValue = NULL);
Now even though the new argument is optional, any subclass overriding this method must have a matching declaration. A subclass using the 1.0.3 declaration creates an overloaded method which will not override the new variation of onStaticModified().

In stock TGEA 1.7.0 there are three subclasses of SimObject that override this method: SimDataBlock, GuiTextEditCtrl, and SFXEmitter. SimDataBlock declares its method correctly so it works, but GuiTextEditCtrl and SFXEmitter still use the form from 1.0.3 so their versions of onStaticModified() will not be called. (onStaticModified() is only called in two places, both in SimObject::setDataField().)

I'm not completely certain what the total ramifications of this is. Most likely it means that GuiTextEditCtrl and SFXEmitter are not updating correctly when they are manipulated in an editor, but it could be causing other subtle errors.

Also, if like me, you use onStaticModified() in your own code, remember to update your declarations. You won't get a nice compiler error or warning. You methods will just silently turn into overloads that are never called.

(edited: minor change for accuracy)

About the author

Jeff Faust creates special effects indie middleware and games for Faust Logic. --- Blog: Effectronica.com --- Twitter: @FaustLogic