From 1dfee7e07276da2783eb762fcc2c94020c6d22e5 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 18 Jun 2025 13:12:14 +0200 Subject: [PATCH] Core/Quests: ported QuestMoneyReward.db2 from Classic as db table --- .../world/4.3.4/2025_06_18_02_world.sql | 117 ++++++++++++++++++ src/server/game/DataStores/DBCEnums.h | 2 + src/server/game/DataStores/DBCStructure.h | 4 +- src/server/game/Globals/ObjectMgr.cpp | 70 ++++++++--- src/server/game/Globals/ObjectMgr.h | 18 ++- src/server/game/Quests/QuestDef.h | 3 +- src/server/game/World/World.cpp | 3 + 7 files changed, 191 insertions(+), 26 deletions(-) create mode 100644 sql/updates/world/4.3.4/2025_06_18_02_world.sql diff --git a/sql/updates/world/4.3.4/2025_06_18_02_world.sql b/sql/updates/world/4.3.4/2025_06_18_02_world.sql new file mode 100644 index 0000000000..82bd4cff90 --- /dev/null +++ b/sql/updates/world/4.3.4/2025_06_18_02_world.sql @@ -0,0 +1,117 @@ +DROP TABLE IF EXISTS `quest_money_reward`; +CREATE TABLE `quest_money_reward` ( + `Id` INT UNSIGNED NOT NULL, + `Difficulty0` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty1` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty2` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty3` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty4` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty5` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty6` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty7` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty8` INT UNSIGNED NOT NULL DEFAULT 0, + `Difficulty9` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`Id`) +) ENGINE=INNODB; + +INSERT INTO `quest_money_reward` (`Id`,`Difficulty0`,`Difficulty1`,`Difficulty2`,`Difficulty3`,`Difficulty4`,`Difficulty5`,`Difficulty6`,`Difficulty7`,`Difficulty8`,`Difficulty9`) VALUES +(1,0,2,4,8,12,15,30,50,75,0), +(2,0,3,8,17,25,35,65,100,125,0), +(3,0,5,13,25,40,50,100,150,200,0), +(4,0,7,20,35,55,75,150,225,300,0), +(5,0,10,25,50,75,100,200,300,400,0), +(6,0,13,35,65,100,125,250,400,500,0), +(7,0,17,45,85,125,175,350,500,700,0), +(8,0,22,55,110,175,225,450,700,900,0), +(9,0,30,70,150,200,300,600,900,1200,0), +(10,0,35,85,175,250,350,700,1000,1300,0), +(11,0,40,100,200,300,400,800,1300,1700,0), +(12,0,50,125,250,350,500,1000,1500,2000,0), +(13,0,55,150,300,400,600,1100,1700,2300,0), +(14,0,65,150,300,500,600,1300,2000,2700,0), +(15,0,70,175,350,500,700,1400,2000,2700,0), +(16,0,80,200,400,600,800,1600,2500,3300,0), +(17,0,90,225,450,700,900,1800,2500,3300,0), +(18,0,100,250,500,700,1000,2000,3000,4000,0), +(19,0,100,250,500,800,1100,2000,3000,4000,0), +(20,0,125,300,600,900,1200,2500,3500,4700,0), +(21,0,125,350,700,1000,1300,2500,4000,5300,0), +(22,0,150,350,700,1100,1400,3000,4500,6000,0), +(23,0,150,400,800,1200,1500,3000,4500,6000,0), +(24,0,175,400,800,1300,1700,3500,5000,6700,0), +(25,0,175,500,900,1400,1800,3500,5500,7300,0), +(26,0,200,500,1000,1500,2000,4000,6000,8000,0), +(27,0,225,600,1100,1700,2200,4500,6500,8700,0), +(28,0,250,600,1200,1800,2500,5000,7000,9300,0), +(29,0,250,600,1300,1900,2500,5000,7500,10000,0), +(30,0,250,700,1400,2100,2500,5500,8000,10700,0), +(31,0,300,700,1500,2200,3000,6000,9000,12000,0), +(32,0,300,800,1600,2500,3000,6500,9500,12700,0), +(33,0,350,800,1700,2500,3500,6500,10000,13300,0), +(34,0,350,900,1700,2500,3500,7000,10500,14000,0), +(35,0,350,900,1800,2500,3500,7500,11000,14700,0), +(36,0,400,1000,2000,3000,4000,7500,11500,15300,0), +(37,0,400,1000,2000,3000,4000,8000,12000,16000,0), +(38,0,400,1100,2000,3000,4500,8500,13000,17300,0), +(39,0,500,1100,2500,3500,4500,9000,14000,18700,0), +(40,0,500,1200,2500,3500,5000,10000,15000,20000,0), +(41,0,500,1300,2500,4000,5500,11000,16000,21300,0), +(42,0,600,1400,3000,4500,5500,11500,17000,22700,0), +(43,0,600,1500,3000,4500,6000,12000,18000,24000,0), +(44,0,600,1600,3000,4500,6500,12500,19000,25300,0), +(45,0,600,1600,3000,5000,6500,13000,19500,26000,0), +(46,0,700,1700,3500,5000,6500,13000,20000,26700,0), +(47,0,700,1700,3500,5000,7000,13500,20500,27300,0), +(48,0,700,1700,3500,5000,7000,14000,21000,28000,0), +(49,0,700,1800,3500,5500,7000,14000,21000,28000,0), +(50,0,700,1800,3500,5500,7500,14500,22000,29300,0), +(51,0,800,1900,4000,5500,7500,15000,22500,30000,0), +(52,0,800,1900,4000,6000,7500,15500,23000,30700,0), +(53,0,800,2000,4000,6000,8000,16000,24000,32000,0), +(54,0,800,2000,4000,6000,8000,16500,24500,32700,0), +(55,0,800,2100,4000,6000,8500,16500,25000,33300,0), +(56,0,800,2100,4000,6500,8500,17000,25500,34000,0), +(57,0,900,2200,4500,6500,8500,17000,26000,34700,0), +(58,0,900,2200,4500,6500,9000,17500,26500,35300,0), +(59,0,900,2200,4500,6500,9000,18000,26500,35300,0), +(60,0,900,2300,4500,7000,9000,18000,27000,36000,0), +(61,0,2000,5200,10000,16000,20000,40000,60000,80000,0), +(62,0,2800,7000,14000,21000,27000,54000,81000,108000,0), +(63,0,3000,7400,15000,23000,29000,58000,87000,116000,0), +(64,0,3200,8000,16000,24000,31000,62000,93000,124000,0), +(65,0,3400,8400,17000,26000,33000,66000,99000,132000,0), +(66,0,3600,9000,18000,27000,35000,70000,105000,140000,0), +(67,0,3800,9400,19000,29000,37000,74000,111000,148000,0), +(68,0,4000,10000,20000,30000,39000,78000,117000,156000,0), +(69,0,4200,10400,21000,32000,41000,82000,123000,164000,0), +(70,0,4400,11200,22000,34000,44000,88000,132000,176000,0), +(71,0,4800,12000,24000,37000,47000,94000,141000,188000,0), +(72,0,5000,12800,25000,39000,50000,100000,150000,200000,0), +(73,0,5400,13600,27000,41000,53000,106000,159000,212000,0), +(74,0,5600,14400,28000,44000,56000,112000,168000,224000,0), +(75,0,6000,15000,30000,46000,59000,118000,177000,236000,0), +(76,0,6200,15800,31000,48000,62000,124000,186000,248000,0), +(77,0,6600,16600,33000,51000,65000,130000,195000,260000,0), +(78,0,6800,17400,34000,53000,68000,136000,204000,272000,0), +(79,0,7200,18200,36000,55000,71000,142000,213000,284000,0), +(80,0,7400,19000,37000,58000,74000,148000,222000,296000,0), +(81,0,7800,19500,39000,59000,78000,156000,234000,312000,0), +(82,0,8200,20500,41000,62000,82000,164000,246000,328000,0), +(83,0,8600,21500,43000,65000,86000,172000,258000,344000,0), +(84,0,9000,22500,45000,68000,90000,180000,270000,360000,0), +(85,0,9400,23500,47000,71000,94000,188000,282000,376000,0), +(86,0,9800,24500,49000,74000,98000,196000,294000,392000,0), +(87,0,10200,25500,51000,77000,102000,204000,306000,408000,0), +(88,0,10600,26500,53000,80000,106000,212000,318000,424000,0), +(89,0,11000,27500,55000,83000,110000,220000,330000,440000,0), +(90,0,11400,28500,57000,86000,114000,228000,342000,456000,0), +(91,0,11800,29500,59000,89000,118000,236000,354000,472000,0), +(92,0,12200,30500,61000,92000,122000,244000,366000,488000,0), +(93,0,12600,31500,63000,95000,126000,252000,378000,504000,0), +(94,0,13000,32500,65000,98000,130000,260000,390000,520000,0), +(95,0,13400,33500,67000,101000,134000,268000,402000,536000,0), +(96,0,13800,34500,69000,104000,138000,276000,414000,552000,0), +(97,0,14200,35500,71000,107000,142000,284000,426000,568000,0), +(98,0,14600,36500,73000,110000,146000,292000,438000,584000,0), +(99,0,15000,37500,75000,113000,150000,300000,450000,600000,0), +(100,0,15400,38500,77000,116000,154000,308000,462000,616000,0); diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h index bcde40339f..d89c9e4115 100644 --- a/src/server/game/DataStores/DBCEnums.h +++ b/src/server/game/DataStores/DBCEnums.h @@ -890,4 +890,6 @@ enum class CurrencyTypeFlags : uint32 DEFINE_ENUM_FLAG(CurrencyTypeFlags); +constexpr uint8 MAX_QUEST_DIFFICULTY = 10; + #endif diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index 361a4dcbaf..0ca165e984 100644 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -1375,13 +1375,13 @@ struct QuestSortEntry struct QuestXPEntry { uint32 ID; // 0 - uint32 Difficulty[10]; // 1 - 10 + uint32 Difficulty[MAX_QUEST_DIFFICULTY]; // 1 - 10 }; struct QuestFactionRewEntry { uint32 ID; // 0 - int32 Difficulty[10]; // 1 - 11 + int32 Difficulty[MAX_QUEST_DIFFICULTY]; // 1 - 11 }; struct QuestPOIBlobEntry diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 81c16aa14a..ab48c3c7d2 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -7837,12 +7837,14 @@ void ObjectMgr::LoadQuestPOI() { uint32 oldMSTime = getMSTime(); - _questPOIStore.clear(); // need for reload case + _questPOIStore.clear(); // need for reload case uint32 count = 0; - // 0 1 2 3 4 5 6 7 - QueryResult result = WorldDatabase.Query("SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by QuestID"); + // 0 1 2 3 4 5 6 7 + QueryResult result = WorldDatabase.Query( + "SELECT QuestID, id, ObjectiveIndex, MapID, WorldMapAreaId, Floor, Priority, Flags FROM quest_poi order by " + "QuestID"); if (!result) { TC_LOG_ERROR("server.loading", ">> Loaded 0 quest POI definitions. DB table `quest_poi` is empty."); @@ -7850,7 +7852,8 @@ void ObjectMgr::LoadQuestPOI() } // 0 1 2 3 - QueryResult points = WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2"); + QueryResult points = + WorldDatabase.Query("SELECT QuestID, Idx1, X, Y FROM quest_poi_points ORDER BY QuestID DESC, Idx2"); std::vector>> POIs; @@ -7865,13 +7868,12 @@ void ObjectMgr::LoadQuestPOI() { fields = points->Fetch(); - uint32 questId = fields[0].GetUInt32(); - uint32 id = fields[1].GetUInt32(); - int32 x = fields[2].GetInt32(); - int32 y = fields[3].GetInt32(); + uint32 questId = fields[0].GetUInt32(); + uint32 id = fields[1].GetUInt32(); + int32 x = fields[2].GetInt32(); + int32 y = fields[3].GetInt32(); - if (POIs[questId].size() <= id + 1) - POIs[questId].resize(id + 10); + if (POIs[questId].size() <= id + 1) POIs[questId].resize(id + 10); QuestPOIBlobPoint point; point.X = x; @@ -7885,14 +7887,14 @@ void ObjectMgr::LoadQuestPOI() { Field* fields = result->Fetch(); - uint32 questId = fields[0].GetUInt32(); - uint32 id = fields[1].GetUInt32(); - int32 objIndex = fields[2].GetInt32(); - uint32 mapId = fields[3].GetUInt32(); - uint32 WorldMapAreaId = fields[4].GetUInt32(); - uint32 FloorId = fields[5].GetUInt32(); - uint32 Priority = fields[6].GetUInt32(); - uint32 Flags = fields[7].GetUInt32(); + uint32 questId = fields[0].GetUInt32(); + uint32 id = fields[1].GetUInt32(); + int32 objIndex = fields[2].GetInt32(); + uint32 mapId = fields[3].GetUInt32(); + uint32 WorldMapAreaId = fields[4].GetUInt32(); + uint32 FloorId = fields[5].GetUInt32(); + uint32 Priority = fields[6].GetUInt32(); + uint32 Flags = fields[7].GetUInt32(); QuestPOIBlobData POI; POI.BlobIndex = id; @@ -7920,7 +7922,8 @@ void ObjectMgr::LoadQuestPOI() _questPOIStore.at(questId).POIData.QuestPOIBlobDataStats.push_back(POI); } else - TC_LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest %u POI id %u", questId, id); + TC_LOG_ERROR("sql.sql", "Table quest_poi references unknown quest points for quest %u POI id %u", questId, + id); ++count; } while (result->NextRow()); @@ -7928,6 +7931,35 @@ void ObjectMgr::LoadQuestPOI() TC_LOG_INFO("server.loading", ">> Loaded %u quest POI definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } +void ObjectMgr::LoadQuestMoneyRewards() +{ + uint32 oldMSTime = getMSTime(); + + _questMoneyRewards.clear(); // for reloading + + // 0 1 2 3 4 5 6 + QueryResult result = WorldDatabase.Query("SELECT Id, Difficulty0, Difficulty1, Difficulty2, Difficulty3, Difficulty4, Difficulty5, " + // 7 8 9 10 + "Difficulty6, Difficulty7, Difficulty8, Difficulty9 FROM quest_money_reward"); + + uint32 count = 0; + if (result) + { + do + { + Field* fields = result->Fetch(); + + std::array& moneyReward = _questMoneyRewards[fields[0].GetUInt32()]; + for (uint8 i = 0; i < MAX_QUEST_DIFFICULTY; ++i) + moneyReward[i] = fields[1 + i].GetUInt32(); + + ++count; + } while (result->NextRow()); + } + + TC_LOG_INFO("server.loading", ">> Loaded %u quest money reward entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + void ObjectMgr::LoadNPCSpellClickSpells() { uint32 oldMSTime = getMSTime(); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 7d1ae59d33..b28f4184af 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -18,12 +18,17 @@ #ifndef _OBJECTMGR_H #define _OBJECTMGR_H +#include +#include +#include + #include "Common.h" #include "ConditionMgr.h" +#include "Containers.h" #include "Corpse.h" #include "CreatureData.h" -#include "DatabaseEnvFwd.h" #include "DB2Stores.h" +#include "DatabaseEnvFwd.h" #include "Errors.h" #include "GameObjectData.h" #include "ItemTemplate.h" @@ -36,9 +41,6 @@ #include "SharedDefines.h" #include "Trainer.h" #include "VehicleDefines.h" -#include -#include -#include class Item; class Unit; @@ -656,6 +658,7 @@ struct QuestRelationResult typedef std::multimap ExclusiveQuestGroups; // exclusiveGroupId -> quest typedef std::pair ExclusiveQuestGroupsBounds; +typedef std::unordered_map> QuestMoneyRewards; struct PlayerCreateInfoItem { @@ -1249,6 +1252,7 @@ class TC_GAME_API ObjectMgr void LoadPointsOfInterest(); void LoadQuestPOI(); + void LoadQuestMoneyRewards(); void LoadNPCSpellClickSpells(); @@ -1615,6 +1619,11 @@ class TC_GAME_API ObjectMgr void LoadNpcTotalHpGameTables(); void LoadNpcDamageByClassGameTables(); + std::array const* GetQuestMoneyRewards(uint32 id) const + { + return Trinity::Containers::MapGetValuePtr(_questMoneyRewards, id); + } + private: // first free id for selected id type uint32 _auctionId; @@ -1671,6 +1680,7 @@ class TC_GAME_API ObjectMgr QuestRelations _creatureQuestRelations; QuestRelations _creatureQuestInvolvedRelations; QuestRelationsReverse _creatureQuestInvolvedRelationsReverse; + QuestMoneyRewards _questMoneyRewards; ExclusiveQuestGroups _exclusiveQuestGroups; diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 9fba55ebdb..58a18f9f3d 100644 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -20,7 +20,6 @@ #include "Common.h" #include "DatabaseEnvFwd.h" -#include "DBCEnums.h" #include "SharedDefines.h" #include "WorldPacket.h" #include @@ -28,6 +27,8 @@ class Player; class WorldPacket; +enum Difficulty : uint8; + namespace WorldPackets { namespace Quest diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 59c9490ee9..0977c3b799 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1966,6 +1966,9 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading Quest POI"); sObjectMgr->LoadQuestPOI(); + TC_LOG_INFO("server.loading", "Loading Quest Money Rewards"); + sObjectMgr->LoadQuestMoneyRewards(); + TC_LOG_INFO("server.loading", "Loading Quests Starters and Enders..."); sObjectMgr->LoadQuestStartersAndEnders(); // must be after quest load