Let the server send cards on request of the corresponding user.
This commit is contained in:
@@ -141,13 +141,13 @@ ClientBoard::setWinners(const std::list<unsigned> &w)
|
||||
std::list<unsigned>
|
||||
ClientBoard::getPlayerNeedToShowCards() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return playerNeedToShowCards;
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return playerNeedToShowCards;
|
||||
}
|
||||
|
||||
void
|
||||
ClientBoard::setPlayerNeedToShowCards(const std::list<unsigned> &p)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
playerNeedToShowCards = p;
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
playerNeedToShowCards = p;
|
||||
}
|
||||
|
||||
@@ -517,7 +517,8 @@ boost::shared_ptr<SessionData> ClientPlayer::getNetSessionData()
|
||||
|
||||
bool ClientPlayer::checkIfINeedToShowCards()
|
||||
{
|
||||
std::list<unsigned> playerNeedToShowCardsList = currentBoard->getPlayerNeedToShowCards();
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
std::list<unsigned> playerNeedToShowCardsList = currentBoard->getPlayerNeedToShowCards();
|
||||
for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); it++)
|
||||
{
|
||||
if(*it == myUniqueID) return true;
|
||||
|
||||
@@ -90,7 +90,6 @@ void ServerGuiWrapper::riverAnimation2() {}
|
||||
|
||||
void ServerGuiWrapper::postRiverAnimation1() {}
|
||||
void ServerGuiWrapper::postRiverRunAnimation1() {}
|
||||
void ServerGuiWrapper::postRiverShowCards(unsigned /*playerId*/) {}
|
||||
void ServerGuiWrapper::flipHolecardsAllIn() {}
|
||||
|
||||
void ServerGuiWrapper::nextRoundCleanGui() {}
|
||||
@@ -123,6 +122,7 @@ void ServerGuiWrapper::SignalNetClientServerListClear() { if (myClientcb) myClie
|
||||
void ServerGuiWrapper::SignalNetClientServerListShow() { if (myClientcb) myClientcb->SignalNetClientServerListShow(); }
|
||||
|
||||
void ServerGuiWrapper::SignalNetClientLoginShow() { if (myClientcb) myClientcb->SignalNetClientLoginShow(); }
|
||||
void ServerGuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientPostRiverShowCards(playerId); }
|
||||
|
||||
void ServerGuiWrapper::SignalNetClientConnect(int actionID) { if (myClientcb) myClientcb->SignalNetClientConnect(actionID); }
|
||||
void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); }
|
||||
|
||||
@@ -78,7 +78,6 @@ public:
|
||||
|
||||
void postRiverAnimation1();
|
||||
void postRiverRunAnimation1();
|
||||
void postRiverShowCards(unsigned playerId);
|
||||
|
||||
void flipHolecardsAllIn();
|
||||
|
||||
@@ -135,6 +134,7 @@ public:
|
||||
void SignalNetClientServerListShow();
|
||||
|
||||
void SignalNetClientLoginShow();
|
||||
void SignalNetClientPostRiverShowCards(unsigned playerId);
|
||||
|
||||
void SignalNetServerSuccess(int actionID);
|
||||
void SignalNetServerError(int errorID, int osErrorID);
|
||||
|
||||
@@ -84,7 +84,6 @@ public:
|
||||
|
||||
virtual void postRiverAnimation1()=0;
|
||||
virtual void postRiverRunAnimation1()=0;
|
||||
virtual void postRiverShowCards(unsigned playerId)=0;
|
||||
virtual void flipHolecardsAllIn()=0;
|
||||
|
||||
virtual void nextRoundCleanGui()=0;
|
||||
|
||||
@@ -97,7 +97,6 @@ void GuiWrapper::riverAnimation2() { myW->signalRiverAnimation2(); }
|
||||
|
||||
void GuiWrapper::postRiverAnimation1() { myW->signalPostRiverAnimation1(); }
|
||||
void GuiWrapper::postRiverRunAnimation1() { myW->signalPostRiverRunAnimation1(); }
|
||||
void GuiWrapper::postRiverShowCards(unsigned playerId) { myW->signalPostRiverShowCards(playerId); }
|
||||
|
||||
void GuiWrapper::flipHolecardsAllIn() { myW->signalFlipHolecardsAllIn(); }
|
||||
|
||||
@@ -130,6 +129,7 @@ void GuiWrapper::SignalNetClientConnect(int actionID) { myStartWindow->signalNet
|
||||
void GuiWrapper::SignalNetClientServerListAdd(unsigned serverId) { myStartWindow->signalNetClientServerListAdd(serverId); }
|
||||
void GuiWrapper::SignalNetClientServerListShow() { myStartWindow->signalNetClientServerListShow(); }
|
||||
void GuiWrapper::SignalNetClientLoginShow() { myStartWindow->signalNetClientLoginShow(); }
|
||||
void GuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId) { myW->signalPostRiverShowCards(playerId); }
|
||||
void GuiWrapper::SignalNetClientServerListClear() { myStartWindow->signalNetClientServerListClear(); }
|
||||
void GuiWrapper::SignalNetClientGameInfo(int actionID) { myStartWindow->signalNetClientGameInfo(actionID); }
|
||||
void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myStartWindow->signalNetClientError(errorID, osErrorID); }
|
||||
|
||||
@@ -85,7 +85,6 @@ public:
|
||||
|
||||
void postRiverAnimation1();
|
||||
void postRiverRunAnimation1();
|
||||
void postRiverShowCards(unsigned playerId);
|
||||
|
||||
void flipHolecardsAllIn();
|
||||
|
||||
@@ -118,6 +117,7 @@ public:
|
||||
void SignalNetClientServerListShow();
|
||||
void SignalNetClientServerListClear();
|
||||
void SignalNetClientLoginShow();
|
||||
void SignalNetClientPostRiverShowCards(unsigned playerId);
|
||||
void SignalNetClientGameInfo(int actionID);
|
||||
void SignalNetClientError(int errorID, int osErrorID);
|
||||
void SignalNetClientNotification(int notificationId);
|
||||
|
||||
@@ -60,12 +60,13 @@ public:
|
||||
virtual void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg) = 0;
|
||||
virtual void SignalNetClientMsgBox(const std::string &msg) = 0;
|
||||
virtual void SignalNetClientWaitDialog() = 0;
|
||||
|
||||
|
||||
virtual void SignalNetClientServerListAdd(unsigned serverId) = 0;
|
||||
virtual void SignalNetClientServerListClear() = 0;
|
||||
virtual void SignalNetClientServerListShow() = 0;
|
||||
|
||||
virtual void SignalNetClientLoginShow() = 0;
|
||||
virtual void SignalNetClientPostRiverShowCards(unsigned playerId) = 0;
|
||||
|
||||
virtual void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName) = 0;
|
||||
virtual void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) = 0;
|
||||
|
||||
@@ -1718,6 +1718,29 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
||||
client->SetState(ClientStateWaitGame::Instance());
|
||||
}
|
||||
}
|
||||
else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_afterHandShowCardsMessage)
|
||||
{
|
||||
AfterHandShowCardsMessage_t *showCards = &tmpPacket->GetMsg()->choice.afterHandShowCardsMessage;
|
||||
PlayerResult_t *r = &showCards->playerResult;
|
||||
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = client->GetGame()->getPlayerByUniqueId(r->playerId);
|
||||
if (!tmpPlayer)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||
|
||||
int tmpCards[2];
|
||||
int bestHandPos[5];
|
||||
tmpCards[0] = static_cast<int>(r->resultCard1);
|
||||
tmpCards[1] = static_cast<int>(r->resultCard2);
|
||||
tmpPlayer->setMyCards(tmpCards);
|
||||
for (int num = 0; num < 5; num++)
|
||||
bestHandPos[num] = *r->bestHandPosition.list.array[num];
|
||||
tmpPlayer->setMyCardsValueInt(r->cardsValue);
|
||||
tmpPlayer->setMyBestHandPosition(bestHandPos);
|
||||
tmpPlayer->setMyCash(r->playerMoney);
|
||||
tmpPlayer->setLastMoneyWon(r->moneyWon);
|
||||
|
||||
client->GetCallback().SignalNetClientPostRiverShowCards(r->playerId);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -134,6 +134,12 @@ ServerGame::SendToAllPlayers(boost::shared_ptr<NetPacket> packet, SessionData::S
|
||||
GetSessionManager().SendToAllSessions(GetLobbyThread().GetSender(), packet, state);
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::SendToAllButOnePlayers(boost::shared_ptr<NetPacket> packet, SessionId except, SessionData::State state)
|
||||
{
|
||||
GetSessionManager().SendToAllButOneSessions(GetLobbyThread().GetSender(), packet, except, state);
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::RemoveAllSessions()
|
||||
{
|
||||
|
||||
@@ -170,6 +170,28 @@ static void PerformPlayerAction(ServerGame &server, boost::shared_ptr<PlayerInte
|
||||
SendPlayerAction(server, player);
|
||||
}
|
||||
|
||||
static void
|
||||
SetPlayerResult(PlayerResult_t &playerResult, boost::shared_ptr<PlayerInterface> tmpPlayer)
|
||||
{
|
||||
playerResult.playerId = tmpPlayer->getMyUniqueID();
|
||||
int tmpCards[2];
|
||||
int bestHandPos[5];
|
||||
tmpPlayer->getMyCards(tmpCards);
|
||||
playerResult.resultCard1 = tmpCards[0];
|
||||
playerResult.resultCard2 = tmpCards[1];
|
||||
tmpPlayer->getMyBestHandPosition(bestHandPos);
|
||||
for (int num = 0; num < 5; num++)
|
||||
{
|
||||
long *handPos = (long *)calloc(1, sizeof(long));
|
||||
*handPos = bestHandPos[num];
|
||||
ASN_SEQUENCE_ADD(&playerResult.bestHandPosition.list, handPos);
|
||||
}
|
||||
|
||||
playerResult.cardsValue = tmpPlayer->getMyCardsValueInt();
|
||||
playerResult.moneyWon = tmpPlayer->getLastMoneyWon();
|
||||
playerResult.playerMoney = tmpPlayer->getMyCash();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ServerGameState::~ServerGameState()
|
||||
@@ -876,23 +898,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
||||
while (i != end)
|
||||
{
|
||||
PlayerResult_t *playerResult = (PlayerResult_t *)calloc(1, sizeof(PlayerResult_t));
|
||||
playerResult->playerId = (*i)->getMyUniqueID();
|
||||
int tmpCards[2];
|
||||
int bestHandPos[5];
|
||||
(*i)->getMyCards(tmpCards);
|
||||
playerResult->resultCard1 = tmpCards[0];
|
||||
playerResult->resultCard2 = tmpCards[1];
|
||||
(*i)->getMyBestHandPosition(bestHandPos);
|
||||
for (int num = 0; num < 5; num++)
|
||||
{
|
||||
long *handPos = (long *)calloc(1, sizeof(long));
|
||||
*handPos = bestHandPos[num];
|
||||
ASN_SEQUENCE_ADD(&playerResult->bestHandPosition.list, handPos);
|
||||
}
|
||||
|
||||
playerResult->cardsValue = (*i)->getMyCardsValueInt();
|
||||
playerResult->moneyWon = (*i)->getLastMoneyWon();
|
||||
playerResult->playerMoney = (*i)->getMyCash();
|
||||
SetPlayerResult(*playerResult, (*i));
|
||||
|
||||
ASN_SEQUENCE_ADD(&endHandShow->playerResults.list, playerResult);
|
||||
++i;
|
||||
@@ -1332,7 +1338,16 @@ ServerGameStateWaitNextHand::InternalProcessPacket(boost::shared_ptr<ServerGame>
|
||||
{
|
||||
if (packet->GetMsg()->present == PokerTHMessage_PR_showMyCardsRequestMessage)
|
||||
{
|
||||
// TODO perform action.
|
||||
Game &curGame = server->GetGame();
|
||||
boost::shared_ptr<NetPacket> show(new NetPacket(NetPacket::Alloc));
|
||||
show->GetMsg()->present = PokerTHMessage_PR_afterHandShowCardsMessage;
|
||||
|
||||
AfterHandShowCardsMessage_t *netShowCards = &packet->GetMsg()->choice.afterHandShowCardsMessage;
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer(curGame.getPlayerByUniqueId(session.playerData->GetUniqueId()));
|
||||
if (tmpPlayer)
|
||||
SetPlayerResult(netShowCards->playerResult, tmpPlayer);
|
||||
|
||||
server->SendToAllButOnePlayers(show, session.sessionData->GetId(), SessionData::Game);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ public:
|
||||
GameState GetCurRound() const;
|
||||
|
||||
void SendToAllPlayers(boost::shared_ptr<NetPacket> packet, SessionData::State state);
|
||||
void RemoveAllSessions();
|
||||
void SendToAllButOnePlayers(boost::shared_ptr<NetPacket> packet, SessionId except, SessionData::State state);
|
||||
void RemoveAllSessions();
|
||||
|
||||
bool IsPasswordProtected() const;
|
||||
bool CheckPassword(const std::string &password) const;
|
||||
|
||||
Reference in New Issue
Block a user