Game Development Community

MissionInfo - what is buildLoadInfo() good for ?

by Orion Elenzil · in Torque Game Engine · 08/24/2007 (6:04 pm) · 7 replies

Does anyone know why buildLoadInfo() is necessary ?
as far as i can tell, the missionInfo object is created just fine by the regular old mission loading process.
buildLoadInfo() results in the missionInfo object being instanciated twice.

also, parsing a mission file line-by-line in script takes a little bit of time when the mission is big. which some of ours are. (1MB+)

i suspect something similar is happening with the Sky object, but haven't confirmed that yet.

// buildLoadInfo
//
// Extract the map description from the .mis file
//------------------------------------------------------------------------------
function buildLoadInfo( %mission ) {
	clearLoadInfo();

	%infoObject = "";
	%file = new FileObject();

	if ( %file.openForRead( %mission ) ) {
		%inInfoBlock = false;
		
		while ( !%file.isEOF() ) {
			%line = %file.readLine();
			%line = trim( %line );
			
			if( %line $= "new ScriptObject(MissionInfo) {" )
				%inInfoBlock = true;
			else if( %inInfoBlock && %line $= "};" ) {
				%inInfoBlock = false;
				%infoObject = %infoObject @ %line; 
				break;
			}
			
			if( %inInfoBlock )
			   %infoObject = %infoObject @ %line @ " ";
		}
		
		%file.close();
	}

   // Will create the object "MissionInfo"
	eval( %infoObject );
	%file.delete();
}

#1
08/24/2007 (6:06 pm)
.. not to mention the obvious fragility of the code there.
#2
08/24/2007 (6:29 pm)
Heh..just goes to show, no matter how much time you spend in the code base, you still don't see everything.

Apologies, but I have no idea what the script code is for, or even if/when it's used.

From a summary perusal, it appears to handle unusual editing factors associated with the MissionInfo line--basically, clearing off unexpected whitespace, unusual formatting, and possibly making the displayed MissionInfo information consistent across different OS's (linux putting in /r, while Windows putting in /n/r for example as end of line terminators).

Other than that, I really can't tell for sure.
#3
08/25/2007 (5:19 am)
This code is used to extract a MissionInfo script object from the mission file during the loading process, nothing more. It has nothing to do with OS compatibility or anything. If you look at the script.. its pulling syntax from the mission file to make a script object called 'MissionInfo' which has certain properties. It then uses eval to create the object.

The MissionInfo object is used to send to the connecting clients information to display about the mission. This could be used to, for instance, display a funny quote at the load screen, or the rules of the particular map. etc.

However, like you said.. this code seems unneeded because the server should already have the MissionInfo object, since it must exec the mission first, before client's can load the missions themselves. However I would take a close look through the whole client connection / mission loading / mission cycling routine to make absolutely certain that the function is in fact not needed. What you are looking for really is.. does the server load the mission, and thus already have the appropriate MissionInfo object defined before the clients need the information sent to it.. via sendLoadInfo.


The problem with the Mission load info is that there is a potential for a lot of stuff to be sent about a mission. In fact, it would probably be easier to just contain 'information about a mission' in a separate file that the client's themselves can parse, thus eliminating the need to send the information across the network to begin with.

Remember though. When I say 'information'.. I don't mean what objects are in a mission or whatever. I'm talking strictly about the MissionInfo object itself. Its their to provide a 'container' to store information.. any kind of information you want.. usually strings for quotes and stuff.
#4
08/25/2007 (10:14 am)
Thanks for the replies guys. perhaps this is trying to account for the case where a client connects to the server before the mission file has been exec'd ?

this came up because i added some sanity checks in simObject::assignName() to check for name collisions,
and was surprised to see the MissionInfo object show up in there. I'll pursue it a bit more.

another surprise was the Sky object, which for some reason gets the same name applied twice to the same object - which is fine, but surprising.

okay, thanks again.
#5
08/25/2007 (6:00 pm)
I've inspected this code before and I was actually just getting ready to expand it a little.

This piece of code extracts the MissionInfo object that contains information like Level Name and Level Description without actually loading the whole mission. This is useful (and used in the starter.fps example) to build a list of all available missions with their proper names and descriptions without having to fully load each mission. I.E. When starting a new game the menu loads the names and descriptions into a list do display to the player to select from.

I'm going to add on to this functionality by including a loadingScreen property that will be used as the background of the loading screen. This way my level designer can specify a new loading background per mission.

You could also use the missionInfo block to store a snap shot of your level that would be displayed on your menu when selecting the level.
#6
08/25/2007 (6:05 pm)
Ah! great, yes, that makes sense. thank you, Brian.

we've got our own server/mission list mechanism going on,
so i think i'll get rid of this guy. thanks.
#7
08/26/2007 (7:52 am)
Orion,

One thing to be aware of that you may already have found by now ... part of the mission load sequence is conditional on receiving the load info. It should be pretty simple to change, but simply removing the server side of the load info stuff will result in an inability to load a mission ;)

T.