From 91f30baf3b6cf00b7ffdf54c75c356dea1fff24a Mon Sep 17 00:00:00 2001 From: Gamemechanic Date: Fri, 18 Apr 2025 19:23:35 +0200 Subject: [PATCH 1/3] minmax --- sql/migrations/20250418172108_world.sql | 20 ++++++++++++++++++++ src/game/ObjectMgr.cpp | 6 ++++++ src/game/Objects/Creature.cpp | 4 ++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 sql/migrations/20250418172108_world.sql diff --git a/sql/migrations/20250418172108_world.sql b/sql/migrations/20250418172108_world.sql new file mode 100644 index 00000000000..9f38ab1d35b --- /dev/null +++ b/sql/migrations/20250418172108_world.sql @@ -0,0 +1,20 @@ +DROP PROCEDURE IF EXISTS add_migration; +DELIMITER ?? +CREATE PROCEDURE `add_migration`() +BEGIN +DECLARE v INT DEFAULT 1; +SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20250418172108'); +IF v = 0 THEN +INSERT INTO `migrations` VALUES ('20250418172108'); +-- Add your query below. + +-- Correct levelrange for Morbent Fel Pre 1.6 + +UPDATE `creature_template` SET `level_max`=35 WHERE `entry`=1200 AND `patch`=0; + +-- End of migration. +END IF; +END?? +DELIMITER ; +CALL add_migration(); +DROP PROCEDURE IF EXISTS add_migration; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 06f1cd92103..793056e7a48 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1236,6 +1236,12 @@ void ObjectMgr::LoadCreatureInfo(Field* fields) pInfo->subname = fields[2].GetCppString(); pInfo->level_min = fields[3].GetUInt32(); pInfo->level_max = fields[4].GetUInt32(); + if (pInfo->level_min > pInfo->level_max) + { + pInfo->level_min = fields[4].GetUInt32(); + pInfo->level_max = fields[3].GetUInt32(); + sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Creature (Entry: %u) has level_min (%u) greater than level_max (%u), values have been swapped.", pInfo->entry, fields[3].GetUInt32(), fields[4].GetUInt32()); + } pInfo->faction = fields[5].GetUInt32(); pInfo->npc_flags = fields[6].GetUInt32(); pInfo->gossip_menu_id = fields[7].GetUInt32(); diff --git a/src/game/Objects/Creature.cpp b/src/game/Objects/Creature.cpp index 0d6322c4c8f..94cde685bf9 100644 --- a/src/game/Objects/Creature.cpp +++ b/src/game/Objects/Creature.cpp @@ -1703,8 +1703,8 @@ void Creature::SelectLevel(float percentHealth, float percentMana) CreatureInfo const* cinfo = GetCreatureInfo(); // level - uint32 const minLevel = std::min(cinfo->level_max, cinfo->level_min); - uint32 const maxLevel = std::max(cinfo->level_max, cinfo->level_min); + uint32 const minLevel = cinfo->level_min; + uint32 const maxLevel = cinfo->level_max; uint32 const level = minLevel == maxLevel ? minLevel : urand(minLevel, maxLevel); SetLevel(level); From ff82e075fb4485beed01b4dd729c61aa5a105712 Mon Sep 17 00:00:00 2001 From: Gamemechanic Date: Fri, 18 Apr 2025 19:38:42 +0200 Subject: [PATCH 2/3] 2 --- src/game/ObjectMgr.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 793056e7a48..4209f53297b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1236,12 +1236,6 @@ void ObjectMgr::LoadCreatureInfo(Field* fields) pInfo->subname = fields[2].GetCppString(); pInfo->level_min = fields[3].GetUInt32(); pInfo->level_max = fields[4].GetUInt32(); - if (pInfo->level_min > pInfo->level_max) - { - pInfo->level_min = fields[4].GetUInt32(); - pInfo->level_max = fields[3].GetUInt32(); - sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Creature (Entry: %u) has level_min (%u) greater than level_max (%u), values have been swapped.", pInfo->entry, fields[3].GetUInt32(), fields[4].GetUInt32()); - } pInfo->faction = fields[5].GetUInt32(); pInfo->npc_flags = fields[6].GetUInt32(); pInfo->gossip_menu_id = fields[7].GetUInt32(); @@ -1626,6 +1620,14 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo* cInfo) sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Creature (Entry: %u) with despawn instantly flag has skinning loot assigned. It will never be lootable.", cInfo->entry); } + if (cInfo->level_min > cInfo->level_max) + { + uint32 tmp = cInfo->level_min; + cInfo->level_min = cInfo->level_max; + cInfo->level_max = tmp; + sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Creature (Entry: %u) has level_min (%u) greater than level_max (%u), values have been swapped.", cInfo->entry, cInfo->level_max, cInfo->level_min); + } + ConvertCreatureAurasField(cInfo, "creature_template", "Entry", cInfo->entry); } From 1360f7dbdd16c528f70d9247c10f9e1ae724fd30 Mon Sep 17 00:00:00 2001 From: Gamemechanic Date: Fri, 18 Apr 2025 21:03:20 +0200 Subject: [PATCH 3/3] cleaner swap --- src/game/ObjectMgr.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 4209f53297b..6b6d3b5dee3 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1622,9 +1622,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo* cInfo) if (cInfo->level_min > cInfo->level_max) { - uint32 tmp = cInfo->level_min; - cInfo->level_min = cInfo->level_max; - cInfo->level_max = tmp; + std::swap(cInfo->level_min, cInfo->level_max); sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Creature (Entry: %u) has level_min (%u) greater than level_max (%u), values have been swapped.", cInfo->entry, cInfo->level_max, cInfo->level_min); }