diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-07-31 11:21:24 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-07-31 11:21:24 +0200 |
commit | 1340f2cdb33a4feac01e68d2f65ae1ae486e135f (patch) | |
tree | bc47f6026c5f493ace39e6c0d9fd128ea8507a14 | |
parent | 8116ad58892b2170d4cea32a6ce2c5c265acf4b2 (diff) |
Core/Creatures: Move gossip trainer assignment to creature_trainer table - same gossip can open different trainers depending on which creature it is assigned to
Closes #21723
-rw-r--r-- | sql/updates/world/master/2020_07_31_04_world.sql | 435 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/GossipDef.cpp | 5 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/GossipDef.h | 4 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 44 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.h | 11 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 8 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_reload.cpp | 2 |
8 files changed, 478 insertions, 35 deletions
diff --git a/sql/updates/world/master/2020_07_31_04_world.sql b/sql/updates/world/master/2020_07_31_04_world.sql new file mode 100644 index 00000000000..e6689be80fd --- /dev/null +++ b/sql/updates/world/master/2020_07_31_04_world.sql @@ -0,0 +1,435 @@ +ALTER TABLE `creature_default_trainer` DROP PRIMARY KEY; +RENAME TABLE `creature_default_trainer` TO `creature_trainer`; +ALTER TABLE `creature_trainer` + ADD `MenuId` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `TrainerId`, + ADD `OptionIndex` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `MenuId`, + ADD PRIMARY KEY(`CreatureId`,`MenuId`,`OptionIndex`); + +DROP TABLE `gossip_menu_option_trainer`; + +INSERT INTO `creature_trainer` (`CreatureId`,`TrainerId`,`MenuId`,`OptionIndex`) VALUES +(514,27,2744,0), +(812,133,7691,0), +(1103,163,4261,0), +(1218,133,7691,0), +(1241,27,2741,0), +(1292,196,648,0), +(1317,62,4161,0), +(1346,163,4353,0), +(1355,136,5853,0), +(1430,136,5853,0), +(1470,122,4115,0), +(1676,407,4145,0), +(1680,10,5665,0), +(1681,91,4361,0), +(1683,10,5665,0), +(1699,136,5853,0), +(1700,10,5665,0), +(1701,91,7690,0), +(1702,407,4135,0), +(2326,160,5855,0), +(2327,160,657,0), +(2329,160,5855,0), +(2367,10,5665,0), +(2485,148,4822,0), +(2489,129,4823,0), +(2627,163,4348,0), +(2834,10,5665,0), +(2836,27,2784,0), +(2837,122,4127,0), +(3001,91,7690,0), +(3013,133,7691,0), +(3028,10,5665,0), +(3087,136,5853,0), +(3136,27,2781,0), +(3137,91,7690,0), +(3179,10,5665,0), +(3181,160,5855,0), +(3357,91,7690,0), +(3363,163,4347,0), +(3404,133,7691,0), +(3523,163,4267,0), +(3607,10,5665,0), +(3967,56,4211,0), +(4156,10,5665,0), +(4210,136,5853,0), +(4211,160,5855,0), +(4900,122,4122,0), +(5157,62,4160,0), +(5161,10,4742,0), +(5174,407,4150,0), +(5177,122,4123,0), +(5388,29,12848,0), +(5392,91,7690,0), +(5482,136,646,0), +(5493,10,645,0), +(5499,122,4201,0), +(5511,27,581,0), +(5513,91,660,0), +(5518,407,4146,0), +(5564,56,4203,0), +(5566,133,643,0), +(5690,10,5665,0), +(5941,10,5665,0), +(6094,160,5855,0), +(7948,122,4133,0), +(7949,62,4164,0), +(8146,133,7691,0), +(8736,407,4152,0), +(10296,4,12045,7), +(10296,10,12046,2), +(10296,37,12045,1), +(10296,105,12045,0), +(10296,119,12045,6), +(10296,125,12045,2), +(10296,126,12045,3), +(10296,136,12046,0), +(10296,157,12045,10), +(10296,160,12046,1), +(10296,383,12045,5), +(10296,424,12045,4), +(10296,425,12045,8), +(10296,426,12045,9), +(10299,4,12045,7), +(10299,10,12046,2), +(10299,37,12045,1), +(10299,105,12045,0), +(10299,119,12045,6), +(10299,125,12045,2), +(10299,126,12045,3), +(10299,136,12046,0), +(10299,157,12045,10), +(10299,160,12046,1), +(10299,383,12045,5), +(10299,424,12045,4), +(10299,425,12045,8), +(10299,426,12045,9), +(11037,407,4138,0), +(11052,163,4355,0), +(11072,62,4169,0), +(11557,163,3626,0), +(12939,160,5382,0), +(16588,122,7810,0), +(16644,133,7691,0), +(16662,160,5855,0), +(16663,91,7690,0), +(16692,196,7842,0), +(16719,136,5853,0), +(16731,160,5855,0), +(16742,62,10365,0), +(16752,91,7690,0), +(16763,196,7842,0), +(16774,10,5665,0), +(16780,10,5665,0), +(16823,27,7826,0), +(17101,10,7361,0), +(17214,160,7380,0), +(17215,105,7384,0), +(17222,407,7383,0), +(17245,27,7389,0), +(17246,136,7388,0), +(17424,160,7455,0), +(17434,133,7459,0), +(17441,196,7429,0), +(17442,56,7430,0), +(17487,163,8519,0), +(17488,91,7690,0), +(17634,407,7512,0), +(18748,133,7691,0), +(18749,163,7817,0), +(18751,29,8646,0), +(18754,56,7816,0), +(18755,196,7842,0), +(18772,62,7818,0), +(18773,62,7818,0), +(18774,62,7818,0), +(18776,133,7691,0), +(18777,196,7842,0), +(18779,91,7690,0), +(18802,62,7818,0), +(18804,91,7833,0), +(18911,10,10437,0), +(18987,62,7818,0), +(18988,62,7818,0), +(18993,136,7879,0), +(19052,122,8540,0), +(19063,29,7815,0), +(19180,62,7818,0), +(19184,160,8522,0), +(19185,136,8460,0), +(19186,136,8785,0), +(19187,56,7816,0), +(19252,62,7818,0), +(19340,149,8433,0), +(19539,29,8646,0), +(19540,62,7818,0), +(19576,62,7818,0), +(20511,386,8622,0), +(20791,149,8268,0), +(21209,27,8254,1), +(22477,160,8522,0), +(23734,160,8802,0), +(23896,10,8826,0), +(25580,10,12641,0), +(26905,136,9985,0), +(26914,163,10116,0), +(26915,29,9894,0), +(26916,63,9879,0), +(26959,63,9879,0), +(26977,63,9879,0), +(26989,136,9986,0), +(26995,63,9879,0), +(26997,29,9892,0), +(27001,163,10114,0), +(27703,144,9581,0), +(28701,29,9873,0), +(28703,122,10627,0), +(28703,122,10628,1), +(28705,136,9772,0), +(28742,10,9833,0), +(28746,386,9750,0), +(29156,114,9777,0), +(31238,137,10723,0), +(31247,386,10210,0), +(33630,122,10359,0), +(33631,27,10362,0), +(33633,62,10365,0), +(33634,407,10363,0), +(33635,56,10361,0), +(33636,163,10364,0), +(33637,29,8646,0), +(33638,63,9879,0), +(33639,133,10350,0), +(33640,91,10351,0), +(33674,122,10359,0), +(33675,27,10362,0), +(33676,62,10365,0), +(33677,407,10363,0), +(33678,133,10350,0), +(33679,63,9879,0), +(33680,29,8646,0), +(33681,56,10361,0), +(33682,91,10351,0), +(33684,163,10364,0), +(36615,877,10826,0), +(39718,373,11821,0), +(42288,136,11615,0), +(43428,163,8519,0), +(44238,373,11821,0), +(44582,29,11861,0), +(44781,37,8521,0), +(45286,48,12197,11), +(45286,51,12180,2), +(45286,51,12193,2), +(45286,59,12191,11), +(45286,80,12192,11), +(45286,102,12195,11), +(45286,103,12198,11), +(45286,117,12180,10), +(45286,117,12199,10), +(45286,117,12199,11), +(45286,387,12196,11), +(45286,388,12188,11), +(45286,389,12189,11), +(45286,390,12190,11), +(45563,4,12045,7), +(45563,10,12046,2), +(45563,37,12045,1), +(45563,105,12045,0), +(45563,119,12045,6), +(45563,125,12045,2), +(45563,126,12045,3), +(45563,136,12046,0), +(45563,157,12045,10), +(45563,160,12046,1), +(45563,383,12045,5), +(45563,424,12045,4), +(45563,425,12045,8), +(45563,426,12045,9), +(46357,91,7690,0), +(46741,133,7691,0), +(47384,48,12197,11), +(47384,51,12180,2), +(47384,51,12193,2), +(47384,59,12191,11), +(47384,80,12192,11), +(47384,102,12195,11), +(47384,103,12198,11), +(47384,117,12180,10), +(47384,117,12199,10), +(47384,117,12199,11), +(47384,387,12196,11), +(47384,388,12188,11), +(47384,389,12189,11), +(47384,390,12190,11), +(47396,48,12197,11), +(47396,51,12180,2), +(47396,51,12193,2), +(47396,59,12191,11), +(47396,80,12192,11), +(47396,102,12195,11), +(47396,103,12198,11), +(47396,117,12180,10), +(47396,117,12199,10), +(47396,117,12199,11), +(47396,387,12196,11), +(47396,388,12188,11), +(47396,389,12189,11), +(47396,390,12190,11), +(47400,48,12197,11), +(47400,51,12180,2), +(47400,51,12193,2), +(47400,59,12191,11), +(47400,80,12192,11), +(47400,102,12195,11), +(47400,103,12198,11), +(47400,117,12180,10), +(47400,117,12199,10), +(47400,117,12199,11), +(47400,387,12196,11), +(47400,388,12188,11), +(47400,389,12189,11), +(47400,390,12190,11), +(47418,48,12197,11), +(47418,51,12180,2), +(47418,51,12193,2), +(47418,59,12191,11), +(47418,80,12192,11), +(47418,102,12195,11), +(47418,103,12198,11), +(47418,117,12180,10), +(47418,117,12199,10), +(47418,117,12199,11), +(47418,387,12196,11), +(47418,388,12188,11), +(47418,389,12189,11), +(47418,390,12190,11), +(47419,48,12197,11), +(47419,51,12180,2), +(47419,51,12193,2), +(47419,59,12191,11), +(47419,80,12192,11), +(47419,102,12195,11), +(47419,103,12198,11), +(47419,117,12180,10), +(47419,117,12199,10), +(47419,117,12199,11), +(47419,387,12196,11), +(47419,388,12188,11), +(47419,389,12189,11), +(47419,390,12190,11), +(47420,48,12197,11), +(47420,51,12180,2), +(47420,51,12193,2), +(47420,59,12191,11), +(47420,80,12192,11), +(47420,102,12195,11), +(47420,103,12198,11), +(47420,117,12180,10), +(47420,117,12199,10), +(47420,117,12199,11), +(47420,387,12196,11), +(47420,388,12188,11), +(47420,389,12189,11), +(47420,390,12190,11), +(47421,48,12197,11), +(47421,51,12180,2), +(47421,51,12193,2), +(47421,59,12191,11), +(47421,80,12192,11), +(47421,102,12195,11), +(47421,103,12198,11), +(47421,117,12180,10), +(47421,117,12199,10), +(47421,117,12199,11), +(47421,387,12196,11), +(47421,388,12188,11), +(47421,389,12189,11), +(47421,390,12190,11), +(47431,48,12197,11), +(47431,51,12180,2), +(47431,51,12193,2), +(47431,59,12191,11), +(47431,80,12192,11), +(47431,102,12195,11), +(47431,103,12198,11), +(47431,117,12180,10), +(47431,117,12199,10), +(47431,117,12199,11), +(47431,387,12196,11), +(47431,388,12188,11), +(47431,389,12189,11), +(47431,390,12190,11), +(47569,373,11821,0), +(47572,373,11821,0), +(47579,373,11821,0), +(48619,48,12197,11), +(48619,51,12180,2), +(48619,51,12193,2), +(48619,59,12191,11), +(48619,80,12192,11), +(48619,102,12195,11), +(48619,103,12198,11), +(48619,117,12180,10), +(48619,117,12199,10), +(48619,117,12199,11), +(48619,387,12196,11), +(48619,388,12188,11), +(48619,389,12189,11), +(48619,390,12190,11), +(49789,136,7879,0), +(50247,48,12197,11), +(50247,51,12180,2), +(50247,51,12193,2), +(50247,59,12191,11), +(50247,80,12192,11), +(50247,102,12195,11), +(50247,103,12198,11), +(50247,117,12180,10), +(50247,117,12199,10), +(50247,117,12199,11), +(50247,387,12196,11), +(50247,388,12188,11), +(50247,389,12189,11), +(50247,390,12190,11), +(50567,136,5853,0), +(50570,10,5665,0), +(50574,160,5855,0), +(51997,373,12725,0), +(52640,37,8521,0), +(52642,91,7690,0), +(52645,29,7815,0), +(52657,29,7815,0), +(53410,62,12843,0), +(53421,373,12850,0), +(53436,56,12852,0), +(56068,10,5665,0), +(57620,48,12197,11), +(57620,51,12180,2), +(57620,51,12193,2), +(57620,59,12191,11), +(57620,80,12192,11), +(57620,102,12195,11), +(57620,103,12198,11), +(57620,117,12180,10), +(57620,117,12199,10), +(57620,117,12199,11), +(57620,387,12196,11), +(57620,388,12188,11), +(57620,389,12189,11), +(57620,390,12190,11), +(63080,580,14991,0), +(65043,48,12197,11), +(65043,51,12180,2), +(65043,51,12193,2), +(65043,59,12191,11), +(65043,80,12192,11), +(65043,102,12195,11), +(65043,103,12198,11), +(65043,117,12180,10), +(65043,117,12199,10), +(65043,117,12199,11), +(65043,387,12196,11), +(65043,388,12188,11), +(65043,389,12189,11), +(65043,390,12190,11); diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 1a7fa91e4f5..aad55cd5c30 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -133,17 +133,16 @@ void GossipMenu::AddMenuItem(uint32 menuId, uint32 optionIndex, uint32 sender, u /// Add menu item with existing method. Menu item id -1 is also used in ADD_GOSSIP_ITEM macro. uint32 newOptionIndex = AddMenuItem(-1, itr->second.OptionIcon, strOptionText, sender, action, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded); - AddGossipMenuItemData(newOptionIndex, itr->second.ActionMenuId, itr->second.ActionPoiId, itr->second.TrainerId); + AddGossipMenuItemData(newOptionIndex, itr->second.ActionMenuId, itr->second.ActionPoiId); } } -void GossipMenu::AddGossipMenuItemData(uint32 optionIndex, uint32 gossipActionMenuId, uint32 gossipActionPoi, uint32 trainerId) +void GossipMenu::AddGossipMenuItemData(uint32 optionIndex, uint32 gossipActionMenuId, uint32 gossipActionPoi) { GossipMenuItemData& itemData = _menuItemData[optionIndex]; itemData.GossipActionMenuId = gossipActionMenuId; itemData.GossipActionPoi = gossipActionPoi; - itemData.TrainerId = trainerId; } uint32 GossipMenu::GetMenuItemSender(uint32 menuItemId) const diff --git a/src/server/game/Entities/Creature/GossipDef.h b/src/server/game/Entities/Creature/GossipDef.h index aacdf164caa..69f5e118277 100644 --- a/src/server/game/Entities/Creature/GossipDef.h +++ b/src/server/game/Entities/Creature/GossipDef.h @@ -147,8 +147,6 @@ struct GossipMenuItemData { uint32 GossipActionMenuId; // MenuId of the gossip triggered by this action uint32 GossipActionPoi; - - uint32 TrainerId; }; // need an ordered container @@ -176,7 +174,7 @@ class TC_GAME_API GossipMenu void SetLocale(LocaleConstant locale) { _locale = locale; } LocaleConstant GetLocale() const { return _locale; } - void AddGossipMenuItemData(uint32 optionIndex, uint32 gossipActionMenuId, uint32 gossipActionPoi, uint32 trainerId); + void AddGossipMenuItemData(uint32 optionIndex, uint32 gossipActionMenuId, uint32 gossipActionPoi); uint32 GetMenuItemCount() const { return uint32(_menuItems.size()); } bool Empty() const { return _menuItems.empty(); } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 4568dcecece..4d47e9d9ccc 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -14712,7 +14712,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool } menu->GetGossipMenu().AddMenuItem(itr->second.OptionIndex, itr->second.OptionIcon, strOptionText, 0, itr->second.OptionType, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded); - menu->GetGossipMenu().AddGossipMenuItemData(itr->second.OptionIndex, itr->second.ActionMenuId, itr->second.ActionPoiId, itr->second.TrainerId); + menu->GetGossipMenu().AddGossipMenuItemData(itr->second.OptionIndex, itr->second.ActionMenuId, itr->second.ActionPoiId); } } } @@ -14813,7 +14813,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 optionIndex, uint32 menu GetSession()->SendStablePet(guid); break; case GOSSIP_OPTION_TRAINER: - GetSession()->SendTrainerList(source->ToCreature(), menuItemData->TrainerId); + GetSession()->SendTrainerList(source->ToCreature(), sObjectMgr->GetCreatureTrainerForGossipOption(source->GetEntry(), menuId, optionIndex)); break; case GOSSIP_OPTION_LEARNDUALSPEC: break; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 73a0b0c0c6d..53681914dfd 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -8738,33 +8738,51 @@ void ObjectMgr::LoadTrainers() TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " Trainers in %u ms", _trainers.size(), GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::LoadCreatureDefaultTrainers() +void ObjectMgr::LoadCreatureTrainers() { uint32 oldMSTime = getMSTime(); _creatureDefaultTrainers.clear(); - if (QueryResult result = WorldDatabase.Query("SELECT CreatureId, TrainerId FROM creature_default_trainer")) + if (QueryResult result = WorldDatabase.Query("SELECT CreatureId, TrainerId, MenuId, OptionIndex FROM creature_trainer")) { do { Field* fields = result->Fetch(); uint32 creatureId = fields[0].GetUInt32(); uint32 trainerId = fields[1].GetUInt32(); + uint32 gossipMenuId = fields[2].GetUInt32(); + uint32 gossipOptionIndex = fields[3].GetUInt32(); if (!GetCreatureTemplate(creatureId)) { - TC_LOG_ERROR("sql.sql", "Table `creature_default_trainer` references non-existing creature template (CreatureId: %u), ignoring", creatureId); + TC_LOG_ERROR("sql.sql", "Table `creature_trainer` references non-existing creature template (CreatureId: %u), ignoring", creatureId); continue; } if (!GetTrainer(trainerId)) { - TC_LOG_ERROR("sql.sql", "Table `creature_default_trainer` references non-existing trainer (TrainerId: %u) for CreatureId %u, ignoring", trainerId, creatureId); + TC_LOG_ERROR("sql.sql", "Table `creature_trainer` references non-existing trainer (TrainerId: %u) for CreatureId %u MenuId %u OptionIndex %u, ignoring", + trainerId, creatureId, gossipMenuId, gossipOptionIndex); continue; } - _creatureDefaultTrainers[creatureId] = trainerId; + if (gossipMenuId || gossipOptionIndex) + { + Trinity::IteratorPair<GossipMenuItemsContainer::const_iterator> gossipMenuItems = GetGossipMenuItemsMapBounds(gossipMenuId); + auto gossipOptionItr = std::find_if(gossipMenuItems.begin(), gossipMenuItems.end(), [gossipOptionIndex](std::pair<uint32 const, GossipMenuItems> const& entry) + { + return entry.second.OptionIndex == gossipOptionIndex; + }); + if (gossipOptionItr == gossipMenuItems.end()) + { + TC_LOG_ERROR("sql.sql", "Table `creature_trainer` references non-existing gossip menu option (MenuId %u OptionIndex %u) for CreatureId %u and TrainerId %u, ignoring", + gossipMenuId, gossipOptionIndex, creatureId, trainerId); + continue; + } + } + + _creatureDefaultTrainers[std::make_tuple(creatureId, gossipMenuId, gossipOptionIndex)] = trainerId; } while (result->NextRow()); } @@ -8924,13 +8942,10 @@ void ObjectMgr::LoadGossipMenuItems() // 7 8 "oa.ActionMenuId, oa.ActionPoiId, " // 9 10 11 12 - "ob.BoxCoded, ob.BoxMoney, ob.BoxText, ob.BoxBroadcastTextId, " - // 13 - "ot.TrainerId " + "ob.BoxCoded, ob.BoxMoney, ob.BoxText, ob.BoxBroadcastTextId " "FROM gossip_menu_option o " "LEFT JOIN gossip_menu_option_action oa ON o.MenuId = oa.MenuId AND o.OptionIndex = oa.OptionIndex " "LEFT JOIN gossip_menu_option_box ob ON o.MenuId = ob.MenuId AND o.OptionIndex = ob.OptionIndex " - "LEFT JOIN gossip_menu_option_trainer ot ON o.MenuId = ot.MenuId AND o.OptionIndex = ot.OptionIndex " "ORDER BY o.MenuId, o.OptionIndex"); if (!result) @@ -8958,7 +8973,6 @@ void ObjectMgr::LoadGossipMenuItems() gMenuItem.BoxMoney = fields[10].GetUInt32(); gMenuItem.BoxText = fields[11].GetString(); gMenuItem.BoxBroadcastTextId = fields[12].GetUInt32(); - gMenuItem.TrainerId = fields[13].GetUInt32(); if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX) { @@ -8993,12 +9007,6 @@ void ObjectMgr::LoadGossipMenuItems() } } - if (gMenuItem.TrainerId && !GetTrainer(gMenuItem.TrainerId)) - { - TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option_trainer` for MenuId %u, OptionIndex %u use non-existing TrainerId %u, ignoring", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.TrainerId); - gMenuItem.TrainerId = 0; - } - _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuId, gMenuItem)); } while (result->NextRow()); @@ -9010,9 +9018,9 @@ Trainer::Trainer const* ObjectMgr::GetTrainer(uint32 trainerId) const return Trinity::Containers::MapGetValuePtr(_trainers, trainerId); } -uint32 ObjectMgr::GetCreatureDefaultTrainer(uint32 creatureId) const +uint32 ObjectMgr::GetCreatureTrainerForGossipOption(uint32 creatureId, uint32 gossipMenuId, uint32 gossipOptionIndex) const { - auto itr = _creatureDefaultTrainers.find(creatureId); + auto itr = _creatureDefaultTrainers.find(std::make_tuple(creatureId, gossipMenuId, gossipOptionIndex)); if (itr != _creatureDefaultTrainers.end()) return itr->second; diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 85974e3b9da..e5b3ba78226 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -682,7 +682,6 @@ struct GossipMenuItems uint32 BoxMoney; std::string BoxText; uint32 BoxBroadcastTextId; - uint32 TrainerId; ConditionContainer Conditions; }; @@ -1297,7 +1296,7 @@ class TC_GAME_API ObjectMgr void LoadVendors(); void LoadTrainers(); - void LoadCreatureDefaultTrainers(); + void LoadCreatureTrainers(); void LoadPhases(); void UnloadPhaseConditions(); @@ -1519,7 +1518,11 @@ class TC_GAME_API ObjectMgr bool DeleteGameTele(std::string const& name); Trainer::Trainer const* GetTrainer(uint32 trainerId) const; - uint32 GetCreatureDefaultTrainer(uint32 creatureId) const; + uint32 GetCreatureDefaultTrainer(uint32 creatureId) const + { + return GetCreatureTrainerForGossipOption(creatureId, 0, 0); + } + uint32 GetCreatureTrainerForGossipOption(uint32 creatureId, uint32 gossipMenuId, uint32 gossipOptionIndex) const; VendorItemData const* GetNpcVendorItemList(uint32 entry) const { @@ -1779,7 +1782,7 @@ class TC_GAME_API ObjectMgr CacheVendorItemContainer _cacheVendorItemStore; std::unordered_map<uint32, Trainer::Trainer> _trainers; - std::unordered_map<uint32, uint32> _creatureDefaultTrainers; + std::map<std::tuple<uint32, uint32, uint32>, uint32> _creatureDefaultTrainers; std::set<uint32> _difficultyEntries[MAX_CREATURE_DIFFICULTIES]; // already loaded difficulty 1 value in creatures, used in CheckCreatureTemplate std::set<uint32> _hasDifficultyEntries[MAX_CREATURE_DIFFICULTIES]; // already loaded creatures with difficulty 1 values, used in CheckCreatureTemplate diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index cce33cd7795..db5c0c45e6e 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1995,14 +1995,14 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading Trainers..."); sObjectMgr->LoadTrainers(); // must be after load CreatureTemplate - TC_LOG_INFO("server.loading", "Loading Creature default trainers..."); - sObjectMgr->LoadCreatureDefaultTrainers(); - TC_LOG_INFO("server.loading", "Loading Gossip menu..."); sObjectMgr->LoadGossipMenu(); TC_LOG_INFO("server.loading", "Loading Gossip menu options..."); - sObjectMgr->LoadGossipMenuItems(); // must be after LoadTrainers + sObjectMgr->LoadGossipMenuItems(); + + TC_LOG_INFO("server.loading", "Loading Creature trainers..."); + sObjectMgr->LoadCreatureTrainers(); // must be after LoadGossipMenuItems TC_LOG_INFO("server.loading", "Loading Vendors..."); sObjectMgr->LoadVendors(); // must be after load CreatureTemplate and ItemTemplate diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index ccb032f6c02..a75bb33fdd7 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -696,7 +696,7 @@ public: { TC_LOG_INFO("misc", "Re-Loading `trainer` Table!"); sObjectMgr->LoadTrainers(); - sObjectMgr->LoadCreatureDefaultTrainers(); + sObjectMgr->LoadCreatureTrainers(); handler->SendGlobalGMSysMessage("DB table `trainer` reloaded."); handler->SendGlobalGMSysMessage("DB table `trainer_locale` reloaded."); handler->SendGlobalGMSysMessage("DB table `trainer_spell` reloaded."); |