No longer use database game id, because it may not exist yet (related to issue #14)

This commit is contained in:
lotodore
2011-03-20 22:38:03 +00:00
parent 6ccd1d0d0e
commit 979f079a57
9 changed files with 19 additions and 47 deletions
+8 -22
View File
@@ -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();
}
+2 -10
View File
@@ -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()
{
-4
View File
@@ -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;
-2
View File
@@ -99,8 +99,6 @@ public:
u_int32_t GetNextGameId();
ServerCallback &GetCallback();
void SetGameDBId(u_int32_t gameId, DB_id gameDBId);
AvatarManager &GetAvatarManager();
ChatCleanerManager &GetChatCleaner();