aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeji <alvaro.megias@outlook.com>2022-08-13 20:17:58 +0200
committerGitHub <noreply@github.com>2022-08-13 20:17:58 +0200
commit1bbc8592d95978a4c681fa6177c7c457189ef485 (patch)
tree550e3397873b815aa5ca6c50073a132fe499fe9b
parent1d5696a08bd5afae366b36d257aa06c465a980f2 (diff)
Core/Gossips: Added support for FriendshipFactionID (#28192)
-rw-r--r--sql/updates/world/master/2022_08_13_00_world.sql19
-rw-r--r--src/server/game/Entities/Creature/GossipDef.cpp3
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp43
-rw-r--r--src/server/game/Globals/ObjectMgr.h15
-rw-r--r--src/server/game/World/World.cpp3
5 files changed, 83 insertions, 0 deletions
diff --git a/sql/updates/world/master/2022_08_13_00_world.sql b/sql/updates/world/master/2022_08_13_00_world.sql
new file mode 100644
index 00000000000..40db4990405
--- /dev/null
+++ b/sql/updates/world/master/2022_08_13_00_world.sql
@@ -0,0 +1,19 @@
+DROP TABLE IF EXISTS `gossip_menu_addon`;
+CREATE TABLE `gossip_menu_addon` (
+ `MenuID` INT UNSIGNED NOT NULL DEFAULT 0,
+ `FriendshipFactionID` INT NOT NULL DEFAULT 0,
+ `VerifiedBuild` INT NOT NULL DEFAULT 0,
+ PRIMARY KEY (`MenuID`)
+) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+DELETE FROM `gossip_menu_addon` WHERE `MenuID` IN (13332, 13338, 13470, 13475, 13486, 13574, 13593, 13594, 13595);
+INSERT INTO `gossip_menu_addon` (`MenuID`, `FriendshipFactionID`, `VerifiedBuild`) VALUES
+(13332, 1283, 44908), -- 57298 (Farmer Fung)
+(13338, 1279, 44908), -- 57402 (Haohan Mudclaw)
+(13470, 1281, 44908), -- 58706 (Gina Mudclaw)
+(13475, 1281, 44908), -- 58706 (Gina Mudclaw)
+(13486, 1275, 44908), -- 58647 (Ella)
+(13574, 1282, 44908), -- 58705 (Fish Fellreed)
+(13593, 1280, 44908), -- 58761 (Tina Mudclaw)
+(13594, 1277, 44908), -- 58709 (Chee Chee)
+(13595, 1276, 44908); -- 58707 (Old Hillpaw)
diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp
index 88874704a89..a99fd890a0f 100644
--- a/src/server/game/Entities/Creature/GossipDef.cpp
+++ b/src/server/game/Entities/Creature/GossipDef.cpp
@@ -214,6 +214,9 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID)
WorldPackets::NPC::GossipMessage packet;
packet.GossipGUID = objectGUID;
packet.GossipID = _gossipMenu.GetMenuId();
+ if (GossipMenuAddon const* addon = sObjectMgr->GetGossipMenuAddon(packet.GossipID))
+ packet.FriendshipFactionID = addon->FriendshipFactionID;
+
if (NpcText const* text = sObjectMgr->GetNpcText(titleTextId))
packet.TextID = Trinity::Containers::SelectRandomWeightedContainerElement(text->Data, [](NpcTextData const& data) { return data.Probability; })->BroadcastTextID;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 140e1c5a6cd..f3873c6c351 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -9687,6 +9687,49 @@ void ObjectMgr::LoadGossipMenuItems()
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " gossip_menu_option entries in %u ms", _gossipMenuItemsStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
+void ObjectMgr::LoadGossipMenuFriendshipFactions()
+{
+ uint32 oldMSTime = getMSTime();
+
+ _gossipMenuAddonStore.clear();
+
+ // 0 1
+ QueryResult result = WorldDatabase.Query("SELECT MenuID, FriendshipFactionID FROM gossip_menu_addon");
+
+ if (!result)
+ {
+ TC_LOG_INFO("server.loading", ">> Loaded 0 gossip_menu_addon IDs. DB table `gossip_menu_addon` is empty!");
+ return;
+ }
+
+ do
+ {
+ Field* fields = result->Fetch();
+
+ uint32 menuID = fields[0].GetUInt32();
+ GossipMenuAddon& addon = _gossipMenuAddonStore[menuID];
+ addon.FriendshipFactionID = fields[1].GetInt32();
+
+ if (FactionEntry const* faction = sFactionStore.LookupEntry(addon.FriendshipFactionID))
+ {
+ if (!sFriendshipReputationStore.LookupEntry(faction->FriendshipRepID))
+ {
+ TC_LOG_ERROR("sql.sql", "Table gossip_menu_addon: ID %u is using FriendshipFactionID %u referencing non-existing FriendshipRepID %u",
+ menuID, addon.FriendshipFactionID, faction->FriendshipRepID);
+ addon.FriendshipFactionID = 0;
+ }
+ }
+ else
+ {
+ TC_LOG_ERROR("sql.sql", "Table gossip_menu_addon: ID %u is using non-existing FriendshipFactionID %u", menuID, addon.FriendshipFactionID);
+ addon.FriendshipFactionID = 0;
+ }
+
+ } while (result->NextRow());
+
+ TC_LOG_INFO("server.loading", ">> Loaded %u gossip_menu_addon IDs in %u ms", uint32(_gossipMenuAddonStore.size()), GetMSTimeDiffToNow(oldMSTime));
+}
+
Trainer::Trainer const* ObjectMgr::GetTrainer(uint32 trainerId) const
{
return Trinity::Containers::MapGetValuePtr(_trainers, trainerId);
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 1cc7d1939e9..afa0c90f2d7 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -766,12 +766,18 @@ struct GossipMenus
ConditionContainer Conditions;
};
+struct GossipMenuAddon
+{
+ int32 FriendshipFactionID;
+};
+
typedef std::multimap<uint32, GossipMenus> GossipMenusContainer;
typedef std::pair<GossipMenusContainer::const_iterator, GossipMenusContainer::const_iterator> GossipMenusMapBounds;
typedef std::pair<GossipMenusContainer::iterator, GossipMenusContainer::iterator> GossipMenusMapBoundsNonConst;
typedef std::multimap<uint32, GossipMenuItems> GossipMenuItemsContainer;
typedef std::pair<GossipMenuItemsContainer::const_iterator, GossipMenuItemsContainer::const_iterator> GossipMenuItemsMapBounds;
typedef std::pair<GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator> GossipMenuItemsMapBoundsNonConst;
+typedef std::unordered_map<uint32, GossipMenuAddon> GossipMenuAddonContainer;
struct QuestPOIBlobPoint
{
@@ -1392,6 +1398,7 @@ class TC_GAME_API ObjectMgr
void LoadGossipMenu();
void LoadGossipMenuItems();
+ void LoadGossipMenuFriendshipFactions();
void LoadVendors();
void LoadTrainers();
@@ -1687,6 +1694,13 @@ class TC_GAME_API ObjectMgr
{
return _gossipMenuItemsStore.equal_range(uiMenuId);
}
+ GossipMenuAddon const* GetGossipMenuAddon(uint32 menuId) const
+ {
+ GossipMenuAddonContainer::const_iterator itr = _gossipMenuAddonStore.find(menuId);
+ if (itr != _gossipMenuAddonStore.end())
+ return &itr->second;
+ return nullptr;
+ }
// for wintergrasp only
GraveyardContainer GraveyardStore;
@@ -1820,6 +1834,7 @@ class TC_GAME_API ObjectMgr
GossipMenusContainer _gossipMenusStore;
GossipMenuItemsContainer _gossipMenuItemsStore;
+ GossipMenuAddonContainer _gossipMenuAddonStore;
PointOfInterestContainer _pointsOfInterestStore;
QuestPOIContainer _questPOIStore;
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 5b741bda0ca..6dab922968a 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -2248,6 +2248,9 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Loading Gossip menu options...");
sObjectMgr->LoadGossipMenuItems();
+ TC_LOG_INFO("server.loading", "Loading Gossip menu friendship factions...");
+ sObjectMgr->LoadGossipMenuFriendshipFactions();
+
TC_LOG_INFO("server.loading", "Loading Creature trainers...");
sObjectMgr->LoadCreatureTrainers(); // must be after LoadGossipMenuItems