Each network session now has a weak ptr to its game, to prevent looking up the game id all the time.

This commit is contained in:
lotodore
2011-03-10 21:53:25 +00:00
parent 9b9a921867
commit 95305e7ba5
5 changed files with 33 additions and 33 deletions
+4 -3
View File
@@ -42,6 +42,7 @@ class ReceiveBuffer;
class SendBuffer;
class NetPacket;
class PlayerData;
class ServerGame;
class SessionData : public boost::enable_shared_from_this<SessionData>
{
@@ -53,8 +54,8 @@ public:
SessionId GetId() const;
unsigned GetGameId() const;
void SetGameId(unsigned gameId);
boost::shared_ptr<ServerGame> GetGame() const;
void SetGame(boost::shared_ptr<ServerGame> game);
State GetState() const;
void SetState(State state);
@@ -111,7 +112,7 @@ protected:
private:
boost::shared_ptr<boost::asio::ip::tcp::socket> m_socket;
const SessionId m_id;
unsigned m_gameId;
boost::weak_ptr<ServerGame> m_game;
State m_state;
std::string m_clientAddr;
boost::shared_ptr<ReceiveBuffer> m_receiveBuffer;