diff --git a/docs/net_protocol.txt b/docs/net_protocol.txt index e4509852..c0fe70e6 100644 --- a/docs/net_protocol.txt +++ b/docs/net_protocol.txt @@ -116,6 +116,9 @@ Server Notification: Game Start [ Dealer Pos can be different for each game, therefore it is not transmitted in Join Game ACK. ] +[ It is not necessary to transmit the Dealer Pos, because the server + decides which player's turn it is. This is only for fast and simple + GUI display. ] Server Notification: Hand Start @@ -143,10 +146,12 @@ Server Request/Notification: Player's Turn +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Game State: - 0 - Preflop - 1 - Flop - 2 - Turn - 3 - River + 0xF0 - Preflop Small Blind (no action requested) + 0xF1 - Preflop Big Blind (no action requested) + 0x00 - Preflop + 0x01 - Flop + 0x02 - Turn + 0x03 - River Client Reply/Request: Player's Action @@ -173,13 +178,25 @@ Cash Value: 0 - states fold, check, call, all in > 0 - states bet, raise +Server Reply/Notification: Player's Action Done + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Message Type = 9 | Message Length = 12 | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Game State | Player Action | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Cash Value | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + Server Reply: Player's Action Rejected 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Message Type = 9 | Message Length = 16 | + | Message Type = 10 | Message Length = 16 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Game State | Player Action | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ diff --git a/src/game.cpp b/src/game.cpp index acad9f58..e68118bc 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -35,7 +35,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, startQuantityPlayers(gameData.numberOfPlayers), startCash(gameData.startCash), startSmallBlind(gameData.smallBlind), startHandsBeforeRaiseSmallBlind(gameData.handsBeforeRaise), - myGameID(gameId), actualQuantityPlayers(gameData.numberOfPlayers), + myGameID(gameId), guiPlayerNum(gameData.guiPlayerNum), actualQuantityPlayers(gameData.numberOfPlayers), actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(startData.startDealerPos) { // cout << "Create Game Object" << "\n"; diff --git a/src/game.h b/src/game.h index 97b99593..a592ea4e 100755 --- a/src/game.h +++ b/src/game.h @@ -63,10 +63,8 @@ public: int getDealerPosition() const { return dealerPosition; } - void setMyGameID(const int& theValue) { myGameID = theValue;} int getMyGameID() const { return myGameID; } - - + int getGuiPlayerNum() const { return guiPlayerNum; } //Zufgriff Laufvariablen void setActualQuantityPlayers(const int& theValue) { actualQuantityPlayers = theValue; } @@ -85,7 +83,7 @@ private: GuiInterface *myGui; HandInterface *actualHand; BoardInterface *actualBoard; - PlayerInterface *playerArray[7]; + PlayerInterface *playerArray[MAX_NUMBER_OF_PLAYERS]; //Startvariablen int startQuantityPlayers; @@ -93,6 +91,7 @@ private: int startSmallBlind; int startHandsBeforeRaiseSmallBlind; int myGameID; + int guiPlayerNum; //Laufvariablen int actualQuantityPlayers; diff --git a/src/game_defs.h b/src/game_defs.h index 09708508..66ac2a3a 100644 --- a/src/game_defs.h +++ b/src/game_defs.h @@ -26,7 +26,9 @@ enum GameState { GAME_STATE_PREFLOP = 0, GAME_STATE_FLOP, GAME_STATE_TURN, - GAME_STATE_RIVER }; + GAME_STATE_RIVER, + GAME_STATE_PREFLOP_SMALL_BLIND = 0xF0, + GAME_STATE_PREFLOP_BIG_BLIND = 0xF1 }; enum PlayerAction { PLAYER_ACTION_NONE = 0, diff --git a/src/gamedata.h b/src/gamedata.h index 8ca0e395..f7e0b763 100644 --- a/src/gamedata.h +++ b/src/gamedata.h @@ -26,12 +26,14 @@ struct GameData { GameData() : numberOfPlayers(0), startCash(0), smallBlind(0), - handsBeforeRaise(1), guiSpeed(4) {} + handsBeforeRaise(1), guiSpeed(4), guiPlayerNum(0), guiPlayerUniqueId(0) {} int numberOfPlayers; int startCash; int smallBlind; int handsBeforeRaise; int guiSpeed; + int guiPlayerNum; + unsigned guiPlayerUniqueId; }; struct StartData diff --git a/src/net/clientthread.h b/src/net/clientthread.h index f1d9e76c..0052a1e0 100644 --- a/src/net/clientthread.h +++ b/src/net/clientthread.h @@ -82,8 +82,6 @@ protected: void RemovePlayerData(unsigned playerId); const PlayerDataList &GetPlayerDataList() const; - int m_myPlayerNum; // TODO: Hack - private: std::auto_ptr m_context; diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index d6576620..694e0172 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -392,12 +392,9 @@ ClientStateWaitSession::Process(ClientThread &client) tmpPacket->ToNetPacketJoinGameAck()->GetData(joinGameAckData); client.SetGameData(joinGameAckData.gameData); - // TODO: Hack - client.m_myPlayerNum = joinGameAckData.playerNumber; - // TODO: Type Human is fixed here. boost::shared_ptr playerData( - new PlayerData(joinGameAckData.playerId, joinGameAckData.playerNumber, PLAYER_TYPE_HUMAN)); + new PlayerData(joinGameAckData.gameData.guiPlayerUniqueId, joinGameAckData.gameData.guiPlayerNum, PLAYER_TYPE_HUMAN)); playerData->SetName(context.GetPlayerName()); client.AddPlayerData(playerData); @@ -515,7 +512,7 @@ ClientStateWaitHand::Process(ClientThread &client) int myCards[2]; myCards[0] = (int)tmpData.yourCards[0]; myCards[1] = (int)tmpData.yourCards[1]; - client.GetGame()->getPlayerArray()[client.m_myPlayerNum]->setMyCards(myCards); + client.GetGame()->getPlayerArray()[client.GetGame()->getGuiPlayerNum()]->setMyCards(myCards); client.GetGui().dealHoleCards(); } } diff --git a/src/net/common/netpacket.cpp b/src/net/common/netpacket.cpp index 79ca0888..e77c04a0 100644 --- a/src/net/common/netpacket.cpp +++ b/src/net/common/netpacket.cpp @@ -528,13 +528,13 @@ NetPacketJoinGameAck::SetData(const NetPacketJoinGameAck::Data &inData) assert(tmpData); tmpData->sessionId = htonl(inData.sessionId); - tmpData->playerId = htons(inData.playerId); - tmpData->playerNumber = htons(inData.playerNumber); tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers); tmpData->smallBlind = htons(inData.gameData.smallBlind); tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise); tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed); tmpData->startCash = htonl(inData.gameData.startCash); + tmpData->playerId = htons(inData.gameData.guiPlayerUniqueId); + tmpData->playerNumber = htons(inData.gameData.guiPlayerNum); } void @@ -544,13 +544,13 @@ NetPacketJoinGameAck::GetData(NetPacketJoinGameAck::Data &outData) const assert(tmpData); outData.sessionId = ntohl(tmpData->sessionId); - outData.playerId = ntohs(tmpData->playerId); - outData.playerNumber = ntohs(tmpData->playerNumber); outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers); outData.gameData.smallBlind = ntohs(tmpData->smallBlind); outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise); outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed); outData.gameData.startCash = ntohl(tmpData->startCash); + outData.gameData.guiPlayerUniqueId = ntohs(tmpData->playerId); + outData.gameData.guiPlayerNum = ntohs(tmpData->playerNumber); } const NetPacketJoinGameAck * diff --git a/src/net/common/serverrecvstate.cpp b/src/net/common/serverrecvstate.cpp index a2ea4493..197862df 100644 --- a/src/net/common/serverrecvstate.cpp +++ b/src/net/common/serverrecvstate.cpp @@ -153,10 +153,10 @@ ServerRecvStateInit::Process(ServerRecvThread &server) // Send ACK to client. boost::shared_ptr answer(new NetPacketJoinGameAck); NetPacketJoinGameAck::Data joinGameAckData; - joinGameAckData.playerId = tmpPlayerData->GetUniqueId(); - joinGameAckData.playerNumber = tmpPlayerData->GetNumber(); joinGameAckData.sessionId = session.sessionData->GetId(); // TODO: currently unused. joinGameAckData.gameData = server.GetGameData(); + joinGameAckData.gameData.guiPlayerUniqueId = tmpPlayerData->GetUniqueId(); + joinGameAckData.gameData.guiPlayerNum = tmpPlayerData->GetNumber(); static_cast(answer.get())->SetData(joinGameAckData); server.GetSender().Send(recvSock, answer); diff --git a/src/net/netpacket.h b/src/net/netpacket.h index d3aee5ba..a91c2ecc 100644 --- a/src/net/netpacket.h +++ b/src/net/netpacket.h @@ -120,8 +120,6 @@ public: struct Data { u_int32_t sessionId; - u_int16_t playerId; - u_int16_t playerNumber; GameData gameData; };