Core/DataStores: Port refactors from Update DBC field names to generated ones (#24999)

(cherry picked from commit c92950b3e1)
This commit is contained in:
Peter Keresztes Schmidt
2020-07-12 15:36:55 +02:00
committed by Shauren
parent b7353fb927
commit 1e1679a1f7
19 changed files with 53 additions and 59 deletions

View File

@@ -48,13 +48,13 @@ Channel::Channel(ObjectGuid const& guid, uint32 channelId, uint32 team /*= 0*/,
_zoneEntry(zoneEntry)
{
ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId);
if (channelEntry->Flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel
if (channelEntry->Flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel
_channelFlags |= CHANNEL_FLAG_TRADE;
if (channelEntry->Flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels
if (channelEntry->Flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels
_channelFlags |= CHANNEL_FLAG_CITY;
if (channelEntry->Flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel
if (channelEntry->Flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel
_channelFlags |= CHANNEL_FLAG_LFG;
else // for all other channels
_channelFlags |= CHANNEL_FLAG_NOT_LFG;

View File

@@ -495,9 +495,9 @@ struct LinkValidator<LinkTags::outfit>
template <>
struct LinkValidator<LinkTags::pvptal>
{
static bool IsTextValid(PvpTalentEntry const* mawPower, char const* pos, size_t len)
static bool IsTextValid(PvpTalentEntry const* pvpTalent, char const* pos, size_t len)
{
if (SpellInfo const* info = sSpellMgr->GetSpellInfo(mawPower->SpellID, DIFFICULTY_NONE))
if (SpellInfo const* info = sSpellMgr->GetSpellInfo(pvpTalent->SpellID, DIFFICULTY_NONE))
return LinkValidator<LinkTags::spell>::IsTextValid(info, pos, len);
return false;
}
@@ -511,9 +511,9 @@ struct LinkValidator<LinkTags::pvptal>
template <>
struct LinkValidator<LinkTags::talent>
{
static bool IsTextValid(TalentEntry const* mawPower, char const* pos, size_t len)
static bool IsTextValid(TalentEntry const* talent, char const* pos, size_t len)
{
if (SpellInfo const* info = sSpellMgr->GetSpellInfo(mawPower->SpellID, DIFFICULTY_NONE))
if (SpellInfo const* info = sSpellMgr->GetSpellInfo(talent->SpellID, DIFFICULTY_NONE))
return LinkValidator<LinkTags::spell>::IsTextValid(info, pos, len);
return false;
}

View File

@@ -1295,12 +1295,10 @@ uint32 Item::GetEnchantRequiredLevel() const
// Check all enchants for required level
for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
{
if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)))
if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id))
if (enchantEntry->MinLevel > level)
level = enchantEntry->MinLevel;
}
return level;
}

View File

@@ -2529,8 +2529,8 @@ ReputationRank WorldObject::GetReactionTo(WorldObject const* target) const
if (targetFactionEntry->CanHaveReputation())
{
// check contested flags
if (targetFactionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD
&& selfPlayerOwner->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
if ((targetFactionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) &&
selfPlayerOwner->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
return REP_HOSTILE;
// if faction has reputation, hostile state depends only from AtWar state
@@ -2562,8 +2562,8 @@ ReputationRank WorldObject::GetReactionTo(WorldObject const* target) const
if (Player const* targetPlayerOwner = target->GetAffectingPlayer())
{
// check contested flags
if (factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD
&& targetPlayerOwner->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
if ((factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) &&
targetPlayerOwner->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
return REP_HOSTILE;
if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(factionTemplateEntry))
return *repRank;

View File

@@ -6570,7 +6570,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
// [39+] Nothing
// this is all wrong, should be going off PvpTitle, not PlayerTitle
uint32 victim_title = plrVictim->m_playerData->PlayerTitle;
// Get Killer titles, CharTitlesEntry::bit_index
// Get Killer titles, CharTitlesEntry::MaskID
// Ranks:
// title[1..14] -> rank[5..18]
// title[15..28] -> rank[5..18]
@@ -8392,7 +8392,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT
if (!spellInfo)
{
TC_LOG_ERROR("entities.player.items", "Player::CastItemCombatSpell: Player '%s' (%s) cast unknown spell (EnchantID: %u, SpellID: %i), ignoring",
GetName().c_str(), GetGUID().ToString().c_str(), enchant_id, pEnchant->EffectArg[s]);
GetName().c_str(), GetGUID().ToString().c_str(), pEnchant->ID, pEnchant->EffectArg[s]);
continue;
}
@@ -8493,7 +8493,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, Objec
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pEnchant->EffectArg[s], DIFFICULTY_NONE);
if (!spellInfo)
{
TC_LOG_ERROR("entities.player", "Player::CastItemUseSpell: Enchant %i, cast unknown spell %i", enchant_id, pEnchant->EffectArg[s]);
TC_LOG_ERROR("entities.player", "Player::CastItemUseSpell: Enchant %i, cast unknown spell %i", pEnchant->ID, pEnchant->EffectArg[s]);
continue;
}

View File

@@ -1876,7 +1876,7 @@ GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(Battleground const*
// check for min / max count
uint32 memberscount = GetMembersCount();
if (int32(memberscount) > bgEntry->MaxGroupSize) // no MinPlayerCount for battlegrounds
if (int32(memberscount) > bgEntry->MaxGroupSize) // no MinPlayerCount for battlegrounds
return ERR_BATTLEGROUND_NONE; // ERR_GROUP_JOIN_BATTLEGROUND_TOO_MANY handled on client side
// get a player as reference, to compare other players' stats to (arena team id, queue id based on level, etc.)

View File

@@ -2486,12 +2486,12 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa
// new team
if (newTeamId == TEAM_ALLIANCE)
{
uint32 maskID = htitleInfo->MaskID;
uint32 index = maskID / 32;
uint32 bitIndex = htitleInfo->MaskID;
uint32 index = bitIndex / 32;
if (index >= knownTitles.size())
continue;
uint32 old_flag = 1 << (maskID % 32);
uint32 old_flag = 1 << (bitIndex % 32);
uint32 new_flag = 1 << (atitleInfo->MaskID % 32);
if (knownTitles[index] & old_flag)
{
@@ -2502,12 +2502,12 @@ void WorldSession::HandleCharRaceOrFactionChangeCallback(std::shared_ptr<WorldPa
}
else
{
uint32 maskID = atitleInfo->MaskID;
uint32 index = maskID / 32;
uint32 bitIndex = htitleInfo->MaskID;
uint32 index = bitIndex / 32;
if (index >= knownTitles.size())
continue;
uint32 old_flag = 1 << (maskID % 32);
uint32 old_flag = 1 << (bitIndex % 32);
uint32 new_flag = 1 << (htitleInfo->MaskID % 32);
if (knownTitles[index] & old_flag)
{

View File

@@ -1037,7 +1037,7 @@ void WorldSession::HandleSocketGems(WorldPackets::Item::SocketGems& socketGems)
{
if (ItemLimitCategoryEntry const* limitEntry = sItemLimitCategoryStore.LookupEntry(iGemProto->GetItemLimitCategory()))
{
// NOTE: limitEntry->mode is not checked because if item has limit then it is applied in equip case
// NOTE: limitEntry->Flags is not checked because if item has limit then it is applied in equip case
for (int j = 0; j < MAX_GEM_SOCKETS; ++j)
{
if (gems[j])

View File

@@ -602,10 +602,10 @@ void WorldSession::HandleBuyStableSlot(WorldPacket& recvData)
if (GetPlayer()->m_stableSlots < MAX_PET_STABLES)
{
/*StableSlotPricesEntry const* SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1);
if (_player->HasEnoughMoney(SlotPrice->Price))
if (_player->HasEnoughMoney(SlotPrice->Cost))
{
++GetPlayer()->m_stableSlots;
_player->ModifyMoney(-int32(SlotPrice->Price));
_player->ModifyMoney(-int32(SlotPrice->Cost));
SendPetStableResult(StableResult::BuySlotSuccess);
}
else

View File

@@ -5740,7 +5740,7 @@ enum ChatLinkColors : uint32
CHAT_LINK_COLOR_TRANSMOG = 0xffff80ff,
};
// Values from ItemPetFood (power of (value-1) used for compare with CreatureFamilyEntry.petDietMask
// Values from ItemPetFood (power of (value-1) used for compare with CreatureFamilyEntry.PetFoodMask
enum PetDiet
{
PET_DIET_MEAT = 1,

View File

@@ -460,7 +460,7 @@ uint32 Quest::CalculateHonorGain(uint8 /*level*/) const
if (!tc)
return 0;
honor = uint32(tc->value * GetRewHonorMultiplier() * 0.1f);
honor = uint32(tc->Data * GetRewHonorMultiplier() * 0.1f);
honor += GetRewHonorAddition();
}*/

View File

@@ -279,7 +279,7 @@ public:
if (titleInfo && target->HasTitle(titleInfo))
{
std::string name = (target->GetNativeGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()];
std::string name = target->GetNativeGender() == GENDER_MALE ? titleInfo->Name[loc] : titleInfo->Name1[loc];
if (name.empty())
continue;

View File

@@ -1472,8 +1472,7 @@ public:
}
if (!mEntry->IsDungeon())
{
handler->PSendSysMessage("'%s' is not a dungeon map.",
mEntry->MapName[handler->GetSessionDbcLocale()]);
handler->PSendSysMessage("'%s' is not a dungeon map.", mEntry->MapName[handler->GetSessionDbcLocale()]);
return true;
}
int32 difficulty = difficulty_str ? atoi(difficulty_str) : -1;
@@ -1484,34 +1483,29 @@ public:
}
if (difficulty >= 0 && !sDB2Manager.GetMapDifficultyData(mEntry->ID, Difficulty(difficulty)))
{
handler->PSendSysMessage("Difficulty %d is not valid for '%s'.",
difficulty, mEntry->MapName[handler->GetSessionDbcLocale()]);
handler->PSendSysMessage("Difficulty %d is not valid for '%s'.", difficulty, mEntry->MapName[handler->GetSessionDbcLocale()]);
return true;
}
if (difficulty == -1)
{
handler->PSendSysMessage("Resetting all difficulties for '%s'.",
mEntry->MapName[handler->GetSessionDbcLocale()]);
handler->PSendSysMessage("Resetting all difficulties for '%s'.", mEntry->MapName[handler->GetSessionDbcLocale()]);
for (DifficultyEntry const* diff : sDifficultyStore)
{
if (sDB2Manager.GetMapDifficultyData(map, Difficulty(diff->ID)))
{
handler->PSendSysMessage("Resetting difficulty %d for '%s'.",
diff->ID, mEntry->MapName[handler->GetSessionDbcLocale()]);
handler->PSendSysMessage("Resetting difficulty %d for '%s'.", diff->ID, mEntry->MapName[handler->GetSessionDbcLocale()]);
sInstanceSaveMgr->ForceGlobalReset(map, Difficulty(diff->ID));
}
}
}
else if (mEntry->IsNonRaidDungeon() && difficulty == DIFFICULTY_NORMAL)
{
handler->PSendSysMessage("'%s' does not have any permanent saves for difficulty %d.",
mEntry->MapName[handler->GetSessionDbcLocale()], difficulty);
handler->PSendSysMessage("'%s' does not have any permanent saves for difficulty %d.", mEntry->MapName[handler->GetSessionDbcLocale()], difficulty);
}
else
{
handler->PSendSysMessage("Resetting difficulty %d for '%s'.",
difficulty, mEntry->MapName[handler->GetSessionDbcLocale()]);
handler->PSendSysMessage("Resetting difficulty %d for '%s'.", difficulty, mEntry->MapName[handler->GetSessionDbcLocale()]);
sInstanceSaveMgr->ForceGlobalReset(map, Difficulty(difficulty));
}
return true;

View File

@@ -419,6 +419,7 @@ public:
{
// ... than, it prints information like "is online", where he is, etc...
onlineState = "online";
LocaleConstant locale = handler->GetSessionDbcLocale();
phases = PhasingHandler::FormatPhases(p->GetPhaseShift());
AreaTableEntry const* area = sAreaTableStore.LookupEntry(p->GetAreaId());
@@ -426,7 +427,7 @@ public:
{
AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->ParentAreaID);
if (zone)
zoneName = zone->AreaName[handler->GetSessionDbcLocale()];
zoneName = zone->AreaName[locale];
}
}
else

View File

@@ -250,12 +250,12 @@ public:
if (!talentInfo)
continue;
TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TabID);
if (!talentTabInfo)
continue;
// prevent learn talent for different family (cheating)
if (((1 << petFamily->PetTalentType) & talentTabInfo->petTalentMask) == 0)
if (((1 << petFamily->PetTalentType) & talentTabInfo->PetTalentMask) == 0)
continue;
// search highest talent rank
@@ -263,9 +263,9 @@ public:
for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
{
if (talentInfo->RankID[rank] != 0)
if (talentInfo->SpellRank[rank] != 0)
{
spellId = talentInfo->RankID[rank];
spellId = talentInfo->SpellRank[rank];
break;
}
}

View File

@@ -1337,13 +1337,13 @@ public:
uint32 counter = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
LocaleConstant locale = handler->GetSessionDbcLocale();
// search in Map.dbc
for (uint32 id = 0; id < sMapStore.GetNumRows(); id++)
{
if (MapEntry const* mapInfo = sMapStore.LookupEntry(id))
{
LocaleConstant locale = handler->GetSessionDbcLocale();
std::string name = mapInfo->MapName[locale];
if (name.empty())
continue;

View File

@@ -1914,13 +1914,13 @@ public:
AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId);
if (area)
{
zoneName = area->AreaName[handler->GetSessionDbcLocale()];
zoneName = area->AreaName[locale];
AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->ParentAreaID);
if (zone)
{
areaName = zoneName;
zoneName = zone->AreaName[handler->GetSessionDbcLocale()];
zoneName = zone->AreaName[locale];
}
}

View File

@@ -939,7 +939,7 @@ class at_bring_your_orphan_to : public AreaTriggerScript
public:
at_bring_your_orphan_to() : AreaTriggerScript("at_bring_your_orphan_to") { }
bool OnTrigger(Player* player, AreaTriggerEntry const* areaTrigger) override
bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
{
if (player->isDead() || !player->HasAura(SPELL_ORPHAN_OUT))
return false;
@@ -947,7 +947,7 @@ class at_bring_your_orphan_to : public AreaTriggerScript
uint32 questId = 0;
uint32 orphanId = 0;
switch (areaTrigger->ID)
switch (trigger->ID)
{
case AT_DOWN_AT_THE_DOCKS:
questId = QUEST_DOWN_AT_THE_DOCKS;

View File

@@ -184,12 +184,12 @@ class AreaTrigger_at_sholazar_waygate : public AreaTriggerScript
public:
AreaTrigger_at_sholazar_waygate() : AreaTriggerScript("at_sholazar_waygate") { }
bool OnTrigger(Player* player, AreaTriggerEntry const* areaTrigger) override
bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
{
if (!player->isDead() && (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) != QUEST_STATUS_NONE ||
(player->GetQuestStatus(QUEST_THE_MAKERS_OVERLOOK) == QUEST_STATUS_REWARDED && player->GetQuestStatus(QUEST_THE_MAKERS_PERCH) == QUEST_STATUS_REWARDED)))
{
switch (areaTrigger->ID)
switch (trigger->ID)
{
case AT_SHOLAZAR:
player->CastSpell(player, SPELL_SHOLAZAR_TO_UNGORO_TELEPORT, true);
@@ -266,9 +266,9 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript
_triggerTimes[AT_BREWFEST_DUROTAR] = _triggerTimes[AT_BREWFEST_DUN_MOROGH] = 0;
}
bool OnTrigger(Player* player, AreaTriggerEntry const* areaTrigger) override
bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
{
uint32 triggerId = areaTrigger->ID;
uint32 triggerId = trigger->ID;
// Second trigger happened too early after first, skip for now
if (GameTime::GetGameTime() - _triggerTimes[triggerId] < AREATRIGGER_TALK_COOLDOWN)
return false;
@@ -319,17 +319,18 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript
_triggerTimes[AT_AREA_52_SOUTH] = _triggerTimes[AT_AREA_52_NORTH] = _triggerTimes[AT_AREA_52_WEST] = _triggerTimes[AT_AREA_52_EAST] = 0;
}
bool OnTrigger(Player* player, AreaTriggerEntry const* areaTrigger) override
bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) override
{
float x = 0.0f, y = 0.0f, z = 0.0f;
if (!player->IsAlive())
return false;
if (GameTime::GetGameTime() - _triggerTimes[areaTrigger->ID] < SUMMON_COOLDOWN)
uint32 triggerId = trigger->ID;
if (GameTime::GetGameTime() - _triggerTimes[triggerId] < SUMMON_COOLDOWN)
return false;
switch (areaTrigger->ID)
switch (triggerId)
{
case AT_AREA_52_EAST:
x = 3044.176f;
@@ -355,7 +356,7 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript
player->SummonCreature(NPC_SPOTLIGHT, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 5000);
player->AddAura(SPELL_A52_NEURALYZER, player);
_triggerTimes[areaTrigger->ID] = GameTime::GetGameTime();
_triggerTimes[trigger->ID] = GameTime::GetGameTime();
return false;
}