Core/Misc: Add helper table phase_name and improve .npc info and .gps

.gps and .npc info now displays names for known phase names
This commit is contained in:
funjoker
2021-12-07 20:38:26 +01:00
parent 9752ef4d6e
commit 833e179985
5 changed files with 3158 additions and 2 deletions
File diff suppressed because one or more lines are too long
+35
View File
@@ -11140,3 +11140,38 @@ void ObjectMgr::LoadJumpChargeParams()
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " Player Choice locale strings in %u ms", _jumpChargeParams.size(), GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadPhaseNames()
{
uint32 oldMSTime = getMSTime();
_phaseNameStore.clear();
// 0 1
QueryResult result = WorldDatabase.Query("SELECT `ID`, `Name` FROM `phase_name`");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 phase names. DB table `phase_name` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 phaseId = fields[0].GetUInt32();
std::string name = fields[1].GetString();
_phaseNameStore[phaseId] = name;
++count;
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u phase names in %u ms.", count, GetMSTimeDiffToNow(oldMSTime));
}
std::string ObjectMgr::GetPhaseName(uint32 phaseId) const
{
PhaseNameContainer::const_iterator iter = _phaseNameStore.find(phaseId);
return iter != _phaseNameStore.end() ? iter->second : "Unknown Name";
}
+7
View File
@@ -802,6 +802,8 @@ struct SceneTemplate
typedef std::unordered_map<uint32, SceneTemplate> SceneTemplateContainer;
typedef std::unordered_map<uint32, std::string> PhaseNameContainer;
struct PlayerChoiceResponseRewardItem
{
PlayerChoiceResponseRewardItem() : Id(0), Quantity(0) { }
@@ -1367,6 +1369,7 @@ class TC_GAME_API ObjectMgr
void LoadPlayerChoicesLocale();
void LoadJumpChargeParams();
void LoadPhaseNames();
void InitializeQueriesData(QueryDataGroup mask);
@@ -1676,6 +1679,8 @@ class TC_GAME_API ObjectMgr
std::string GetNormalizedRealmName(uint32 realm) const;
bool GetRealmName(uint32 realmId, std::string& name, std::string& normalizedName) const;
std::string GetPhaseName(uint32 phaseId) const;
std::unordered_map<uint8, RaceUnlockRequirement> const& GetRaceUnlockRequirements() const { return _raceUnlockRequirementStore; }
RaceUnlockRequirement const* GetRaceUnlockRequirement(uint8 race) const
{
@@ -1879,6 +1884,8 @@ class TC_GAME_API ObjectMgr
std::unordered_map<int32, JumpChargeParams> _jumpChargeParams;
PhaseNameContainer _phaseNameStore;
std::set<uint32> _transportMaps; // Helper container storing map ids that are for transports only, loaded from gameobject_template
};
+3 -2
View File
@@ -553,12 +553,13 @@ void PhasingHandler::PrintToChat(ChatHandler* chat, PhaseShift const& phaseShift
std::string personal = sObjectMgr->GetTrinityString(LANG_PHASE_FLAG_PERSONAL, chat->GetSessionDbLocaleIndex());
for (PhaseShift::PhaseRef const& phase : phaseShift.Phases)
{
phases << phase.Id;
phases << "\r\n";
phases << ' ' << ' ' << ' ';
phases << phase.Id << ' ' << '(' << sObjectMgr->GetPhaseName(phase.Id) << ')';
if (phase.Flags.HasFlag(PhaseFlags::Cosmetic))
phases << ' ' << '(' << cosmetic << ')';
if (phase.Flags.HasFlag(PhaseFlags::Personal))
phases << ' ' << '(' << personal << ')';
phases << ", ";
}
chat->PSendSysMessage(LANG_PHASESHIFT_PHASES, phases.str().c_str());
+3
View File
@@ -2397,6 +2397,9 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading scenario poi data");
sScenarioMgr->LoadScenarioPOI();
TC_LOG_INFO("server.loading", "Loading phase names...");
sObjectMgr->LoadPhaseNames();
// Preload all cells, if required for the base maps
if (sWorld->getBoolConfig(CONFIG_BASEMAP_LOAD_GRIDS))
{