Game Development Community

cls = boom

by baylor wetzel · in Torque Game Builder · 07/29/2009 (3:28 pm) · 1 replies

i use the console alot and therefore the cls command a lot. i've just built the engine from source (no changes made). Debug mode. i copy it to my game directory and run it. Game runs fine but the cls command always crashes the game, no matter where i am in the game (cls does not cause this problem using the pre-built binaries running through the level editor)

Error tVector.h line 435
AssertFatal(index < mElementCount, "Vector<T>::operator[] - out of bounds array access!");

Any idea why this might be or how i fix it? (other than, obviously, removing the assertion)

#1
07/29/2009 (5:45 pm)
I ran into this myself. Apparently it's due to the fact that in the console log code, it calls operator[](0) without checking to see if the console log is empty, and the Vector class complains because there is no index 0. I fixed it by doing the following.

In console/console.cc, change this:
void getLockLog(ConsoleLogEntry *&log, U32 &size)
{
   consoleLogLocked = true;
   log = &consoleLog[0];
   size = consoleLog.size();
}

...to this:

void getLockLog(ConsoleLogEntry *&log, U32 &size)
{
   consoleLogLocked = true;
   size = consoleLog.size();
   if (size) {
	   log = &consoleLog[0];
   } else {
	   log = NULL;
   }
}