Omega_K2

export_server.cpp

Jul 7th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.08 KB | None | 0 0
  1. /**
  2. * =============================================================================
  3. * Eventscripts
  4. * Copyright (C) 2012 Eventscripts Development Team.  All rights reserved.
  5. * =============================================================================
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU General Public License, version 3.0, as published by the
  9. * Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  14. * details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program.  If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * As a special exception, the Eventscripts Development Team gives you permission
  20. * to link the code of this program (as well as its derivative works) to
  21. * "Half-Life 2," the "Source Engine," and any Game MODs that run on software
  22. * by the Valve Corporation.  You must obey the GNU General Public License in
  23. * all respects for all other code used.  Additionally, the Eventscripts
  24. * Development Team grants this exception to all derivative works.  
  25. */
  26.  
  27. //---------------------------------------------------------------------------------
  28. // Includes
  29. //---------------------------------------------------------------------------------
  30. #include "export_main.h"
  31. #include "core/es_python.h"
  32. #include "utility/wrap_macros.h"
  33. #include "iserver.h"
  34. #include "iclient.h" // Compile fails because IClient is not defined but used as return :P
  35.  
  36. //---------------------------------------------------------------------------------
  37. // Namespaces to use.
  38. //---------------------------------------------------------------------------------
  39. using namespace boost::python;
  40.  
  41. //---------------------------------------------------------------------------------
  42. // External variables to use.
  43. //---------------------------------------------------------------------------------
  44.  
  45. extern IServer* iserver;
  46.  
  47. //---------------------------------------------------------------------------------
  48. // Returns the server instance.
  49. //---------------------------------------------------------------------------------
  50.  
  51. IServer* GetServer( void )
  52. {
  53.     return iserver;
  54. }
  55.  
  56. //---------------------------------------------------------------------------------
  57. // IServer overloads
  58. //---------------------------------------------------------------------------------
  59.  
  60. DECLARE_CLASS_METHOD_OVERLOAD(IServer, BroadcastMessage, 1, 3)
  61.  
  62. //---------------------------------------------------------------------------------
  63. // Wraps game server related structures.
  64. //---------------------------------------------------------------------------------
  65. DECLARE_ES_MODULE(server)
  66. {  
  67.     // ----------------------------------------------------------
  68.     // The server interface.
  69.     // ----------------------------------------------------------
  70.     BOOST_ABSTRACT_CLASS( IServer )
  71.        
  72.         CLASS_METHOD(IServer,
  73.             GetNumClients,
  74.             "returns current number of clients"
  75.         )
  76.  
  77.         CLASS_METHOD(IServer,
  78.             GetNumProxies,
  79.             "returns number of attached HLTV proxies"
  80.         )
  81.  
  82.         CLASS_METHOD(IServer,
  83.             GetNumFakeClients,
  84.             "returns number of fake clients/bots"
  85.         )
  86.  
  87.         CLASS_METHOD(IServer,
  88.             GetMaxClients,
  89.             "returns current client limit"
  90.         )
  91.  
  92.         CLASS_METHOD(IServer,
  93.             GetClient,
  94.             reference_existing_object_policy(),
  95.             "returns interface to client",
  96.             args("index")
  97.         )
  98.  
  99.         CLASS_METHOD(IServer,
  100.             GetClientCount,
  101.             "returns number of clients slots (used & unused)"
  102.         )
  103.  
  104.         CLASS_METHOD(IServer,
  105.             GetUDPPort,
  106.             "returns current used UDP port"
  107.         )
  108.  
  109.         CLASS_METHOD(IServer,
  110.             GetTime,
  111.             "returns game world time"
  112.         )
  113.  
  114.         CLASS_METHOD(IServer,
  115.             GetTick,
  116.             "returns game world tick"
  117.         )
  118.  
  119.         CLASS_METHOD(IServer,
  120.             GetTickInterval,
  121.             "returns tick interval in seconds"
  122.         )
  123.  
  124.         CLASS_METHOD(IServer,
  125.             GetTimescale,
  126.             "returns the game time scale (multiplied in conjunction with host_timescale)"
  127.         )
  128.  
  129.         CLASS_METHOD(IServer,
  130.             GetName,
  131.             "returns public server name"
  132.         )
  133.  
  134.         CLASS_METHOD(IServer,
  135.             GetMapName,
  136.             "current map name (BSP)"
  137.         )
  138.  
  139.         CLASS_METHOD(IServer,
  140.             GetSpawnCount,
  141.             "TODO"
  142.         )
  143.  
  144.         CLASS_METHOD(IServer,
  145.             GetNumClasses,
  146.             "TODO"
  147.         )
  148.  
  149.         CLASS_METHOD(IServer,
  150.             GetClassBits,
  151.             "TODO"
  152.         )
  153.  
  154.         CLASS_METHOD(IServer,
  155.             GetNetStats,
  156.             "total net in/out in bytes/sec",
  157.             args("avgIn","avgOut")
  158.         )
  159.  
  160.         CLASS_METHOD(IServer,
  161.             GetNumPlayers,
  162.             "TODO"
  163.         )
  164.  
  165.         CLASS_METHOD(IServer,
  166.             GetPlayerInfo,
  167.             "TODO",
  168.             args("ClientIndex","Player_Info_T")
  169.         )
  170.  
  171.         CLASS_METHOD(IServer,
  172.             IsActive,
  173.             "TODO"
  174.         )
  175.  
  176.         CLASS_METHOD(IServer,
  177.             IsLoading,
  178.             "TODO"
  179.         )
  180.  
  181.         CLASS_METHOD(IServer,
  182.             IsDedicated,
  183.             "TODO"
  184.         )
  185.  
  186.         CLASS_METHOD(IServer,
  187.             IsPaused,
  188.             "TODO"
  189.         )
  190.  
  191.         CLASS_METHOD(IServer,
  192.             IsMultiplayer,
  193.             "TODO"
  194.         )
  195.  
  196.         CLASS_METHOD(IServer,
  197.             IsPausable,
  198.             "TODO"
  199.         )
  200.  
  201.         CLASS_METHOD(IServer,
  202.             IsHLTV,
  203.             "TODO"
  204.         )
  205.  
  206.         CLASS_METHOD(IServer,
  207.             IsReplay,
  208.             "TODO"
  209.         )
  210.  
  211.         CLASS_METHOD(IServer,
  212.             GetPassword,
  213.             "returns the password or NULL if none set"
  214.         )
  215.  
  216.         CLASS_METHOD(IServer,
  217.             SetPaused,
  218.             "TODO",
  219.             args("bPaused")
  220.         )
  221.  
  222.         CLASS_METHOD(IServer,
  223.             SetTimescale,
  224.             "TODO",
  225.             args("flTimescale")
  226.         )
  227.  
  228.         CLASS_METHOD(IServer,
  229.             SetPassword,
  230.             "set password (NULL to disable)",
  231.             args("szPassword")
  232.         )
  233.  
  234.         /*CLASS_METHOD_OVERLOAD(IServer,
  235.             BroadcastMessage,
  236.             "TODO",
  237.             args("msg", "onlyactive", "reliaable")
  238.         )
  239.  
  240.         CLASS_METHOD(IServer,
  241.             BroadcastMessage,
  242.             "TODO",
  243.             args("msg", "filter")
  244.         )*/
  245.  
  246.         CLASS_METHOD(IServer,
  247.             DisconnectClient,
  248.             "TODO",
  249.             args("client", "reason")
  250.         )
  251.  
  252.     BOOST_END_CLASS()
  253.  
  254.     // ----------------------------------------------------------
  255.     // Expose the global interface to the event manager.
  256.     // ----------------------------------------------------------
  257.     BOOST_FUNCTION(GetServer, reference_existing_object_policy());
  258. }
Add Comment
Please, Sign In to add comment