Minor Bug with Loading Mounted Objects
by Eric Armstrong · in Torque Game Builder · 01/05/2006 (10:19 am) · 4 replies
I think I may have discovered a little bug in the loading of scenes when you have mounted objects. In the t2dSceneObject load method there is the following line:
The problem is that the call to mount returns the index of the newly created mount. If this is the first mount created, than the index returned is 0, which causes the return false to run and stops the loading of the scene file with an error.
I changed the call to be:
This allowed my scene to load, and everything appears to be working correctly. I would think this would have been something that would have been experienced by others, so I'm kind of wondering why it appears no one has run into the problem before. I am saving and loading custom created objects that are children of t2dStaticSprite, so I suppose it could be a by product of something I didn't do correctly with that, but the logic of what was going on made sense to me.
Let me know if you see anything wrong with the change I made.
Eric
if (!object->mount( pMountObject2D,mountOffset,mountForce,mountTrackRotation,
false,mountOwned,mountInheritAttributes) )
// Error.
return false;The problem is that the call to mount returns the index of the newly created mount. If this is the first mount created, than the index returned is 0, which causes the return false to run and stops the loading of the scene file with an error.
I changed the call to be:
if (object->mount( pMountObject2D,mountOffset,mountForce,mountTrackRotation,
false,mountOwned,mountInheritAttributes) == -1 )
// Error.
return false;This allowed my scene to load, and everything appears to be working correctly. I would think this would have been something that would have been experienced by others, so I'm kind of wondering why it appears no one has run into the problem before. I am saving and loading custom created objects that are children of t2dStaticSprite, so I suppose it could be a by product of something I didn't do correctly with that, but the logic of what was going on made sense to me.
Let me know if you see anything wrong with the change I made.
Eric
#2
I changed the line to be "< 0" as the test, particularly in mind of some changes I'm about to make with regards to mounting/link-points. This is, in-fact, what v9 uses.
Thanks again.
- Melv.
01/06/2006 (2:12 am)
I'll just add that this problem only exists for loading v8 t2dSceneObjects, not v9.I changed the line to be "< 0" as the test, particularly in mind of some changes I'm about to make with regards to mounting/link-points. This is, in-fact, what v9 uses.
Thanks again.
- Melv.
#3
01/06/2006 (9:55 am)
Wow, didn't see this thread before. I wish I would have before I wasted time tracking down the problem myself. Anyway Melv, the reason it didn't exist for v9 objects was because I fixed that yesterday. Guess I should have checked v8, too.
Associate Melv May
That is totally correct. I cannot believe that it hasn't been noticed before! The mount command returns the index of the mount-link, not a bool!
Big thanks,
- Melv.