More protocol changes for rejoin. Re-adding server password to protocol.
This commit is contained in:
@@ -982,8 +982,7 @@ ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost:
|
||||
InitMessage_t *netInit = &init->GetMsg()->choice.initMessage;
|
||||
netInit->requestedVersion.major = NET_VERSION_MAJOR;
|
||||
netInit->requestedVersion.minor = NET_VERSION_MINOR;
|
||||
if (!context.GetSessionGuid().empty())
|
||||
{
|
||||
if (!context.GetSessionGuid().empty()) {
|
||||
netInit->myLastSessionId =
|
||||
OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_OCTET_STRING,
|
||||
@@ -1499,8 +1498,7 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> clien
|
||||
|
||||
StartData startData;
|
||||
startData.startDealerPlayerId = netGameStart->startDealerPlayerId;
|
||||
if (netGameStart->gameStartMode.present == gameStartMode_PR_gameStartModeInitial)
|
||||
{
|
||||
if (netGameStart->gameStartMode.present == gameStartMode_PR_gameStartModeInitial) {
|
||||
GameStartModeInitial_t *netStartModeInitial = &netGameStart->gameStartMode.choice.gameStartModeInitial;
|
||||
startData.numberOfPlayers = netStartModeInitial->playerSeats.list.count;
|
||||
client->SetStartData(startData);
|
||||
|
||||
@@ -221,16 +221,16 @@ ClientThread::SendJoinFirstGame(const std::string &password, bool autoLeave)
|
||||
packet->GetMsg()->present = PokerTHMessage_PR_joinGameRequestMessage;
|
||||
JoinGameRequestMessage_t *netJoinGame = &packet->GetMsg()->choice.joinGameRequestMessage;
|
||||
netJoinGame->autoLeave = autoLeave;
|
||||
if (!password.empty()) {
|
||||
netJoinGame->password = OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_UTF8String,
|
||||
password.c_str(),
|
||||
(int)password.length());
|
||||
}
|
||||
netJoinGame->joinGameAction.present = joinGameAction_PR_joinExistingGame;
|
||||
|
||||
JoinExistingGame_t *joinExisting = &netJoinGame->joinGameAction.choice.joinExistingGame;
|
||||
joinExisting->gameId = 1;
|
||||
if (!password.empty()) {
|
||||
joinExisting->password = OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_UTF8String,
|
||||
password.c_str(),
|
||||
(int)password.length());
|
||||
}
|
||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||
}
|
||||
|
||||
@@ -243,16 +243,16 @@ ClientThread::SendJoinGame(unsigned gameId, const std::string &password, bool au
|
||||
packet->GetMsg()->present = PokerTHMessage_PR_joinGameRequestMessage;
|
||||
JoinGameRequestMessage_t *netJoinGame = &packet->GetMsg()->choice.joinGameRequestMessage;
|
||||
netJoinGame->autoLeave = autoLeave;
|
||||
if (!password.empty()) {
|
||||
netJoinGame->password = OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_UTF8String,
|
||||
password.c_str(),
|
||||
(int)password.length());
|
||||
}
|
||||
netJoinGame->joinGameAction.present = joinGameAction_PR_joinExistingGame;
|
||||
|
||||
JoinExistingGame_t *joinExisting = &netJoinGame->joinGameAction.choice.joinExistingGame;
|
||||
joinExisting->gameId = gameId;
|
||||
if (!password.empty()) {
|
||||
joinExisting->password = OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_UTF8String,
|
||||
password.c_str(),
|
||||
(int)password.length());
|
||||
}
|
||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||
}
|
||||
|
||||
@@ -281,12 +281,6 @@ ClientThread::SendCreateGame(const GameData &gameData, const std::string &name,
|
||||
packet->GetMsg()->present = PokerTHMessage_PR_joinGameRequestMessage;
|
||||
JoinGameRequestMessage_t *netJoinGame = &packet->GetMsg()->choice.joinGameRequestMessage;
|
||||
netJoinGame->autoLeave = autoLeave;
|
||||
if (!password.empty()) {
|
||||
netJoinGame->password = OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_UTF8String,
|
||||
password.c_str(),
|
||||
(int)password.length());
|
||||
}
|
||||
netJoinGame->joinGameAction.present = joinGameAction_PR_joinNewGame;
|
||||
|
||||
JoinNewGame_t *joinNew = &netJoinGame->joinGameAction.choice.joinNewGame;
|
||||
@@ -294,6 +288,12 @@ ClientThread::SendCreateGame(const GameData &gameData, const std::string &name,
|
||||
OCTET_STRING_fromBuf(&joinNew->gameInfo.gameName,
|
||||
name.c_str(),
|
||||
(int)name.length());
|
||||
if (!password.empty()) {
|
||||
joinNew->password = OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_UTF8String,
|
||||
password.c_str(),
|
||||
(int)password.length());
|
||||
}
|
||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||
}
|
||||
|
||||
@@ -1411,8 +1411,7 @@ ClientThread::ReadSessionGuidFromFile()
|
||||
{
|
||||
string guidFileName(GetContext().GetCacheDir() + TEMP_GUID_FILENAME);
|
||||
ifstream guidStream(guidFileName.c_str(), ios::in | ios::binary);
|
||||
if (guidStream.good())
|
||||
{
|
||||
if (guidStream.good()) {
|
||||
std::vector<char> tmpGuid(CLIENT_GUID_SIZE);
|
||||
guidStream.read(&tmpGuid[0], CLIENT_GUID_SIZE);
|
||||
GetContext().SetSessionGuid(string(tmpGuid.begin(), tmpGuid.end()));
|
||||
@@ -1424,8 +1423,7 @@ ClientThread::WriteSessionGuidToFile() const
|
||||
{
|
||||
string guidFileName(GetContext().GetCacheDir() + TEMP_GUID_FILENAME);
|
||||
ofstream guidStream(guidFileName.c_str(), ios::out | ios::trunc | ios::binary);
|
||||
if (guidStream.good())
|
||||
{
|
||||
if (guidStream.good()) {
|
||||
guidStream.write(GetContext().GetSessionGuid().c_str(), GetContext().GetSessionGuid().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,8 +568,7 @@ boost::shared_ptr<PlayerInterface>
|
||||
ServerGame::GetPlayerInterfaceFromGame(const std::string &playerName)
|
||||
{
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||
if (m_game)
|
||||
{
|
||||
if (m_game) {
|
||||
tmpPlayer = m_game->getPlayerByName(playerName);
|
||||
}
|
||||
return tmpPlayer;
|
||||
|
||||
@@ -1146,8 +1146,7 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr<ServerGame> server)
|
||||
if (session) {
|
||||
// Set new player id.
|
||||
boost::shared_ptr<PlayerInterface> rejoinPlayer = curGame.getPlayerByName(session->GetPlayerData()->GetName());
|
||||
if (rejoinPlayer)
|
||||
{
|
||||
if (rejoinPlayer) {
|
||||
rejoinPlayer->setMyUniqueID(session->GetPlayerData()->GetUniqueId());
|
||||
rejoinPlayer->setIsConnected(true);
|
||||
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
||||
|
||||
@@ -904,7 +904,7 @@ ServerLobbyThread::HandlePacket(boost::shared_ptr<SessionData> session, boost::s
|
||||
else if (packet->GetMsg()->present == PokerTHMessage_PR_avatarRequestMessage)
|
||||
HandleNetPacketRetrieveAvatar(session, packet->GetMsg()->choice.avatarRequestMessage);
|
||||
else if (packet->GetMsg()->present == PokerTHMessage_PR_resetTimeoutMessage)
|
||||
{}
|
||||
{}
|
||||
else if (packet->GetMsg()->present == PokerTHMessage_PR_subscriptionRequestMessage) {
|
||||
SubscriptionRequestMessage_t *subscriptionRequest = &packet->GetMsg()->choice.subscriptionRequestMessage;
|
||||
if (subscriptionRequest->subscriptionAction == subscriptionAction_resubscribeGameList)
|
||||
@@ -913,13 +913,10 @@ ServerLobbyThread::HandlePacket(boost::shared_ptr<SessionData> session, boost::s
|
||||
session->ResetWantsLobbyMsg();
|
||||
} else if (packet->GetMsg()->present == PokerTHMessage_PR_joinGameRequestMessage) {
|
||||
JoinGameRequestMessage_t *joinRequest = &packet->GetMsg()->choice.joinGameRequestMessage;
|
||||
string password;
|
||||
if (joinRequest->password)
|
||||
password = string((char *)joinRequest->password->buf, joinRequest->password->size);
|
||||
if (joinRequest->joinGameAction.present == joinGameAction_PR_joinNewGame)
|
||||
HandleNetPacketCreateGame(session, password, joinRequest->autoLeave, joinRequest->joinGameAction.choice.joinNewGame);
|
||||
HandleNetPacketCreateGame(session, joinRequest->autoLeave, joinRequest->joinGameAction.choice.joinNewGame);
|
||||
else if (joinRequest->joinGameAction.present == joinGameAction_PR_joinExistingGame)
|
||||
HandleNetPacketJoinGame(session, password, joinRequest->autoLeave, joinRequest->joinGameAction.choice.joinExistingGame);
|
||||
HandleNetPacketJoinGame(session, joinRequest->autoLeave, joinRequest->joinGameAction.choice.joinExistingGame);
|
||||
else if (joinRequest->joinGameAction.present == joinGameAction_PR_rejoinExistingGame)
|
||||
HandleNetPacketRejoinGame(session, joinRequest->autoLeave, joinRequest->joinGameAction.choice.rejoinExistingGame);
|
||||
} else if (packet->GetMsg()->present == PokerTHMessage_PR_chatRequestMessage)
|
||||
@@ -1034,8 +1031,7 @@ ServerLobbyThread::HandleNetPacketInit(boost::shared_ptr<SessionData> session, c
|
||||
new PlayerData(GetNextUniquePlayerId(), 0, PLAYER_TYPE_HUMAN, validGuest ? PLAYER_RIGHTS_GUEST : PLAYER_RIGHTS_NORMAL, false));
|
||||
tmpPlayerData->SetName(playerName);
|
||||
tmpPlayerData->SetAvatarMD5(avatarMD5);
|
||||
if (initMessage.myLastSessionId)
|
||||
{
|
||||
if (initMessage.myLastSessionId) {
|
||||
tmpPlayerData->SetOldGuid(STL_STRING_FROM_OCTET_STRING(*initMessage.myLastSessionId));
|
||||
}
|
||||
|
||||
@@ -1235,10 +1231,14 @@ ServerLobbyThread::HandleNetPacketRetrieveAvatar(boost::shared_ptr<SessionData>
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> session, const std::string &password, bool autoLeave, const JoinNewGame_t &newGame)
|
||||
ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> session, bool autoLeave, const JoinNewGame_t &newGame)
|
||||
{
|
||||
LOG_VERBOSE("Creating new game, initiated by session #" << session->GetId() << ".");
|
||||
|
||||
string password;
|
||||
if (newGame.password)
|
||||
password = string((char *)newGame.password->buf, newGame.password->size);
|
||||
|
||||
// Create a new game.
|
||||
GameData tmpData;
|
||||
NetPacket::GetGameData(&newGame.gameInfo, tmpData);
|
||||
@@ -1276,8 +1276,12 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> sess
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> session, const std::string &password, bool autoLeave, const JoinExistingGame_t &joinGame)
|
||||
ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> session, bool autoLeave, const JoinExistingGame_t &joinGame)
|
||||
{
|
||||
string password;
|
||||
if (joinGame.password)
|
||||
password = string((char *)joinGame.password->buf, joinGame.password->size);
|
||||
|
||||
// Join an existing game.
|
||||
GameMap::iterator pos = m_gameMap.find(joinGame.gameId);
|
||||
|
||||
@@ -1490,8 +1494,7 @@ ServerLobbyThread::EstablishSession(boost::shared_ptr<SessionData> session)
|
||||
|
||||
u_int32_t rejoinPlayerId = 0;
|
||||
u_int32_t rejoinGameId = GetRejoinGameIdForPlayer(session->GetPlayerData()->GetName(), session->GetPlayerData()->GetOldGuid(), rejoinPlayerId);
|
||||
if (rejoinGameId != 0)
|
||||
{
|
||||
if (rejoinGameId != 0) {
|
||||
// Offer rejoin, and disconnect current player with the same name.
|
||||
InternalRemovePlayer(rejoinPlayerId, ERR_NET_PLAYER_NAME_IN_USE);
|
||||
}
|
||||
@@ -1527,8 +1530,7 @@ ServerLobbyThread::EstablishSession(boost::shared_ptr<SessionData> session)
|
||||
session->GetPlayerData()->GetGuid().c_str(),
|
||||
session->GetPlayerData()->GetGuid().size());
|
||||
netInitAck->yourPlayerId = session->GetPlayerData()->GetUniqueId();
|
||||
if (rejoinGameId != 0)
|
||||
{
|
||||
if (rejoinGameId != 0) {
|
||||
netInitAck->rejoinGameId = (NonZeroId_t *)calloc(1, sizeof(NonZeroId_t));
|
||||
*netInitAck->rejoinGameId = rejoinGameId;
|
||||
}
|
||||
@@ -2194,8 +2196,7 @@ ServerLobbyThread::GetRejoinGameIdForPlayer(const std::string &playerName, const
|
||||
while (i != end) {
|
||||
boost::shared_ptr<ServerGame> tmpGame = i->second;
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = tmpGame->GetPlayerInterfaceFromGame(playerName);
|
||||
if (tmpPlayer && tmpPlayer->getMyGuid() == guid)
|
||||
{
|
||||
if (tmpPlayer && tmpPlayer->getMyGuid() == guid) {
|
||||
retGameId = tmpGame->GetId();
|
||||
outPlayerUniqueId = tmpPlayer->getMyUniqueID();
|
||||
break;
|
||||
|
||||
@@ -137,8 +137,8 @@ protected:
|
||||
void HandleNetPacketAvatarEnd(boost::shared_ptr<SessionData> session, unsigned requestId, const AvatarEnd_t &avatarEnd);
|
||||
void HandleNetPacketRetrievePlayerInfo(boost::shared_ptr<SessionData> session, const PlayerInfoRequestMessage_t &playerInfoRequest);
|
||||
void HandleNetPacketRetrieveAvatar(boost::shared_ptr<SessionData> session, const AvatarRequestMessage_t &retrieveAvatar);
|
||||
void HandleNetPacketCreateGame(boost::shared_ptr<SessionData> session, const std::string &password, bool autoLeave, const JoinNewGame_t &newGame);
|
||||
void HandleNetPacketJoinGame(boost::shared_ptr<SessionData> session, const std::string &password, bool autoLeave, const JoinExistingGame_t &joinGame);
|
||||
void HandleNetPacketCreateGame(boost::shared_ptr<SessionData> session, bool autoLeave, const JoinNewGame_t &newGame);
|
||||
void HandleNetPacketJoinGame(boost::shared_ptr<SessionData> session, bool autoLeave, const JoinExistingGame_t &joinGame);
|
||||
void HandleNetPacketRejoinGame(boost::shared_ptr<SessionData> session, bool autoLeave, const RejoinExistingGame_t &rejoinGame);
|
||||
void HandleNetPacketChatRequest(boost::shared_ptr<SessionData> session, const ChatRequestMessage_t &chatRequest);
|
||||
void HandleNetPacketRejectGameInvitation(boost::shared_ptr<SessionData> session, const RejectGameInvitationMessage_t &reject);
|
||||
|
||||
Reference in New Issue
Block a user