From eb95b0106deae74bcc928dbbb17db50f43529bf6 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 23 May 2022 17:18:01 -0400 Subject: [PATCH] Core/Quests: Fixes response selection to use correct referenced identifier Port From (https://github.com/TrinityCore/TrinityCore/commit/8de5053a655a59cc1d38b1e1de59950ab32629cf) --- Source/Game/Globals/ObjectManager.cs | 15 ++++++++++----- Source/Game/Handlers/QuestHandler.cs | 6 +++--- Source/Game/Networking/Packets/QuestPackets.cs | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 7276006a2..529e97b86 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -11842,11 +11842,6 @@ namespace Game public class PlayerChoice { - public PlayerChoiceResponse GetResponse(int responseId) - { - return Responses.FirstOrDefault(playerChoiceResponse => playerChoiceResponse.ResponseId == responseId); - } - public int ChoiceId; public int UiTextureKitId; public uint SoundKitId; @@ -11857,6 +11852,16 @@ namespace Game public List Responses = new(); public bool HideWarboardHeader; public bool KeepOpenAfterChoice; + + public PlayerChoiceResponse GetResponse(int responseId) + { + return Responses.Find(playerChoiceResponse => playerChoiceResponse.ResponseId == responseId); + } + + public PlayerChoiceResponse GetResponseByIdentifier(int responseIdentifier) + { + return Responses.Find(playerChoiceResponse => playerChoiceResponse.ResponseIdentifier == responseIdentifier); + } } public class ClassAvailability diff --git a/Source/Game/Handlers/QuestHandler.cs b/Source/Game/Handlers/QuestHandler.cs index f8f631ccc..1cfc186cd 100644 --- a/Source/Game/Handlers/QuestHandler.cs +++ b/Source/Game/Handlers/QuestHandler.cs @@ -787,14 +787,14 @@ namespace Game if (playerChoice == null) return; - PlayerChoiceResponse playerChoiceResponse = playerChoice.GetResponse(choiceResponse.ResponseID); + PlayerChoiceResponse playerChoiceResponse = playerChoice.GetResponseByIdentifier(choiceResponse.ResponseIdentifier); if (playerChoiceResponse == null) { - Log.outError(LogFilter.Player, $"Error in CMSG_CHOICE_RESPONSE: {GetPlayerInfo()} tried to select invalid player choice response {choiceResponse.ResponseID} (possible packet-hacking detected)"); + Log.outError(LogFilter.Player, $"Error in CMSG_CHOICE_RESPONSE: {GetPlayerInfo()} tried to select invalid player choice response {choiceResponse.ResponseIdentifier} (possible packet-hacking detected)"); return; } - Global.ScriptMgr.OnPlayerChoiceResponse(GetPlayer(), (uint)choiceResponse.ChoiceID, (uint)choiceResponse.ResponseID); + Global.ScriptMgr.OnPlayerChoiceResponse(GetPlayer(), (uint)choiceResponse.ChoiceID, (uint)choiceResponse.ResponseIdentifier); if (playerChoiceResponse.Reward != null) { diff --git a/Source/Game/Networking/Packets/QuestPackets.cs b/Source/Game/Networking/Packets/QuestPackets.cs index c833025c9..f2c4188f2 100644 --- a/Source/Game/Networking/Packets/QuestPackets.cs +++ b/Source/Game/Networking/Packets/QuestPackets.cs @@ -889,12 +889,12 @@ namespace Game.Networking.Packets public override void Read() { ChoiceID = _worldPacket.ReadInt32(); - ResponseID = _worldPacket.ReadInt32(); + ResponseIdentifier = _worldPacket.ReadInt32(); IsReroll = _worldPacket.HasBit(); } public int ChoiceID; - public int ResponseID; + public int ResponseIdentifier; public bool IsReroll; }