More work on report game function on server side.

This commit is contained in:
lotodore
2012-04-08 16:54:31 +00:00
parent c49abf215e
commit dbdd135bc7
7 changed files with 56 additions and 0 deletions
+6
View File
@@ -90,3 +90,9 @@ ServerDBGeneric::AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id /
{ {
m_ioService->post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &m_callback, requestId, replyId)); m_ioService->post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &m_callback, requestId, replyId));
} }
void
ServerDBGeneric::AsyncReportGame(unsigned requestId, unsigned replyId, DB_id */*creatorPlayerId*/, unsigned /*gameId*/, const std::string &/*gameName*/, DB_id */*byPlayerId*/)
{
m_ioService->post(boost::bind(&ServerDBCallback::ReportGameFailed, &m_callback, requestId, replyId));
}
+3
View File
@@ -47,6 +47,9 @@ public:
virtual void ReportAvatarSuccess(unsigned requestId, unsigned replyId) = 0; virtual void ReportAvatarSuccess(unsigned requestId, unsigned replyId) = 0;
virtual void ReportAvatarFailed(unsigned requestId, unsigned replyId) = 0; virtual void ReportAvatarFailed(unsigned requestId, unsigned replyId) = 0;
virtual void ReportGameSuccess(unsigned requestId, unsigned replyId) = 0;
virtual void ReportGameFailed(unsigned requestId, unsigned replyId) = 0;
}; };
#endif #endif
+1
View File
@@ -47,6 +47,7 @@ public:
virtual void EndGame(unsigned requestId); virtual void EndGame(unsigned requestId);
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId); virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
virtual void AsyncReportGame(unsigned requestId, unsigned replyId, DB_id *creatorPlayerId, unsigned gameId, const std::string &gameName, DB_id *byPlayerId);
private: private:
boost::shared_ptr<boost::asio::io_service> m_ioService; boost::shared_ptr<boost::asio::io_service> m_ioService;
+1
View File
@@ -47,6 +47,7 @@ public:
virtual void EndGame(unsigned requestId) = 0; virtual void EndGame(unsigned requestId) = 0;
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0; virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0;
virtual void AsyncReportGame(unsigned requestId, unsigned replyId, DB_id *creatorPlayerId, unsigned gameId, const std::string &gameName, DB_id *byPlayerId) = 0;
}; };
#endif #endif
+1
View File
@@ -45,6 +45,7 @@ public:
virtual void EndGame(unsigned /*requestId*/) {} virtual void EndGame(unsigned /*requestId*/) {}
virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {} virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {}
virtual void AsyncReportGame(unsigned /*requestId*/, unsigned /*replyId*/, DB_id */*creatorPlayerId*/, unsigned /*gameId*/, const std::string &/*gameName*/, DB_id */*byPlayerId*/) {}
}; };
#endif // _SERVERDBNOACTION_H_ #endif // _SERVERDBNOACTION_H_
+42
View File
@@ -178,6 +178,14 @@ public:
m_server.SendReportAvatarResult(requestId, replyId, false); m_server.SendReportAvatarResult(requestId, replyId, false);
} }
virtual void ReportGameSuccess(unsigned requestId, unsigned replyId) {
// TODO
}
virtual void ReportGameFailed(unsigned requestId, unsigned replyId) {
// TODO
}
private: private:
ServerLobbyThread &m_server; ServerLobbyThread &m_server;
}; };
@@ -1456,6 +1464,40 @@ ServerLobbyThread::HandleNetPacketRejectGameInvitation(boost::shared_ptr<Session
void void
ServerLobbyThread::HandleNetPacketReportGame(boost::shared_ptr<SessionData> session, const ReportGameMessage_t &report) ServerLobbyThread::HandleNetPacketReportGame(boost::shared_ptr<SessionData> session, const ReportGameMessage_t &report)
{ {
GameMap::iterator pos = m_gameMap.find(report.reportedGameId);
if (pos != m_gameMap.end() && session->GetPlayerData()) {
if (!IsGameReported(report.reportedGameId)) {
// Temporarily note that this game was reported.
// This prevents spamming of the game report.
AddReportedGame(report.reportedGameId);
boost::shared_ptr<ServerGame> tmpGame(pos->second);
unsigned creatorDBId = tmpGame->GetCreatorDBId();
unsigned reporterDBId = session->GetPlayerData()->GetDBId();
GetDatabase()->AsyncReportGame(
session->GetPlayerData()->GetUniqueId(),
tmpGame->GetId(),
creatorDBId != 0 ? &creatorDBId : NULL,
tmpGame->GetId(),
tmpGame->GetName(),
reporterDBId != 0 ? &reporterDBId : NULL
);
} else {
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
packet->GetMsg()->present = PokerTHMessage_PR_reportGameAckMessage;
ReportGameAckMessage_t *netReportAck = &packet->GetMsg()->choice.reportGameAckMessage;
netReportAck->reportedGameId = report.reportedGameId;
netReportAck->reportGameResult = reportGameResult_gameReportDuplicate;
GetSender().Send(session, packet);
}
} else {
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
packet->GetMsg()->present = PokerTHMessage_PR_reportGameAckMessage;
ReportGameAckMessage_t *netReportAck = &packet->GetMsg()->choice.reportGameAckMessage;
netReportAck->reportedGameId = report.reportedGameId;
netReportAck->reportGameResult = reportGameResult_gameReportInvalid;
GetSender().Send(session, packet);
}
} }
void void
+2
View File
@@ -154,6 +154,8 @@ protected:
void UserValid(unsigned playerId, const DBPlayerData &dbPlayerData); void UserValid(unsigned playerId, const DBPlayerData &dbPlayerData);
void UserInvalid(unsigned playerId); void UserInvalid(unsigned playerId);
void UserBlocked(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 SendReportAvatarResult(unsigned byPlayerId, unsigned reportedPlayerId, bool success);
void RequestPlayerAvatar(boost::shared_ptr<SessionData> session); void RequestPlayerAvatar(boost::shared_ptr<SessionData> session);