From df79a35eaee34deed433345fade0f8553352bb14 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Mon, 4 Aug 2025 11:35:51 +0200 Subject: [PATCH] add packets --- include/td/protocol/packet/Packets.h | 11 ++++++++--- include/td/simulation/ClientSimulation.h | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/td/protocol/packet/Packets.h b/include/td/protocol/packet/Packets.h index 9b2ebd9..0fce78f 100644 --- a/include/td/protocol/packet/Packets.h +++ b/include/td/protocol/packet/Packets.h @@ -8,11 +8,11 @@ #include #include +#include #include #include #include #include -#include namespace td { namespace protocol { @@ -24,10 +24,12 @@ enum class PacketID : std::uint8_t { KeepAlive, LockSteps, LoggingSuccess, + PlaceTower, PlayerJoin, PlayerLeave, PlayerLogin, PredictCommand, + SpawnTroop, WorldHeader, WorldData, }; @@ -49,18 +51,21 @@ using DisconnectPacket = PacketMessage; using KeepAlivePacket = PacketMessage; using LockStepsPacket = PacketMessage; using LoggingSuccessPacket = PacketMessage; +using PlaceTowerPacket = PacketMessage; using PlayerJoinPacket = PacketMessage; using PlayerLeavePacket = PacketMessage; using PlayerLoginPacket = PacketMessage; using PredictCommandPacket = PacketMessage; +using SpawnTroopPacket = PacketMessage; using WorldHeaderPacket = PacketMessage; using WorldDataPacket = PacketMessage; } // namespace packets using AllPackets = std::tuple; + packets::KeepAlivePacket, packets::LockStepsPacket, packets::LoggingSuccessPacket, packets::PlaceTowerPacket, + packets::PlayerJoinPacket, packets::PlayerLeavePacket, packets::PlayerLoginPacket, packets::PredictCommandPacket, + packets::SpawnTroopPacket, packets::WorldHeaderPacket, packets::WorldDataPacket>; class PacketHandler : public sp::GenericHandler {}; diff --git a/include/td/simulation/ClientSimulation.h b/include/td/simulation/ClientSimulation.h index f58abde..d445ab2 100644 --- a/include/td/simulation/ClientSimulation.h +++ b/include/td/simulation/ClientSimulation.h @@ -24,6 +24,8 @@ class ClientSimulation : public protocol::PacketHandler { static const protocol::LockStep EMPTY_LOCKSTEP; + using protocol::PacketHandler::Handle; + public: /** * \brief Replay constructor @@ -42,8 +44,8 @@ class ClientSimulation : public protocol::PacketHandler { */ float Update(); - void Handle(const protocol::packets::LockStepsPacket& a_LockSteps) override; - void Handle(const protocol::packets::PredictCommandPacket& a_Predict) override; + virtual void Handle(const protocol::packets::LockStepsPacket& a_LockSteps) override; + virtual void Handle(const protocol::packets::PredictCommandPacket& a_Predict) override; private: void Step();