Game Development Community

Engine Crash again

by Howard Dortch · in Torque 3D Professional · 12/03/2012 (5:12 pm) · 11 replies

I put this code in any script file and the engine just crashes. The code is not even being called and it chokes the engine. Script stops here:

*** LOADING MISSION: levels/Hyperia.mis

Here is the function:

function findFlat(%x,%y, %player)
{
%z = getTerrainHeight(%x SPC %y);
%start = %x SPC %Y SPC %z + 50;
%end = %x SPC %y SPC %z;
%res = serverContainerRayCast(%start, %end, $TypeMasks::TerrainObjectType,%player);
if(%res != 0)
{
%angle = getWord(%res,6);
echo("ANGLE "@%angle);
}
else
echo("NO RES");
}

MSVC DEBUGGER Stops here

> int ret = torque_winmain(hInstance, hPrevInstance, lpszCmdLine, nCommandShow );

CALL STACK
> GAME_DEBUG.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpszCmdLine=0x002320a2, int nCommandShow=1) Line 52 + 0x16 bytes C++

I get crashes all the time just putting in simple code.

#1
12/03/2012 (5:16 pm)
Can't really figure out what torque_winmain has got to do with that function.. Do you have torsion?
Otherwise can you put in some echoes to try and determine exactly which line in the script causes the engine to crash?

Also what Visual Studio are you using?
#2
12/03/2012 (6:47 pm)
Yes I have Torsion and this is the last entry in the console.log

** Loading GameItems's **
*** LOADING MISSION: levels/Hyperia.mis

I get all kinds of wierd crashes for no reason. Even the editor crashes when I hit F11.
Thanks for a reply....
#3
12/03/2012 (7:31 pm)
Insert echo functions to pinpoint where the functio n crashes. For example, slip in something right after the ray cast and before the if. When the engine crashes again, check the console log and see if the echo was called. If so, then your crash is in the if, or somewhere else altogether.
#4
12/03/2012 (7:49 pm)
The function is never called, ever. I put echo in there and nothing gets echoed. The mere fact that the function is in at all crashes it. I remove the function and game runs.
#5
12/03/2012 (9:40 pm)
Quote:
The function is never called, ever. I put echo in there and nothing gets echoed. The mere fact that the function is in at all crashes it. I remove the function and game runs.
Where are you placing the function?

#6
12/04/2012 (1:33 am)
Copy-pasting the function into my game works just fine, I'm able to call it aswell so yeah would like to know where you place that function aswell
#7
12/04/2012 (6:49 am)
Are there messages in the console log about syntax errors?
#8
12/04/2012 (10:13 am)
I put the function in 4 different script files and it crashes. Take it out and game runs. I have a utility.cs for this kind of thing and it has code for various things. I move it out to other files and crash. And Yes I delete the DSO files each time.

No syntax errors, Lucas used it with no Ill effects so it works.

All I want to do is find a flat spot on the terrain to drop an object and the normal from the raycast would give me that. I guess I do it manually..
/shrug ... Thanks for responding
#9
12/04/2012 (10:23 am)
Hmm Howard, do you have the same function defined in 4 scripts? I don't know what the effects of that is.. Functions are global so if you define it in a.cs and b.cs calls that function, you are all fine so long as you don't call the function before you exec a.cs
e.g.:
a.cs
function foo(){echo "bar";}
b.cs
function bar(){foo();}
exec.cs
exec("./b.cs");
bar(); // Error foo haven't been defined yet
exec("./a.cs");
bar(); // outputs "bar"
#10
12/04/2012 (11:20 am)
Have you made many modifications to the engine itself?

If so, then I'd go looking at those changes for uninitialized variables, or for reading/writing to incorrectly allocated memory. The fact that the engine is crashing in an unrelated place from just having the function defined makes me think that something is doing stuff to parts of memory that it shouldn't.
#11
12/04/2012 (9:12 pm)
@Lucas its only in one file at a time but I have tried several files.

@Guy the mods I made were done months ago. Game has been running with a few crashes here and there. This is all recent. I never code unitialized data in a constructor.

Hitting F11 to enter world editor will crash in the same place as well.

I'll just manually edit the thing. I use a older version that the editor will work in and just move the files around.

Thanks for the response.