Game Development Community

1.1.3 frame in datablock not being set on new t2dStaticSprite?

by Magnus Blikstad · in Torque Game Builder · 03/28/2007 (6:20 am) · 2 replies

I seem to have come across a "bug", or a case of missing code (or so it seems).
I'm trying to set the frame to use on a t2dStaticSprite through a datablock but it always ends up using frame 0.

This is my datablocks:
new t2dSceneObjectDatablock(Wing){
   //class = "Wing";
   MountOwned = "1";
};

new t2dSceneObjectDatablock (StableWing : Wing) {
   superClass = "Wing";
   class = "StableWing";
   imageMap = "shipImageMap";
   MountInheritAttributes = "0";
   frame = "2";
   type = "Stable";
   layer = "2";
};

And I'm creating my sprite with something like this:
%spr = new t2dStaticSprite() { config = StableWing; scenegraph = %this.scenegraph; }


The weird part is that this works just fine if I use the precompiled TGB.exe that comes with 1.1.3, but NOT when I compile it myself. (which leads me to believe someone forgot to check in some code somewhere before the release went out).

Calling %this.setFrame(2) in StableWing::onAdd does work fine, as well as adding frame = "2" in the call to new t2dStaticSprite(), but both those two solutions are a bit cumbersome in this particular case. I'm guessing something is missing in t2dSceneObject, because when I step through t2dSceneObject::setConfigDatablock frame IS being set to 2 but it's being handled as a "dynamic field".

Any ideas?

#1
03/28/2007 (7:20 am)
Okay, I dug a bit more and noticed everything is getting called correctly. But there's still something odd going on here. For some reason t2dStaticSprite::setFrame is being called before t2dStaticSprite::setImageMap (no matter what order the variables are in the datablock).

This causes t2dStaticSprite::setImageMap to overwrite the mFrame variable set previously in ::setFrame.

I can work around it now, but I'm still looking for the "proper" way to fix this, SOMETHING has to be different in the code used for the precompiled exe and what's supplied in the release since if I use the exe that comes with 1.1.3 it works fine.
#2
03/28/2007 (7:23 am)
Okay, another update, this is how I fixed it. Any comments as to if this will cause "bad things" to happen somewhere else?

replace the static bool setImageMap line in t2dStaticSprite.h with this:
static bool setImageMap(void* obj, const char* data) { static_cast<t2dStaticSprite*>(obj)->setImageMap(data, static_cast<t2dStaticSprite*>(obj)->mFrame); return false; };