mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
fix(Core): Memleaks fixes - Part II. (#5760)
This commit is contained in:
@@ -205,6 +205,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
// Chat channel handling
|
||||
PrepareStatement(CHAR_INS_CHANNEL, "INSERT INTO channels(channelId, name, team, announce, lastUsed) VALUES (?, ?, ?, ?, UNIX_TIMESTAMP())", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_CHANNEL, "UPDATE channels SET announce = ?, password = ?, lastUsed = UNIX_TIMESTAMP() WHERE channelId = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_CHANNEL, "DELETE FROM channels WHERE name = ? AND team = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_CHANNEL_USAGE, "UPDATE channels SET lastUsed = UNIX_TIMESTAMP() WHERE channelId = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_OLD_CHANNELS, "DELETE FROM channels WHERE lastUsed + ? < UNIX_TIMESTAMP()", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_OLD_CHANNELS_BANS, "DELETE cb.* FROM channels_bans cb LEFT JOIN channels cn ON cb.channelId=cn.channelId WHERE cn.channelId IS NULL OR cb.banTime <= UNIX_TIMESTAMP()", CONNECTION_ASYNC);
|
||||
|
||||
@@ -184,6 +184,7 @@ enum CharacterDatabaseStatements
|
||||
|
||||
CHAR_INS_CHANNEL,
|
||||
CHAR_UPD_CHANNEL,
|
||||
CHAR_DEL_CHANNEL,
|
||||
CHAR_UPD_CHANNEL_USAGE,
|
||||
CHAR_DEL_OLD_CHANNELS,
|
||||
CHAR_DEL_OLD_CHANNELS_BANS,
|
||||
|
||||
@@ -2943,24 +2943,20 @@ void AchievementGlobalMgr::LoadRewardLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
std::string Subject = fields[2].GetString();
|
||||
std::string Text = fields[3].GetString();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
if (m_achievementRewards.find(ID) == m_achievementRewards.end())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `achievement_reward_locale` (Entry: %u) has locale strings for non-existing achievement reward.", ID);
|
||||
continue;
|
||||
}
|
||||
|
||||
AchievementRewardLocale& data = m_achievementRewardLocales[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
ObjectMgr::AddLocaleString(Subject, locale, data.Subject);
|
||||
ObjectMgr::AddLocaleString(Text, locale, data.Text);
|
||||
AchievementRewardLocale& data = m_achievementRewardLocales[ID];
|
||||
ObjectMgr::AddLocaleString(fields[2].GetString(), locale, data.Subject);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetString(), locale, data.Text);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %lu Achievement Reward Locale strings in %u ms", (unsigned long)m_achievementRewardLocales.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
|
||||
@@ -142,7 +142,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction&
|
||||
.SendMailTo(trans, MailReceiver(bidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED);
|
||||
}
|
||||
else
|
||||
sAuctionMgr->RemoveAItem(auction->item_guid, true);
|
||||
sAuctionMgr->RemoveAItem(auction->item_guid, true, &trans);
|
||||
}
|
||||
|
||||
void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry* auction, SQLTransaction& trans, bool sendMail)
|
||||
@@ -229,7 +229,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti
|
||||
.SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, 0);
|
||||
}
|
||||
else
|
||||
sAuctionMgr->RemoveAItem(auction->item_guid, true);
|
||||
sAuctionMgr->RemoveAItem(auction->item_guid, true, &trans);
|
||||
}
|
||||
|
||||
//this function sends mail to old bidder
|
||||
@@ -377,7 +377,7 @@ void AuctionHouseMgr::AddAItem(Item* it)
|
||||
mAitems[it->GetGUID()] = it;
|
||||
}
|
||||
|
||||
bool AuctionHouseMgr::RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB)
|
||||
bool AuctionHouseMgr::RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB, SQLTransaction* trans /*= nullptr*/)
|
||||
{
|
||||
ItemMap::iterator i = mAitems.find(itemGuid);
|
||||
if (i == mAitems.end())
|
||||
@@ -385,10 +385,9 @@ bool AuctionHouseMgr::RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB)
|
||||
|
||||
if (deleteFromDB)
|
||||
{
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
ASSERT(trans);
|
||||
i->second->FSetState(ITEM_REMOVED);
|
||||
i->second->SaveToDB(trans);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
i->second->SaveToDB(*trans);
|
||||
}
|
||||
|
||||
mAitems.erase(i);
|
||||
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
void LoadAuctions();
|
||||
|
||||
void AddAItem(Item* it);
|
||||
bool RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB = false);
|
||||
bool RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB = false, SQLTransaction* trans = nullptr);
|
||||
|
||||
void Update();
|
||||
|
||||
|
||||
@@ -461,10 +461,8 @@ void Battlefield::BroadcastPacketToWar(WorldPacket& data) const
|
||||
|
||||
void Battlefield::SendWarningToAllInZone(uint32 entry)
|
||||
{
|
||||
if (Map* map = sMapMgr->CreateBaseMap(m_MapId))
|
||||
if (Unit* unit = map->GetCreature(StalkerGuid))
|
||||
if (Creature* stalker = unit->ToCreature())
|
||||
sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE);
|
||||
if (Creature* stalker = GetCreature(StalkerGuid))
|
||||
sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE);
|
||||
}
|
||||
|
||||
void Battlefield::SendWarningToPlayer(Player* player, uint32 entry)
|
||||
@@ -814,6 +812,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
|
||||
|
||||
// Set creature in world
|
||||
map->AddToMap(creature);
|
||||
creature->setActive(true);
|
||||
|
||||
return creature;
|
||||
}
|
||||
@@ -822,7 +821,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
|
||||
GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z, float o)
|
||||
{
|
||||
// Get map object
|
||||
Map* map = sMapMgr->CreateBaseMap(571); // *vomits*
|
||||
Map* map = sMapMgr->CreateBaseMap(m_MapId);
|
||||
if (!map)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -39,28 +39,42 @@ void ChannelMgr::LoadChannels()
|
||||
uint32 count = 0;
|
||||
|
||||
// 0 1 2 3 4 5
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT channelId, name, team, announce, ownership, password FROM channels WHERE team = %u ORDER BY channelId ASC", _teamId);
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT channelId, name, team, announce, ownership, password FROM channels ORDER BY channelId ASC");
|
||||
if (!result)
|
||||
{
|
||||
LOG_INFO("server", ">> Loaded 0 channels for %s", _teamId == TEAM_ALLIANCE ? "Alliance" : "Horde");
|
||||
LOG_INFO("server", ">> Loaded 0 channels. DB table `channels` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, uint32>> toDelete;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
if (!fields)
|
||||
break;
|
||||
|
||||
uint32 channelDBId = fields[0].GetUInt32();
|
||||
std::string channelName = fields[1].GetString();
|
||||
TeamId team = TeamId(fields[2].GetUInt32());
|
||||
std::string password = fields[5].GetString();
|
||||
std::wstring channelWName;
|
||||
Utf8toWStr(channelName, channelWName);
|
||||
|
||||
Channel* newChannel = new Channel(channelName, 0, channelDBId, TeamId(fields[2].GetUInt32()), fields[3].GetUInt8(), fields[4].GetUInt8());
|
||||
std::wstring channelWName;
|
||||
if (!Utf8toWStr(channelName, channelWName))
|
||||
{
|
||||
LOG_ERROR("server", "Failed to load channel '%s' from database - invalid utf8 sequence? Deleted.", channelName.c_str());
|
||||
toDelete.push_back({ channelName, team });
|
||||
continue;
|
||||
}
|
||||
|
||||
ChannelMgr* mgr = forTeam(team);
|
||||
if (!mgr)
|
||||
{
|
||||
LOG_ERROR("server", "Failed to load custom chat channel '%s' from database - invalid team %u. Deleted.", channelName.c_str(), team);
|
||||
toDelete.push_back({ channelName, team });
|
||||
continue;
|
||||
}
|
||||
|
||||
Channel* newChannel = new Channel(channelName, 0, channelDBId, team, fields[3].GetUInt8(), fields[4].GetUInt8());
|
||||
newChannel->SetPassword(password);
|
||||
channels[channelWName] = newChannel;
|
||||
mgr->channels[channelWName] = newChannel;
|
||||
|
||||
if (QueryResult banResult = CharacterDatabase.PQuery("SELECT playerGUID, banTime FROM channels_bans WHERE channelId = %u", channelDBId))
|
||||
{
|
||||
@@ -78,7 +92,15 @@ void ChannelMgr::LoadChannels()
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u channels for %s in %ums", count, _teamId == TEAM_ALLIANCE ? "Alliance" : "Horde", GetMSTimeDiffToNow(oldMSTime));
|
||||
for (auto pair : toDelete)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHANNEL);
|
||||
stmt->setString(0, pair.first);
|
||||
stmt->setUInt32(1, pair.second);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u channels in %ums", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server", " ");
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
Channel* GetJoinChannel(std::string const& name, uint32 channel_id);
|
||||
Channel* GetChannel(std::string const& name, Player* p, bool pkt = true);
|
||||
void LoadChannels();
|
||||
static void LoadChannels();
|
||||
|
||||
static void LoadChannelRights();
|
||||
static const ChannelRights& GetChannelRightsFor(const std::string& name);
|
||||
|
||||
@@ -19253,7 +19253,6 @@ void Player::_LoadMailedItems(Mail* mail)
|
||||
}
|
||||
|
||||
Item* item = NewItemOrBag(proto);
|
||||
|
||||
if (!item->LoadFromDB(itemGuid, ObjectGuid::Create<HighGuid::Player>(fields[13].GetUInt32()), fields, itemTemplate))
|
||||
{
|
||||
LOG_ERROR("server", "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, itemGuid);
|
||||
@@ -19319,6 +19318,13 @@ void Player::_LoadMail()
|
||||
itr = GetMailBegin();
|
||||
}
|
||||
|
||||
// Delete mailed items aswell
|
||||
// Created again below in Player::_LoadMailedItems
|
||||
for (ItemMap::iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter)
|
||||
delete iter->second;
|
||||
|
||||
mMitems.clear();
|
||||
|
||||
//Now load the new ones
|
||||
m_mailCache.clear();
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL);
|
||||
|
||||
@@ -12688,11 +12688,11 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply,
|
||||
if (spellId == 0 && std::find_if(m_spellImmune[op].begin(), m_spellImmune[op].end(), spellIdImmunityPredicate(type)) != m_spellImmune[op].end())
|
||||
return;
|
||||
|
||||
SpellImmune Immune;
|
||||
Immune.spellId = spellId;
|
||||
Immune.type = type;
|
||||
Immune.blockType = blockType;
|
||||
m_spellImmune[op].push_back(Immune);
|
||||
SpellImmune immune;
|
||||
immune.spellId = spellId;
|
||||
immune.type = type;
|
||||
immune.blockType = blockType;
|
||||
m_spellImmune[op].push_back(std::move(immune));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -342,12 +342,14 @@ enum SpellImmuneBlockType
|
||||
|
||||
struct SpellImmune
|
||||
{
|
||||
SpellImmune() : spellId(0), type(IMMUNITY_EFFECT), blockType(SPELL_BLOCK_TYPE_ALL) { }
|
||||
|
||||
uint32 spellId;
|
||||
uint32 type : 16;
|
||||
uint32 blockType : 16;
|
||||
uint32 type;
|
||||
uint32 blockType;
|
||||
};
|
||||
|
||||
typedef std::list<SpellImmune> SpellImmuneList;
|
||||
typedef std::vector<SpellImmune> SpellImmuneList;
|
||||
|
||||
enum UnitModifierType
|
||||
{
|
||||
|
||||
@@ -361,14 +361,14 @@ ObjectMgr* ObjectMgr::instance()
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data)
|
||||
void ObjectMgr::AddLocaleString(std::string&& s, LocaleConstant locale, StringVector& data)
|
||||
{
|
||||
if (!s.empty())
|
||||
{
|
||||
if (data.size() <= size_t(locale))
|
||||
data.resize(locale + 1);
|
||||
|
||||
data[locale] = s;
|
||||
data[locale] = std::move(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,18 +387,15 @@ void ObjectMgr::LoadCreatureLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
std::string Name = fields[2].GetString();
|
||||
std::string Title = fields[3].GetString();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
|
||||
CreatureLocale& data = _creatureLocaleStore[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AddLocaleString(Name, locale, data.Name);
|
||||
AddLocaleString(Title, locale, data.Title);
|
||||
CreatureLocale& data = _creatureLocaleStore[ID];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Name);
|
||||
AddLocaleString(fields[3].GetString(), locale, data.Title);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %lu Creature Locale strings in %u ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -420,20 +417,16 @@ void ObjectMgr::LoadGossipMenuItemsLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint16 MenuID = fields[0].GetUInt16();
|
||||
uint16 OptionID = fields[1].GetUInt16();
|
||||
std::string LocaleName = fields[2].GetString();
|
||||
uint16 MenuID = fields[0].GetUInt16();
|
||||
uint16 OptionID = fields[1].GetUInt16();
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[2].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
std::string OptionText = fields[3].GetString();
|
||||
std::string BoxText = fields[4].GetString();
|
||||
|
||||
GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[MAKE_PAIR32(MenuID, OptionID)];
|
||||
AddLocaleString(OptionText, locale, data.OptionText);
|
||||
AddLocaleString(BoxText, locale, data.BoxText);
|
||||
AddLocaleString(fields[3].GetString(), locale, data.OptionText);
|
||||
AddLocaleString(fields[4].GetString(), locale, data.BoxText);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u Gossip Menu Option Locale strings in %u ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -455,16 +448,14 @@ void ObjectMgr::LoadPointOfInterestLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
std::string Name = fields[2].GetString();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
|
||||
PointOfInterestLocale& data = _pointOfInterestLocaleStore[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AddLocaleString(Name, locale, data.Name);
|
||||
PointOfInterestLocale& data = _pointOfInterestLocaleStore[ID];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Name);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u Points Of Interest Locale strings in %u ms", (uint32)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -2380,18 +2371,15 @@ void ObjectMgr::LoadItemLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
std::string Name = fields[2].GetString();
|
||||
std::string Description = fields[3].GetString();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
|
||||
ItemLocale& data = _itemLocaleStore[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AddLocaleString(Name, locale, data.Name);
|
||||
AddLocaleString(Description, locale, data.Description);
|
||||
ItemLocale& data = _itemLocaleStore[ID];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Name);
|
||||
AddLocaleString(fields[3].GetString(), locale, data.Description);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u Item Locale strings in %u ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -3006,16 +2994,14 @@ void ObjectMgr::LoadItemSetNameLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
std::string Name = fields[2].GetString();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
|
||||
ItemSetNameLocale& data = _itemSetNameLocaleStore[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AddLocaleString(Name, locale, data.Name);
|
||||
ItemSetNameLocale& data = _itemSetNameLocaleStore[ID];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Name);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u Item Set Name Locale strings in %u ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -4737,14 +4723,13 @@ void ObjectMgr::LoadQuestLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
|
||||
QuestLocale& data = _questLocaleStore[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
QuestLocale& data = _questLocaleStore[ID];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Title);
|
||||
AddLocaleString(fields[3].GetString(), locale, data.Details);
|
||||
AddLocaleString(fields[4].GetString(), locale, data.Objectives);
|
||||
@@ -5362,14 +5347,14 @@ void ObjectMgr::LoadPageTextLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
std::string Text = fields[2].GetString();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
|
||||
PageTextLocale& data = _pageTextLocaleStore[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AddLocaleString(Text, locale, data.Text);
|
||||
PageTextLocale& data = _pageTextLocaleStore[ID];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Text);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u Page Text Locale strings in %u ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -5613,14 +5598,13 @@ void ObjectMgr::LoadNpcTextLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
|
||||
NpcTextLocale& data = _npcTextLocaleStore[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
NpcTextLocale& data = _npcTextLocaleStore[ID];
|
||||
for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i)
|
||||
{
|
||||
AddLocaleString(fields[2 + i * 2].GetString(), locale, data.Text_0[i]);
|
||||
@@ -6498,18 +6482,15 @@ void ObjectMgr::LoadGameObjectLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
std::string Name = fields[2].GetString();
|
||||
std::string CastBarCaption = fields[3].GetString();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
|
||||
GameObjectLocale& data = _gameObjectLocaleStore[ID];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AddLocaleString(Name, locale, data.Name);
|
||||
AddLocaleString(CastBarCaption, locale, data.CastBarCaption);
|
||||
GameObjectLocale& data = _gameObjectLocaleStore[ID];
|
||||
AddLocaleString(fields[2].GetString(), locale, data.Name);
|
||||
AddLocaleString(fields[3].GetString(), locale, data.CastBarCaption);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u Gameobject Locale strings in %u ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
@@ -8800,10 +8781,7 @@ void ObjectMgr::LoadBroadcastTextLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string LocaleName = fields[1].GetString();
|
||||
std::string MaleText = fields[2].GetString();
|
||||
std::string FemaleText = fields[3].GetString();
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
|
||||
BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
|
||||
if (bct == _broadcastTextStore.end())
|
||||
@@ -8812,12 +8790,12 @@ void ObjectMgr::LoadBroadcastTextLocales()
|
||||
continue;
|
||||
}
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AddLocaleString(MaleText, locale, bct->second.MaleText);
|
||||
AddLocaleString(FemaleText, locale, bct->second.FemaleText);
|
||||
AddLocaleString(fields[2].GetString(), locale, bct->second.MaleText);
|
||||
AddLocaleString(fields[3].GetString(), locale, bct->second.FemaleText);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u Broadcast Text Locales in %u ms", uint32(_broadcastTextStore.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
|
||||
@@ -1326,7 +1326,7 @@ public:
|
||||
return _gossipMenuItemsStore.equal_range(uiMenuId);
|
||||
}
|
||||
|
||||
static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data);
|
||||
static void AddLocaleString(std::string&& s, LocaleConstant locale, StringVector& data);
|
||||
static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value)
|
||||
{
|
||||
if (data.size() > size_t(loc_idx) && !data[loc_idx].empty())
|
||||
|
||||
@@ -34,8 +34,8 @@ private:
|
||||
const uint32 m_savedMana;
|
||||
|
||||
public:
|
||||
LoadPetFromDBQueryHolder(uint32 petNumber, bool current, uint32 diffTime, std::string actionBar, uint32 health, uint32 mana)
|
||||
: m_petNumber(petNumber), m_current(current), m_diffTime(diffTime), m_actionBar(actionBar),
|
||||
LoadPetFromDBQueryHolder(uint32 petNumber, bool current, uint32 diffTime, std::string&& actionBar, uint32 health, uint32 mana)
|
||||
: m_petNumber(petNumber), m_current(current), m_diffTime(diffTime), m_actionBar(std::move(actionBar)),
|
||||
m_savedHealth(health), m_savedMana(mana) { }
|
||||
|
||||
uint32 GetPetNumber() const { return m_petNumber; }
|
||||
@@ -129,8 +129,14 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result,
|
||||
Map* map = owner->GetMap();
|
||||
ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>();
|
||||
Pet* pet = new Pet(owner, pet_type);
|
||||
if (!pet->Create(guid, map, owner->GetPhaseMask(), petentry, pet_number))
|
||||
{
|
||||
delete pet;
|
||||
return PET_LOAD_ERROR;
|
||||
}
|
||||
|
||||
LoadPetFromDBQueryHolder* holder = new LoadPetFromDBQueryHolder(pet_number, current, uint32(time(nullptr) - fields[14].GetUInt32()), fields[13].GetString(), savedhealth, savedmana);
|
||||
if (!pet->Create(guid, map, owner->GetPhaseMask(), petentry, pet_number) || !holder->Initialize())
|
||||
if (!holder->Initialize())
|
||||
{
|
||||
delete pet;
|
||||
delete holder;
|
||||
|
||||
@@ -130,7 +130,7 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
|
||||
}
|
||||
|
||||
if (!i_path || moveToward != _movingTowards)
|
||||
i_path = new PathGenerator(owner);
|
||||
i_path = std::make_unique<PathGenerator>(owner);
|
||||
|
||||
float x, y, z;
|
||||
bool shortenPath;
|
||||
@@ -188,6 +188,7 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
|
||||
template<>
|
||||
void ChaseMovementGenerator<Player>::DoInitialize(Player* owner)
|
||||
{
|
||||
i_path = nullptr;
|
||||
_lastTargetPosition.reset();
|
||||
owner->AddUnitState(UNIT_STATE_CHASE);
|
||||
}
|
||||
@@ -195,6 +196,7 @@ void ChaseMovementGenerator<Player>::DoInitialize(Player* owner)
|
||||
template<>
|
||||
void ChaseMovementGenerator<Creature>::DoInitialize(Creature* owner)
|
||||
{
|
||||
i_path = nullptr;
|
||||
_lastTargetPosition.reset();
|
||||
owner->SetWalk(false);
|
||||
owner->AddUnitState(UNIT_STATE_CHASE);
|
||||
@@ -305,7 +307,7 @@ bool FollowMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
|
||||
return true;
|
||||
|
||||
if (!i_path)
|
||||
i_path = new PathGenerator(owner);
|
||||
i_path = std::make_unique<PathGenerator>(owner);
|
||||
|
||||
float x, y, z;
|
||||
// select angle
|
||||
@@ -376,6 +378,7 @@ void FollowMovementGenerator<Creature>::_updateSpeed(Creature* owner)
|
||||
template<class T>
|
||||
void FollowMovementGenerator<T>::DoInitialize(T* owner)
|
||||
{
|
||||
i_path = nullptr;
|
||||
_lastTargetPosition.reset();
|
||||
owner->AddUnitState(UNIT_STATE_FOLLOW);
|
||||
_updateSpeed(owner);
|
||||
|
||||
@@ -29,7 +29,7 @@ class ChaseMovementGenerator : public MovementGeneratorMedium<T, ChaseMovementGe
|
||||
public:
|
||||
ChaseMovementGenerator(Unit* target, std::optional<ChaseRange> range = {}, std::optional<ChaseAngle> angle = {})
|
||||
: TargetedMovementGeneratorBase(target), i_path(nullptr), i_recheckDistance(0), i_recalculateTravel(true), _range(range), _angle(angle) {}
|
||||
~ChaseMovementGenerator() { delete i_path; }
|
||||
~ChaseMovementGenerator() { }
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() { return CHASE_MOTION_TYPE; }
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
bool HasLostTarget(Unit* unit) const { return unit->GetVictim() != this->GetTarget(); }
|
||||
|
||||
private:
|
||||
PathGenerator* i_path;
|
||||
std::unique_ptr<PathGenerator> i_path;
|
||||
TimeTrackerSmall i_recheckDistance;
|
||||
bool i_recalculateTravel;
|
||||
|
||||
@@ -65,7 +65,7 @@ class FollowMovementGenerator : public MovementGeneratorMedium<T, FollowMovement
|
||||
public:
|
||||
FollowMovementGenerator(Unit* target, float range, ChaseAngle angle)
|
||||
: TargetedMovementGeneratorBase(target), i_path(nullptr), i_recheckDistance(0), i_recalculateTravel(true), _range(range), _angle(angle) {}
|
||||
~FollowMovementGenerator() { delete i_path; }
|
||||
~FollowMovementGenerator() { }
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() { return FOLLOW_MOTION_TYPE; }
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
void _updateSpeed(T* owner);
|
||||
|
||||
private:
|
||||
PathGenerator* i_path;
|
||||
std::unique_ptr<PathGenerator> i_path;
|
||||
TimeTrackerSmall i_recheckDistance;
|
||||
bool i_recalculateTravel;
|
||||
|
||||
|
||||
@@ -1308,6 +1308,9 @@ void WorldSession::ProcessQueryCallbackPet()
|
||||
Player* player = GetPlayer();
|
||||
if (!player)
|
||||
{
|
||||
SQLQueryHolder* param;
|
||||
_loadPetFromDBSecondCallback.get(param);
|
||||
delete param;
|
||||
_loadPetFromDBSecondCallback.cancel();
|
||||
}
|
||||
else if (!player->IsInWorld())
|
||||
|
||||
@@ -174,15 +174,13 @@ void CreatureTextMgr::LoadCreatureTextLocales()
|
||||
uint32 CreatureId = fields[0].GetUInt32();
|
||||
uint32 GroupId = fields[1].GetUInt8();
|
||||
uint32 ID = fields[2].GetUInt8();
|
||||
std::string LocaleName = fields[3].GetString();
|
||||
std::string Text = fields[4].GetString();
|
||||
|
||||
CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(CreatureId, GroupId, ID)];
|
||||
LocaleConstant locale = GetLocaleByName(LocaleName);
|
||||
LocaleConstant locale = GetLocaleByName(fields[3].GetString());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
ObjectMgr::AddLocaleString(Text, locale, data.Text);
|
||||
CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(CreatureId, GroupId, ID)];
|
||||
ObjectMgr::AddLocaleString(fields[4].GetString(), locale, data.Text);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server", ">> Loaded %u Creature Text Locale in %u ms", uint32(mLocaleTextMap.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
|
||||
@@ -2039,10 +2039,7 @@ void World::SetInitialWorldSettings()
|
||||
ChannelMgr::LoadChannelRights();
|
||||
|
||||
LOG_INFO("server", "Load Channels...");
|
||||
ChannelMgr* mgr = ChannelMgr::forTeam(TEAM_ALLIANCE);
|
||||
mgr->LoadChannels();
|
||||
mgr = ChannelMgr::forTeam(TEAM_HORDE);
|
||||
mgr->LoadChannels();
|
||||
ChannelMgr::LoadChannels();
|
||||
|
||||
#ifdef ELUNA
|
||||
///- Run eluna scripts.
|
||||
|
||||
Reference in New Issue
Block a user