Game Development Community

Merging the RTS lobby into starter.fps

by Dracola · in RTS Starter Kit · 05/03/2006 (6:52 pm) · 4 replies

If anybody wanted to merge the RTS lobby into Starter.fps it is pretty simple but there are some scattered parts which are a bit hard to find, which is why I'm posting them here.

To start it off you should copy Starter.RTS/client/ui/lobbygui.gui and the lobby and mainmenu files into Starter.fps/client/ui and the client/scripts/playerlist.cs from starter.rts over the one in starter.fps.

Open the newly copied lobbygui and go to the bottom functions there should be some links to various pictures that use "starter.rts" change that to "starter.fps"

add
exec("./ui/lobby/LobbyGui.gui");
next to all the others in starter.fps/client/init.cs

go into common/server/server.cs and modify the following three functions

function createServer(%serverType, %mission)
{
   if (%mission $= "") {
      error("createServer: mission name unspecified");
      return;
   }

   destroyServer();

   //
   $missionSequence = 0;
   $Server::PlayerCount = 0;
   $Server::ServerType = %serverType;

   // Setup for multi-player, the network must have been
   // initialized before now.
   if (%serverType $= "MultiPlayer") {
      echo("Starting multiplayer mode");

      // Make sure the network port is set to the correct pref.
      portInit($Pref::Server::Port);
      allowConnections(true);

      if ($pref::Net::DisplayOnMaster !$= "Never" )
         schedule(0,0,startHeartbeat);
   }
   $MissionToLoad = %mission;
   $LoadingMission = false;
}

function serverCmdPlayerReady(%client, %ready)
{
   if ($LoadingMission)
      return;

   %client.ready = %ready;
   messageAll('MsgClientReady', "", %client, %ready);

   %allReady = true;
   for (%k = 0; %k < ClientGroup.getCount(); %k++)
   {
      if (!ClientGroup.getObject(%k).ready)
      {
         %allReady = false;
         break;
      }
   }
   
   if (%allReady)
   {
      // Load the mission
      $ServerGroup = new SimGroup(ServerGroup);
      onServerCreated();
      schedule(2000, 0, "loadMission", $MissionToLoad, true);
      schedule(1500, 0, "MessageAll", 'MsgMissionLoad', "");
      allowConnections(false);  //don't allow any more connections
      $LoadingMission = true;

      for (%k = 0; %k < ClientGroup.getCount(); %k++)
         ClientGroup.getObject(%k).ready = false;
   }
}

//-----------------------------------------------------------------------------

function destroyServer()
{
   $PlayerReady = false;
   $Server::ServerType = "";
   allowConnections(false);
   stopHeartbeat();
   $missionRunning = false;
   
   // End any running mission
   endMission();
   onServerDestroyed();

   // Delete all the server objects
   if (isObject(MissionGroup))
      MissionGroup.delete();
   if (isObject(MissionCleanup))
      MissionCleanup.delete();
   if (isObject($ServerGroup))
      $ServerGroup.delete();

   // Delete all the connections:
   while (ClientGroup.getCount())
   {
      %client = ClientGroup.getObject(0);
      %client.delete();
   }

   $Server::GuidList = "";

   // Delete all the data blocks...
   deleteDataBlocks();
   
   // Save any server settings
   echo( "Exporting server prefs..." );
   export( "$Pref::Server::*", "~/prefs.cs", false );

   // Dump anything we're not using
   purgeResources();
}

find the function
function GameConnection::onConnectionAccepted(%this)
in starter.fps/client/scripts/serverConnection.cs and add these two lines into it
Canvas.setContent(LobbyGui);
   LobbyChatCtrl.attach(HudMessageVector);

I may have forgot something if you put this in and it doesn't work let me know.

#1
05/07/2006 (4:06 am)
PlayerList.cs is found here
C:\.........\example\starter.RTS\client\scripts
not client\server there is no such path under normal install
#2
05/07/2006 (11:56 am)
Oops okay I fixed that up above.
#4
01/29/2010 (7:51 pm)
I know this is an old post but I just ran across it and tried to install it into TGEA head and got Main Menu, and Start Mission working but when I click on the start mission in the RTS kit , it takes me to the lobby but if I try it in the TGEA setup , it tries to load the mission but hangs.

Any idea on how to get it into the lobby?

Thanks