init.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. //-----------------------------------------------------------------------------
  23. // Variables used by server scripts & code. The ones marked with (c)
  24. // are accessed from code. Variables preceeded by Pref:: are server
  25. // preferences and stored automatically in the ServerPrefs.cs file
  26. // in between server sessions.
  27. //
  28. // (c) Server::ServerType {SinglePlayer, MultiPlayer}
  29. // (c) Server::GameType Unique game name
  30. // (c) Server::Dedicated Bool
  31. // ( ) Server::MissionFile Mission .mis file name
  32. // (c) Server::MissionName DisplayName from .mis file
  33. // (c) Server::MissionType Not used
  34. // (c) Server::PlayerCount Current player count
  35. // (c) Server::GuidList Player GUID (record list?)
  36. // (c) Server::Status Current server status
  37. //
  38. // (c) Pref::Server::Name Server Name
  39. // (c) Pref::Server::Password Password for client connections
  40. // ( ) Pref::Server::AdminPassword Password for client admins
  41. // (c) Pref::Server::Info Server description
  42. // (c) Pref::Server::MaxPlayers Max allowed players
  43. // (c) Pref::Server::RegionMask Registers this mask with master server
  44. // ( ) Pref::Server::BanTime Duration of a player ban
  45. // ( ) Pref::Server::KickBanTime Duration of a player kick & ban
  46. // ( ) Pref::Server::MaxChatLen Max chat message len
  47. // ( ) Pref::Server::FloodProtectionEnabled Bool
  48. //-----------------------------------------------------------------------------
  49. //-----------------------------------------------------------------------------
  50. function initServer()
  51. {
  52. echo("\n--------- Initializing " @ $appName @ ": Server Scripts ---------");
  53. // Server::Status is returned in the Game Info Query and represents the
  54. // current status of the server. This string sould be very short.
  55. $Server::Status = "Unknown";
  56. // Turn on testing/debug script functions
  57. $Server::TestCheats = false;
  58. // Specify where the mission files are.
  59. $Server::MissionFileSpec = "levels/*.mis";
  60. // The common module provides the basic server functionality
  61. initBaseServer();
  62. // Load up game server support scripts
  63. exec("./commands.cs");
  64. exec("./game.cs");
  65. }
  66. //-----------------------------------------------------------------------------
  67. function initDedicated()
  68. {
  69. enableWinConsole(true);
  70. echo("\n--------- Starting Dedicated Server ---------");
  71. // Make sure this variable reflects the correct state.
  72. $Server::Dedicated = true;
  73. // The server isn't started unless a mission has been specified.
  74. if ($missionArg !$= "") {
  75. createServer("MultiPlayer", $missionArg);
  76. }
  77. else
  78. echo("No mission specified (use -mission filename)");
  79. }