Fixed init gui in networking (is now thread safe). Fixed displaying of game/hand number for network games.
This commit is contained in:
1 parent
baad95427f
commit
1fcb0c80fd
13 files changed
+58
-34
No files matched your search
@@ -257,7 +257,7 @@ protected:
|
||||
static void SetPlayersTurn(Game &curGame, int playersTurn);
|
||||
};
|
||||
|
||||
// State: Final (TODO).
|
||||
// State: Final (just for testing, should not be used).
|
||||
class ClientStateFinal : public ClientState
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -538,6 +538,7 @@ ClientStateWaitHand::InternalProcess(ClientThread &client, boost::shared_ptr<Net
|
||||
client.GetGame()->initHand();
|
||||
client.GetGame()->startHand();
|
||||
client.GetGui().dealHoleCards();
|
||||
client.GetGui().refreshGameLabels();
|
||||
client.SetState(ClientStateRunHand::Instance());
|
||||
|
||||
retVal = MSG_NET_GAME_CLIENT_HAND_START;
|
||||
@@ -577,7 +578,8 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
||||
NetPacketPlayersActionDone::Data actionDoneData;
|
||||
packet->ToNetPacketPlayersActionDone()->GetData(actionDoneData);
|
||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId);
|
||||
assert(tmpPlayer); // TODO: throw exception
|
||||
if (!tmpPlayer)
|
||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||
|
||||
if (actionDoneData.gameState == GAME_STATE_PREFLOP_SMALL_BLIND)
|
||||
tmpPlayer->setMyButton(BUTTON_SMALL_BLIND);
|
||||
@@ -609,7 +611,8 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
||||
NetPacketPlayersTurn::Data turnData;
|
||||
packet->ToNetPacketPlayersTurn()->GetData(turnData);
|
||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId);
|
||||
assert(tmpPlayer); // TODO: throw exception
|
||||
if (!tmpPlayer)
|
||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||
|
||||
// Set round.
|
||||
if (curGame->getCurrentHand()->getActualRound() != turnData.gameState)
|
||||
@@ -623,12 +626,13 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
||||
curGame->getPlayerArray()[i]->setMySetNull();
|
||||
}
|
||||
|
||||
curGame->getCurrentHand()->setActualRound(turnData.gameState);
|
||||
|
||||
client.GetGui().refreshPot();
|
||||
client.GetGui().refreshSet();
|
||||
client.GetGui().refreshAction();
|
||||
client.GetGui().refreshCash();
|
||||
|
||||
curGame->getCurrentHand()->setActualRound(turnData.gameState);
|
||||
client.GetGui().refreshGameLabels();
|
||||
}
|
||||
|
||||
// Next player's turn.
|
||||
@@ -683,7 +687,8 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
||||
packet->ToNetPacketEndOfHandHideCards()->GetData(endHandData);
|
||||
|
||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId);
|
||||
assert(tmpPlayer); // TODO: throw exception
|
||||
if (!tmpPlayer)
|
||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||
|
||||
tmpPlayer->setMyCash(endHandData.playerMoney);
|
||||
// TODO use moneyWon
|
||||
@@ -711,7 +716,8 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
||||
while (i != end)
|
||||
{
|
||||
PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId);
|
||||
assert(tmpPlayer); // TODO: throw exception
|
||||
if (!tmpPlayer)
|
||||
throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||
|
||||
int tmpCards[2];
|
||||
tmpCards[0] = static_cast<int>((*i).cards[0]);
|
||||
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
|
||||
|
||||
ClientThread::ClientThread(GuiInterface &gui)
|
||||
: m_curState(NULL), m_gui(gui), m_curGameId(0), m_guiPlayerNum(0)
|
||||
: m_curState(NULL), m_gui(gui), m_curGameId(1), m_guiPlayerNum(0)
|
||||
{
|
||||
m_context.reset(new ClientContext);
|
||||
m_senderCallback.reset(new ClientSenderCallback(*this));
|
||||
@@ -70,7 +70,10 @@ ClientThread::Init(
|
||||
const string &serverAddress, unsigned serverPort, bool ipv6, const string &pwd, const string &playerName)
|
||||
{
|
||||
if (IsRunning())
|
||||
return; // TODO: throw exception
|
||||
{
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ClientContext &context = GetContext();
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#define ERR_NET_INVALID_PLAYER_NAME 107
|
||||
#define ERR_NET_INVALID_PLAYER_RESULTS 108
|
||||
#define ERR_NET_INVALID_CHAT_TEXT 109
|
||||
#define ERR_NET_UNKNOWN_PLAYER_ID 110
|
||||
|
||||
// This is an internal message which is not reported.
|
||||
#define MSG_SOCK_INTERNAL_PENDING 0
|
||||
|
||||
Reference in new issue
Block a user