Server feedback after report game.

This commit is contained in:
lotodore
2012-04-09 10:22:24 +00:00
parent dbdd135bc7
commit ed43fa107c
5 changed files with 55 additions and 8 deletions
+15
View File
@@ -765,6 +765,21 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
break;
}
client->GetCallback().SignalNetClientMsgBox(msgCode);
} else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_reportGameAckMessage) {
ReportGameAckMessage_t *netReportAck = &tmpPacket->GetMsg()->choice.reportGameAckMessage;
unsigned msgCode;
switch (netReportAck->reportGameResult) {
case reportGameResult_gameReportAccepted:
msgCode = MSG_NET_GAMENAME_REPORT_ACCEPTED;
break;
case reportGameResult_gameReportDuplicate:
msgCode = MSG_NET_GAMENAME_REPORT_DUP;
break;
default:
msgCode = MSG_NET_GAMENAME_REPORT_REJECTED;
break;
}
client->GetCallback().SignalNetClientMsgBox(msgCode);
} else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_statisticsMessage) {
StatisticsMessage_t *netStatistics = &tmpPacket->GetMsg()->choice.statisticsMessage;
+14 -1
View File
@@ -52,7 +52,8 @@ ServerGame::ServerGame(boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32
m_gameData(gameData), m_curState(NULL), m_id(id), m_name(name),
m_password(pwd), m_creatorPlayerDBId(creatorPlayerDBId), m_playerConfig(playerConfig),
m_gameNum(1), m_curPetitionId(1), m_voteKickTimer(lobbyThread->GetIOService()),
m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService())
m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService()),
m_isNameReported(false)
{
LOG_VERBOSE("Game object " << GetId() << " created.");
}
@@ -724,6 +725,18 @@ ServerGame::GetAndResetReactivatePlayers()
return tmpList;
}
void
ServerGame::SetNameReported()
{
m_isNameReported = true;
}
bool
ServerGame::IsNameReported() const
{
return m_isNameReported;
}
void
ServerGame::AddComputerPlayer(boost::shared_ptr<PlayerData> player)
{
+21 -5
View File
@@ -179,11 +179,11 @@ public:
}
virtual void ReportGameSuccess(unsigned requestId, unsigned replyId) {
// TODO
m_server.SendReportGameResult(requestId, replyId, true);
}
virtual void ReportGameFailed(unsigned requestId, unsigned replyId) {
// TODO
m_server.SendReportGameResult(requestId, replyId, false);
}
private:
@@ -1467,11 +1467,11 @@ ServerLobbyThread::HandleNetPacketReportGame(boost::shared_ptr<SessionData> sess
GameMap::iterator pos = m_gameMap.find(report.reportedGameId);
if (pos != m_gameMap.end() && session->GetPlayerData()) {
if (!IsGameReported(report.reportedGameId)) {
boost::shared_ptr<ServerGame> tmpGame(pos->second);
if (!tmpGame->IsNameReported()) {
// Temporarily note that this game was reported.
// This prevents spamming of the game report.
AddReportedGame(report.reportedGameId);
boost::shared_ptr<ServerGame> tmpGame(pos->second);
tmpGame->SetNameReported();
unsigned creatorDBId = tmpGame->GetCreatorDBId();
unsigned reporterDBId = session->GetPlayerData()->GetDBId();
GetDatabase()->AsyncReportGame(
@@ -1682,6 +1682,22 @@ ServerLobbyThread::SendReportAvatarResult(unsigned byPlayerId, unsigned reported
}
}
void
ServerLobbyThread::SendReportGameResult(unsigned byPlayerId, unsigned reportedGameId, bool success)
{
boost::shared_ptr<SessionData> session = m_sessionManager.GetSessionByUniquePlayerId(byPlayerId);
if (!session)
session = m_gameSessionManager.GetSessionByUniquePlayerId(byPlayerId);
if (session) {
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
packet->GetMsg()->present = PokerTHMessage_PR_reportGameAckMessage;
ReportGameAckMessage_t *netReportAck = &packet->GetMsg()->choice.reportGameAckMessage;
netReportAck->reportedGameId = reportedGameId;
netReportAck->reportGameResult = success ? reportGameResult_gameReportAccepted : reportGameResult_gameReportInvalid;
GetSender().Send(session, packet);
}
}
void
ServerLobbyThread::UserBlocked(unsigned playerId)
{
+4
View File
@@ -98,6 +98,9 @@ public:
void AddReactivatePlayer(unsigned playerId);
PlayerIdList GetAndResetReactivatePlayers();
void SetNameReported();
bool IsNameReported() const;
// should be protected, but is needed in function.
const Game &GetGame() const;
Game &GetGame();
@@ -216,6 +219,7 @@ private:
boost::asio::deadline_timer m_voteKickTimer;
boost::asio::deadline_timer m_stateTimer1;
boost::asio::deadline_timer m_stateTimer2;
bool m_isNameReported;
friend class ServerLobbyThread;
friend class AbstractServerGameStateReceiving;
+1 -2
View File
@@ -154,10 +154,9 @@ protected:
void UserValid(unsigned playerId, const DBPlayerData &dbPlayerData);
void UserInvalid(unsigned playerId);
void UserBlocked(unsigned playerId);
bool IsGameReported(unsigned /*gameId*/) const {return false;}
void AddReportedGame(unsigned /*gameId*/) {}
void SendReportAvatarResult(unsigned byPlayerId, unsigned reportedPlayerId, bool success);
void SendReportGameResult(unsigned byPlayerId, unsigned reportedGameId, bool success);
void RequestPlayerAvatar(boost::shared_ptr<SessionData> session);
void TimerRemoveGame(const boost::system::error_code &ec);
void TimerRemovePlayer(const boost::system::error_code &ec);