Add spectator list during the game (when lobby messages are disabled).
This commit is contained in:
+9
-6
@@ -220,8 +220,9 @@ void Game::startHand()
|
|||||||
boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||||
PlayerListIterator i = getSeatsList()->begin();
|
PlayerList tmpList = getSeatsList();
|
||||||
PlayerListIterator end = getSeatsList()->end();
|
PlayerListIterator i = tmpList->begin();
|
||||||
|
PlayerListIterator end = tmpList->end();
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
if ((*i)->getMyUniqueID() == id) {
|
if ((*i)->getMyUniqueID() == id) {
|
||||||
tmpPlayer = *i;
|
tmpPlayer = *i;
|
||||||
@@ -235,8 +236,9 @@ boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
|||||||
boost::shared_ptr<PlayerInterface> Game::getPlayerByNumber(int number)
|
boost::shared_ptr<PlayerInterface> Game::getPlayerByNumber(int number)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||||
PlayerListIterator i = getSeatsList()->begin();
|
PlayerList tmpList = getSeatsList();
|
||||||
PlayerListIterator end = getSeatsList()->end();
|
PlayerListIterator i = tmpList->begin();
|
||||||
|
PlayerListIterator end = tmpList->end();
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
if ((*i)->getMyID() == number) {
|
if ((*i)->getMyID() == number) {
|
||||||
tmpPlayer = *i;
|
tmpPlayer = *i;
|
||||||
@@ -258,8 +260,9 @@ boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
|
|||||||
boost::shared_ptr<PlayerInterface> Game::getPlayerByName(const std::string &name)
|
boost::shared_ptr<PlayerInterface> Game::getPlayerByName(const std::string &name)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||||
PlayerListIterator i = getSeatsList()->begin();
|
PlayerList tmpList = getSeatsList();
|
||||||
PlayerListIterator end = getSeatsList()->end();
|
PlayerListIterator i = tmpList->begin();
|
||||||
|
PlayerListIterator end = tmpList->end();
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
if ((*i)->getMyName() == name) {
|
if ((*i)->getMyName() == name) {
|
||||||
tmpPlayer = *i;
|
tmpPlayer = *i;
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ struct GameInfo {
|
|||||||
unsigned adminPlayerId;
|
unsigned adminPlayerId;
|
||||||
PlayerIdList players;
|
PlayerIdList players;
|
||||||
PlayerIdList spectators;
|
PlayerIdList spectators;
|
||||||
|
PlayerIdList spectatorsDuringGame;
|
||||||
bool isPasswordProtected;
|
bool isPasswordProtected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -218,6 +218,9 @@ protected:
|
|||||||
void ModifyGameInfoRemovePlayer(unsigned gameId, unsigned playerId);
|
void ModifyGameInfoRemovePlayer(unsigned gameId, unsigned playerId);
|
||||||
void ModifyGameInfoAddSpectator(unsigned gameId, unsigned playerId);
|
void ModifyGameInfoAddSpectator(unsigned gameId, unsigned playerId);
|
||||||
void ModifyGameInfoRemoveSpectator(unsigned gameId, unsigned playerId);
|
void ModifyGameInfoRemoveSpectator(unsigned gameId, unsigned playerId);
|
||||||
|
void ModifyGameInfoClearSpectatorsDuringGame();
|
||||||
|
void ModifyGameInfoAddSpectatorDuringGame(unsigned playerId);
|
||||||
|
void ModifyGameInfoRemoveSpectatorDuringGame(unsigned playerId, int removeReason);
|
||||||
void ClearGameInfoMap();
|
void ClearGameInfoMap();
|
||||||
|
|
||||||
void StartPetition(unsigned petitionId, unsigned proposingPlayerId, unsigned kickPlayerId, int timeoutSec, int numVotesToKick);
|
void StartPetition(unsigned petitionId, unsigned proposingPlayerId, unsigned kickPlayerId, int timeoutSec, int numVotesToKick);
|
||||||
|
|||||||
@@ -631,7 +631,12 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
|||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameSpectatorJoinedMessage) {
|
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameSpectatorJoinedMessage) {
|
||||||
// Another spectator joined the network game.
|
// Another spectator joined the network game.
|
||||||
const GameSpectatorJoinedMessage &netSpectatorJoined = tmpPacket->GetMsg()->gamespectatorjoinedmessage();
|
const GameSpectatorJoinedMessage &netSpectatorJoined = tmpPacket->GetMsg()->gamespectatorjoinedmessage();
|
||||||
client->GetCallback().SignalNetClientSpectatorJoined(netSpectatorJoined.playerid(), client->GetPlayerName(netSpectatorJoined.playerid()));
|
// Request player info if needed.
|
||||||
|
PlayerInfo info;
|
||||||
|
if (!client->GetCachedPlayerInfo(netSpectatorJoined.playerid(), info)) {
|
||||||
|
client->RequestPlayerInfo(netSpectatorJoined.playerid());
|
||||||
|
}
|
||||||
|
client->ModifyGameInfoAddSpectatorDuringGame(netSpectatorJoined.playerid());
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameSpectatorLeftMessage) {
|
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameSpectatorLeftMessage) {
|
||||||
// A spectator left the network game.
|
// A spectator left the network game.
|
||||||
const GameSpectatorLeftMessage &netSpectatorLeft = tmpPacket->GetMsg()->gamespectatorleftmessage();
|
const GameSpectatorLeftMessage &netSpectatorLeft = tmpPacket->GetMsg()->gamespectatorleftmessage();
|
||||||
@@ -645,7 +650,7 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
|||||||
removeReason = NTF_NET_REMOVED_ON_REQUEST;
|
removeReason = NTF_NET_REMOVED_ON_REQUEST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
client->GetCallback().SignalNetClientSpectatorLeft(netSpectatorLeft.playerid(), client->GetPlayerName(netSpectatorLeft.playerid()), removeReason);
|
client->ModifyGameInfoRemoveSpectatorDuringGame(netSpectatorLeft.playerid(), removeReason);
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_TimeoutWarningMessage) {
|
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_TimeoutWarningMessage) {
|
||||||
const TimeoutWarningMessage &tmpTimeout = tmpPacket->GetMsg()->timeoutwarningmessage();
|
const TimeoutWarningMessage &tmpTimeout = tmpPacket->GetMsg()->timeoutwarningmessage();
|
||||||
client->GetCallback().SignalNetClientShowTimeoutDialog((NetTimeoutReason)tmpTimeout.timeoutreason(), tmpTimeout.remainingseconds());
|
client->GetCallback().SignalNetClientShowTimeoutDialog((NetTimeoutReason)tmpTimeout.timeoutreason(), tmpTimeout.remainingseconds());
|
||||||
@@ -1252,6 +1257,7 @@ ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
|||||||
GameData tmpData;
|
GameData tmpData;
|
||||||
NetPacket::GetGameData(netJoinAck.gameinfo(), tmpData);
|
NetPacket::GetGameData(netJoinAck.gameinfo(), tmpData);
|
||||||
client->SetGameData(tmpData);
|
client->SetGameData(tmpData);
|
||||||
|
client->ModifyGameInfoClearSpectatorsDuringGame();
|
||||||
|
|
||||||
// Player number is 0 on init. Will be set when the game starts.
|
// Player number is 0 on init. Will be set when the game starts.
|
||||||
boost::shared_ptr<PlayerData> playerData(
|
boost::shared_ptr<PlayerData> playerData(
|
||||||
|
|||||||
@@ -1454,6 +1454,48 @@ ClientThread::ModifyGameInfoRemoveSpectator(unsigned gameId, unsigned playerId)
|
|||||||
GetCallback().SignalNetClientGameListSpectatorLeft(gameId, playerId);
|
GetCallback().SignalNetClientGameListSpectatorLeft(gameId, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientThread::ModifyGameInfoClearSpectatorsDuringGame()
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
|
||||||
|
GameInfoMap::iterator pos = m_gameInfoMap.find(GetGameId());
|
||||||
|
if (pos != m_gameInfoMap.end()) {
|
||||||
|
pos->second.spectatorsDuringGame.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientThread::ModifyGameInfoAddSpectatorDuringGame(unsigned playerId)
|
||||||
|
{
|
||||||
|
bool spectatorAdded = false;
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
|
||||||
|
GameInfoMap::iterator pos = m_gameInfoMap.find(GetGameId());
|
||||||
|
if (pos != m_gameInfoMap.end()) {
|
||||||
|
pos->second.spectatorsDuringGame.push_back(playerId);
|
||||||
|
spectatorAdded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (spectatorAdded)
|
||||||
|
GetCallback().SignalNetClientSpectatorJoined(playerId, GetPlayerName(playerId));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientThread::ModifyGameInfoRemoveSpectatorDuringGame(unsigned playerId, int removeReason)
|
||||||
|
{
|
||||||
|
bool spectatorRemoved = false;
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
|
||||||
|
GameInfoMap::iterator pos = m_gameInfoMap.find(GetGameId());
|
||||||
|
if (pos != m_gameInfoMap.end()) {
|
||||||
|
pos->second.spectatorsDuringGame.remove(playerId);
|
||||||
|
spectatorRemoved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (spectatorRemoved)
|
||||||
|
GetCallback().SignalNetClientSpectatorLeft(playerId, GetPlayerName(playerId), removeReason);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientThread::ClearGameInfoMap()
|
ClientThread::ClearGameInfoMap()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user