aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp140
1 files changed, 73 insertions, 67 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 0b82a4b60c7..587e776ff74 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -282,14 +282,14 @@ ObjectMgr::~ObjectMgr()
delete itr->second;
}
-void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data)
+void ObjectMgr::AddLocaleString(std::string const& value, LocaleConstant localeConstant, StringVector& data)
{
- if (!s.empty())
+ if (!value.empty())
{
- if (data.size() <= size_t(locale))
- data.resize(locale + 1);
+ if (data.size() <= size_t(localeConstant))
+ data.resize(localeConstant + 1);
- data[locale] = s;
+ data[localeConstant] = value;
}
}
@@ -370,7 +370,8 @@ void ObjectMgr::LoadPointOfInterestLocales()
_pointOfInterestLocaleStore.clear(); // need for reload case
- QueryResult result = WorldDatabase.Query("SELECT entry, icon_name_loc1, icon_name_loc2, icon_name_loc3, icon_name_loc4, icon_name_loc5, icon_name_loc6, icon_name_loc7, icon_name_loc8 FROM locales_points_of_interest");
+ // 0 1 2
+ QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM points_of_interest_locale");
if (!result)
return;
@@ -379,12 +380,14 @@ void ObjectMgr::LoadPointOfInterestLocales()
{
Field* fields = result->Fetch();
- uint32 entry = fields[0].GetUInt32();
+ uint32 id = fields[0].GetUInt32();
+ std::string localeName = fields[1].GetString();
+ std::string name = fields[2].GetString();
- PointOfInterestLocale& data = _pointOfInterestLocaleStore[entry];
+ PointOfInterestLocale& data = _pointOfInterestLocaleStore[id];
+ LocaleConstant locale = GetLocaleByName(localeName);
- for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i)
- AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.IconName);
+ AddLocaleString(name, locale, data.Name);
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u points_of_interest locale strings in %u ms", uint32(_pointOfInterestLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
@@ -5252,10 +5255,10 @@ void ObjectMgr::LoadPageTexts()
{
Field* fields = result->Fetch();
- PageText& pageText = _pageTextStore[fields[0].GetUInt32()];
+ PageText& pageText = _pageTextStore[fields[0].GetUInt32()];
- pageText.Text = fields[1].GetString();
- pageText.NextPage = fields[2].GetUInt32();
+ pageText.Text = fields[1].GetString();
+ pageText.NextPageID = fields[2].GetUInt32();
++count;
}
@@ -5263,11 +5266,11 @@ void ObjectMgr::LoadPageTexts()
for (PageTextContainer::const_iterator itr = _pageTextStore.begin(); itr != _pageTextStore.end(); ++itr)
{
- if (itr->second.NextPage)
+ if (itr->second.NextPageID)
{
- PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPage);
+ PageTextContainer::const_iterator itr2 = _pageTextStore.find(itr->second.NextPageID);
if (itr2 == _pageTextStore.end())
- TC_LOG_ERROR("sql.sql", "Page text (Id: %u) has not existing next page (Id: %u)", itr->first, itr->second.NextPage);
+ TC_LOG_ERROR("sql.sql", "Page text (ID: %u) has non-existing `NextPageID` (%u)", itr->first, itr->second.NextPageID);
}
}
@@ -5290,7 +5293,8 @@ void ObjectMgr::LoadPageTextLocales()
_pageTextLocaleStore.clear(); // need for reload case
- QueryResult result = WorldDatabase.Query("SELECT entry, text_loc1, text_loc2, text_loc3, text_loc4, text_loc5, text_loc6, text_loc7, text_loc8 FROM locales_page_text");
+ // 0 1 2
+ QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale");
if (!result)
return;
@@ -5299,12 +5303,14 @@ void ObjectMgr::LoadPageTextLocales()
{
Field* fields = result->Fetch();
- uint32 entry = fields[0].GetUInt32();
+ uint32 id = fields[0].GetUInt32();
+ std::string localeName = fields[1].GetString();
+ std::string text = fields[2].GetString();
- PageTextLocale& data = _pageTextLocaleStore[entry];
+ PageTextLocale& data = _pageTextLocaleStore[id];
+ LocaleConstant locale = GetLocaleByName(localeName);
- for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i)
- AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Text);
+ AddLocaleString(text, locale, data.Text);
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u PageText locale strings in %u ms", uint32(_pageTextLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
@@ -7239,7 +7245,7 @@ void ObjectMgr::LoadPointsOfInterest()
uint32 count = 0;
// 0 1 2 3 4 5 6
- QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Data, Name FROM points_of_interest");
+ QueryResult result = WorldDatabase.Query("SELECT ID, PositionX, PositionY, Icon, Flags, Importance, Name FROM points_of_interest");
if (!result)
{
@@ -7251,24 +7257,24 @@ void ObjectMgr::LoadPointsOfInterest()
{
Field* fields = result->Fetch();
- uint32 point_id = fields[0].GetUInt32();
+ uint32 id = fields[0].GetUInt32();
- PointOfInterest POI;
- POI.entry = point_id;
- POI.x = fields[1].GetFloat();
- POI.y = fields[2].GetFloat();
- POI.icon = fields[3].GetUInt32();
- POI.flags = fields[4].GetUInt32();
- POI.data = fields[5].GetUInt32();
- POI.icon_name = fields[6].GetString();
+ PointOfInterest pointOfInterest;
+ pointOfInterest.ID = id;
+ pointOfInterest.PositionX = fields[1].GetFloat();
+ pointOfInterest.PositionY = fields[2].GetFloat();
+ pointOfInterest.Icon = fields[3].GetUInt32();
+ pointOfInterest.Flags = fields[4].GetUInt32();
+ pointOfInterest.Importance = fields[5].GetUInt32();
+ pointOfInterest.Name = fields[6].GetString();
- if (!Trinity::IsValidMapCoord(POI.x, POI.y))
+ if (!Trinity::IsValidMapCoord(pointOfInterest.PositionX, pointOfInterest.PositionY))
{
- TC_LOG_ERROR("sql.sql", "Table `points_of_interest` (Entry: %u) have invalid coordinates (X: %f Y: %f), ignored.", point_id, POI.x, POI.y);
+ TC_LOG_ERROR("sql.sql", "Table `points_of_interest` (ID: %u) have invalid coordinates (X: %f Y: %f), ignored.", id, pointOfInterest.PositionX, pointOfInterest.PositionY);
continue;
}
- _pointsOfInterestStore[point_id] = POI;
+ _pointsOfInterestStore[id] = pointOfInterest;
++count;
} while (result->NextRow());
@@ -8199,76 +8205,76 @@ void ObjectMgr::LoadMailLevelRewards()
TC_LOG_INFO("server.loading", ">> Loaded %u level dependent mail rewards in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
-void ObjectMgr::AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel)
+void ObjectMgr::AddSpellToTrainer(uint32 ID, uint32 SpellID, uint32 MoneyCost, uint32 ReqSkillLine, uint32 ReqSkillRank, uint32 ReqLevel)
{
- if (entry >= TRINITY_TRAINER_START_REF)
+ if (ID >= TRINITY_TRAINER_START_REF)
return;
- CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
+ CreatureTemplate const* cInfo = GetCreatureTemplate(ID);
if (!cInfo)
{
- TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains entries for a non-existing creature template (Entry: %u), ignoring", entry);
+ TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains entries for a non-existing creature template (ID: %u), ignoring", ID);
return;
}
if (!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER))
{
- TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains entries for a creature template (Entry: %u) without trainer flag, ignoring", entry);
+ TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains entries for a creature template (ID: %u) without trainer flag, ignoring", ID);
return;
}
- SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spell);
+ SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(SpellID);
if (!spellinfo)
{
- TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: %u) for a non-existing spell (Spell: %u), ignoring", entry, spell);
+ TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains an ID (%u) for a non-existing SpellID (%u), ignoring", ID, SpellID);
return;
}
if (!SpellMgr::IsSpellValid(spellinfo))
{
- TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: %u) for a broken spell (Spell: %u), ignoring", entry, spell);
+ TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains an ID (%u) for a broken SpellID (%u), ignoring", ID, SpellID);
return;
}
- if (GetTalentSpellCost(spell))
+ if (GetTalentSpellCost(SpellID))
{
- TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: %u) for a non-existing spell (Spell: %u) which is a talent, ignoring", entry, spell);
+ TC_LOG_ERROR("sql.sql", "Table `npc_trainer` contains an ID (%u) for a non-existing SpellID (%u) which is a talent, ignoring", ID, SpellID);
return;
}
- TrainerSpellData& data = _cacheTrainerSpellStore[entry];
+ TrainerSpellData& data = _cacheTrainerSpellStore[ID];
- TrainerSpell& trainerSpell = data.spellList[spell];
- trainerSpell.spell = spell;
- trainerSpell.spellCost = spellCost;
- trainerSpell.reqSkill = reqSkill;
- trainerSpell.reqSkillValue = reqSkillValue;
- trainerSpell.reqLevel = reqLevel;
+ TrainerSpell& trainerSpell = data.spellList[SpellID];
+ trainerSpell.SpellID = SpellID;
+ trainerSpell.MoneyCost = MoneyCost;
+ trainerSpell.ReqSkillLine = ReqSkillLine;
+ trainerSpell.ReqSkillRank = ReqSkillRank;
+ trainerSpell.ReqLevel = ReqLevel;
- if (!trainerSpell.reqLevel)
- trainerSpell.reqLevel = spellinfo->SpellLevel;
+ if (!trainerSpell.ReqLevel)
+ trainerSpell.ReqLevel = spellinfo->SpellLevel;
// calculate learned spell for profession case when stored cast-spell
- trainerSpell.learnedSpell[0] = spell;
+ trainerSpell.ReqAbility[0] = SpellID;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellinfo->Effects[i].Effect != SPELL_EFFECT_LEARN_SPELL)
continue;
- if (trainerSpell.learnedSpell[0] == spell)
- trainerSpell.learnedSpell[0] = 0;
+ if (trainerSpell.ReqAbility[0] == SpellID)
+ trainerSpell.ReqAbility[0] = 0;
// player must be able to cast spell on himself
if (spellinfo->Effects[i].TargetA.GetTarget() != 0 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ALLY
&& spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ANY && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_CASTER)
{
- TC_LOG_ERROR("sql.sql", "Table `npc_trainer` has spell %u for trainer entry %u with learn effect which has incorrect target type, ignoring learn effect!", spell, entry);
+ TC_LOG_ERROR("sql.sql", "Table `npc_trainer` has spell %u for trainer entry %u with learn effect which has incorrect target type, ignoring learn effect!", SpellID, ID);
continue;
}
- trainerSpell.learnedSpell[i] = spellinfo->Effects[i].TriggerSpell;
+ trainerSpell.ReqAbility[i] = spellinfo->Effects[i].TriggerSpell;
- if (trainerSpell.learnedSpell[i])
+ if (trainerSpell.ReqAbility[i])
{
- SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(trainerSpell.learnedSpell[i]);
+ SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(trainerSpell.ReqAbility[i]);
if (learnedSpellInfo && learnedSpellInfo->IsProfession())
data.trainerType = 2;
}
@@ -8301,14 +8307,14 @@ void ObjectMgr::LoadTrainerSpell()
{
Field* fields = result->Fetch();
- uint32 entry = fields[0].GetUInt32();
- uint32 spell = fields[1].GetUInt32();
- uint32 spellCost = fields[2].GetUInt32();
- uint32 reqSkill = fields[3].GetUInt16();
- uint32 reqSkillValue = fields[4].GetUInt16();
- uint32 reqLevel = fields[5].GetUInt8();
+ uint32 ID = fields[0].GetUInt32();
+ uint32 SpellID = fields[1].GetUInt32();
+ uint32 MoneyCost = fields[2].GetUInt32();
+ uint32 ReqSkillLine = fields[3].GetUInt16();
+ uint32 ReqSkillRank = fields[4].GetUInt16();
+ uint32 ReqLevel = fields[5].GetUInt8();
- AddSpellToTrainer(entry, spell, spellCost, reqSkill, reqSkillValue, reqLevel);
+ AddSpellToTrainer(ID, SpellID, MoneyCost, ReqSkillLine, ReqSkillRank, ReqLevel);
++count;
}