From 03253f0d289fbdd8dbca9532b57c539ee66f719b Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 24 Feb 2024 16:13:14 -0500 Subject: [PATCH] Core/PacketIO: Implemented CMSG_CHECK_IS_ADVENTURE_MAP_POI_VALID and SMSG_PLAYER_IS_ADVENTURE_MAP_POI_VALID Port From (https://github.com/TrinityCore/TrinityCore/commit/f6646739908215311f110842ed41055a54dae1f0) --- Source/Game/Handlers/AdventureMapHandler.cs | 32 ++++++++++++++++++ .../Networking/Packets/AdventureMapPackets.cs | 33 +++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/Source/Game/Handlers/AdventureMapHandler.cs b/Source/Game/Handlers/AdventureMapHandler.cs index 6c2a7fcf1..19206a7a4 100644 --- a/Source/Game/Handlers/AdventureMapHandler.cs +++ b/Source/Game/Handlers/AdventureMapHandler.cs @@ -5,12 +5,44 @@ using Framework.Constants; using Game.DataStorage; using Game.Networking; using Game.Networking.Packets; +using System.Collections.Generic; using System.Linq; namespace Game { public partial class WorldSession { + [WorldPacketHandler(ClientOpcodes.CheckIsAdventureMapPoiValid)] + void HandleCheckIsAdventureMapPoiValid(CheckIsAdventureMapPoiValid checkIsAdventureMapPoiValid) + { + AdventureMapPOIRecord entry = CliDB.AdventureMapPOIStorage.LookupByKey(checkIsAdventureMapPoiValid.AdventureMapPoiID); + if (entry == null) + return; + + void sendIsPoiValid(uint adventureMapPoiId, bool isVisible) + { + PlayerIsAdventureMapPoiValid isMapPoiValid = new(); + isMapPoiValid.AdventureMapPoiID = adventureMapPoiId; + isMapPoiValid.IsVisible = isVisible; + SendPacket(isMapPoiValid); + }; + + Quest quest = Global.ObjectMgr.GetQuestTemplate(entry.QuestID); + if (quest == null) + { + sendIsPoiValid(entry.Id, false); + return; + } + + if (!_player.MeetPlayerCondition(entry.PlayerConditionID)) + { + sendIsPoiValid(entry.Id, false); + return; + } + + sendIsPoiValid(entry.Id, true); + } + [WorldPacketHandler(ClientOpcodes.AdventureMapStartQuest)] void HandleAdventureMapStartQuest(AdventureMapStartQuest startQuest) { diff --git a/Source/Game/Networking/Packets/AdventureMapPackets.cs b/Source/Game/Networking/Packets/AdventureMapPackets.cs index e7167e8e7..054bdb612 100644 --- a/Source/Game/Networking/Packets/AdventureMapPackets.cs +++ b/Source/Game/Networking/Packets/AdventureMapPackets.cs @@ -1,17 +1,46 @@ // Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. +using Framework.Constants; + namespace Game.Networking.Packets { + class CheckIsAdventureMapPoiValid : ClientPacket + { + public uint AdventureMapPoiID; + + public CheckIsAdventureMapPoiValid(WorldPacket packet) : base(packet) { } + + public override void Read() + { + AdventureMapPoiID = _worldPacket.ReadUInt32(); + } + } + + class PlayerIsAdventureMapPoiValid : ServerPacket + { + public uint AdventureMapPoiID; + public bool IsVisible; + + public PlayerIsAdventureMapPoiValid() : base(ServerOpcodes.PlayerIsAdventureMapPoiValid, ConnectionType.Instance) { } + + public override void Write() + { + _worldPacket.WriteUInt32(AdventureMapPoiID); + _worldPacket.WriteBit(IsVisible); + _worldPacket.FlushBits(); + } + } + class AdventureMapStartQuest : ClientPacket { + public uint QuestID; + public AdventureMapStartQuest(WorldPacket packet) : base(packet) { } public override void Read() { QuestID = _worldPacket.ReadUInt32(); } - - public uint QuestID; } }