diff options
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index bbe04f8c383..37c849a3db8 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1032,13 +1032,13 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) const_cast<CreatureTemplate*>(cInfo)->MovementType = IDLE_MOTION_TYPE; } - if (cInfo->HealthScalingExpansion < EXPANSION_LEVEL_CURRENT || cInfo->HealthScalingExpansion > (MAX_EXPANSIONS - 1)) + if (cInfo->HealthScalingExpansion < EXPANSION_LEVEL_CURRENT || cInfo->HealthScalingExpansion >= MAX_EXPANSIONS) { TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (ID: %u) with invalid `HealthScalingExpansion` %i. Ignored and set to 0.", cInfo->Entry, cInfo->HealthScalingExpansion); const_cast<CreatureTemplate*>(cInfo)->HealthScalingExpansion = 0; } - if (cInfo->RequiredExpansion > (MAX_EXPANSIONS - 1)) + if (cInfo->RequiredExpansion >= MAX_EXPANSIONS) { TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: %u) with `RequiredExpansion` %u. Ignored and set to 0.", cInfo->Entry, cInfo->RequiredExpansion); const_cast<CreatureTemplate*>(cInfo)->RequiredExpansion = 0; @@ -1050,26 +1050,19 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) const_cast<CreatureTemplate*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED; } - // -1, as expansion, is used in CreatureDifficulty.db2 for - // auto-updating the levels of creatures having their expansion - // set to that value to the current expansion's max leveling level - if (cInfo->HealthScalingExpansion == EXPANSION_LEVEL_CURRENT) + std::pair<int16, int16> levels = cInfo->GetMinMaxLevel(); + if (levels.first < 1 || levels.first > STRONG_MAX_LEVEL) { - const_cast<CreatureTemplate*>(cInfo)->minlevel = (MAX_LEVEL + cInfo->minlevel); - const_cast<CreatureTemplate*>(cInfo)->maxlevel = (MAX_LEVEL + cInfo->maxlevel); - const_cast<CreatureTemplate*>(cInfo)->HealthScalingExpansion = CURRENT_EXPANSION; + TC_LOG_ERROR("sql.sql", "Creature (ID: %u): Calculated minLevel %i is not within [1, 255], value has been set to %u.", cInfo->Entry, cInfo->minlevel, + cInfo->HealthScalingExpansion == EXPANSION_LEVEL_CURRENT ? MAX_LEVEL : 1); + const_cast<CreatureTemplate*>(cInfo)->minlevel = cInfo->HealthScalingExpansion == EXPANSION_LEVEL_CURRENT ? 0 : 1; } - if (cInfo->minlevel < 1 || cInfo->minlevel > STRONG_MAX_LEVEL) + if (levels.second < 1 || levels.second > STRONG_MAX_LEVEL) { - TC_LOG_ERROR("sql.sql", "Creature (ID: %u): MinLevel %i is not within [1, 255], value has been set to 1.", cInfo->Entry, cInfo->minlevel); - const_cast<CreatureTemplate*>(cInfo)->minlevel = 1; - } - - if (cInfo->maxlevel < 1 || cInfo->maxlevel > STRONG_MAX_LEVEL) - { - TC_LOG_ERROR("sql.sql", "Creature (ID: %u): MaxLevel %i is not within [1, 255], value has been set to 1.", cInfo->Entry, cInfo->maxlevel); - const_cast<CreatureTemplate*>(cInfo)->maxlevel = 1; + TC_LOG_ERROR("sql.sql", "Creature (ID: %u): Calculated maxLevel %i is not within [1, 255], value has been set to %u.", cInfo->Entry, cInfo->maxlevel, + cInfo->HealthScalingExpansion == EXPANSION_LEVEL_CURRENT ? MAX_LEVEL : 1); + const_cast<CreatureTemplate*>(cInfo)->maxlevel = cInfo->HealthScalingExpansion == EXPANSION_LEVEL_CURRENT ? 0 : 1; } const_cast<CreatureTemplate*>(cInfo)->ModDamage *= Creature::_GetDamageMod(cInfo->rank); @@ -2229,7 +2222,8 @@ ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float if (!cInfo) return UI64LIT(0); - uint32 level = cInfo->minlevel == cInfo->maxlevel ? cInfo->minlevel : urand(cInfo->minlevel, cInfo->maxlevel); // Only used for extracting creature base stats + std::pair<int16, int16> levels = cInfo->GetMinMaxLevel(); + uint32 level = levels.first == levels.second ? levels.first : urand(levels.first, levels.second); // Only used for extracting creature base stats CreatureBaseStats const* stats = GetCreatureBaseStats(level, cInfo->unit_class); Map* map = sMapMgr->CreateBaseMap(mapId); if (!map) @@ -2250,7 +2244,7 @@ ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float data.spawntimesecs = spawntimedelay; data.spawndist = 0; data.currentwaypoint = 0; - data.curhealth = sDB2Manager.EvaluateExpectedStat(ExpectedStatType::CreatureHealth, level, cInfo->HealthScalingExpansion, scaling->ContentTuningID, Classes(cInfo->unit_class)) * cInfo->ModHealth * cInfo->ModHealthExtra; + data.curhealth = sDB2Manager.EvaluateExpectedStat(ExpectedStatType::CreatureHealth, level, cInfo->GetHealthScalingExpansion(), scaling->ContentTuningID, Classes(cInfo->unit_class)) * cInfo->ModHealth * cInfo->ModHealthExtra; data.curmana = stats->GenerateMana(cInfo); data.movementType = cInfo->MovementType; data.spawnDifficulties.push_back(DIFFICULTY_NONE); @@ -9298,9 +9292,10 @@ void ObjectMgr::LoadCreatureClassLevelStats() while (result->NextRow()); CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates(); - for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr) + for (auto itr = ctc->begin(); itr != ctc->end(); ++itr) { - for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl) + std::pair<int16, int16> levels = itr->second.GetMinMaxLevel(); + for (int16 lvl = levels.first; lvl <= levels.second; ++lvl) { if (_creatureBaseStatsStore.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == _creatureBaseStatsStore.end()) TC_LOG_ERROR("sql.sql", "Missing base stats for creature class %u level %u", itr->second.unit_class, lvl); |