Game Development Community

Weird iTGB bug (freezes my coputer)

by Jereis Zaatri · in iTorque 2D · 05/13/2010 (10:36 am) · 6 replies

Hello,

So I noticed a really weird bug where the program freezes mid way through the script. The bug happens when I load a level. Anyone have a clue what may cause this?

...code
if(...)
{
...more code
...echo("a");
<----- freezes here
}
...echo("b");
...more code

Currently running ver 1.3 on windows as 1.4 seems to not work.

#1
05/13/2010 (11:05 am)
@Jereis -

1. Could you post the full code? No way to tell what is going on.

2. What about 1.4 does not work for you?
#2
05/13/2010 (3:09 pm)
In terms of 1.4, it complains about the executable when I run it.

As for that bug....

in file levelManager.cs:

function t2dSceneWindow::loadLevel(%sceneWindow, %levelFile)
{
warn("asa");
// Clean up any previously loaded stuff.
%sceneWindow.endLevel();
warn("asda");
// Load the level.
$useNewSceneGraph = true;
%scenegraph = %sceneWindow.addToLevel(%levelFile);
warn("asdda");
if (!isObject(%scenegraph))
return 0;
warn("asddda");
%sceneWindow.setSceneGraph(%scenegraph);
warn("asdddssa");
// Set the window properties from the scene graph if they are available.
%cameraPosition = %sceneWindow.getCurrentCameraPosition();
%cameraSize = t2dVectorSub(getWords(%sceneWindow.getCurrentCameraArea(), 2, 3),
getWords(%sceneWindow.getCurrentCameraArea(), 0, 1));
warn("asaddddddddss");
if (%scenegraph.cameraPosition !$= "")
%cameraPosition = %scenegraph.cameraPosition;
if (%scenegraph.cameraSize !$= "")
%cameraSize = %scenegraph.cameraSize;
warn("asadddsfdgret");
%sceneWindow.setCurrentCameraPosition(%cameraPosition, %cameraSize);
warn("aswrwer23a");
// Only perform "onLevelLoaded" callbacks when we're NOT editing a level
//
// This is so that objects that may have script associated with them that
// the level builder cannot undo will not be executed while using the tool.
//

if (!$LevelEditorActive)
{
// Notify the scenegraph that it was loaded.
if( %scenegraph.isMethod( "onLevelLoaded" ) )
%scenegraph.onLevelLoaded();

// And finally, notify all the objects that they were loaded.
%sceneObjectList = %scenegraph.getSceneObjectList();
%sceneObjectCount = getWordCount(%sceneObjectList);
for (%i = 0; %i < %sceneObjectCount; %i++)
{
warn("addddsssswesa");
echo( %sceneObjectCount);
echo( %i);
%sceneObject = getWord(%sceneObjectList, %i);
//if( %sceneObject.isMethod( "onLevelLoaded" ) )
echo("in aba");
%sceneObject.onLevelLoaded(%scenegraph);
echo("out aba");

}
echo("out asdfsdfba");
}
//<--------------------------------------never get's here
warn("out");
$lastLoadedScene = %scenegraph;
return %scenegraph;
}
#3
05/13/2010 (3:56 pm)
Wow...that's a lot of echos...

Let's start with the simplest step. Make sure your t2dSceneWindow::loadLevel(...) function looks like mine:

function t2dSceneWindow::loadLevel(%sceneWindow, %levelFile)
{
   // Clean up any previously loaded stuff.
   %sceneWindow.endLevel();
   
   // Load the level.
   $useNewSceneGraph = true;

   alxStopAll();//kill any leftovers
   
   
   //-Mat loadlevel stuff can go here for now
   hideCursor();

   //load level resources        -Mat
   %resPath = expandFileName("game");    

   //now get level specific resources 
   //Get just filename, then strip out extension         -Mat
   %levelFileName = fileName( %levelFile );
   %levelFileName = strreplace( %levelFileName, ".t2d", "" );
   
   $CurrentLevel = %levelFileName;
   
   //load Shared resources first
   %commonFile = %resPath @ "/PlatformerArt/SharedResources.cs";
   %commonObject = ResourceObject::load( %commonFile );
   
   //load level-specific resources
   %resFile = %resPath @ "/PlatformerArt/" @ %levelFileName @"Resources.cs";   
   
   echo( "--------Loading Resource file" SPC %resFile );//-Mat iPhone debug output	   
   
   %resObject = ResourceObject::load( %resFile );

   if( strstr( %levelFile, "game/" ) != 0 ) {
      %newlevelfile = %resPath @ stripChars( %levelFile, "~" );
   } else {
      %newlevelfile = stripChars( %levelFile, "~" );//just in case there is a stray char from a previous manipulation
   }
   
   echo( "--------Adding to Level" SPC %newlevelfile);//-Mat iPhone debug output	   
   
   //Get a datablock file name for this level - Sven
   %dbFileName = %newlevelfile;
   %dbFileName = strreplace(%dbFileName, %levelFileName @ ".t2d", "datablocks/" @ %levelFileName @ "_datablocks.cs");   
   
   //load level         -Mat
   %scenegraph = %sceneWindow.addToLevel(%newlevelfile, %dbFileName);
   
   //Load any level specific GUI
   %LevelGUIfunction = "load" @ %levelFileName @ "GUI";
   if( isFunction( %LevelGUIfunction ) ) {
      eval( %LevelGUIfunction @ "();" );//call the function with no parameters
   }  
   
   
   if (!isObject(%scenegraph))
      return 0;
   
   %sceneWindow.setSceneGraph(%scenegraph);
   
   // Set the window properties from the scene graph if they are available.
   %cameraPosition = %sceneWindow.getCurrentCameraPosition();
   %cameraSize = t2dVectorSub(getWords(%sceneWindow.getCurrentCameraArea(), 2, 3),
                              getWords(%sceneWindow.getCurrentCameraArea(), 0, 1));
                              
   if (%scenegraph.cameraPosition !$= "")
      %cameraPosition = %scenegraph.cameraPosition;
   if (%scenegraph.cameraSize !$= "")
      %cameraSize = %scenegraph.cameraSize;
      
   %sceneWindow.setCurrentCameraPosition(%cameraPosition, %cameraSize);
   
   // Only perform "onLevelLoaded" callbacks when we're NOT editing a level
   //
   //  This is so that objects that may have script associated with them that
   //  the level builder cannot undo will not be executed while using the tool.
   //
          
   if (!$LevelEditorActive)
   {
      // Notify the scenegraph that it was loaded.
      if( %scenegraph.isMethod( "onLevelLoaded" ) )
         %scenegraph.onLevelLoaded( %levelFile );
      
      // And finally, notify all the objects that they were loaded.
      %sceneObjectList = %scenegraph.getSceneObjectList();
      %sceneObjectCount = getWordCount(%sceneObjectList);
      for (%i = 0; %i < %sceneObjectCount; %i++)
      {
         %sceneObject = getWord(%sceneObjectList, %i);
         //if( %sceneObject.isMethod( "onLevelLoaded" ) )
            %sceneObject.onLevelLoaded(%scenegraph);
      }
   }
   
   $lastLoadedScene = %scenegraph;
   return %scenegraph;
}

That's from the stock 1.4 build, which works. At first glance your function looks like mine, but the echos make it difficult to parse.

Next, could you please show me your entire console log from the game? Just open console.log, then copy and paste its contents to pastebin.com. Once you have that, post the link so I can look through it. I have a feeling you might have a parse error or a bad datablock which is preventing the load.

As for the 1.4 issue, I think I know what issue you are talking about. This is fixed in the release that is going out tomorrow. Just to let you know.
#4
05/15/2010 (12:02 am)
Here's the log:
http://pastebin.com/QyTN7PMW

Here's the code:
http://pastebin.com/efaKrFjJ
#5
05/17/2010 (9:09 am)
@Jereis - OK, I'm having trouble parsing your console log due to its size (my browser keeps freezing). Can you just e-mail me the log? Use the address I replied to in your support mail.

This will help me parse the code as well.
#6
05/22/2010 (1:40 pm)
Thanks for the help!

The latest version of the beta fixed that problem.