Loops cause lockup?
by Davis Ray Sickmon, Jr · in Torque Game Engine · 02/18/2004 (10:30 pm) · 5 replies
OK, I'm now sure that I'm going nuts when it comes to the Mac port of Trajectory Zone. This is something that shouldn't be going wrong. Simply put, it looks like some places that there's a for(...) loop is locking up inside the loop.
My first "hey, something bizzare here" was that the game loaded to the main menu fine, but, starting a game caused a lockup. Hm. So, I did some looking with use of logs and trace(1), and discovered that it was getting stuck in a loop on:
Uh... WFT? Of course, this all runs perfectly on the Windows version, and Xavier never complained about similar problems on the Linux builds. And I assume someone would be complaining in the forums too :-) This is the 1.2 build of Torque, successfully compiled using XCode, for those who are following along.
Any ideas? This one is blowing my mind here!
My first "hey, something bizzare here" was that the game loaded to the main menu fine, but, starting a game caused a lockup. Hm. So, I did some looking with use of logs and trace(1), and discovered that it was getting stuck in a loop on:
for( %i = 0; MissionInfo.desc[%i] !$= ""; %i++ )
messageClient( %client, 'MsgLoadDescripition', "", MissionInfo.desc[%i] );Checking trace, it just sent the same line over and over and over. Strange. Well, I don't make use of the mission description since I have unique loading screens for each level, so, just commented it out and moved on. Next, it gets stuck on:for ( %i = 0; %i < %count; %i++ )
{
%test = ClientGroup.getObject( %i );
%rawName = stripChars( detag( getTaggedString( %test.name ) ), "\cp\co\c6\c7\c8\c9" );
if ( strcmp( %name, %rawName ) == 0 )
return false;
}Uh... WFT? Of course, this all runs perfectly on the Windows version, and Xavier never complained about similar problems on the Linux builds. And I assume someone would be complaining in the forums too :-) This is the 1.2 build of Torque, successfully compiled using XCode, for those who are following along.
Any ideas? This one is blowing my mind here!
About the author
#2
Try "%i = %i + 1" to see if that makes any difference; maybe the post-increment has got screwed?
Try using "%n" (or anything else) instead of "%i".
All I can think of really but definately try Harolds suggestion.
- Melv.
EDIT: Perhaps rewrite it as a "while" loop with a decrementing counter or something to see if it's the "for" mechanism that's playing-up;
02/19/2004 (10:25 am)
Hmmm,Try "%i = %i + 1" to see if that makes any difference; maybe the post-increment has got screwed?
Try using "%n" (or anything else) instead of "%i".
All I can think of really but definately try Harolds suggestion.
- Melv.
EDIT: Perhaps rewrite it as a "while" loop with a decrementing counter or something to see if it's the "for" mechanism that's playing-up;
#3
Maybe even try that??
- Brett
02/19/2004 (10:35 am)
%idx = 0;
while (MissionInfo.desc[%idx] !$= "")
{
messageClient( %client, ´MsgLoadDescripition´, "", MissionInfo.desc[%idx] );
%idx++; // Or: %idx+=1
}Maybe even try that??
- Brett
#4
So, I inserted an echo(%count SPC %i); in the loop it stopped on. It proceeded to output... exactly what it should, and execution continued until it hit the next loop. Did the same thing, with the same result. And again. And again... for some reason, putting the echo in made it work. I thought at first it was just a logging error to console.log, but, running trace() or using echo's without addressing the variables would show repeating results. I deleted all the .dso files, and tried again. No luck. Kept poking and proding, just to see WTF was going on.
Then I had to take a two day break to handle the details of buying a new car since mine was dying a horrible rapid death. This got my mind off of it for a bit. So, I came back, deleted the whole thing, re-transfered (the whole project, minus the Torque source files) it from the Windows machine to the Mac, just to get a fresh start again...
And it works perfectly fine now. Go fig that one. Something, somewhere, somehow went wrong with the transfer the first time (but not wrong enough to make it crash or produce an obvious error in the log!), and this was the result. Friggin' bizzare. Thanks for the suggestions everyone!
02/23/2004 (9:07 pm)
I'm followin' up with what I did, and how I fixed it, just in case anyone else runs into it. It's kinda funny.So, I inserted an echo(%count SPC %i); in the loop it stopped on. It proceeded to output... exactly what it should, and execution continued until it hit the next loop. Did the same thing, with the same result. And again. And again... for some reason, putting the echo in made it work. I thought at first it was just a logging error to console.log, but, running trace() or using echo's without addressing the variables would show repeating results. I deleted all the .dso files, and tried again. No luck. Kept poking and proding, just to see WTF was going on.
Then I had to take a two day break to handle the details of buying a new car since mine was dying a horrible rapid death. This got my mind off of it for a bit. So, I came back, deleted the whole thing, re-transfered (the whole project, minus the Torque source files) it from the Windows machine to the Mac, just to get a fresh start again...
And it works perfectly fine now. Go fig that one. Something, somewhere, somehow went wrong with the transfer the first time (but not wrong enough to make it crash or produce an obvious error in the log!), and this was the result. Friggin' bizzare. Thanks for the suggestions everyone!
#5
02/24/2004 (1:31 pm)
If you're adding and removing files from a project, you'll sometimes get compile and/ or link errors and warnings that won't register when you compile. I've had similar crashes occur with other programs when I've removed a few files and haven't bothered with re-compiling everything.
Torque Owner Harold "LabRat" Brown
echo("DEBUG =>" SPC %i SPC %count);Either your %count is incrementing, or your %i isn't...