From a661de2a841315252b9d6367837fb452c6ea8ee2 Mon Sep 17 00:00:00 2001 From: Koncord Date: Mon, 29 Aug 2016 21:00:19 +0800 Subject: [PATCH] PacketClass --- components/CMakeLists.txt | 3 ++- components/openmw-mp/Packets/PacketClass.cpp | 26 ++++++++++++++++++++ components/openmw-mp/Packets/PacketClass.hpp | 23 +++++++++++++++++ components/openmw-mp/PacketsController.cpp | 2 ++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 components/openmw-mp/Packets/PacketClass.cpp create mode 100644 components/openmw-mp/Packets/PacketClass.hpp diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8843ef10e..1f1dc18ab 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -150,7 +150,8 @@ add_component_dir (openmw-mp PacketsController Packets/BasePacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquiped Packets/PacketAttributesAndStats Packets/PacketAttack Packets/PacketMainStats Packets/PacketCell Packets/PacketDrawState Packets/PacketChatMessage - Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketHandshake Packets/PacketGUIBoxes) + Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketHandshake Packets/PacketGUIBoxes + Packets/PacketClass) add_component_dir (fallback fallback validate diff --git a/components/openmw-mp/Packets/PacketClass.cpp b/components/openmw-mp/Packets/PacketClass.cpp new file mode 100644 index 000000000..7f3c91487 --- /dev/null +++ b/components/openmw-mp/Packets/PacketClass.cpp @@ -0,0 +1,26 @@ +// +// Created by koncord on 29.08.16. +// + +#include +#include "PacketClass.hpp" + +mwmp::PacketClass::PacketClass(RakNet::RakPeerInterface *peer) : BasePacket(peer) +{ + packetID = ID_GAME_CHARCLASS; +} + +void mwmp::PacketClass::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +{ + BasePacket::Packet(bs, player, send); + + RW(player->klass.mId, send); + RW(player->customClass, send); + + if(player->customClass) + { + RW(player->klass.mName, send); + RW(player->klass.mDescription, send); + RW(player->klass.mData, send); + } +} diff --git a/components/openmw-mp/Packets/PacketClass.hpp b/components/openmw-mp/Packets/PacketClass.hpp new file mode 100644 index 000000000..27db8529b --- /dev/null +++ b/components/openmw-mp/Packets/PacketClass.hpp @@ -0,0 +1,23 @@ +// +// Created by koncord on 29.08.16. +// + +#ifndef OPENMW_PACKETCLASS_HPP +#define OPENMW_PACKETCLASS_HPP + + +#include + +namespace mwmp +{ + class PacketClass : public BasePacket + { + public: + PacketClass(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + }; +} + + +#endif //OPENMW_PACKETCLASS_HPP diff --git a/components/openmw-mp/PacketsController.cpp b/components/openmw-mp/PacketsController.cpp index b7bf69c4a..5133c6f9f 100644 --- a/components/openmw-mp/PacketsController.cpp +++ b/components/openmw-mp/PacketsController.cpp @@ -6,6 +6,7 @@ #include #include +#include "Packets/PacketClass.hpp" #include "Packets/PacketPosition.hpp" #include "Packets/PacketBaseInfo.hpp" #include "components/openmw-mp/Packets/PacketEquiped.hpp" @@ -59,6 +60,7 @@ mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer) AddPacket(&packets, peer); AddPacket(&packets, peer); + AddPacket(&packets, peer); }