Game Development Community

LoadMission

by gamer · in Torque Game Engine · 06/01/2006 (6:46 pm) · 3 replies

When loading a mission there's a few lines of code as follows:
%conn = new GameConnection(ServerConnection);

   
   RootGroup.add(ServerConnection);
  
   %conn.setConnectArgs($pref::Player::Name, $pref::Player::Armor);
   %conn.setJoinPassword($Client::Password);
   %conn.connectLocal();

I looked for the function setConnectArgs, setJoinPassword, connectLocal everywhere in the scripts under common and mygame, can't find them. why? are they defined in the c++ engine only?


the reason I am asking is that I found two ways of loading a mission, the first one is calling loadMission:
function loadMission( %missionName, %isFirstMission ) 
{
  error("MissionName is "@%missionName);
  
   endMission();
   echo("*** LOADING MISSION: " @ %missionName);
   echo("*** Stage 1 load");
   echo("serverGroup is "@ServerGroup);
   // Reset all of these
   clearCenterPrintAll();
   clearBottomPrintAll();

   // increment the mission sequence (used for ghost sequencing)
   $missionSequence++;
   $missionRunning = false;
   $Server::MissionFile = %missionName;

   // Extract mission info from the mission file,
   // including the display name and stuff to send
   // to the client.
   buildLoadInfo( %missionName );

   // Download mission info to the clients
   %count = ClientGroup.getCount();
   for( %cl = 0; %cl < %count; %cl++ ) {
      %client = ClientGroup.getObject( %cl );
      if (!%client.isAIControlled())
         sendLoadInfoToClient(%client);
   }

   // if this isn't the first mission, allow some time for the server
   // to transmit information to the clients:
   if( %isFirstMission || $Server::ServerType $= "SinglePlayer" )
      loadMissionStage2();
   else
      schedule( $MissionLoadPause, ServerGroup, loadMissionStage2 );
}

the second one is
function SM_StartMission()
{
 
   %id = SM_missionList.getSelectedId();
   %mission = getField(SM_missionList.getRowTextById(%id), 1);
 
   if ($pref::HostMultiPlayer)
      %serverType = "MultiPlayer";
   else
      %serverType = "SinglePlayer";
   createServer(%serverType, %mission);
   %conn = new GameConnection(ServerConnection);
 
   
   RootGroup.add(ServerConnection);
  
   echo("playerName is " @ $pref::Player::Name@",player armor is "@ $pref::Player::Armor);
   %conn.setConnectArgs($pref::Player::Name, $pref::Player::Armor);
   %conn.setJoinPassword($Client::Password);
   %conn.connectLocal();
}

I am guessing that the first one is from the server and the second way is from the client. So if I want to be able to click on the button to load a mission file, should I use the second one instead of the first one? I am guess that connectLocal from client will eventually make the server call loadMission(), is this right?

thanks

#1
06/01/2006 (6:51 pm)
I have been using this resource a lot since the book came out:

http://tdn.garagegames.com/wiki/Torque_Console_Objects

I run a search over at tdn.garagegames.com and usually look for pages that start with "Torque Console Objects...".


[b]setConnectArgs( name [ , arg1 , ... , arg15 ] ) [/b]
 
[b]Purpose[/b]
Use the setConnectArgs method to set the connection arguments for this 
client-side GameConnection. These values will be passed to the server upon 
establishing a connection.

[b]Syntax[/b]
name - Generally, the first argument is the name of the player.
arg1 , ... , arg15 - 15 additional arguments may be passed.

[b]Returns[/b]
No return value.

[b]See Also[/b]
setJoinPassword



[b]setJoinPassword( password ) [/b]
 
[b]Purpose[/b]
Use the setJoinPassword method to set the password required to 
connect to this server-side GameConnection.

[b]Syntax[/b]
password - A string representing the case insensitive password to 
use for this server-side GameConnection.

[b]Returns[/b]
No return value.

[b]Notes[/b]
Pass a NULL string to clear the password.

[b]See Also[/b]
setConnectArgs

[b]connectLocal() [/b]
 
[b]Purpose[/b]
Use the connectLocal method to connect the current client-side connection 
to a local NetConnection, that is to create an internal connection from this 
client to the internal server. This is accomplished through the use of a back 
door mechanism and has an extremely high bandwidth.

[b]Returns[/b]
No return value.

[b]See Also[/b]
connect, getAddress
#2
06/01/2006 (7:05 pm)
Thank you that is defnitely a good resource!
#3
06/02/2006 (8:53 am)
The reason that you didn't find those functions defined in script is because they are actually ConsoleFunctions, which, as you surmised, are implemented in c++.

In general, you always need to search in both the script code and the c++ code when looking for a specific implementation of a referenced function or method.