New start event type to mark a certain game start as "rejoin" (in order to show a special dialog).
This commit is contained in:
@@ -944,13 +944,12 @@ ClientStateStartSession::InternalHandlePacket(boost::shared_ptr<ClientThread> cl
|
||||
InitMessage_t *netInit = &init->GetMsg()->choice.initMessage;
|
||||
netInit->requestedVersion.major = NET_VERSION_MAJOR;
|
||||
netInit->requestedVersion.minor = NET_VERSION_MINOR;
|
||||
if (!context.GetServerPassword().empty())
|
||||
{
|
||||
if (!context.GetServerPassword().empty()) {
|
||||
netInit->authServerPassword =
|
||||
OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_OCTET_STRING,
|
||||
context.GetServerPassword().c_str(),
|
||||
context.GetServerPassword().length());
|
||||
OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_OCTET_STRING,
|
||||
context.GetServerPassword().c_str(),
|
||||
context.GetServerPassword().length());
|
||||
}
|
||||
netInit->login.present = login_PR_unauthenticatedLogin;
|
||||
UnauthenticatedLogin_t *noauthLogin = &netInit->login.choice.unauthenticatedLogin;
|
||||
@@ -1027,13 +1026,12 @@ ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost:
|
||||
context.GetSessionGuid().c_str(),
|
||||
(int)context.GetSessionGuid().length());
|
||||
}
|
||||
if (!context.GetServerPassword().empty())
|
||||
{
|
||||
if (!context.GetServerPassword().empty()) {
|
||||
netInit->authServerPassword =
|
||||
OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_OCTET_STRING,
|
||||
context.GetServerPassword().c_str(),
|
||||
context.GetServerPassword().length());
|
||||
OCTET_STRING_new_fromBuf(
|
||||
&asn_DEF_OCTET_STRING,
|
||||
context.GetServerPassword().c_str(),
|
||||
context.GetServerPassword().length());
|
||||
}
|
||||
|
||||
context.SetPlayerName(loginData.userName);
|
||||
@@ -1391,7 +1389,12 @@ void
|
||||
ClientStateWaitGame::InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket)
|
||||
{
|
||||
if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_startEventMessage) {
|
||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_SYNCSTART);
|
||||
StartEventMessage_t *netStartEvent = &tmpPacket->GetMsg()->choice.startEventMessage;
|
||||
if (netStartEvent->startEventType.present == startEventType_PR_rejoinEvent) {
|
||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_SYNCSTART);
|
||||
} else {
|
||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_SYNCREJOIN);
|
||||
}
|
||||
client->SetState(ClientStateSynchronizeStart::Instance());
|
||||
} else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_inviteNotifyMessage) {
|
||||
InviteNotifyMessage_t *netInvNotify = &tmpPacket->GetMsg()->choice.inviteNotifyMessage;
|
||||
@@ -1799,7 +1802,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
||||
// Set round.
|
||||
if (curGame->getCurrentHand()->getCurrentRound() != netPlayersTurn->gameState) {
|
||||
ResetPlayerActions(*curGame);
|
||||
curGame->getCurrentHand()->setCurrentRound(GameState(netPlayersTurn->gameState));
|
||||
curGame->getCurrentHand()->setCurrentRound(GameState(netPlayersTurn->gameState));
|
||||
// Refresh actions.
|
||||
client->GetGui().refreshSet();
|
||||
client->GetGui().refreshAction();
|
||||
|
||||
@@ -55,7 +55,7 @@ ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager, Conf
|
||||
m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false),
|
||||
m_stateTimer(*m_ioService), m_avatarTimer(*m_ioService)
|
||||
{
|
||||
m_clientLog.reset(new Log(config));
|
||||
m_clientLog.reset(new Log(config));
|
||||
m_context.reset(new ClientContext);
|
||||
myQtToolsInterface.reset(CreateQtToolsWrapper());
|
||||
m_senderHelper.reset(new SenderHelper(m_ioService));
|
||||
@@ -132,7 +132,10 @@ ClientThread::SendStartEvent(bool fillUpWithCpuPlayers)
|
||||
packet->GetMsg()->present = PokerTHMessage_PR_startEventMessage;
|
||||
StartEventMessage_t *netStartEvent = &packet->GetMsg()->choice.startEventMessage;
|
||||
netStartEvent->gameId = GetGameId();
|
||||
netStartEvent->fillWithComputerPlayers = fillUpWithCpuPlayers;
|
||||
|
||||
netStartEvent->startEventType.present = startEventType_PR_startEvent;
|
||||
StartEvent_t *start = &netStartEvent->startEventType.choice.startEvent;
|
||||
start->fillWithComputerPlayers = fillUpWithCpuPlayers;
|
||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||
}
|
||||
|
||||
|
||||
@@ -590,7 +590,10 @@ ServerGameStateInit::SendStartEvent(ServerGame &server, bool fillWithComputerPla
|
||||
packet->GetMsg()->present = PokerTHMessage_PR_startEventMessage;
|
||||
StartEventMessage_t *netStartEvent = &packet->GetMsg()->choice.startEventMessage;
|
||||
netStartEvent->gameId = server.GetId();
|
||||
netStartEvent->fillWithComputerPlayers = fillWithComputerPlayers;
|
||||
|
||||
netStartEvent->startEventType.present = startEventType_PR_startEvent;
|
||||
StartEvent_t *start = &netStartEvent->startEventType.choice.startEvent;
|
||||
start->fillWithComputerPlayers = fillWithComputerPlayers;
|
||||
|
||||
// Wait for all players to confirm start of game.
|
||||
server.SendToAllPlayers(packet, SessionData::Game);
|
||||
@@ -608,9 +611,10 @@ ServerGameStateInit::InternalProcessPacket(boost::shared_ptr<ServerGame> server,
|
||||
// Only admins are allowed to start the game.
|
||||
if (session->GetPlayerData()->IsGameAdmin()
|
||||
&& netStartEvent->gameId == server->GetId()
|
||||
&& netStartEvent->startEventType.present == startEventType_PR_startEvent
|
||||
&& (server->GetGameData().gameType != GAME_TYPE_RANKING // ranking games need to be full
|
||||
|| server->GetGameData().maxNumberOfPlayers == server->GetCurNumberOfPlayers())) {
|
||||
SendStartEvent(*server, netStartEvent->fillWithComputerPlayers);
|
||||
SendStartEvent(*server, netStartEvent->startEventType.choice.startEvent.fillWithComputerPlayers);
|
||||
} else { // kick players who try to start but are not allowed to
|
||||
server->MoveSessionToLobby(session, NTF_NET_REMOVED_START_FAILED);
|
||||
}
|
||||
@@ -782,7 +786,7 @@ AbstractServerGameStateRunning::HandleNewSession(boost::shared_ptr<ServerGame> s
|
||||
packet->GetMsg()->present = PokerTHMessage_PR_startEventMessage;
|
||||
StartEventMessage_t *netStartEvent = &packet->GetMsg()->choice.startEventMessage;
|
||||
netStartEvent->gameId = server->GetId();
|
||||
netStartEvent->fillWithComputerPlayers = false;
|
||||
netStartEvent->startEventType.present = startEventType_PR_rejoinEvent;
|
||||
|
||||
// Wait for rejoining player to confirm start of game.
|
||||
server->GetLobbyThread().GetSender().Send(session, packet);
|
||||
|
||||
@@ -214,7 +214,7 @@ ServerLobbyThread::Init(const string &logDir)
|
||||
m_serverConfig.readConfigString("DBServerEncryptionKey"));
|
||||
|
||||
GetBanManager().InitGameNameBadWordList(m_serverConfig.readConfigStringList("GameNameBadWordList"));
|
||||
m_serverLog.reset(new Log(&m_serverConfig));
|
||||
m_serverLog.reset(new Log(&m_serverConfig));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+12
-11
@@ -139,18 +139,19 @@
|
||||
// The following messages are game messages.
|
||||
#define MSG_NET_GAME_CLIENT_JOIN MSG_SOCK_LIMIT_CONNECT + 1
|
||||
#define MSG_NET_GAME_CLIENT_SYNCSTART MSG_SOCK_LIMIT_CONNECT + 2
|
||||
#define MSG_NET_GAME_CLIENT_START MSG_SOCK_LIMIT_CONNECT + 3
|
||||
#define MSG_NET_GAME_CLIENT_HAND_START MSG_SOCK_LIMIT_CONNECT + 4
|
||||
#define MSG_NET_GAME_CLIENT_HAND_END MSG_SOCK_LIMIT_CONNECT + 5
|
||||
#define MSG_NET_GAME_CLIENT_END MSG_SOCK_LIMIT_CONNECT + 6
|
||||
#define MSG_NET_GAME_CLIENT_SYNCREJOIN MSG_SOCK_LIMIT_CONNECT + 3
|
||||
#define MSG_NET_GAME_CLIENT_START MSG_SOCK_LIMIT_CONNECT + 4
|
||||
#define MSG_NET_GAME_CLIENT_HAND_START MSG_SOCK_LIMIT_CONNECT + 5
|
||||
#define MSG_NET_GAME_CLIENT_HAND_END MSG_SOCK_LIMIT_CONNECT + 6
|
||||
#define MSG_NET_GAME_CLIENT_END MSG_SOCK_LIMIT_CONNECT + 7
|
||||
|
||||
#define MSG_NET_GAME_SERVER_START MSG_SOCK_LIMIT_CONNECT + 7
|
||||
#define MSG_NET_GAME_SERVER_HAND_START MSG_SOCK_LIMIT_CONNECT + 8
|
||||
#define MSG_NET_GAME_SERVER_HAND_END MSG_SOCK_LIMIT_CONNECT + 9
|
||||
#define MSG_NET_GAME_SERVER_ROUND MSG_SOCK_LIMIT_CONNECT + 10
|
||||
#define MSG_NET_GAME_SERVER_ACTION MSG_SOCK_LIMIT_CONNECT + 11
|
||||
#define MSG_NET_GAME_SERVER_CARDS_DELAY MSG_SOCK_LIMIT_CONNECT + 12
|
||||
#define MSG_NET_GAME_SERVER_END MSG_SOCK_LIMIT_CONNECT + 13
|
||||
#define MSG_NET_GAME_SERVER_START MSG_SOCK_LIMIT_CONNECT + 8
|
||||
#define MSG_NET_GAME_SERVER_HAND_START MSG_SOCK_LIMIT_CONNECT + 9
|
||||
#define MSG_NET_GAME_SERVER_HAND_END MSG_SOCK_LIMIT_CONNECT + 10
|
||||
#define MSG_NET_GAME_SERVER_ROUND MSG_SOCK_LIMIT_CONNECT + 11
|
||||
#define MSG_NET_GAME_SERVER_ACTION MSG_SOCK_LIMIT_CONNECT + 12
|
||||
#define MSG_NET_GAME_SERVER_CARDS_DELAY MSG_SOCK_LIMIT_CONNECT + 13
|
||||
#define MSG_NET_GAME_SERVER_END MSG_SOCK_LIMIT_CONNECT + 14
|
||||
|
||||
#define MSG_NET_LIMIT_GAME MSG_NET_GAME_SERVER_END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user