No longer use database game id, because it may not exist yet (related to issue #14)
This commit is contained in:
@@ -77,12 +77,12 @@ ServerDBGeneric::AsyncCreateGame(unsigned requestId, const string &/*gameName*/)
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBGeneric::SetGamePlayerPlace(DB_id /*gameId*/, DB_id /*playerId*/, unsigned /*place*/)
|
||||
ServerDBGeneric::SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBGeneric::EndGame(DB_id /*gameId*/)
|
||||
ServerDBGeneric::EndGame(unsigned /*requestId*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
virtual void AvatarIsBlacklisted(unsigned requestId) = 0;
|
||||
virtual void AvatarIsOK(unsigned requestId) = 0;
|
||||
|
||||
virtual void CreateGameSuccess(unsigned requestId, DB_id gameId) = 0;
|
||||
virtual void CreateGameSuccess(unsigned requestId) = 0;
|
||||
virtual void CreateGameFailed(unsigned requestId) = 0;
|
||||
|
||||
virtual void ReportAvatarSuccess(unsigned requestId, unsigned replyId) = 0;
|
||||
|
||||
@@ -44,8 +44,8 @@ public:
|
||||
virtual void PlayerLogout(DB_id playerId);
|
||||
|
||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
||||
virtual void SetGamePlayerPlace(DB_id gameId, DB_id playerId, unsigned place);
|
||||
virtual void EndGame(DB_id gameId);
|
||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
||||
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);
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ public:
|
||||
virtual void PlayerLogout(DB_id playerId) = 0;
|
||||
|
||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0;
|
||||
virtual void SetGamePlayerPlace(DB_id gameId, DB_id playerId, unsigned place) = 0;
|
||||
virtual void EndGame(DB_id gameId) = 0;
|
||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 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;
|
||||
};
|
||||
|
||||
@@ -42,8 +42,8 @@ public:
|
||||
virtual void PlayerLogout(DB_id /*playerId*/) {}
|
||||
|
||||
virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {}
|
||||
virtual void SetGamePlayerPlace(DB_id /*gameId*/, DB_id /*playerId*/, unsigned /*place*/) {}
|
||||
virtual void EndGame(DB_id /*gameId*/) {}
|
||||
virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {}
|
||||
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*/) {}
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ static bool LessThanPlayerHandStartMoney(const boost::shared_ptr<PlayerInterface
|
||||
|
||||
ServerGame::ServerGame(boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32_t id, const string &name, const string &pwd, const GameData &gameData, unsigned adminPlayerId, GuiInterface &gui, ConfigFile &playerConfig, Log &serverLog)
|
||||
: m_adminPlayerId(adminPlayerId), m_lobbyThread(lobbyThread), m_gui(gui),
|
||||
m_gameData(gameData), m_curState(NULL), m_id(id), m_dbId(DB_ID_INVALID), m_name(name),
|
||||
m_gameData(gameData), m_curState(NULL), m_id(id), m_name(name),
|
||||
m_password(pwd), m_playerConfig(playerConfig), m_serverLog(serverLog), m_gameNum(1),
|
||||
m_curPetitionId(1), m_doNotAutoKickSmallDelaySec(10), m_voteKickTimer(lobbyThread->GetIOService()),
|
||||
m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService())
|
||||
@@ -89,18 +89,6 @@ ServerGame::GetName() const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
DB_id
|
||||
ServerGame::GetDBId() const
|
||||
{
|
||||
return m_dbId;
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::SetDBId(DB_id newId)
|
||||
{
|
||||
m_dbId = newId;
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::AddSession(boost::shared_ptr<SessionData> session)
|
||||
{
|
||||
@@ -351,17 +339,15 @@ void
|
||||
ServerGame::StoreAndResetRanking()
|
||||
{
|
||||
// Store players in database.
|
||||
if (GetDBId() != DB_ID_INVALID) {
|
||||
RankingMap::const_iterator i = m_rankingMap.begin();
|
||||
RankingMap::const_iterator end = m_rankingMap.end();
|
||||
while (i != end) {
|
||||
if ((*i).second.dbid != DB_ID_INVALID) {
|
||||
GetDatabase().SetGamePlayerPlace(GetDBId(), (*i).second.dbid, (*i).second.place);
|
||||
}
|
||||
++i;
|
||||
RankingMap::const_iterator i = m_rankingMap.begin();
|
||||
RankingMap::const_iterator end = m_rankingMap.end();
|
||||
while (i != end) {
|
||||
if ((*i).second.dbid != DB_ID_INVALID) {
|
||||
GetDatabase().SetGamePlayerPlace(GetId(), (*i).second.dbid, (*i).second.place);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
GetDatabase().EndGame(GetDBId());
|
||||
GetDatabase().EndGame(GetId());
|
||||
m_rankingMap.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -150,8 +150,8 @@ public:
|
||||
m_server.AvatarOK(requestId);
|
||||
}
|
||||
|
||||
virtual void CreateGameSuccess(unsigned requestId, DB_id gameId) {
|
||||
m_server.SetGameDBId((u_int32_t)requestId, gameId);
|
||||
virtual void CreateGameSuccess(unsigned /*requestId*/) {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
virtual void CreateGameFailed(unsigned requestId) {
|
||||
@@ -2054,14 +2054,6 @@ ServerLobbyThread::GetCallback()
|
||||
return m_gui;
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::SetGameDBId(u_int32_t gameId, DB_id gameDBId)
|
||||
{
|
||||
boost::shared_ptr<ServerGame> game = InternalGetGameFromId(gameId);
|
||||
if (game)
|
||||
game->SetDBId(gameDBId);
|
||||
}
|
||||
|
||||
ServerIrcBotCallback &
|
||||
ServerLobbyThread::GetIrcBotCallback()
|
||||
{
|
||||
|
||||
@@ -52,9 +52,6 @@ public:
|
||||
u_int32_t GetId() const;
|
||||
const std::string &GetName() const;
|
||||
|
||||
DB_id GetDBId() const;
|
||||
void SetDBId(DB_id newId);
|
||||
|
||||
void AddSession(boost::shared_ptr<SessionData> session);
|
||||
void RemovePlayer(unsigned playerId, unsigned errorCode);
|
||||
|
||||
@@ -193,7 +190,6 @@ private:
|
||||
ServerGameState *m_curState;
|
||||
|
||||
const u_int32_t m_id;
|
||||
DB_id m_dbId;
|
||||
const std::string m_name;
|
||||
const std::string m_password;
|
||||
ConfigFile &m_playerConfig;
|
||||
|
||||
@@ -99,8 +99,6 @@ public:
|
||||
u_int32_t GetNextGameId();
|
||||
ServerCallback &GetCallback();
|
||||
|
||||
void SetGameDBId(u_int32_t gameId, DB_id gameDBId);
|
||||
|
||||
AvatarManager &GetAvatarManager();
|
||||
ChatCleanerManager &GetChatCleaner();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user