diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index d06e44253..9449e4f6e 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -201,16 +201,13 @@ BattleGround::~BattleGround() // (this is done automatically in mapmanager update, when the instance is reset after the reset time) int size = m_BgCreatures.size(); for(int i = 0; i < size; ++i) - { DelCreature(i); - } + size = m_BgObjects.size(); for(int i = 0; i < size; ++i) - { DelObject(i); - } - if(GetInstanceID()) // not spam by useless queries in case BG templates + if (GetInstanceID()) // not spam by useless queries in case BG templates { // delete creature and go respawn times WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'",GetInstanceID()); @@ -227,6 +224,9 @@ BattleGround::~BattleGround() ((BattleGroundMap*)map)->SetUnload(); // remove from bg free slot queue this->RemoveFromBGFreeSlotQueue(); + + for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) + delete itr->second; } void BattleGround::Update(uint32 diff) @@ -939,7 +939,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac participant = true; } - std::map::iterator itr2 = m_PlayerScores.find(guid); + BattleGroundScoreMap::iterator itr2 = m_PlayerScores.find(guid); if (itr2 != m_PlayerScores.end()) { delete itr2->second; // delete player's score @@ -1081,6 +1081,9 @@ void BattleGround::Reset() m_InBGFreeSlotQueue = false; m_Players.clear(); + + for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) + delete itr->second; m_PlayerScores.clear(); } @@ -1271,7 +1274,7 @@ bool BattleGround::HasFreeSlots() const void BattleGround::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) { //this procedure is called from virtual function implemented in bg subclass - std::map::const_iterator itr = m_PlayerScores.find(Source->GetGUID()); + BattleGroundScoreMap::const_iterator itr = m_PlayerScores.find(Source->GetGUID()); if(itr == m_PlayerScores.end()) // player not found... return; diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index fd6039515..3ba5a238f 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -374,8 +374,9 @@ class BattleGround BattleGroundPlayerMap const& GetPlayers() const { return m_Players; } uint32 GetPlayersSize() const { return m_Players.size(); } - std::map::const_iterator GetPlayerScoresBegin() const { return m_PlayerScores.begin(); } - std::map::const_iterator GetPlayerScoresEnd() const { return m_PlayerScores.end(); } + typedef std::map BattleGroundScoreMap; + BattleGroundScoreMap::const_iterator GetPlayerScoresBegin() const { return m_PlayerScores.begin(); } + BattleGroundScoreMap::const_iterator GetPlayerScoresEnd() const { return m_PlayerScores.end(); } uint32 GetPlayerScoresSize() const { return m_PlayerScores.size(); } uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); } @@ -512,8 +513,8 @@ class BattleGround void PlayerAddedToBGCheckIfBGIsRunning(Player* plr); /* Scorekeeping */ - // Player scores - std::map m_PlayerScores; + + BattleGroundScoreMap m_PlayerScores; // Player scores // must be implemented in BG subclass virtual void RemovePlayer(Player * /*player*/, uint64 /*guid*/) {} diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp index 1a5d4a283..7e27972ff 100644 --- a/src/game/BattleGroundAB.cpp +++ b/src/game/BattleGroundAB.cpp @@ -659,8 +659,7 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player) void BattleGroundAB::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) { - std::map::iterator itr = m_PlayerScores.find(Source->GetGUID()); - + BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID()); if( itr == m_PlayerScores.end() ) // player not found... return; diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index 84789ce70..9a52e726f 100644 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -96,8 +96,7 @@ void BattleGroundAV::HandleAreaTrigger(Player *Source, uint32 Trigger) void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) { - std::map::iterator itr = m_PlayerScores.find(Source->GetGUID()); - + BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID()); if(itr == m_PlayerScores.end()) // player not found... return; diff --git a/src/game/BattleGroundBE.cpp b/src/game/BattleGroundBE.cpp index 111fff722..e15e360ba 100644 --- a/src/game/BattleGroundBE.cpp +++ b/src/game/BattleGroundBE.cpp @@ -180,8 +180,7 @@ bool BattleGroundBE::SetupBattleGround() void BattleGroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) { - std::map::iterator itr = m_PlayerScores.find(Source->GetGUID()); - + BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID()); if(itr == m_PlayerScores.end()) // player not found... return; diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp index 60bfaa70e..824a8dd99 100644 --- a/src/game/BattleGroundEY.cpp +++ b/src/game/BattleGroundEY.cpp @@ -778,8 +778,7 @@ void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, uint32 BgObjectType void BattleGroundEY::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) { - std::map::iterator itr = m_PlayerScores.find(Source->GetGUID()); - + BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID()); if(itr == m_PlayerScores.end()) // player not found return; diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index df9276fe4..1a21e0aa7 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -1331,7 +1331,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg) *data << (int32)(bg->GetPlayerScoresSize()); - for(std::map::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr) + for(BattleGround::BattleGroundScoreMap::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr) { *data << (uint64)itr->first; *data << (int32)itr->second->KillingBlows; diff --git a/src/game/BattleGroundSA.cpp b/src/game/BattleGroundSA.cpp index c52635a04..20cadac93 100644 --- a/src/game/BattleGroundSA.cpp +++ b/src/game/BattleGroundSA.cpp @@ -72,8 +72,7 @@ void BattleGroundSA::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/) void BattleGroundSA::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) { - std::map::iterator itr = m_PlayerScores.find(Source->GetGUID()); - + BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID()); if(itr == m_PlayerScores.end()) // player not found... return; diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index 5f6fb4b2c..312735654 100644 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -631,8 +631,7 @@ void BattleGroundWS::HandleKillPlayer(Player *player, Player *killer) void BattleGroundWS::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) { - std::map::iterator itr = m_PlayerScores.find(Source->GetGUID()); - + BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID()); if(itr == m_PlayerScores.end()) // player not found return; diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index 3ed40ad3d..ccfe5b9d1 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -808,17 +808,17 @@ void Guild::DisplayGuildEventlog(WorldSession *session) for (GuildEventlog::const_iterator itr = m_GuildEventlog.begin(); itr != m_GuildEventlog.end(); ++itr) { // Event type - data << uint8((*itr)->EventType); + data << uint8(itr->EventType); // Player 1 - data << uint64((*itr)->PlayerGuid1); + data << uint64(itr->PlayerGuid1); // Player 2 not for left/join guild events - if( (*itr)->EventType != GUILD_EVENT_LOG_JOIN_GUILD && (*itr)->EventType != GUILD_EVENT_LOG_LEAVE_GUILD ) - data << uint64((*itr)->PlayerGuid2); + if (itr->EventType != GUILD_EVENT_LOG_JOIN_GUILD && itr->EventType != GUILD_EVENT_LOG_LEAVE_GUILD) + data << uint64(itr->PlayerGuid2); // New Rank - only for promote/demote guild events - if( (*itr)->EventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || (*itr)->EventType == GUILD_EVENT_LOG_DEMOTE_PLAYER ) - data << uint8((*itr)->NewRank); + if (itr->EventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || itr->EventType == GUILD_EVENT_LOG_DEMOTE_PLAYER) + data << uint8(itr->NewRank); // Event timestamp - data << uint32(time(NULL)-(*itr)->TimeStamp); + data << uint32(time(NULL)-itr->TimeStamp); } session->SendPacket(&data); sLog.outDebug("WORLD: Sent (MSG_GUILD_EVENT_LOG_QUERY)"); @@ -837,14 +837,14 @@ void Guild::LoadGuildEventLogFromDB() do { Field *fields = result->Fetch(); - GuildEventlogEntry *NewEvent = new GuildEventlogEntry; + GuildEventlogEntry NewEvent; // Fill entry - NewEvent->LogGuid = fields[0].GetUInt32(); - NewEvent->EventType = fields[1].GetUInt8(); - NewEvent->PlayerGuid1 = fields[2].GetUInt32(); - NewEvent->PlayerGuid2 = fields[3].GetUInt32(); - NewEvent->NewRank = fields[4].GetUInt8(); - NewEvent->TimeStamp = fields[5].GetUInt64(); + NewEvent.LogGuid = fields[0].GetUInt32(); + NewEvent.EventType = fields[1].GetUInt8(); + NewEvent.PlayerGuid1 = fields[2].GetUInt32(); + NewEvent.PlayerGuid2 = fields[3].GetUInt32(); + NewEvent.NewRank = fields[4].GetUInt8(); + NewEvent.TimeStamp = fields[5].GetUInt64(); // Add entry to map m_GuildEventlog.push_front(NewEvent); @@ -854,9 +854,8 @@ void Guild::LoadGuildEventLogFromDB() // Check lists size in case to many event entries in db // This cases can happen only if a crash occured somewhere and table has too many log entries if (!m_GuildEventlog.empty()) - { - CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid=%u AND LogGuid < %u", Id, m_GuildEventlog.front()->LogGuid); - } + CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid=%u AND LogGuid < %u", Id, m_GuildEventlog.front().LogGuid); + m_eventlogloaded = true; } @@ -865,16 +864,8 @@ void Guild::UnloadGuildEventlog() { if (!m_eventlogloaded) return; - GuildEventlogEntry *EventLogEntry; - if( !m_GuildEventlog.empty() ) - { - do - { - EventLogEntry = *(m_GuildEventlog.begin()); - m_GuildEventlog.pop_front(); - delete EventLogEntry; - }while( !m_GuildEventlog.empty() ); - } + + m_GuildEventlog.clear(); m_eventlogloaded = false; } @@ -894,27 +885,25 @@ void Guild::RenumGuildEventlog() // Add entry to guild eventlog void Guild::LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank) { - GuildEventlogEntry *NewEvent = new GuildEventlogEntry; + GuildEventlogEntry NewEvent; // Fill entry - NewEvent->LogGuid = GuildEventlogMaxGuid++; - NewEvent->EventType = EventType; - NewEvent->PlayerGuid1 = PlayerGuid1; - NewEvent->PlayerGuid2 = PlayerGuid2; - NewEvent->NewRank = NewRank; - NewEvent->TimeStamp = uint32(time(NULL)); + NewEvent.LogGuid = GuildEventlogMaxGuid++; + NewEvent.EventType = EventType; + NewEvent.PlayerGuid1 = PlayerGuid1; + NewEvent.PlayerGuid2 = PlayerGuid2; + NewEvent.NewRank = NewRank; + NewEvent.TimeStamp = uint32(time(NULL)); // Check max entry limit and delete from db if needed if (m_GuildEventlog.size() > GUILD_EVENTLOG_MAX_ENTRIES) { - GuildEventlogEntry *OldEvent = *(m_GuildEventlog.begin()); + CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, m_GuildEventlog.front().LogGuid); m_GuildEventlog.pop_front(); - CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); - delete OldEvent; } // Add entry to map m_GuildEventlog.push_back(NewEvent); // Add new eventlog entry into DB CharacterDatabase.PExecute("INSERT INTO guild_eventlog (guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','" UI64FMTD "')", - Id, NewEvent->LogGuid, uint32(NewEvent->EventType), NewEvent->PlayerGuid1, NewEvent->PlayerGuid2, uint32(NewEvent->NewRank), NewEvent->TimeStamp); + Id, NewEvent.LogGuid, uint32(NewEvent.EventType), NewEvent.PlayerGuid1, NewEvent.PlayerGuid2, uint32(NewEvent.NewRank), NewEvent.TimeStamp); } // ************************************************* @@ -1486,30 +1475,28 @@ void Guild::LoadGuildBankEventLogFromDB() do { Field *fields = result->Fetch(); - GuildBankEvent *NewEvent = new GuildBankEvent; + GuildBankEvent NewEvent; - NewEvent->LogGuid = fields[0].GetUInt32(); - NewEvent->LogEntry = fields[1].GetUInt8(); + NewEvent.LogGuid = fields[0].GetUInt32(); + NewEvent.LogEntry = fields[1].GetUInt8(); uint8 TabId = fields[2].GetUInt8(); - NewEvent->PlayerGuid = fields[3].GetUInt32(); - NewEvent->ItemOrMoney = fields[4].GetUInt32(); - NewEvent->ItemStackCount = fields[5].GetUInt8(); - NewEvent->DestTabId = fields[6].GetUInt8(); - NewEvent->TimeStamp = fields[7].GetUInt64(); + NewEvent.PlayerGuid = fields[3].GetUInt32(); + NewEvent.ItemOrMoney = fields[4].GetUInt32(); + NewEvent.ItemStackCount = fields[5].GetUInt8(); + NewEvent.DestTabId = fields[6].GetUInt8(); + NewEvent.TimeStamp = fields[7].GetUInt64(); if (TabId >= GUILD_BANK_MAX_TABS) { - sLog.outError( "Guild::LoadGuildBankEventLogFromDB: Invalid tabid '%u' for guild bank log entry (guild: '%s', LogGuid: %u), skipped.", TabId, GetName().c_str(), NewEvent->LogGuid); - delete NewEvent; + sLog.outError( "Guild::LoadGuildBankEventLogFromDB: Invalid tabid '%u' for guild bank log entry (guild: '%s', LogGuid: %u), skipped.", TabId, GetName().c_str(), NewEvent.LogGuid); continue; } - if (NewEvent->isMoneyEvent() && m_GuildBankEventLog_Money.size() >= GUILD_BANK_MAX_LOGS - || m_GuildBankEventLog_Item[TabId].size() >= GUILD_BANK_MAX_LOGS) - { - delete NewEvent; + + if (NewEvent.isMoneyEvent() && m_GuildBankEventLog_Money.size() >= GUILD_BANK_MAX_LOGS || + m_GuildBankEventLog_Item[TabId].size() >= GUILD_BANK_MAX_LOGS) continue; - } - if (NewEvent->isMoneyEvent()) + + if (NewEvent.isMoneyEvent()) m_GuildBankEventLog_Money.push_front(NewEvent); else m_GuildBankEventLog_Item[TabId].push_front(NewEvent); @@ -1522,43 +1509,24 @@ void Guild::LoadGuildBankEventLogFromDB() if (!m_GuildBankEventLog_Money.empty()) { CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid=%u AND LogGuid < %u", - Id, m_GuildBankEventLog_Money.front()->LogGuid); + Id, m_GuildBankEventLog_Money.front().LogGuid); } for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) { if (!m_GuildBankEventLog_Item[i].empty()) { CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid=%u AND LogGuid < %u", - Id, m_GuildBankEventLog_Item[i].front()->LogGuid); + Id, m_GuildBankEventLog_Item[i].front().LogGuid); } } } void Guild::UnloadGuildBankEventLog() { - GuildBankEvent *EventLogEntry; - if( !m_GuildBankEventLog_Money.empty() ) - { - do - { - EventLogEntry = *(m_GuildBankEventLog_Money.begin()); - m_GuildBankEventLog_Money.pop_front(); - delete EventLogEntry; - }while( !m_GuildBankEventLog_Money.empty() ); - } + m_GuildBankEventLog_Money.clear(); for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) - { - if( !m_GuildBankEventLog_Item[i].empty() ) - { - do - { - EventLogEntry = *(m_GuildBankEventLog_Item[i].begin()); - m_GuildBankEventLog_Item[i].pop_front(); - delete EventLogEntry; - }while( !m_GuildBankEventLog_Item[i].empty() ); - } - } + m_GuildBankEventLog_Item[i].clear(); } void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId) @@ -1574,24 +1542,24 @@ void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId) data << uint8(m_GuildBankEventLog_Money.size()); // number of log entries for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Money.begin(); itr != m_GuildBankEventLog_Money.end(); ++itr) { - data << uint8((*itr)->LogEntry); - data << uint64(MAKE_NEW_GUID((*itr)->PlayerGuid,0,HIGHGUID_PLAYER)); - if ((*itr)->LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY || - (*itr)->LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY || - (*itr)->LogEntry == GUILD_BANK_LOG_REPAIR_MONEY || - (*itr)->LogEntry == GUILD_BANK_LOG_UNK1 || - (*itr)->LogEntry == GUILD_BANK_LOG_UNK2) + data << uint8(itr->LogEntry); + data << uint64(MAKE_NEW_GUID(itr->PlayerGuid,0,HIGHGUID_PLAYER)); + if (itr->LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY || + itr->LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY || + itr->LogEntry == GUILD_BANK_LOG_REPAIR_MONEY || + itr->LogEntry == GUILD_BANK_LOG_UNK1 || + itr->LogEntry == GUILD_BANK_LOG_UNK2) { - data << uint32((*itr)->ItemOrMoney); + data << uint32(itr->ItemOrMoney); } else { - data << uint32((*itr)->ItemOrMoney); - data << uint32((*itr)->ItemStackCount); - if ((*itr)->LogEntry == GUILD_BANK_LOG_MOVE_ITEM || (*itr)->LogEntry == GUILD_BANK_LOG_MOVE_ITEM2) - data << uint8((*itr)->DestTabId); // moved tab + data << uint32(itr->ItemOrMoney); + data << uint32(itr->ItemStackCount); + if (itr->LogEntry == GUILD_BANK_LOG_MOVE_ITEM || itr->LogEntry == GUILD_BANK_LOG_MOVE_ITEM2) + data << uint8(itr->DestTabId); // moved tab } - data << uint32(time(NULL)-(*itr)->TimeStamp); + data << uint32(time(NULL) - itr->TimeStamp); } session->SendPacket(&data); } @@ -1604,24 +1572,24 @@ void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId) data << uint8(m_GuildBankEventLog_Item[TabId].size()); for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Item[TabId].begin(); itr != m_GuildBankEventLog_Item[TabId].end(); ++itr) { - data << uint8((*itr)->LogEntry); - data << uint64(MAKE_NEW_GUID((*itr)->PlayerGuid,0,HIGHGUID_PLAYER)); - if ((*itr)->LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY || - (*itr)->LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY || - (*itr)->LogEntry == GUILD_BANK_LOG_REPAIR_MONEY || - (*itr)->LogEntry == GUILD_BANK_LOG_UNK1 || - (*itr)->LogEntry == GUILD_BANK_LOG_UNK2) + data << uint8(itr->LogEntry); + data << uint64(MAKE_NEW_GUID(itr->PlayerGuid,0,HIGHGUID_PLAYER)); + if (itr->LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY || + itr->LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY || + itr->LogEntry == GUILD_BANK_LOG_REPAIR_MONEY || + itr->LogEntry == GUILD_BANK_LOG_UNK1 || + itr->LogEntry == GUILD_BANK_LOG_UNK2) { - data << uint32((*itr)->ItemOrMoney); + data << uint32(itr->ItemOrMoney); } else { - data << uint32((*itr)->ItemOrMoney); - data << uint32((*itr)->ItemStackCount); - if ((*itr)->LogEntry == GUILD_BANK_LOG_MOVE_ITEM || (*itr)->LogEntry == GUILD_BANK_LOG_MOVE_ITEM2) - data << uint8((*itr)->DestTabId); // moved tab + data << uint32(itr->ItemOrMoney); + data << uint32(itr->ItemStackCount); + if (itr->LogEntry == GUILD_BANK_LOG_MOVE_ITEM || itr->LogEntry == GUILD_BANK_LOG_MOVE_ITEM2) + data << uint8(itr->DestTabId); // moved tab } - data << uint32(time(NULL)-(*itr)->TimeStamp); + data << uint32(time(NULL) - itr->TimeStamp); } session->SendPacket(&data); } @@ -1630,24 +1598,23 @@ void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId) void Guild::LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount, uint8 DestTabId) { - GuildBankEvent *NewEvent = new GuildBankEvent; + GuildBankEvent NewEvent; - NewEvent->LogGuid = LogMaxGuid++; - NewEvent->LogEntry = LogEntry; - NewEvent->PlayerGuid = PlayerGuidLow; - NewEvent->ItemOrMoney = ItemOrMoney; - NewEvent->ItemStackCount = ItemStackCount; - NewEvent->DestTabId = DestTabId; - NewEvent->TimeStamp = uint32(time(NULL)); + NewEvent.LogGuid = LogMaxGuid++; + NewEvent.LogEntry = LogEntry; + NewEvent.PlayerGuid = PlayerGuidLow; + NewEvent.ItemOrMoney = ItemOrMoney; + NewEvent.ItemStackCount = ItemStackCount; + NewEvent.DestTabId = DestTabId; + NewEvent.TimeStamp = uint32(time(NULL)); - if (NewEvent->isMoneyEvent()) + if (NewEvent.isMoneyEvent()) { if (m_GuildBankEventLog_Money.size() > GUILD_BANK_MAX_LOGS) { - GuildBankEvent *OldEvent = *(m_GuildBankEventLog_Money.begin()); + CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", + Id, m_GuildBankEventLog_Money.front().LogGuid); m_GuildBankEventLog_Money.pop_front(); - CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); - delete OldEvent; } m_GuildBankEventLog_Money.push_back(NewEvent); } @@ -1655,15 +1622,14 @@ void Guild::LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint { if (m_GuildBankEventLog_Item[TabId].size() > GUILD_BANK_MAX_LOGS) { - GuildBankEvent *OldEvent = *(m_GuildBankEventLog_Item[TabId].begin()); + CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", + Id, m_GuildBankEventLog_Item[TabId].front().LogGuid); m_GuildBankEventLog_Item[TabId].pop_front(); - CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); - delete OldEvent; } m_GuildBankEventLog_Item[TabId].push_back(NewEvent); } CharacterDatabase.PExecute("INSERT INTO guild_bank_eventlog (guildid,LogGuid,LogEntry,TabId,PlayerGuid,ItemOrMoney,ItemStackCount,DestTabId,TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','%u','%u','" UI64FMTD "')", - Id, NewEvent->LogGuid, uint32(NewEvent->LogEntry), uint32(TabId), NewEvent->PlayerGuid, NewEvent->ItemOrMoney, uint32(NewEvent->ItemStackCount), uint32(NewEvent->DestTabId), NewEvent->TimeStamp); + Id, NewEvent.LogGuid, uint32(NewEvent.LogEntry), uint32(TabId), NewEvent.PlayerGuid, NewEvent.ItemOrMoney, uint32(NewEvent.ItemStackCount), uint32(NewEvent.DestTabId), NewEvent.TimeStamp); } // This will renum guids used at load to prevent always going up until infinit diff --git a/src/game/Guild.h b/src/game/Guild.h index d856ebea1..9794668ee 100644 --- a/src/game/Guild.h +++ b/src/game/Guild.h @@ -458,8 +458,8 @@ class Guild TabListMap m_TabListMap; /** These are actually ordered lists. The first element is the oldest entry.*/ - typedef std::list GuildEventlog; - typedef std::list GuildBankEventLog; + typedef std::list GuildEventlog; + typedef std::list GuildBankEventLog; GuildEventlog m_GuildEventlog; GuildBankEventLog m_GuildBankEventLog_Money; GuildBankEventLog m_GuildBankEventLog_Item[GUILD_BANK_MAX_TABS]; diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 17e35f973..58c220f8e 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -44,7 +44,11 @@ INSTANTIATE_SINGLETON_2(ObjectAccessor, CLASS_LOCK); INSTANTIATE_CLASS_MUTEX(ObjectAccessor, ACE_Thread_Mutex); ObjectAccessor::ObjectAccessor() {} -ObjectAccessor::~ObjectAccessor() {} +ObjectAccessor::~ObjectAccessor() +{ + for(Player2CorpsesMapType::const_iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); ++itr) + delete itr->second; +} Creature* ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const &u, uint64 guid) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 60d8fef78..54877f1c8 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -170,6 +170,9 @@ ObjectMgr::~ObjectMgr() for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr) delete itr->second; + for (ArenaTeamMap::iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr) + delete itr->second; + for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) itr->second.Clear(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 995276071..e592c6e2c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8314" + #define REVISION_NR "8315" #endif // __REVISION_NR_H__