Game Development Community

Recompilation Issue - Vital Code commented out

by CdnGater · in Torque Game Engine Advanced · 02/14/2009 (7:14 am) · 1 replies


Once I got around the issues around sfxXAudioDevice as talked about in another thread I managed to get the recompiled code to run.. Sort of. Using the 'Template' as a test bed, the app would close after displaying the main menu. So I did some digging.

I found StandardManLoop::doMainLoop in engine\source\app\mainloop.cpp
//   while(keepRunning)

So I uncommented the code, recompiled and it worked as expected. This totaly explains why the mainloop was running once and exiting.


#1
02/14/2009 (11:44 am)
That's not a bug. Chances are, your TorqueMain function is incorrect. In >= 1.8.0, it should look like this:

// Entry point for your game.
//
// This is build by default using the "StandardMainLoop" toolkit. Feel free
// to bring code over directly as you need to modify or extend things. You 
// will need to merge against future changes to the SML code if you do this.
S32 TorqueMain(S32 argc, const char **argv)
{
   // Some handy debugging code:
   //   if (argc == 1) {
   //      static const char* argvFake[] = { "dtest.exe", "-jload", "test.jrn" };
   //      argc = 3;
   //      argv = argvFake;
   //   }

   //   Memory::enableLogging("testMem.log");
   //   Memory::setBreakAlloc(104717);

   // Initialize the subsystems.
   StandardMainLoop::init();

   // Handle any command line args.
   if(!StandardMainLoop::handleCommandLine(argc, argv))
   {
      Platform::AlertOK("Error", "Failed to initialize game, shutting down.");

      return 1;
   }

   // Main loop
   while(StandardMainLoop::doMainLoop());

   // Clean everything up.
   StandardMainLoop::shutdown();

   // Do we need to restart?
   if( StandardMainLoop::requiresRestart() )
      Platform::restartInstance();

   // Return.
   return 0;
}

Note the
while(StandardMainLoop::doMainLoop());
The while was added in 1.8.0. If you haven't updated your version of TorqueMain to match this, then you are going to see issues with the main loop only running once. Uncommenting the lines you did in StandardMainLoop::doMainLoop will completely break the Mac build, so I'd suggest fixing up TorqueMain.