It is now possible to start the network game with a player number below the maximum player count.

This commit is contained in:
lotodore
2007-06-11 19:46:18 +00:00
parent 07dc39d107
commit 0d4e38705d
11 changed files with 40 additions and 23 deletions
+3 -1
View File
@@ -160,6 +160,8 @@ ClientThread::Main()
boost::shared_ptr<EngineFactory> factory(new ClientEngineFactory); // LocalEngine erstellen
MapPlayerDataList();
if (GetPlayerDataList().size() != GetStartData().numberOfPlayers)
throw NetException(ERR_NET_INVALID_PLAYER_COUNT, 0);
m_game.reset(new Game(&m_gui, factory, GetPlayerDataList(), GetGameData(), GetStartData(), m_curGameId++));
// Initialize GUI speed.
GetGui().initGui(GetGameData().guiSpeed);
@@ -315,7 +317,7 @@ ClientThread::MapPlayerDataList()
if (numberDiff >= 0)
tmpData->SetNumber(numberDiff);
else
tmpData->SetNumber(GetGameData().numberOfPlayers + numberDiff);
tmpData->SetNumber(GetStartData().numberOfPlayers + numberDiff);
mappedList.push_back(tmpData);
++i;
}
+6 -4
View File
@@ -94,7 +94,7 @@ struct GCC_PACKED NetPacketJoinGameAckData
u_int32_t sessionId;
u_int16_t playerId;
u_int16_t playerNumber;
u_int16_t numberOfPlayers;
u_int16_t maxNumberOfPlayers;
u_int16_t smallBlind;
u_int16_t handsBeforeRaise;
u_int16_t proposedGuiSpeed;
@@ -130,7 +130,7 @@ struct GCC_PACKED NetPacketGameStartData
{
NetPacketHeader head;
u_int16_t startDealerPlayerId;
u_int16_t reserved;
u_int16_t numberOfPlayers;
};
struct GCC_PACKED NetPacketHandStartData
@@ -737,7 +737,7 @@ NetPacketJoinGameAck::SetData(const NetPacketJoinGameAck::Data &inData)
tmpData->sessionId = htonl(inData.sessionId);
tmpData->playerId = htons(inData.yourPlayerUniqueId);
tmpData->playerNumber = htons(inData.yourPlayerNum);
tmpData->numberOfPlayers = htons(inData.gameData.numberOfPlayers);
tmpData->maxNumberOfPlayers = htons(inData.gameData.maxNumberOfPlayers);
tmpData->smallBlind = htons(inData.gameData.smallBlind);
tmpData->handsBeforeRaise = htons(inData.gameData.handsBeforeRaise);
tmpData->proposedGuiSpeed = htons(inData.gameData.guiSpeed);
@@ -754,7 +754,7 @@ NetPacketJoinGameAck::GetData(NetPacketJoinGameAck::Data &outData) const
outData.sessionId = ntohl(tmpData->sessionId);
outData.yourPlayerUniqueId = ntohs(tmpData->playerId);
outData.yourPlayerNum = ntohs(tmpData->playerNumber);
outData.gameData.numberOfPlayers = ntohs(tmpData->numberOfPlayers);
outData.gameData.maxNumberOfPlayers = ntohs(tmpData->maxNumberOfPlayers);
outData.gameData.smallBlind = ntohs(tmpData->smallBlind);
outData.gameData.handsBeforeRaise = ntohs(tmpData->handsBeforeRaise);
outData.gameData.guiSpeed = ntohs(tmpData->proposedGuiSpeed);
@@ -973,6 +973,7 @@ NetPacketGameStart::SetData(const NetPacketGameStart::Data &inData)
assert(tmpData);
tmpData->startDealerPlayerId = htons(inData.startData.startDealerPlayerId);
tmpData->numberOfPlayers = htons(inData.startData.numberOfPlayers);
}
void
@@ -982,6 +983,7 @@ NetPacketGameStart::GetData(NetPacketGameStart::Data &outData) const
assert(tmpData);
outData.startData.startDealerPlayerId = ntohs(tmpData->startDealerPlayerId);
outData.startData.numberOfPlayers = ntohs(tmpData->numberOfPlayers);
}
const NetPacketGameStart *
+1 -1
View File
@@ -261,7 +261,7 @@ ServerRecvStateInit::InternalProcess(ServerRecvThread &server, SessionWrapper se
size_t curNumPlayers = server.GetCurNumberOfPlayers();
// Check the number of players.
if (curNumPlayers >= (size_t)server.GetGameData().numberOfPlayers)
if (curNumPlayers >= (size_t)server.GetGameData().maxNumberOfPlayers)
{
server.SessionError(session, ERR_NET_SERVER_FULL);
return retVal;
+4 -2
View File
@@ -261,10 +261,12 @@ ServerRecvThread::InternalStartGame()
// Create EngineFactory
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(m_playerConfig)); // LocalEngine erstellen
// Set dealer pos.
// Set start data.
StartData startData;
startData.numberOfPlayers = playerData.size();
int tmpDealerPos = 0;
Tools::getRandNumber(0, GetGameData().numberOfPlayers-1, 1, &tmpDealerPos, 0);
Tools::getRandNumber(0, startData.numberOfPlayers-1, 1, &tmpDealerPos, 0);
// The Player Id is not continuous. Therefore, the start dealer position
// needs to be converted to a player Id, and cannot be directly generated
// as player Id.