Implement a general way to store selection data for gossip and fix trainer exploit

This commit is contained in:
hondacrx
2017-08-15 10:42:52 -04:00
parent 000aa1d993
commit 8d113d506d
7 changed files with 48 additions and 13 deletions
+17 -5
View File
@@ -182,8 +182,6 @@ namespace Game.Misc
public void SetMenuId(uint menu_id) { _menuId = menu_id; }
public uint GetMenuId() { return _menuId; }
public void SetSenderGUID(ObjectGuid guid) { _senderGUID = guid; }
public ObjectGuid GetSenderGUID() { return _senderGUID; }
public void SetLocale(LocaleConstant locale) { _locale = locale; }
LocaleConstant GetLocale() { return _locale; }
@@ -215,10 +213,21 @@ namespace Game.Misc
Dictionary<uint, GossipMenuItem> _menuItems = new Dictionary<uint, GossipMenuItem>();
Dictionary<uint, GossipMenuItemData> _menuItemData = new Dictionary<uint, GossipMenuItemData>();
uint _menuId;
ObjectGuid _senderGUID;
LocaleConstant _locale;
}
public class InteractionData
{
public void Reset()
{
SourceGuid.Clear();
TrainerId = 0;
}
public ObjectGuid SourceGuid;
public uint TrainerId;
}
public class PlayerMenu
{
public PlayerMenu(WorldSession session)
@@ -236,7 +245,8 @@ namespace Game.Misc
public void SendGossipMenu(uint titleTextId, ObjectGuid objectGUID)
{
_gossipMenu.SetSenderGUID(objectGUID);
_interactionData.Reset();
_interactionData.SourceGuid = objectGUID;
GossipMessagePkt packet = new GossipMessagePkt();
packet.GossipGUID = objectGUID;
@@ -294,7 +304,7 @@ namespace Game.Misc
public void SendCloseGossip()
{
_gossipMenu.SetSenderGUID(ObjectGuid.Empty);
_interactionData.Reset();
_session.SendPacket(new GossipComplete());
}
@@ -726,6 +736,7 @@ namespace Game.Misc
public GossipMenu GetGossipMenu() { return _gossipMenu; }
public QuestMenu GetQuestMenu() { return _questMenu; }
public InteractionData GetInteractionData() { return _interactionData; }
bool IsEmpty() { return _gossipMenu.IsEmpty() && _questMenu.IsEmpty(); }
@@ -736,6 +747,7 @@ namespace Game.Misc
GossipMenu _gossipMenu = new GossipMenu();
QuestMenu _questMenu = new QuestMenu();
WorldSession _session;
InteractionData _interactionData = new InteractionData();
}
public class QuestMenu
-2
View File
@@ -140,8 +140,6 @@ namespace Game.Entities
RestMgr _restMgr;
uint _currentTrainerId;
//Combat
int[] baseRatingValue = new int[(int)CombatRating.Max];
public float[][] m_auraBaseMod = new float[(int)BaseModGroup.End][];
-3
View File
@@ -1034,9 +1034,6 @@ namespace Game.Entities
public RestMgr GetRestMgr() { return _restMgr; }
public uint GetCurrentTrainerId() { return _currentTrainerId; }
public void SetCurrentTrainerId(uint trainerId) { _currentTrainerId = trainerId; }
public bool IsAdvancedCombatLoggingEnabled() { return _advancedCombatLoggingEnabled; }
public void SetAdvancedCombatLogging(bool enabled) { _advancedCombatLoggingEnabled = enabled; }
+5
View File
@@ -367,6 +367,9 @@ namespace Game
[WorldPacketHandler(ClientOpcodes.MailReturnToSender)]
void HandleMailReturnToSender(MailReturnToSender packet)
{
if (!CanOpenMailBox(_player.PlayerTalkClass.GetInteractionData().SourceGuid))
return;
Player player = GetPlayer();
Mail m = player.GetMail(packet.MailID);
if (m == null || m.state == MailState.Deleted || m.deliver_time > Time.UnixTime || m.sender != packet.SenderGUID.GetCounter())
@@ -576,6 +579,8 @@ namespace Game
response.Mails.Add(new MailListEntry(m, player));
}
player.PlayerTalkClass.GetInteractionData().Reset();
player.PlayerTalkClass.GetInteractionData().SourceGuid = packet.Mailbox;
SendPacket(response);
// recalculate m_nextMailDelivereTime and unReadMails
+6
View File
@@ -432,6 +432,12 @@ namespace Game
_player.Prestige();
}
[WorldPacketHandler(ClientOpcodes.CloseInteraction, Processing = PacketProcessing.ThreadSafe)]
void HandleCloseInteraction(CloseInteraction packet)
{
_player.PlayerTalkClass.GetInteractionData().Reset();
}
[WorldPacketHandler(ClientOpcodes.ChatUnregisterAllAddonPrefixes)]
void HandleUnregisterAllAddonPrefixes(ChatUnregisterAllAddonPrefixes packet)
{
+8 -3
View File
@@ -79,7 +79,9 @@ namespace Game
return;
}
_player.SetCurrentTrainerId(trainerId);
_player.PlayerTalkClass.GetInteractionData().Reset();
_player.PlayerTalkClass.GetInteractionData().SourceGuid = guid;
_player.PlayerTalkClass.GetInteractionData().TrainerId = trainerId;
trainer.SendSpells(unit, _player, GetSessionDbLocaleIndex());
}
@@ -97,7 +99,10 @@ namespace Game
if (_player.HasUnitState(UnitState.Died))
_player.RemoveAurasByType(AuraType.FeignDeath);
if (_player.GetCurrentTrainerId() != packet.TrainerID)
if (_player.PlayerTalkClass.GetInteractionData().SourceGuid != packet.TrainerGUID)
return;
if (_player.PlayerTalkClass.GetInteractionData().TrainerId != packet.TrainerID)
return;
// check present spell in trainer spell list
@@ -164,7 +169,7 @@ namespace Game
return;
// Prevent cheating on C# scripted menus
if (GetPlayer().PlayerTalkClass.GetGossipMenu().GetSenderGUID() != packet.GossipUnit)
if (GetPlayer().PlayerTalkClass.GetInteractionData().SourceGuid != packet.GossipUnit)
return;
Creature unit = null;
+12
View File
@@ -1287,4 +1287,16 @@ namespace Game.Network.Packets
public override void Read() { }
}
class CloseInteraction : ClientPacket
{
public CloseInteraction(WorldPacket packet) : base(packet) { }
public override void Read()
{
SourceGuid = _worldPacket.ReadPackedGuid();
}
public ObjectGuid SourceGuid;
}
}