Core/Gossips: Added support for FriendshipFactionID

Port From (https://github.com/TrinityCore/TrinityCore/commit/1bbc8592d95978a4c681fa6177c7c457189ef485)
This commit is contained in:
hondacrx
2022-08-13 17:54:36 -04:00
parent 7431e719c6
commit a6a9d05e98
5 changed files with 82 additions and 4 deletions
+11 -1
View File
@@ -249,7 +249,12 @@ namespace Game.Misc
GossipMessagePkt packet = new();
packet.GossipGUID = objectGUID;
packet.GossipID = (int)_gossipMenu.GetMenuId();
packet.GossipID = _gossipMenu.GetMenuId();
GossipMenuAddon addon = Global.ObjectMgr.GetGossipMenuAddon(packet.GossipID);
if (addon != null)
packet.FriendshipFactionID = addon.FriendshipFactionID;
NpcText text = Global.ObjectMgr.GetNpcText(titleTextId);
if (text != null)
packet.TextID = (int)text.Data.SelectRandomElementByWeight(data => data.Probability).BroadcastTextID;
@@ -747,6 +752,11 @@ namespace Game.Misc
public List<Condition> Conditions = new();
}
public class GossipMenuAddon
{
public int FriendshipFactionID;
}
public class PointOfInterest
{
public uint Id;
+47 -1
View File
@@ -652,6 +652,47 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, $"Loaded {gossipMenuItemsStorage.Count} gossip_menu_option entries in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
}
public void LoadGossipMenuFriendshipFactions()
{
uint oldMSTime = Time.GetMSTime();
_gossipMenuAddonStorage.Clear();
// 0 1
SQLResult result = DB.World.Query("SELECT MenuID, FriendshipFactionID FROM gossip_menu_addon");
if (result.IsEmpty())
{
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 gossip_menu_addon IDs. DB table `gossip_menu_addon` is empty!");
return;
}
do
{
uint menuID = result.Read<uint>(0);
GossipMenuAddon addon = new();
addon.FriendshipFactionID = result.Read<int>(1);
var faction = CliDB.FactionStorage.LookupByKey(addon.FriendshipFactionID);
if (faction != null)
{
if (!CliDB.FriendshipReputationStorage.ContainsKey(faction.FriendshipRepID))
{
Log.outError(LogFilter.Sql, $"Table gossip_menu_addon: ID {menuID} is using FriendshipFactionID {addon.FriendshipFactionID} referencing non-existing FriendshipRepID {faction.FriendshipRepID}");
addon.FriendshipFactionID = 0;
}
}
else
{
Log.outError(LogFilter.Sql, $"Table gossip_menu_addon: ID {menuID} is using non-existing FriendshipFactionID {addon.FriendshipFactionID}");
addon.FriendshipFactionID = 0;
}
_gossipMenuAddonStorage[menuID] = addon;
} while (result.NextRow());
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_gossipMenuAddonStorage.Count} gossip_menu_addon IDs in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
}
public void LoadPointsOfInterest()
{
uint oldMSTime = Time.GetMSTime();
@@ -702,6 +743,10 @@ namespace Game
{
return gossipMenuItemsStorage.LookupByKey(uiMenuId);
}
public GossipMenuAddon GetGossipMenuAddon(uint menuId)
{
return _gossipMenuAddonStorage.LookupByKey(menuId);
}
public PointOfInterest GetPointOfInterest(uint id)
{
return pointsOfInterestStorage.LookupByKey(id);
@@ -10778,8 +10823,9 @@ namespace Game
Dictionary<uint, SkillTiersEntry> _skillTiers = new();
//Gossip
MultiMap<uint, GossipMenuItems> gossipMenuItemsStorage = new();
MultiMap<uint, GossipMenus> gossipMenusStorage = new();
MultiMap<uint, GossipMenuItems> gossipMenuItemsStorage = new();
Dictionary<uint, GossipMenuAddon> _gossipMenuAddonStorage = new();
Dictionary<uint, PointOfInterest> pointsOfInterestStorage = new();
//Creature
+2 -2
View File
@@ -50,7 +50,7 @@ namespace Game.Networking.Packets
public override void Write()
{
_worldPacket.WritePackedGuid(GossipGUID);
_worldPacket.WriteInt32(GossipID);
_worldPacket.WriteUInt32(GossipID);
_worldPacket.WriteInt32(FriendshipFactionID);
_worldPacket.WriteInt32(TextID);
@@ -89,7 +89,7 @@ namespace Game.Networking.Packets
public ObjectGuid GossipGUID;
public List<ClientGossipText> GossipText = new();
public int TextID;
public int GossipID;
public uint GossipID;
}
public class GossipSelectOption : ClientPacket
+3
View File
@@ -885,6 +885,9 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading Gossip menu options...");
Global.ObjectMgr.LoadGossipMenuItems();
Log.outInfo(LogFilter.ServerLoading, "Loading Gossip menu friendship factions...");
Global.ObjectMgr.LoadGossipMenuFriendshipFactions();
Log.outInfo(LogFilter.ServerLoading, "Loading Creature trainers...");
Global.ObjectMgr.LoadCreatureTrainers(); // must be after LoadGossipMenuItems
@@ -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)