home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58b_TRIBES.iso / Tribes / console.cs next >
Encoding:
Text File  |  1998-12-16  |  6.1 KB  |  244 lines

  1. //-----------------------------------
  2. //
  3. // Tribes startup
  4. //
  5. //-----------------------------------
  6.  
  7. // test if this is a dedicated server
  8. $dedicated = false;
  9.  
  10. $numExecFiles = 0;
  11.  
  12. for(%i = 1; $cargv[%i] != ""; %i++)
  13. {
  14.    if($cargv[%i] == "-mod")
  15.    {
  16.       %mod = $cargv[%i + 1];
  17.       %i++;
  18.       $modList = %mod @ " " @ $modList;
  19.    }
  20.    else if($cargv[%i] == "-dedicated")
  21.    {
  22.       $dedicated = true;
  23.       %mission = $cargv[%i + 1];
  24.       if(%mission != "")
  25.       {
  26.          $pref::lastMission = %mission;
  27.          %i++;
  28.       }
  29.    }
  30.    else if($cargv[%i] == "+exec")
  31.    {
  32.       $execFile[$numExecFiles] = $cargv[%i+1];
  33.       %i++;
  34.       $numExecFiles++;
  35.    }
  36.    else if($cargv[%i] == "+connect")
  37.    {
  38.       $connectAddress = $cargv[%i+1];
  39.       %i++;
  40.    }
  41. }
  42.  
  43. $WinConsoleEnabled = $dedicated;
  44. $Console::logBufferEnabled = !$dedicated; // turn off window scroll back
  45. $Console::Prompt = "% ";
  46.  
  47. if($dedicated)
  48. {
  49.    newServer();
  50.    focusServer();
  51. }
  52. else
  53. {
  54.    newClient();
  55.    focusClient();
  56.    $Console::LastLineTimeout = 0;
  57. }
  58.  
  59. function EvalSearchPath()
  60. {
  61.    // search path always contains the config directory
  62.    %searchPath = "config";
  63.    if($modList == "")
  64.       $modList = "base";
  65.    else
  66.    {
  67.       for(%i = 0; (%word = getWord($modList, %i)) != -1; %i++)
  68.          if(%word == "base")
  69.             break;
  70.       if(%word == -1)
  71.          $modList = $modList @ " base";
  72.    }
  73.    for(%i = 0; (%word = getWord($modList, %i)) != -1; %i++)
  74.    {
  75.       %addPath = %word @ ";" @ %word @ "\\missions;" @ %word @ 
  76.          "\\fonts;" @ %word @ "\\skins;" @ %word @ "\\voices;" @ %word @ "\\scripts";
  77.       %searchPath = %searchPath @ ";" @ %addPath;
  78.    }
  79.    %searchPath = %searchPath @ ";recordings;temp";
  80.    echo(%searchPath);
  81.  
  82.    $ConsoleWorld::DefaultSearchPath = %searchPath;
  83.  
  84.    // clear out the volumes:
  85.    for(%i = 0; isObject(%vol = "VoiceVolume" @ %i); %i++)
  86.       deleteObject(%vol);
  87.    for(%i = 0; isObject(%vol = "SkinVolume" @ %i); %i++)
  88.       deleteObject(%vol);
  89.  
  90.    // load all the volumes:
  91.    %file = File::findFirst("voices\\*.vol");
  92.    for(%i = 0; %file != ""; %file = File::findNext("voices\\*.vol"))
  93.       if(newObject("VoiceVolume" @ %i, SimVolume, %file))
  94.          %i++;
  95.  
  96.    %file = File::findFirst("skins\\*.vol");
  97.    for(%i = 0; %file != ""; %file = File::findNext("skins\\*.vol"))
  98.       if(newObject("SkinVolume" @ %i, SimVolume, %file))
  99.          %i++;
  100. }
  101.  
  102. EvalSearchPath();
  103. newObject(FontsVolume, SimVolume, "fonts.vol");
  104. newObject(ScriptsVolume, SimVolume, "scripts.vol");
  105. newObject(GuiVolume, SimVolume, "gui.vol");
  106. newObject(EditVolume, SimVolume, "edit.vol");
  107. newObject(EditorVolume, SimVolume, "editor.vol");
  108. newObject(DarkstarVolume, SimVolume, "darkstar.vol");
  109. newObject(InterfaceVolume, SimVolume, "interface.vol");
  110. newObject(ShellVolume, SimVolume, "shell.vol");
  111. newObject(ShellCommonVolume, SimVolume, "shellcommon.vol");
  112. newObject(EntitiesVolume, SimVolume, "entities.vol");
  113.  
  114. $Console::GFXFont = "interface.pft";
  115.  
  116. ////
  117. // Default volumes and tags
  118. //
  119.  
  120. exec("darkstar.strings.cs");
  121. exec("editor.strings.cs");
  122. exec("commonEditor.strings.cs");
  123. exec("esf.strings.cs");
  124. exec("fear.strings.cs");
  125. exec("help.strings.cs");
  126. exec("sfx.strings.cs");
  127. exec("banlist.cs");
  128. exec("gui.cs");
  129. exec("sae.cs");
  130. exec("client.cs");
  131. exec("server.cs");
  132. exec("tsDefaultMatProps.cs");
  133. exec("game.cs");
  134. exec("GenericTriggers.cs");
  135. exec("chatmenu.cs");
  136. exec("menu.cs");
  137. exec("observer.cs");
  138. exec("PlayerSetup.cs");
  139. exec("players.cs");
  140.  
  141. newObject("", IRCClient);
  142. exec("IRCClient.cs");
  143. exec("IRCServers.cs");
  144.  
  145. exec("Options.cs");
  146. exec("commander.cs");
  147.  
  148. //
  149. // Default keys
  150. //
  151. bind(keyboard, make, control, o, to, "messageCanvasDevice(MainWindow, outline);");
  152. bind(keyboard, make, sysreq, to, "screenShot(MainWindow);");
  153. bind(keyboard, make, control, "-", to, "prevRes(MainWindow);");
  154. bind(keyboard, make, control, "+",  to, "nextRes(MainWindow);");
  155.  
  156.  
  157. // Load prefs and execute any autoexec commands...
  158. exec("clientDefaults.cs");
  159. exec("serverDefaults.cs");
  160. exec("clientPrefs.cs");
  161. exec("serverPrefs.cs");
  162. exec("config.cs");
  163. exec("autoexec.cs");
  164.  
  165. for(%i = 0; %i < $numExecFiles; %i++)
  166.    exec($execFile[%i]);
  167.  
  168. if($dedicated)
  169. {
  170.    createServer($pref::lastMission, True);
  171.     translateMasters();
  172. }
  173. else
  174. {
  175.    newObject(ConsoleScheduler, SimConsoleScheduler);
  176.  
  177.    if (GUI::issueInternetWarning() == "false") {
  178.       quit();
  179.    } else {
  180.       // Create the main window with a gui in it
  181.       newObject(MainWindow, SimGui::Canvas, "Tribes", 640, 480, True, "512 384", "1024 768");
  182.  
  183.        exec("sound.cs");
  184.       inputActivate(keyboard0);
  185.       inputActivate(mouse0);
  186.  
  187.       newObject(clientDelegate, FearCSDelegate, false, "IP", 0, "IPX", 0, "LOOPBACK", 0);
  188.  
  189.       // Action map for flying cameras
  190.       exec("move.cs");
  191.       move();
  192.  
  193.  
  194.       // Play the intro smacker file
  195.       setCursor(MainWindow, "Cur_Empty.bmp");
  196.       cursorOn(MainWindow);
  197.       GuiLoadContentCtrl(MainWindow, "gui\\empty.gui");
  198.  
  199.        //all video initialization is now done in Options.cs
  200.        OptionsVideo::validate();
  201.        OptionsVideo::apply();
  202.  
  203.        if ($pref::cdMusic == "")
  204.            $pref::cdMusic = True;
  205.        if ($pref::cdVolume == "")
  206.            $pref::cdVolume = 0.5;
  207.        if ($pref::userCDOverride == "")
  208.            $pref::userCDOverride = False;
  209.        if ($pref::cdMusic || $pref::userCDOverrride)
  210.        {
  211.            newRedBook (CD, MainWindow);
  212.            rbSetVolume (CD, 1 - $pref::cdVolume);
  213.        }
  214.  
  215.       if($connectAddress != "")
  216.       {
  217.          $Server::Address = $connectAddress;
  218.           IRCLogin::AutoConnect();
  219.          JoinGame();
  220.       }
  221.       else
  222.       {
  223.           //translate all master server addressess - this function will eventually call startTheGame()
  224.          if($pref::quickstart)
  225.           {
  226.              Quickstart();
  227.               translateMasters();
  228.           }
  229.           else
  230.          {
  231.              if (!$pref::skipIntro)
  232.                 GuiLoadContentCtrl(MainWindow, "gui\\intro.gui");
  233.              else
  234.                  startMainMenuScreen();
  235.           }
  236.  
  237.           //autologin to the irc client
  238.           IRCLogin::AutoConnect();
  239.       }
  240.    }
  241. }
  242.  
  243.  
  244.