Odd crash with lighting kit
by Jeff Murray · in Torque Game Engine · 08/09/2006 (4:35 pm) · 5 replies
HelloooO!
I seem to be running into a problem restarting my game after game over. Essentially, it just crashes at the lighting stage (just after loading the mission).
I'm ending the game with endgame();
My endgame script looks like...
The standard end game script, of course ... the clientCmdGameEnd script looks like this:
THEN, my EndGameGui.gui has a button, which sets the canvas to my main menu ...
... which seems to work so far. Only problem is, when I click to start the game again it crashes right at the start of the lighting stage. Unfortunately, I don't have the exact point at which it crashes in debug mode as it's at the office and I'm working from home right now... I seem to remember it was just in the register lights functions.
What could be causing this crash? Am I missing some kind of cleanup script specifically for the lighting pack? I've tried this on both my 'dirty' modified version of the engine and a clean install of 1.4 ... so it's just got me confused now!
Thanks in advance for any clues/help/suggestions you can give me!!
:)
Jeff.
I seem to be running into a problem restarting my game after game over. Essentially, it just crashes at the lighting stage (just after loading the mission).
I'm ending the game with endgame();
My endgame script looks like...
function endGame()
{
if (!$Game::Running) {
error("endGame: No game running!");
return;
}
// Stop the AIManager
AIManager.delete();
// Stop any game timers
cancel($Game::Schedule);
// Inform the client the game is over
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
%cl = ClientGroup.getObject( %clientIndex );
commandToClient(%cl, 'GameEnd');
}
// Delete all the temporary mission objects
resetMission();
$Game::Running = false;
}The standard end game script, of course ... the clientCmdGameEnd script looks like this:
function clientCmdGameEnd(%seq)
{
// Stop local activity... the game will be destroyed on the server
alxStopAll();
// Copy the current scores from the player list into the
// end game gui (bit of a hack for now).
EndGameGuiList.clear();
for (%i = 0; %i < PlayerListGuiList.rowCount(); %i++) {
%text = PlayerListGuiList.getRowText(%i);
%id = PlayerListGuiList.getRowId(%i);
EndGameGuiList.addRow(%id,%text);
}
EndGameGuiList.sortNumerical(1,false);
// Display the end-game screen
Canvas.setContent(EndGameGui);
}THEN, my EndGameGui.gui has a button, which sets the canvas to my main menu ...
new GuiButtonCtrl() {
Profile = "GuiButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "306 313";
Extent = "140 30";
MinExtent = "8 2";
Visible = "1";
Command = "Canvas.setContent(mainMenuGui);";
text = "PLAY AGAIN";
groupNum = "-1";
buttonType = "PushButton";
};... which seems to work so far. Only problem is, when I click to start the game again it crashes right at the start of the lighting stage. Unfortunately, I don't have the exact point at which it crashes in debug mode as it's at the office and I'm working from home right now... I seem to remember it was just in the register lights functions.
What could be causing this crash? Am I missing some kind of cleanup script specifically for the lighting pack? I've tried this on both my 'dirty' modified version of the engine and a clean install of 1.4 ... so it's just got me confused now!
Thanks in advance for any clues/help/suggestions you can give me!!
:)
Jeff.
#2
Thanks for the reply. Appreciate it :)
I'm hoping that it isn't just my two systems that are doing this ... so, please feel free to play along at home ;)
I just re-installed TLK 1.4.0 right from the original ZIP file and ran the example (TorqueLightingKit.exe). Selecting the first mission (lighting pack demo), I looked into the swamp (!) then brought up the console to type endgame();
This brought up the end game gui. At this point, the only difference in my game is that I have a button to call Canvas.setContent(mainMenuGui); - so I re-open the console and type it in here instead.
The main menu comes up, then I click start mission and select the first mission (lighting pack demo) again. It crashes soon after (almost immediately this time).
Does this happen to you? If so, is there a different way of ending the game that cleans things up better?
Sorry if I'm missing something silly ... I've only been with Torque for about 3 weeks now. Still learning ...
Thanks again :) I'll try this again tommorow at work and see what it's doing in debug mode.
08/09/2006 (7:25 pm)
Hi John,Thanks for the reply. Appreciate it :)
I'm hoping that it isn't just my two systems that are doing this ... so, please feel free to play along at home ;)
I just re-installed TLK 1.4.0 right from the original ZIP file and ran the example (TorqueLightingKit.exe). Selecting the first mission (lighting pack demo), I looked into the swamp (!) then brought up the console to type endgame();
This brought up the end game gui. At this point, the only difference in my game is that I have a button to call Canvas.setContent(mainMenuGui); - so I re-open the console and type it in here instead.
The main menu comes up, then I click start mission and select the first mission (lighting pack demo) again. It crashes soon after (almost immediately this time).
Does this happen to you? If so, is there a different way of ending the game that cleans things up better?
Sorry if I'm missing something silly ... I've only been with Torque for about 3 weeks now. Still learning ...
Thanks again :) I'll try this again tommorow at work and see what it's doing in debug mode.
#3
You're mixing two different types of client side processing; endGame is designed to be used during cycleMission processing, it maintains the client connection and then loads a new mission using loadMission. Whereas the mission selection window off of the main menu creates a new server and loads a mission into it.
So when you select a second mission the local client is likely starting up a second server.
You can either create a new or modified mission selection screen that only loads the mission on the existing server (though that won't work on a client/server setup), or fully disconnect the client from the server by calling disconnect() on the client.
08/09/2006 (8:29 pm)
Ah I didn't realize you were calling endGame directly.You're mixing two different types of client side processing; endGame is designed to be used during cycleMission processing, it maintains the client connection and then loads a new mission using loadMission. Whereas the mission selection window off of the main menu creates a new server and loads a mission into it.
So when you select a second mission the local client is likely starting up a second server.
You can either create a new or modified mission selection screen that only loads the mission on the existing server (though that won't work on a client/server setup), or fully disconnect the client from the server by calling disconnect() on the client.
#4
Sorry bout that and thanks for your help... tonight my bedtime reading will be client/server commands until my eyes hurt ;)
08/09/2006 (9:03 pm)
Doh. So the fact that it was crashing on TLK was a red herring eh? Now I just feel a bit daft for rushing headlong into it without checking everything else out!Sorry bout that and thanks for your help... tonight my bedtime reading will be client/server commands until my eyes hurt ;)
#5
08/10/2006 (9:09 am)
Moving this thread over to the 'getting started', as I believe this has more to do with my being a newb than anything else ;)
Torque Owner John Kabus (BobTheCBuilder)
Also make sure your resetMission function is working correctly, here is the stock version:
function resetMission() { echo("*** MISSION RESET"); // Remove any temporary mission objects MissionCleanup.delete(); $instantGroup = ServerGroup; new SimGroup( MissionCleanup ); $instantGroup = MissionCleanup; // onMissionReset(); }Also try running the game as separate client and server to see which one crashes (if the crash is in scene lighting then it should be the client, but that could just be a side effect from another problem).
Definitely post the crash point when running in debug mode.