diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2017-07-28 18:54:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-28 18:54:40 +0200 |
commit | eb4432bb6260eaadb41495149739244308e9e125 (patch) | |
tree | 8f1787586d23194ef5f4d7af8a4454f0ea9e179a /src/Server.h | |
parent | Handle incomplete packets in cProtocolRecognizer (diff) | |
download | cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.gz cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.bz2 cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.lz cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.xz cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.zst cuberite-eb4432bb6260eaadb41495149739244308e9e125.zip |
Diffstat (limited to 'src/Server.h')
-rw-r--r-- | src/Server.h | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/src/Server.h b/src/Server.h index 68741b144..88f91120c 100644 --- a/src/Server.h +++ b/src/Server.h @@ -67,9 +67,9 @@ public: const AString & GetShutdownMessage(void) const { return m_ShutdownMessage; } // Player counts: - int GetMaxPlayers(void) const { return m_MaxPlayers; } - int GetNumPlayers(void) const; - void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; } + size_t GetMaxPlayers(void) const { return m_MaxPlayers; } + size_t GetNumPlayers(void) const { return m_PlayerCount; } + void SetMaxPlayers(size_t a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; } /** Check if the player is queued to be transferred to a World. Returns true is Player is found in queue. */ @@ -106,17 +106,14 @@ public: const AString & GetServerID(void) const { return m_ServerID; } // tolua_export - /** Called by cClientHandle's destructor; stop m_SocketThreads from calling back into a_Client */ - void ClientDestroying(const cClientHandle * a_Client); - /** Don't tick a_Client anymore, it will be ticked from its cPlayer instead */ void ClientMovedToWorld(const cClientHandle * a_Client); /** Notifies the server that a player was created; the server uses this to adjust the number of players */ - void PlayerCreated(const cPlayer * a_Player); + void PlayerCreated(); /** Notifies the server that a player is being destroyed; the server uses this to adjust the number of players */ - void PlayerDestroying(const cPlayer * a_Player); + void PlayerDestroyed(); /** Returns base64 encoded favicon data (obtained from favicon.png) */ const AString & GetFaviconData(void) const { return m_FaviconData; } @@ -182,17 +179,8 @@ private: /** Clients that have just been moved into a world and are to be removed from m_Clients in the next Tick(). */ cClientHandles m_ClientsToRemove; - /** Protects m_PlayerCount against multithreaded access. */ - mutable cCriticalSection m_CSPlayerCount; - /** Number of players currently playing in the server. */ - int m_PlayerCount; - - /** Protects m_PlayerCountDiff against multithreaded access. */ - cCriticalSection m_CSPlayerCountDiff; - - /** Adjustment to m_PlayerCount to be applied in the Tick thread. */ - int m_PlayerCountDiff; + std::atomic_size_t m_PlayerCount; int m_ClientViewDistance; // The default view distance for clients; settable in Settings.ini @@ -211,7 +199,7 @@ private: AString m_Description; AString m_ShutdownMessage; AString m_FaviconData; - int m_MaxPlayers; + size_t m_MaxPlayers; bool m_bIsHardcore; /** True - allow same username to login more than once False - only once */ |