Most annoying and retarded crash EVER
by Chris \"Hobbiticus\" Weiland · in Torque Game Engine · 12/06/2002 (7:39 pm) · 4 replies
Ok, someone from GG needs to look over how the script interacts with code calls, because I cannot, for the life of me, keep my turrets from crashing.
I've been trying to debug this for hours (and my vc debugger is broken somehow, so that doesn't help) and I've been reduced to using Con::printf's and echo's to try and solve the problem. Basically, I put an echo or a printf inbetween every single line (fun fun fun). This is just a snippet...
Now, it would be SO simple if it would crash every time that's called, but no, of course not. I can't even recreate it consistantly, but I think it has something to do with going passed a distance threshold from the turret, then going back in then coming right back out...
Anyway, as you can see, it doesn't matter if I use a direct reference to the player number or using a variable stored elsewhere, it still crashes (seemingly randomly). Now, I'm STILL working on it as I'm typing, and NOW even if I comment out everything between those two echos, it STILL CRASHES THERE! That means that either the code, for some reason, has trouble parsing the script, or echos suddenly become minions of the devil, coming to take control of my computer.
As for the structure of what's going on, I wrote a turret class (obviously) where all of the aiming and deploying and such are done in script. Basically what happens is every second or so, the turret does a container search for players, and if it finds one, it stops the searching and schedules a checkOnTarget function. That function checks to see if the turret has LOS with the target and if it does, fires. If it doesn't, then it schedules the function to get a new target. Meanwhile, the code controls how the turret rotates through animations.
Here's a portion of checkOnTarget:
Also, I know for a fact that the code portion of the turret class does not cause the crash.
Anyway, this is getting really long. I hope someone can help me out, because I think the people in #GG are getting tired of hearing me yelling at this thing now.
I've been trying to debug this for hours (and my vc debugger is broken somehow, so that doesn't help) and I've been reduced to using Con::printf's and echo's to try and solve the problem. Basically, I put an echo or a printf inbetween every single line (fun fun fun). This is just a snippet...
echo("hoho");
//%targetPos = 1870.getPosition();
%transform = %target.getTransform();
echo("hehe");And, as you might expect, when I log the console, I get "hoho" but no "hehe" no matter how I try and get the player position. And yes, I do check to see if it's an object. It doesn't give me any errors, it just locks, and sometimes, my sound goes with it! (Have to reboot to be able to hear anything again)Now, it would be SO simple if it would crash every time that's called, but no, of course not. I can't even recreate it consistantly, but I think it has something to do with going passed a distance threshold from the turret, then going back in then coming right back out...
Anyway, as you can see, it doesn't matter if I use a direct reference to the player number or using a variable stored elsewhere, it still crashes (seemingly randomly). Now, I'm STILL working on it as I'm typing, and NOW even if I comment out everything between those two echos, it STILL CRASHES THERE! That means that either the code, for some reason, has trouble parsing the script, or echos suddenly become minions of the devil, coming to take control of my computer.
As for the structure of what's going on, I wrote a turret class (obviously) where all of the aiming and deploying and such are done in script. Basically what happens is every second or so, the turret does a container search for players, and if it finds one, it stops the searching and schedules a checkOnTarget function. That function checks to see if the turret has LOS with the target and if it does, fires. If it doesn't, then it schedules the function to get a new target. Meanwhile, the code controls how the turret rotates through animations.
Here's a portion of checkOnTarget:
function DepTurretPlaced::checkOnTarget( %data, %object )
{
// ----
echo("checking on target...");
%target = %object.getTargetId();
echo("got id: ", %target);
if ( isObject(%target))
{
echo("hoho");
//%targetPos = 1870.getPosition();
//%transform = %target.getTransform();
%transform = "0 0 0";
echo("hehe");
// Get transform returns 7? digits seperated by a space
// The first 3 numbers of this variable represent
// the position of the object
%posX = getWord(%transform, 0);
%posY = getWord(%transform, 1);
%posZ = getWord(%transform, 2);
// Optional step
%targetPos = %posX @ SPC @ %posY @ SPC @ %posZ;
echo("position: ", %targetPos);
%objectPos = %object.getPosition();
%vec = vectorSub(%objectPos,%targetPos);
...And, as it stands now, I get a hoho and no hehe when it crashes.Also, I know for a fact that the code portion of the turret class does not cause the crash.
Anyway, this is getting really long. I hope someone can help me out, because I think the people in #GG are getting tired of hearing me yelling at this thing now.
#2
it should be:
The SPC constant means:
12/06/2002 (8:31 pm)
this is wrong:%targetPos = %posX @ SPC @ %posY @ SPC @ %posZ;
it should be:
%targetPos = %posX SPC %posY SPC %posZ;
The SPC constant means:
@ " " @
#3
12/06/2002 (9:23 pm)
Yeah, i just copy pasted that from somewhere else, but that still doesn't solve the crashing though.
#4
If not then the function is forked. Dunno why it would be though. Are you calling a "while" loop in it at any time? I would assume you are so you can constantly check for targets. If so take it out and try again without it to see if it still crashes.
I had a similar problem checking for targets with the AI. Thus I havent messed with em since.
Sam
12/07/2002 (10:24 am)
Does this happen if you dont make the call to "checkOnTarget"?If not then the function is forked. Dunno why it would be though. Are you calling a "while" loop in it at any time? I would assume you are so you can constantly check for targets. If so take it out and try again without it to see if it still crashes.
I had a similar problem checking for targets with the AI. Thus I havent messed with em since.
Sam
Associate Ken Finney
Tubetti World