Skip to content

Commit

Permalink
merge in
Browse files Browse the repository at this point in the history
  • Loading branch information
hatersgit committed Oct 23, 2023
1 parent c3df9e9 commit f7e0f2a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 298 deletions.
2 changes: 1 addition & 1 deletion src/server/game/Entities/Player/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -2678,8 +2678,8 @@ class Player : public Unit, public GridObject<Player>

void SendSystemMessage(std::string_view msg, bool escapeCharacters = false);

// hater: xmog
BasicEvent* pendingTransmogCheck = nullptr;
BasicEvent* mythicStartCheck = nullptr;
typedef std::array<std::unordered_set<uint32>, EQUIPMENT_SLOT_END> AppearanceContainer;
AppearanceContainer transmogrification_appearances;
PresetMapType presetMap;
Expand Down
255 changes: 50 additions & 205 deletions src/server/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9247,211 +9247,6 @@ void ObjectMgr::LoadTrainerSpell()
LOG_INFO("server.loading", " ");
}

void ObjectMgr::LoadWorldSafeLocs()
{
uint32 oldMSTime = getMSTime();

// 0 1 2 3 4 5
if (QueryResult result = WorldDatabase.Query("SELECT ID, MapID, LocX, LocY, LocZ, Facing FROM world_safe_locs"))
{
do
{
Field* fields = result->Fetch();
uint32 id = fields[0].Get<uint32>();
WorldLocation loc(fields[1].Get<uint32>(), fields[2].Get<float>(), fields[3].Get<float>(), fields[4].Get<float>(), fields[5].Get<float>());
if (!MapMgr::IsValidMapCoord(loc))
{
LOG_ERROR("sql.sql", "World location (ID: %u) has a invalid position MapID: %u %s, skipped", id, loc.GetMapId(), loc.ToString().c_str());
continue;
}

WorldSafeLocsEntry* worldSafeLocs = _worldSafeLocs[id];
worldSafeLocs->ID = id;
worldSafeLocs->Loc.WorldRelocate(loc);

} while (result->NextRow());

LOG_INFO("server.loading", ">> Loaded {} world locations %u ms", _worldSafeLocs.size(), GetMSTimeDiffToNow(oldMSTime));
}
else
LOG_INFO("server.loading", ">> Loaded 0 world locations. DB table `world_safe_locs` is empty.");
}

MapChallengeModeEntry* ObjectMgr::GetChallengeMode(uint32 id) const
{
auto out = _cacheChallengeMode.find(id);
if (out != _cacheChallengeMode.end())
return out->second;
else
return nullptr;
}

WorldSafeLocsEntry* ObjectMgr::GetWorldSafeLoc(uint32 id) const
{
auto out = _worldSafeLocs.find(id);
if (out != _worldSafeLocs.end())
return out->second;
else
return nullptr;
}

void ObjectMgr::LoadInstanceDifficultyMultiplier()
{
uint32 oldMSTime = getMSTime();

_instanceDifficultyMultipliers.clear();

QueryResult result = WorldDatabase.Query("SELECT mapId, difficultyId, healthMultiplier, damageMultiplier FROM instance_difficulty_multiplier");

if (!result)
{
LOG_ERROR("sql.sql", ">> Loaded 0 instance difficulty multiplier. DB table `instance_difficulty_multiplier` is empty.");
LOG_INFO("server.loading", " ");
return;
}

do
{
Field* fields = result->Fetch();

uint32 mapId = fields[0].Get<uint32>();
uint32 difficultyId = fields[1].Get<uint32>();

InstanceDifficultyMultiplier* multipliers = new InstanceDifficultyMultiplier();
multipliers->healthMultiplier = fields[2].Get<float>();
multipliers->damageMultiplier = fields[3].Get<float>();
_instanceDifficultyMultipliers[mapId][difficultyId] = multipliers;
} while (result->NextRow());

LOG_INFO("server.loading", ">> Loaded {} instance difficulty multipliers in {} ms", _instanceDifficultyMultipliers.size(), GetMSTimeDiffToNow(oldMSTime));
}

void ObjectMgr::LoadMythicLevelScale()
{
uint32 oldMSTime = getMSTime();

_mythicLevelScales.clear();

QueryResult result = WorldDatabase.Query("SELECT * FROM forge_mythic_level_scale");

if (!result)
{
LOG_ERROR("sql.sql", ">> Loaded 0 challenge level scales. DB table `forge_mythic_level_scale` is empty.");
LOG_INFO("server.loading", " ");
return;
}

do
{
Field* fields = result->Fetch();

uint32 difficulty = fields[0].Get<uint32>();

MythicDifficultyScale* scale = new MythicDifficultyScale();
scale->mod = fields[1].Get<float>();
_mythicLevelScales[difficulty] = scale;
} while (result->NextRow());

LOG_INFO("server.loading", ">> Loaded {} forge_mythic_level_scale in {} ms", _mythicLevelScales.size(), GetMSTimeDiffToNow(oldMSTime));
}

void ObjectMgr::LoadMythicMinionValue()
{
uint32 oldMSTime = getMSTime();

_cacheMythicMinionValues.clear();

QueryResult result = WorldDatabase.Query("SELECT * FROM forge_mythic_minion_value");

if (!result)
{
LOG_ERROR("sql.sql", ">> Loaded 0 minion values. DB table `forge_mythic_minion_value` is empty.");
LOG_INFO("server.loading", " ");
return;
}

do
{
Field* fields = result->Fetch();

uint32 instance = fields[0].Get<uint32>();
uint32 unit = fields[1].Get<uint32>();
float value = fields[2].Get<float>();

_cacheMythicMinionValues[instance][unit] = value;
} while (result->NextRow());

LOG_INFO("server.loading", ">> Loaded {} instances from forge_mythic_minion_value in {} ms", _cacheMythicMinionValues.size(), GetMSTimeDiffToNow(oldMSTime));
}

void ObjectMgr::LoadMythicDungeonKeyMap()
{
uint32 oldMSTime = getMSTime();

_forgeMythicKeys.clear();
_forgeMythicMaps.clear();

QueryResult result = WorldDatabase.Query("SELECT * FROM forge_mythic_instance_key");

if (!result)
{
LOG_ERROR("sql.sql", ">> Loaded 0 instance keys. DB table `forge_mythic_instance_key` is empty.");
LOG_INFO("server.loading", " ");
return;
}

do
{
Field* fields = result->Fetch();

uint32 map = fields[0].Get<uint32>();
uint32 key = fields[1].Get<uint32>();
int32 baseTimer = fields[2].Get<int32>();

KeyInfo* info = new KeyInfo();
info->baseTimer = baseTimer;
info->itemId = key;
_forgeMythicKeys[map] = info;
_forgeMythicMaps.push_back(map);
} while (result->NextRow());

LOG_INFO("server.loading", ">> Loaded {} instances from forge_mythic_instance_key in {} ms", _forgeMythicMaps.size(), GetMSTimeDiffToNow(oldMSTime));
}

void ObjectMgr::LoadMythicAffixes()
{
uint32 oldMSTime = getMSTime();

_forgeAffixes.clear();

QueryResult result = WorldDatabase.Query("SELECT * FROM forge_mythic_affixes");

if (!result)
{
LOG_ERROR("sql.sql", ">> Loaded 0 affixes. DB table `forge_mythic_affixes` is empty.");
LOG_INFO("server.loading", " ");
return;
}

do
{
Field* fields = result->Fetch();

uint32 spell = fields[0].Get<uint32>();
uint32 tier = fields[1].Get<uint32>();
int32 timerDiff = fields[2].Get<int32>();

AffixInfo* affix = new AffixInfo();
affix->tier = tier;
affix->timerDiff = timerDiff;

_forgeAffixes[spell] = affix;
_forgeAffixTiers[tier].push_back(spell);
} while (result->NextRow());

LOG_INFO("server.loading", ">> Loaded {} instances from forge_mythic_affixes in {} ms", _forgeMythicMaps.size(), GetMSTimeDiffToNow(oldMSTime));
}

int ObjectMgr::LoadReferenceVendor(int32 vendor, int32 item, std::set<uint32>* skip_vendors)
{
// find all items from the reference vendor
Expand Down Expand Up @@ -10673,6 +10468,8 @@ void ObjectMgr::LoadMailServerTemplates()
LOG_INFO("server.loading", " ");
}

// hater: m+

void ObjectMgr::LoadInstanceDifficultyMultiplier()
{
uint32 oldMSTime = getMSTime();
Expand Down Expand Up @@ -10829,3 +10626,51 @@ void ObjectMgr::LoadMythicAffixes()

LOG_INFO("server.loading", ">> Loaded {} instances from forge_mythic_affixes in {} ms", _forgeMythicMaps.size(), GetMSTimeDiffToNow(oldMSTime));
}

void ObjectMgr::LoadWorldSafeLocs()
{
uint32 oldMSTime = getMSTime();

// 0 1 2 3 4 5
if (QueryResult result = WorldDatabase.Query("SELECT ID, MapID, LocX, LocY, LocZ, Facing FROM world_safe_locs"))
{
do
{
Field* fields = result->Fetch();
uint32 id = fields[0].Get<uint32>();
WorldLocation loc(fields[1].Get<uint32>(), fields[2].Get<float>(), fields[3].Get<float>(), fields[4].Get<float>(), fields[5].Get<float>());
if (!MapMgr::IsValidMapCoord(loc))
{
LOG_ERROR("sql.sql", "World location (ID: %u) has a invalid position MapID: %u %s, skipped", id, loc.GetMapId(), loc.ToString().c_str());
continue;
}

WorldSafeLocsEntry* worldSafeLocs = _worldSafeLocs[id];
worldSafeLocs->ID = id;
worldSafeLocs->Loc.WorldRelocate(loc);

} while (result->NextRow());

LOG_INFO("server.loading", ">> Loaded {} world locations %u ms", _worldSafeLocs.size(), GetMSTimeDiffToNow(oldMSTime));
}
else
LOG_INFO("server.loading", ">> Loaded 0 world locations. DB table `world_safe_locs` is empty.");
}

MapChallengeModeEntry* ObjectMgr::GetChallengeMode(uint32 id) const
{
auto out = _cacheChallengeMode.find(id);
if (out != _cacheChallengeMode.end())
return out->second;
else
return nullptr;
}

WorldSafeLocsEntry* ObjectMgr::GetWorldSafeLoc(uint32 id) const
{
auto out = _worldSafeLocs.find(id);
if (out != _worldSafeLocs.end())
return out->second;
else
return nullptr;
}
70 changes: 0 additions & 70 deletions src/server/game/Globals/ObjectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,20 +462,6 @@ struct WorldSafeLocsEntry
WorldLocation Loc;
};

struct SpellScalingEntry
{
//uint32 Id; // 0 m_ID
int32 CastTimeMin; // 1
int32 CastTimeMax; // 2
int32 CastTimeMaxLevel; // 3
int32 ScalingClass; // 4 (index * 100) + charLevel - 1 => gtSpellScaling.dbc
float Multiplier[3]; // 5-7
float RandomMultiplier[3]; // 8-10
float OtherMultiplier[3]; // 11-13
float CoefBase; // 14 some coefficient, mostly 1.0f
int32 CoefLevelBase; // 15 some level
};

struct KeyInfo {
uint32 itemId;
int32 baseTimer;
Expand Down Expand Up @@ -687,26 +673,6 @@ struct GossipMenus
ConditionList Conditions;
};

struct WorldSafeLocsEntry
{
uint32 ID = 0;
WorldLocation Loc;
};

struct SpellScalingEntry
{
//uint32 Id; // 0 m_ID
int32 CastTimeMin; // 1
int32 CastTimeMax; // 2
int32 CastTimeMaxLevel; // 3
int32 ScalingClass; // 4 (index * 100) + charLevel - 1 => gtSpellScaling.dbc
float Multiplier[3]; // 5-7
float RandomMultiplier[3]; // 8-10
float OtherMultiplier[3]; // 11-13
float CoefBase; // 14 some coefficient, mostly 1.0f
int32 CoefLevelBase; // 15 some level
};

typedef std::multimap<uint32, GossipMenus> GossipMenusContainer;
typedef std::pair<GossipMenusContainer::const_iterator, GossipMenusContainer::const_iterator> GossipMenusMapBounds;
typedef std::pair<GossipMenusContainer::iterator, GossipMenusContainer::iterator> GossipMenusMapBoundsNonConst;
Expand Down Expand Up @@ -791,16 +757,6 @@ struct DungeonEncounter
uint32 lastEncounterDungeon;
};

struct KeyInfo {
uint32 itemId;
int32 baseTimer;
};

struct AffixInfo {
uint8 tier;
int32 timerDiff;
};

typedef std::list<DungeonEncounter const*> DungeonEncounterList;
typedef std::unordered_map<uint32, DungeonEncounterList> DungeonEncounterContainer;

Expand Down Expand Up @@ -1035,10 +991,6 @@ class ObjectMgr
return nullptr;
}

// hater: m+
WorldSafeLocsEntry* GetWorldSafeLoc(uint32 id) const;
MapChallengeModeEntry* GetChallengeMode(uint32 id) const;

void LoadQuests();
void LoadQuestMoneyRewards();
void LoadQuestStartersAndEnders()
Expand Down Expand Up @@ -1191,14 +1143,6 @@ class ObjectMgr
void LoadTrainerSpell();
void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell);

// hater: m+
void LoadWorldSafeLocs();
void LoadMythicLevelScale();
void LoadInstanceDifficultyMultiplier();
void LoadMythicMinionValue();
void LoadMythicDungeonKeyMap();
void LoadMythicAffixes();

std::string GeneratePetName(uint32 entry);
std::string GeneratePetNameLocale(uint32 entry, LocaleConstant locale);
uint32 GetBaseXP(uint8 level);
Expand Down Expand Up @@ -1792,20 +1736,6 @@ class ObjectMgr
CacheVendorItemContainer _cacheVendorItemStore;
CacheTrainerSpellContainer _cacheTrainerSpellStore;

// hater: m+
std::unordered_map<uint32, WorldSafeLocsEntry*> _worldSafeLocs;
std::unordered_map<uint32, MapChallengeModeEntry*> _cacheChallengeMode;
std::unordered_map<uint32, std::unordered_map<uint32, float>> _cacheMythicMinionValues;
typedef std::unordered_map<uint32, std::unordered_map<uint32, InstanceDifficultyMultiplier*>> InstanceDifficultyMultiplierContainer;
InstanceDifficultyMultiplierContainer _instanceDifficultyMultipliers;
typedef std::unordered_map<uint32, MythicDifficultyScale*> MythicDifficultyScaleContainer;

std::unordered_map<uint32, KeyInfo*> _forgeMythicKeys;
MythicDifficultyScaleContainer _mythicLevelScales;
std::vector<uint32> _forgeMythicMaps;
std::unordered_map<uint32 /*spellid*/, AffixInfo*> _forgeAffixes;
std::unordered_map<uint8 /*tier*/, std::vector<uint32 /*spellid*/>> _forgeAffixTiers;

ServerMailContainer _serverMailStore;

std::set<uint32> _difficultyEntries[MAX_DIFFICULTY - 1]; // already loaded difficulty 1 value in creatures, used in CheckCreatureTemplate
Expand Down
Loading

0 comments on commit f7e0f2a

Please sign in to comment.