BVB Source Codes

CRYENGINE Show GameServerNub.h Source code

Return Download CRYENGINE: download GameServerNub.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: Implements the IGameNub interface for the server side.
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 11:8:2004   11:30 : Created by Marcio Martins
  12.  
  13. *************************************************************************/
  14. #ifndef __GAMESERVERNUB_H__
  15. #define __GAMESERVERNUB_H__
  16.  
  17. #if _MSC_VER > 1000
  18.         #pragma once
  19. #endif
  20.  
  21. #include <map>
  22.  
  23. typedef std::map<uint16, class CGameServerChannel*> TServerChannelMap;
  24. class CGameContext;
  25.  
  26. class CGameServerNub :
  27.         public IGameNub
  28. {
  29.         typedef std::map<INetChannel*, uint16> TNetServerChannelMap;
  30.         typedef struct SHoldChannel
  31.         {
  32.                 SHoldChannel() : channelId(0), time(0.0f) {};
  33.                 SHoldChannel(uint16 chanId, const CTimeValue& tv) : channelId(chanId), time(tv) {};
  34.  
  35.                 uint16     channelId;
  36.                 CTimeValue time;
  37.         } SHoldChannel;
  38.  
  39.         typedef std::map<int, SHoldChannel> THoldChannelMap;
  40.  
  41.         struct SBannedPlayer
  42.         {
  43.                 SBannedPlayer() : profileId(0), time(0.0f) {}
  44.                 SBannedPlayer(int32 profId, uint32 addr, const CTimeValue& tv) : profileId(profId), ip(addr), time(tv) {}
  45.  
  46.                 int32      profileId; //profile id
  47.                 uint32     ip;        //in LAN we use ip
  48.                 CTimeValue time;
  49.         };
  50.         typedef std::vector<SBannedPlayer> TBannedVector;
  51. public:
  52.         CGameServerNub();
  53.         virtual ~CGameServerNub();
  54.  
  55.         // IGameNub
  56.         virtual void                 Release();
  57.         virtual SCreateChannelResult CreateChannel(INetChannel* pChannel, const char* pRequest);
  58.         virtual void                 FailedActiveConnect(EDisconnectionCause cause, const char* description);
  59.         // ~IGameNub
  60.  
  61.         void                SetGameContext(CGameContext* pGameContext) { m_pGameContext = pGameContext; };
  62.         TServerChannelMap*  GetServerChannelMap()                      { return &m_channels; };
  63.  
  64.         void                Update();
  65.  
  66.         void                GetMemoryUsage(ICrySizer* s) const;
  67.  
  68.         void                SetMaxPlayers(int maxPlayers);
  69.         int                 GetMaxPlayers() const  { return m_maxPlayers; }
  70.         int                 GetPlayerCount() const { return int(m_channels.size()); }
  71.  
  72.         CGameServerChannel* GetChannel(uint16 channelId);
  73.         CGameServerChannel* GetChannel(INetChannel* pNetChannel);
  74.         INetChannel*        GetLocalChannel();
  75.         uint16              GetChannelId(INetChannel* pNetChannel) const;
  76.         void                RemoveChannel(uint16 channelId);
  77.  
  78.         bool                IsPreordered(uint16 channelId);
  79.         bool                PutChannelOnHold(CGameServerChannel* pServerChannel);
  80.         void                RemoveOnHoldChannel(CGameServerChannel* pServerChannel, bool renewed);
  81.         CGameServerChannel* GetOnHoldChannelFor(INetChannel* pNetChannel);
  82.         void                ResetOnHoldChannels();//called when onhold channels loose any sense - game reset, new level etc.
  83.  
  84.         void                BanPlayer(uint16 channelId, const char* reason);
  85.         bool                CheckBanned(INetChannel* pNetChannel);
  86.         void                BannedStatus();
  87.         void                UnbanPlayer(int profileId);
  88.  
  89.         bool                ControlsEntity(EntityId id) const;
  90.  
  91. private:
  92.         TServerChannelMap    m_channels;
  93.         TNetServerChannelMap m_netchannels;
  94.         THoldChannelMap      m_onhold;
  95.         TBannedVector        m_banned;
  96.         CGameContext*        m_pGameContext;
  97.         uint16               m_genId;
  98.         int                  m_maxPlayers;
  99.  
  100.         static ICVar*        sv_timeout_disconnect;
  101.         bool                 m_allowRemoveChannel;
  102. };
  103.  
  104. #endif // __GAMESERVERNUB_H__
  105.  
downloadGameServerNub.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top