diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 0ea9a9257..6e19faa36 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -156,6 +156,7 @@ add_component_dir (openmw-mp Packets/Player/PacketAttribute Packets/Player/PacketSkill Packets/Player/PacketLevel Packets/Player/PacketHandshake Packets/Player/PacketGUIBoxes Packets/Player/PacketClass Packets/Player/PacketTime Packets/Player/PacketInventory Packets/Player/PacketSpellbook + Packets/Player/PacketActiveSkills Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace Packets/World/PacketObjectLock Packets/World/PacketObjectUnlock Packets/World/PacketObjectScale Packets/World/PacketObjectMove diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index 311dd22eb..a0dbda3a1 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -196,6 +196,7 @@ namespace mwmp Spellbook spellbook; bool consoleAllowed; bool ignorePosPacket; + ESM::ActiveSpells activeSpells; protected: ESM::Position pos; diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 9de08ec40..8a200cd9c 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -33,6 +33,7 @@ enum GameMessages ID_GAME_TIME, ID_GAME_INVENTORY, ID_GAME_SPELLBOOK, + ID_GAME_ACTIVESKILLS, ID_OBJECT_PLACE, ID_OBJECT_DELETE, diff --git a/components/openmw-mp/Packets/Player/PacketActiveSkills.cpp b/components/openmw-mp/Packets/Player/PacketActiveSkills.cpp new file mode 100644 index 000000000..015bf669e --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketActiveSkills.cpp @@ -0,0 +1,58 @@ +// +// Created by koncord on 03.12.16. +// + +#include "PacketActiveSkills.hpp" +#include + +using namespace mwmp; + +PacketActiveSkills::PacketActiveSkills(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) +{ + packetID = ID_GAME_ACTIVESKILLS; +} + +void PacketActiveSkills::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send) +{ + PlayerPacket::Packet(bs, player, send); + + unsigned long spells = 0; + + if (send) + spells = player->activeSpells.mSpells.size(); + + RW(spells, send); + + if (send) + for (ESM::ActiveSpells::TContainer::const_iterator spell = player->activeSpells.mSpells.begin(); + spell != player->activeSpells.mSpells.end(); ++spell) + { + RW(spell->first, true); + RW(spell->second.mTimeStamp, true); + unsigned long effects = spell->second.mEffects.size(); + RW(effects, true); + + for (std::vector::const_iterator effect = spell->second.mEffects.begin(); + effect != spell->second.mEffects.end(); ++effect) + RW(effect, true); + + } + else + for (unsigned int i = 0; i < spells; i++) + { + ESM::ActiveSpells::TContainer::value_type spell; + + RW(spell.first, false); + RW(spell.second.mTimeStamp, false); + unsigned long effects; + RW(effects, false); + + ESM::ActiveEffect effect; + for (unsigned int j = 0; j < effects; j++) + { + RW(effect, false); + spell.second.mEffects.push_back(effect); + } + player->activeSpells.mSpells.insert(spell); + } +} \ No newline at end of file diff --git a/components/openmw-mp/Packets/Player/PacketActiveSkills.hpp b/components/openmw-mp/Packets/Player/PacketActiveSkills.hpp new file mode 100644 index 000000000..33f826e98 --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketActiveSkills.hpp @@ -0,0 +1,21 @@ +// +// Created by koncord on 03.12.16. +// + +#ifndef OPENMW_PACKETACTIVESKILLS_HPP +#define OPENMW_PACKETACTIVESKILLS_HPP + +#include + +namespace mwmp +{ + class PacketActiveSkills : public PlayerPacket + { + public: + PacketActiveSkills(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + }; +} + +#endif //OPENMW_PACKETACTIVESKILLS_HPP