Bug in t2dSceneObject moveTo method
by David House · in Torque Game Builder · 12/04/2005 (6:25 am) · 2 replies
If you don't pass in the last parameter ( targetMargin ), the engine will crash. Looking at the code, the problem appears to be with this section:
The way you are checking the number of arguments isn't really accurate. In the case of Target Margin, the number of arguments will be 8, not 7. If it is 7, then the caller has left off the target margin, but your code will still try to get it at position 7. Crashola... :)
Dang C++ and those zero based arrays... :)
// Fetch AutoStop Flag.
bool autoStop = true;
if ( argc >= 4 ) autoStop = dAtob(argv[4]);
// Fetch Callback Flag.
bool callback = false;
if ( argc >= 5 ) callback = dAtob(argv[5]);
// Fetch Snap.
bool snap = true;
if ( argc >= 6 ) snap = dAtob(argv[6]);
// Fetch Target Margin.
F32 targetMargin = 0.1f;
if ( argc >= 7 ) targetMargin = dAtof(argv[7]);The way you are checking the number of arguments isn't really accurate. In the case of Target Margin, the number of arguments will be 8, not 7. If it is 7, then the caller has left off the target margin, but your code will still try to get it at position 7. Crashola... :)
Dang C++ and those zero based arrays... :)
#2
Amended the "rotateTo()" function to be:
- Melv.
12/05/2005 (2:56 am)
Just thought I'd mention that this problem existed in the "rotateTo()" function as well. Guess I was having a bad day that day!Amended the "rotateTo()" function to be:
// Fetch AutoStop Flag.
bool autoStop = true;
if ( argc >= 5 ) autoStop = dAtob(argv[4]);
// Fetch Callback Flag.
bool callback = false;
if ( argc >= 6 ) callback = dAtob(argv[5]);
// Fetch Snap.
bool snap = true;
if ( argc >= 7 ) snap = dAtob(argv[6]);
// Fetch Target Margin.
F32 targetMargin = 0.1f;
if ( argc >= 8 ) targetMargin = dAtof(argv[7]);- Melv.
Associate Melv May
SDK Updated to:
// Fetch AutoStop Flag. bool autoStop = true; if ( argc >= 5 ) autoStop = dAtob(argv[4]); // Fetch Callback Flag. bool callback = false; if ( argc >= 6 ) callback = dAtob(argv[5]); // Fetch Snap. bool snap = true; if ( argc >= 7 ) snap = dAtob(argv[6]); // Fetch Target Margin. F32 targetMargin = 0.1f; if ( argc >= 8 ) targetMargin = dAtof(argv[7]);- Melv.