aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
4 files changed, 64 insertions, 0 deletions
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