Protocol changes for big blind / small blind. GUI Player is now stored in Game.

This commit is contained in:
lotodore
2007-05-20 22:49:07 +00:00
parent 63b278a88e
commit e4039695c0
10 changed files with 40 additions and 27 deletions
-2
View File
@@ -82,8 +82,6 @@ protected:
void RemovePlayerData(unsigned playerId);
const PlayerDataList &GetPlayerDataList() const;
int m_myPlayerNum; // TODO: Hack
private:
std::auto_ptr<ClientContext> m_context;
+2 -5
View File
@@ -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> 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();
}
}
+4 -4
View File
@@ -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 *
+2 -2
View File
@@ -153,10 +153,10 @@ ServerRecvStateInit::Process(ServerRecvThread &server)
// Send ACK to client.
boost::shared_ptr<NetPacket> 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<NetPacketJoinGameAck *>(answer.get())->SetData(joinGameAckData);
server.GetSender().Send(recvSock, answer);
-2
View File
@@ -120,8 +120,6 @@ public:
struct Data
{
u_int32_t sessionId;
u_int16_t playerId;
u_int16_t playerNumber;
GameData gameData;
};