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