Game Development Community

TGEA 1.0.3 and Constructor 1.0.4 crashes off and on - why?

by Andy Hawkins · in Torque Game Engine Advanced · 04/16/2008 (11:55 pm) · 5 replies

I load up TGEA 1.0.3 with DIF exported from Constructor 1.0.4 and they work one time, then I load TGEA 1.0.3 again and it crashes

-With no DIF's in the scene it nevers crashes

-When I do a debug from Visual Studio it never crashes.

-When I fly past DIF's the screen judders.

-When enemies fly past them, the screen judders.


Looks like I might have to drop back to TGE again while all these bugs are sorted out.

EDIT: Took out crazed rants that had nothing to do with the issue

#1
04/17/2008 (12:30 am)
Ran a debug session - after a while I got an assertion...

in engine\math\mathrandom.h

MRandomGenerator::randI: inverted range

... my quest continues...
#2
04/17/2008 (1:03 am)
Here's the call stack when it crashes...
>	TGEA_DEBUG.exe!MRandomGenerator::randI(int i=0, int n=-1)  Line 46	C++
 	TGEA_DEBUG.exe!MRandomLCG::randI(int i=0, int n=-1)  Line 89	C++
 	TGEA_DEBUG.exe!cgetRandom(SimObject * __formal=0x0fb409dc, int argc=2, const char * * argv=0x00edcd00)  Line 535 + 0x1c bytes	C++
 	TGEA_DEBUG.exe!CodeBlock::exec(unsigned int ip=2482, const char * functionName=0x03076650, Namespace * thisNamespace=0x017ffa78, unsigned int argc=1, const char * * argv=0x00edcd00, bool noCalls=false, const char * packageName=0x00000000, int setFrame=-1)  Line 1068 + 0x22 bytes	C++
 	TGEA_DEBUG.exe!CodeBlock::exec(unsigned int ip=171, const char * functionName=0x07d50268, Namespace * thisNamespace=0x017ffa78, unsigned int argc=1, const char * * argv=0x07d50260, bool noCalls=false, const char * packageName=0x00000000, int setFrame=-1)  Line 1021	C++
 	TGEA_DEBUG.exe!Namespace::Entry::execute(int argc=2, const char * * argv=0x07d50260, ExprEvalState * state=0x00ee34f4)  Line 915 + 0x31 bytes	C++
 	TGEA_DEBUG.exe!Con::execute(SimObject * object=0x0fb409dc, int argc=2, const char * * argv=0x07d50260)  Line 985 + 0x15 bytes	C++
 	TGEA_DEBUG.exe!SimConsoleEvent::process(SimObject * object=0x0fb409dc)  Line 1948 + 0x17 bytes	C++
 	TGEA_DEBUG.exe!Sim::advanceToTime(unsigned int targetTime=241039)  Line 226 + 0x13 bytes	C++
 	TGEA_DEBUG.exe!Sim::advanceTime(unsigned int delta=132)  Line 235 + 0xe bytes	C++
 	TGEA_DEBUG.exe!DemoGame::processTimeEvent(TimeEvent * event=0x0012fc9c)  Line 730 + 0x9 bytes	C++
 	TGEA_DEBUG.exe!GameInterface::processEvent(Event * event=0x0012fc9c)  Line 74 + 0x13 bytes	C++
 	TGEA_DEBUG.exe!GameInterface::postEvent(Event & event={...})  Line 156 + 0x13 bytes	C++
 	TGEA_DEBUG.exe!TimeManager::process()  Line 1049 + 0x19 bytes	C++
 	TGEA_DEBUG.exe!DemoGame::main(int argc=1, const char * * argv=0x01434fb8)  Line 542	C++
 	TGEA_DEBUG.exe!run(int argc=1, const char * * argv=0x01434fb8)  Line 922 + 0x1c bytes	C++
 	TGEA_DEBUG.exe!main(int argc=1, const char * * argv=0x01434fb8)  Line 1000 + 0xd bytes	C++
 	TGEA_DEBUG.exe!__tmainCRTStartup()  Line 582 + 0x19 bytes	C
 	TGEA_DEBUG.exe!mainCRTStartup()  Line 399	C
 	kernel32.dll!7c816fd7() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	TGEA_DEBUG.exe!AudioBuffer::find(const char * filename=0x00000000)  Line 111 + 0x9 bytes	C++
#3
04/17/2008 (1:18 am)
Seems to boil down to this function...

ConsoleFunction(getRandom, F32, 1, 3, "(int a=1, int b=0)"
                "Get a random number between a and b.")


I'm assuming my TorqueScript is calling this with invalid numbers.

Anyway any idea how I can track this in further?
#4
04/17/2008 (2:36 am)
Should getRandom even assert on these values? Shouldn't it sanitise the values?
#5
04/17/2008 (3:20 am)
I did this to sanitise it for now... on to the next bug

(in engine\math\mathrandom.h)
inline S32 MRandomGenerator::randI(S32 i, S32 n)
{
   if (i>n)
   {
	   Con::printf("MRandomGenerator error '%d','%d'.  Check your inputs - aborting function", i,n);
	   return 0;
   }
   AssertFatal(i<=n, "MRandomGenerator::randi: inverted range.");
   return (S32)(i + (randI() % (n - i + 1)) );
}