Use client game id when kicking players during game.
This commit is contained in:
@@ -65,10 +65,11 @@ public:
|
||||
void SendJoinGame(unsigned gameId, const std::string &password);
|
||||
void SendCreateGame(const GameData &gameData, const std::string &name, const std::string &password);
|
||||
|
||||
GameInfo GetGameInfo(unsigned playerId) const;
|
||||
GameInfo GetGameInfo(unsigned gameId) const;
|
||||
PlayerInfo GetPlayerInfo(unsigned playerId) const;
|
||||
bool GetPlayerIdFromName(const std::string &playerName, unsigned &playerId) const;
|
||||
ServerStats GetStatData() const;
|
||||
unsigned GetGameId() const;
|
||||
|
||||
ClientCallback &GetCallback();
|
||||
GuiInterface &GetGui();
|
||||
@@ -106,6 +107,7 @@ protected:
|
||||
SenderThread &GetSender();
|
||||
ReceiverHelper &GetReceiver();
|
||||
|
||||
void SetGameId(unsigned id);
|
||||
const GameData &GetGameData() const;
|
||||
void SetGameData(const GameData &gameData);
|
||||
const StartData &GetStartData() const;
|
||||
@@ -170,9 +172,12 @@ private:
|
||||
mutable boost::mutex m_playerInfoMapMutex;
|
||||
PlayerIdList m_playerInfoRequestList;
|
||||
|
||||
unsigned m_curGameId;
|
||||
mutable boost::mutex m_curGameIdMutex;
|
||||
|
||||
AvatarDataMap m_tempAvatarMap;
|
||||
|
||||
unsigned m_curGameId;
|
||||
unsigned m_curGameNum;
|
||||
unsigned m_guiPlayerId;
|
||||
bool m_sessionEstablished;
|
||||
|
||||
|
||||
@@ -628,6 +628,7 @@ ClientStateWaitJoin::InternalProcess(ClientThread &client, boost::shared_ptr<Net
|
||||
// Successfully joined a game.
|
||||
NetPacketJoinGameAck::Data joinGameAckData;
|
||||
packet->ToNetPacketJoinGameAck()->GetData(joinGameAckData);
|
||||
client.SetGameId(joinGameAckData.gameId);
|
||||
client.SetGameData(joinGameAckData.gameData);
|
||||
|
||||
// Player number is 0 on init. Will be set when the game starts.
|
||||
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
|
||||
ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager)
|
||||
: m_curState(NULL), m_gui(gui), m_avatarManager(avatarManager),
|
||||
m_curGameId(1), m_guiPlayerId(0), m_sessionEstablished(false)
|
||||
m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false)
|
||||
{
|
||||
m_context.reset(new ClientContext);
|
||||
m_senderCallback.reset(new ClientSenderCallback(*this));
|
||||
@@ -331,7 +331,7 @@ ClientThread::Main()
|
||||
MapPlayerDataList();
|
||||
if (GetPlayerDataList().size() != (unsigned)GetStartData().numberOfPlayers)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
|
||||
m_game.reset(new Game(&m_gui, factory, GetPlayerDataList(), GetGameData(), GetStartData(), m_curGameId++));
|
||||
m_game.reset(new Game(&m_gui, factory, GetPlayerDataList(), GetGameData(), GetStartData(), m_curGameNum++));
|
||||
// Initialize GUI speed.
|
||||
GetGui().initGui(GetGameData().guiSpeed);
|
||||
// Signal start of game to GUI.
|
||||
@@ -566,6 +566,20 @@ ClientThread::GetReceiver()
|
||||
return *m_receiver;
|
||||
}
|
||||
|
||||
unsigned
|
||||
ClientThread::GetGameId() const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_curGameIdMutex);
|
||||
return m_curGameId;
|
||||
}
|
||||
|
||||
void
|
||||
ClientThread::SetGameId(unsigned id)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_curGameIdMutex);
|
||||
m_curGameId = id;
|
||||
}
|
||||
|
||||
const GameData &
|
||||
ClientThread::GetGameData() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user