Game Development Community

Zombie objects after switching missions

by Shayne Gelo · in Torque Game Engine · 01/31/2006 (10:02 am) · 1 replies

I'm using a separate mission as an intro for my game, however, when I switch missions to go into the main part of the game, I find that some objects from the intro are still hanging around, but in a strange sort of zombie state. If I call isObject() on the Items themselves, it returns false, but isObject on their datablock returns true. They are rendered in the scene (and WorldEditor) but aren't selectable in the WorldEditor.

Here is the code I'm using:

In my own file globe.cs:
datablock ItemData(GlobeData)
{
	shapeFile = "~/data/shapes/globe/sphere.dts";
};

MissionCleanup.add(GlobeData);

function insertGlobe()
{
	%globe = new Item(Globe) {
		position = "0 600 200";
		rotation = "0 0 1 185.7";
		scale = "100 100 100";
		dataBlock = "GlobeData";
		collideable = "0";
		static = "0";
		rotate = "0";
		rotate2 = "0";
	};

	MissionCleanup.add(%globe);
}

In server/scripts/game.cs:
function onMissionLoaded()
{
   // Perform mission specific setup
   if (%curMission $= "disaster/data/missions/space.mis")
   {
	   insertGlobe();
   }

   // Called by loadMission() once the mission is finished loading.
   // Nothing special for now, just start up the game play.
   startGame();
}

Then, to switch the mission, I call this function from client/init.cs
function loadDefaultMission(%mission)
{
   Canvas.setCursor("DefaultCursor");
   createServer( "SinglePlayer", %mission $= "" ? $pref::mission : %mission);

   %conn = new GameConnection(ServerConnection);
   RootGroup.add(ServerConnection);
   %conn.setConnectArgs($pref::Player::Name);
   %conn.setJoinPassword($Client::Password);
   %conn.connectLocal();
}

createServer calls destroyServer, which calls endMission in common/server/missionLoad.cs:
function endMission()
{
	if (!isObject( MissionGroup )) {
		echo("endMission: no mission to end");
		return;
	}

   echo("*** ENDING MISSION");
   
   // Inform the game code we're done.
   onMissionEnded();

   // Inform the clients
   for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
      // clear ghosts and paths from all clients
      %cl = ClientGroup.getObject( %clientIndex );
      %cl.endMission();
      %cl.resetGhosting();
      %cl.clearPaths();
   }
   
   // Delete everything
   MissionGroup.delete();
   MissionCleanup.delete();

   $ServerGroup.delete();
   $ServerGroup = new SimGroup(ServerGroup);
}

This seems to delete everything appropriately before starting up the new mission, but I still get these zombies. Can anybody tell me what I'm doing wrong?

Also, I had previously put the Item(Globe) creation directly in the mission file, assuming it would be deleted when endMission() called MissionGroup.delete(). Moving it out and adding the objects to MissionCleanupGroup didn't seem to help. Is it better to leave the Item creation in the mission file?

Edit:
If I call endMission() manually before calling loadDefaultMission(), it seems to work, but endMission() is called in the course of loadDefaultMission(), so it really shouldn't be necessary, should it?

#1
02/09/2006 (5:16 pm)
Hey Shayne, I'm gonna bump this with a image, since I'm having the same thing happening but with projected decals. This is a blood splatter from the level loaded before this one. If I manually change levels it doesn't happen, but if I let the levels cycle, then is does. It probably has to do with the difference of how the the levels are loaded (and the previous mission is deleted, like you mention) but I don't know what that might be.

www.reallyreallygoodthings.com/screens/screenshot_040-00002.png
- Alan
Really Really Good Things Studio