From 40a768135890f48c84acff7938fa39f933352787 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Thu, 19 Oct 2023 15:14:41 +0100 Subject: [PATCH] [core] Allow external modification of packet guard allow list --- modules/renamer/cpp/renamer.cpp | 8 +++++++- src/map/packet_guard.cpp | 5 +++++ src/map/packet_guard.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/renamer/cpp/renamer.cpp b/modules/renamer/cpp/renamer.cpp index 36d06d59995..9c7946eef40 100644 --- a/modules/renamer/cpp/renamer.cpp +++ b/modules/renamer/cpp/renamer.cpp @@ -1,4 +1,5 @@ -#include "../src/map/utils/moduleutils.h" +#include "../src/map/packet_guard.h" +#include "../src/map/utils/moduleutils.h" #include "../src/map/zone.h" extern uint8 PacketSize[512]; @@ -87,6 +88,11 @@ class RenamerModule : public CPPModule SendListPacket(PChar, dataString); }; + + // Add new possible packet to PacketGuard allow list + auto& allowList = PacketGuard::GetPacketAllowList(); + + allowList[SUBSTATE_IN_CS][0x01] = true; } }; diff --git a/src/map/packet_guard.cpp b/src/map/packet_guard.cpp index 9c0624dc6aa..3aff3a1ee31 100644 --- a/src/map/packet_guard.cpp +++ b/src/map/packet_guard.cpp @@ -136,4 +136,9 @@ namespace PacketGuard output += "=======================================\n"; ShowInfo(output); } + + auto GetPacketAllowList() -> std::unordered_map>& + { + return allowList; + } } // namespace PacketGuard diff --git a/src/map/packet_guard.h b/src/map/packet_guard.h index 85054cf7f3b..a92b87d24c3 100644 --- a/src/map/packet_guard.h +++ b/src/map/packet_guard.h @@ -13,6 +13,8 @@ namespace PacketGuard bool PacketIsValidForPlayerState(CCharEntity* PChar, uint16 SmallPD_Type); bool IsRateLimitedPacket(CCharEntity* PChar, uint16 SmallPD_Type); void PrintPacketList(CCharEntity* PChar); + + auto GetPacketAllowList() -> std::unordered_map>&; } // namespace PacketGuard #endif // _PACKETGUARD_H