Major design change in network protocol: Player information is now requested by clients whenever it is needed. The server only sends player ids. The client has a cache with player information.

This commit is contained in:
lotodore
2007-08-26 22:41:37 +00:00
parent ba17f1d08e
commit 56b24e09eb
19 changed files with 755 additions and 104 deletions
+7 -1
View File
@@ -27,7 +27,7 @@
#include <gamedata.h>
#include <string>
#include <memory>
#include <boost/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
class ClientContext;
class ClientState;
@@ -68,6 +68,7 @@ public:
protected:
typedef std::map<unsigned, std::string> GameMap;
typedef std::list<boost::shared_ptr<NetPacket> > NetPacketList;
typedef std::map<unsigned, PlayerInfo> PlayerInfoMap;
// Main function of the thread.
virtual void Main();
@@ -75,6 +76,10 @@ protected:
void AddPacket(boost::shared_ptr<NetPacket> packet);
void SendPacketLoop();
PlayerInfo GetCachedPlayerInfo(unsigned id) const;
void RequestPlayerInfo(unsigned id, const PlayerInfo &tempInfo);
void SetPlayerInfo(unsigned id, const PlayerInfo &info);
const ClientContext &GetContext() const;
ClientContext &GetContext();
@@ -132,6 +137,7 @@ private:
mutable boost::mutex m_gameMapMutex;
boost::shared_ptr<Game> m_game;
PlayerInfoMap m_playerInfoMap;
unsigned m_curGameId;
unsigned m_guiPlayerId;