From ce4b326b025df176baa8f2c43b68aa4df6bc0c23 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 28 Sep 2016 07:50:16 +0300 Subject: [PATCH] Rename ID_GAME_UPDATE_BASESTATS into ID_GAME_DYNAMICSTATS_CURRENT --- apps/openmw-mp/Networking.cpp | 12 +- apps/openmw-mp/Script/Functions/Items.cpp | 4 +- apps/openmw-mp/Script/Functions/Stats.cpp | 24 ++-- apps/openmw-mp/Script/Functions/Stats.hpp | 105 +++++++++--------- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwmp/LocalPlayer.cpp | 8 +- apps/openmw/mwmp/LocalPlayer.hpp | 2 +- apps/openmw/mwmp/Main.cpp | 2 +- apps/openmw/mwmp/Networking.cpp | 8 +- apps/openmw/mwmp/Networking.hpp | 3 +- components/CMakeLists.txt | 6 +- components/openmw-mp/NetworkMessages.hpp | 3 +- ...inStats.cpp => PacketDynamicStatsBase.cpp} | 10 +- .../Packets/PacketDynamicStatsBase.hpp | 22 ++++ .../Packets/PacketDynamicStatsCurrent.cpp | 21 ++++ .../Packets/PacketDynamicStatsCurrent.hpp | 22 ++++ .../openmw-mp/Packets/PacketMainStats.hpp | 22 ---- components/openmw-mp/PacketsController.cpp | 6 +- 18 files changed, 169 insertions(+), 113 deletions(-) rename components/openmw-mp/Packets/{PacketMainStats.cpp => PacketDynamicStatsBase.cpp} (50%) create mode 100644 components/openmw-mp/Packets/PacketDynamicStatsBase.hpp create mode 100644 components/openmw-mp/Packets/PacketDynamicStatsCurrent.cpp create mode 100644 components/openmw-mp/Packets/PacketDynamicStatsCurrent.hpp delete mode 100644 components/openmw-mp/Packets/PacketMainStats.hpp diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 8b895f026..218d6e206 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -259,14 +259,14 @@ void Networking::Update(RakNet::Packet *packet) #endif myPacket->Send(player, true); - controller->GetPacket(ID_GAME_UPDATE_BASESTATS)->RequestData(player->GetAttack()->target); + controller->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->RequestData(player->GetAttack()->target); } break; } - case ID_GAME_UPDATE_BASESTATS: + case ID_GAME_DYNAMICSTATS_CURRENT: { - DEBUG_PRINTF("ID_GAME_UPDATE_BASESTATS\n"); + DEBUG_PRINTF("ID_GAME_DYNAMICSTATS_CURRENT\n"); myPacket->Read(player); myPacket->Send(player, true); break; @@ -277,7 +277,6 @@ void Networking::Update(RakNet::Packet *packet) LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_DIE from %s", player->Npc()->mName.c_str()); - //packetMainStats.Read(player); player->CreatureStats()->mDead = true; myPacket->Send(player, true); @@ -294,7 +293,6 @@ void Networking::Update(RakNet::Packet *packet) myPacket->Send(player, true); controller->GetPacket(ID_GAME_UPDATE_POS)->RequestData(player->guid); controller->GetPacket(ID_GAME_CELL)->RequestData(player->guid); - //packetMainStats.RequestData(player->guid); Script::Call(player->GetID()); @@ -364,7 +362,7 @@ void Networking::Update(RakNet::Packet *packet) void Networking::NewPlayer(RakNet::RakNetGUID guid) { controller->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid); - controller->GetPacket(ID_GAME_UPDATE_BASESTATS)->RequestData(guid); + controller->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->RequestData(guid); controller->GetPacket(ID_GAME_UPDATE_POS)->RequestData(guid); controller->GetPacket(ID_GAME_CELL)->RequestData(guid); controller->GetPacket(ID_GAME_UPDATE_EQUIPED)->RequestData(guid); @@ -374,7 +372,7 @@ void Networking::NewPlayer(RakNet::RakNetGUID guid) if (pl->first == guid) continue; controller->GetPacket(ID_GAME_BASE_INFO)->Send(pl->second, guid); - controller->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(pl->second, guid); + controller->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(pl->second, guid); controller->GetPacket(ID_GAME_ATTRIBUTE)->Send(pl->second, guid); controller->GetPacket(ID_GAME_SKILL)->Send(pl->second, guid); controller->GetPacket(ID_GAME_UPDATE_POS)->Send(pl->second, guid); diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index 752d0b7aa..43f1d85d1 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -16,8 +16,8 @@ void ItemFunctions::AddItem(unsigned short pid, const char* itemName, unsigned s - mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(player, false); - mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(player, true);*/ + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(player, false); + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(player, true);*/ LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); } diff --git a/apps/openmw-mp/Script/Functions/Stats.cpp b/apps/openmw-mp/Script/Functions/Stats.cpp index 53fabf6ef..13b093545 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -437,6 +437,22 @@ void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, true); } +void StatsFunctions::SendDynamicStatsBase(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS_BASE)->Send(player, false); + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS_BASE)->Send(player, true); +} + +void StatsFunctions::SendDynamicStatsCurrent(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(player, false); + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(player, true); +} + void StatsFunctions::SendAttributes(unsigned short pid) noexcept { Player *player; @@ -446,14 +462,6 @@ void StatsFunctions::SendAttributes(unsigned short pid) noexcept mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, true); } -void StatsFunctions::SendBaseStats(unsigned short pid) noexcept -{ - Player *player; - GET_PLAYER(pid, player,); - mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(player, false); - mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(player, true); -} - void StatsFunctions::SendSkills(unsigned short pid) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/Functions/Stats.hpp b/apps/openmw-mp/Script/Functions/Stats.hpp index 1cf6738a5..f6cfefaaf 100644 --- a/apps/openmw-mp/Script/Functions/Stats.hpp +++ b/apps/openmw-mp/Script/Functions/Stats.hpp @@ -6,68 +6,70 @@ #define OPENMW_STATS_HPP #define STATSFUNCTIONS \ - {"GetName", StatsFunctions::GetName},\ - {"SetName", StatsFunctions::SetName},\ + {"GetName", StatsFunctions::GetName},\ + {"SetName", StatsFunctions::SetName},\ \ - {"GetRace", StatsFunctions::GetRace},\ - {"SetRace", StatsFunctions::SetRace},\ + {"GetRace", StatsFunctions::GetRace},\ + {"SetRace", StatsFunctions::SetRace},\ \ - {"GetHead", StatsFunctions::GetHead},\ - {"SetHead", StatsFunctions::SetHead},\ + {"GetHead", StatsFunctions::GetHead},\ + {"SetHead", StatsFunctions::SetHead},\ \ - {"GetHair", StatsFunctions::GetHairstyle},\ - {"SetHair", StatsFunctions::SetHairstyle},\ + {"GetHair", StatsFunctions::GetHairstyle},\ + {"SetHair", StatsFunctions::SetHairstyle},\ \ - {"GetIsMale", StatsFunctions::GetIsMale},\ - {"SetIsMale", StatsFunctions::SetIsMale},\ + {"GetIsMale", StatsFunctions::GetIsMale},\ + {"SetIsMale", StatsFunctions::SetIsMale},\ \ - {"GetLevel", StatsFunctions::GetLevel},\ - {"SetLevel", StatsFunctions::SetLevel},\ + {"GetLevel", StatsFunctions::GetLevel},\ + {"SetLevel", StatsFunctions::SetLevel},\ \ - {"GetBirthsign", StatsFunctions::GetBirthsign},\ - {"SetBirthsign", StatsFunctions::SetBirthsign},\ + {"GetBirthsign", StatsFunctions::GetBirthsign},\ + {"SetBirthsign", StatsFunctions::SetBirthsign},\ \ - {"GetAttributeCount", StatsFunctions::GetAttributeCount},\ - {"GetSkillCount", StatsFunctions::GetSkillCount},\ - {"GetAttributeId", StatsFunctions::GetAttributeId},\ - {"GetSkillId", StatsFunctions::GetSkillId},\ - {"GetAttributeName", StatsFunctions::GetAttributeName},\ - {"GetSkillName", StatsFunctions::GetSkillName},\ + {"GetAttributeCount", StatsFunctions::GetAttributeCount},\ + {"GetSkillCount", StatsFunctions::GetSkillCount},\ + {"GetAttributeId", StatsFunctions::GetAttributeId},\ + {"GetSkillId", StatsFunctions::GetSkillId},\ + {"GetAttributeName", StatsFunctions::GetAttributeName},\ + {"GetSkillName", StatsFunctions::GetSkillName},\ \ - {"GetAttributeBase", StatsFunctions::GetAttributeBase},\ - {"SetAttributeBase", StatsFunctions::SetAttributeBase},\ - {"GetAttributeCurrent", StatsFunctions::GetAttributeCurrent},\ - {"SetAttributeCurrent", StatsFunctions::SetAttributeCurrent},\ - {"GetSkillBase", StatsFunctions::GetSkillBase},\ - {"SetSkillBase", StatsFunctions::SetSkillBase},\ - {"GetSkillCurrent", StatsFunctions::GetSkillCurrent},\ - {"SetSkillCurrent", StatsFunctions::SetSkillCurrent},\ + {"GetAttributeBase", StatsFunctions::GetAttributeBase},\ + {"SetAttributeBase", StatsFunctions::SetAttributeBase},\ + {"GetAttributeCurrent", StatsFunctions::GetAttributeCurrent},\ + {"SetAttributeCurrent", StatsFunctions::SetAttributeCurrent},\ + {"GetSkillBase", StatsFunctions::GetSkillBase},\ + {"SetSkillBase", StatsFunctions::SetSkillBase},\ + {"GetSkillCurrent", StatsFunctions::GetSkillCurrent},\ + {"SetSkillCurrent", StatsFunctions::SetSkillCurrent},\ \ - {"GetHealthBase", StatsFunctions::GetHealthBase},\ - {"SetHealthBase", StatsFunctions::SetHealthBase},\ - {"GetHealthCurrent", StatsFunctions::GetHealthCurrent},\ - {"SetHealthCurrent", StatsFunctions::SetHealthCurrent},\ + {"GetHealthBase", StatsFunctions::GetHealthBase},\ + {"SetHealthBase", StatsFunctions::SetHealthBase},\ + {"GetHealthCurrent", StatsFunctions::GetHealthCurrent},\ + {"SetHealthCurrent", StatsFunctions::SetHealthCurrent},\ \ - {"GetMagickaBase", StatsFunctions::GetMagickaBase},\ - {"SetMagickaBase", StatsFunctions::SetMagickaBase},\ - {"GetMagickaCurrent", StatsFunctions::GetMagickaCurrent},\ - {"SetMagickaCurrent", StatsFunctions::SetMagickaCurrent},\ + {"GetMagickaBase", StatsFunctions::GetMagickaBase},\ + {"SetMagickaBase", StatsFunctions::SetMagickaBase},\ + {"GetMagickaCurrent", StatsFunctions::GetMagickaCurrent},\ + {"SetMagickaCurrent", StatsFunctions::SetMagickaCurrent},\ \ - {"SetFatigueBase", StatsFunctions::SetFatigueBase},\ - {"GetFatigueBase", StatsFunctions::GetFatigueBase},\ - {"SetFatigueCurrent", StatsFunctions::SetFatigueCurrent},\ - {"GetFatigueCurrent", StatsFunctions::GetFatigueCurrent},\ + {"SetFatigueBase", StatsFunctions::SetFatigueBase},\ + {"GetFatigueBase", StatsFunctions::GetFatigueBase},\ + {"SetFatigueCurrent", StatsFunctions::SetFatigueCurrent},\ + {"GetFatigueCurrent", StatsFunctions::GetFatigueCurrent},\ \ - {"GetSkillIncrease", StatsFunctions::GetSkillIncrease},\ - {"SetSkillIncrease", StatsFunctions::SetSkillIncrease},\ + {"GetSkillIncrease", StatsFunctions::GetSkillIncrease},\ + {"SetSkillIncrease", StatsFunctions::SetSkillIncrease},\ \ - {"SetCharGenStage", StatsFunctions::SetCharGenStage},\ - {"Resurrect", StatsFunctions::Resurrect},\ - {"SendBaseInfo", StatsFunctions::SendBaseInfo},\ - {"SendAttributes", StatsFunctions::SendAttributes},\ - {"SendBaseStats", StatsFunctions::SendBaseStats},\ - {"SendSkills", StatsFunctions::SendSkills},\ - {"SendLevel", StatsFunctions::SendLevel} + {"SetCharGenStage", StatsFunctions::SetCharGenStage},\ + {"Resurrect", StatsFunctions::Resurrect},\ + {"SendBaseInfo", StatsFunctions::SendBaseInfo},\ + + {"SendDynamicStatsBase", StatsFunctions::SendDynamicStatsBase}, \ + {"SendDynamicStatsCurrent", StatsFunctions::SendDynamicStatsCurrent}, \ + {"SendAttributes", StatsFunctions::SendAttributes},\ + {"SendSkills", StatsFunctions::SendSkills},\ + {"SendLevel", StatsFunctions::SendLevel} class StatsFunctions { @@ -130,10 +132,11 @@ public: static void Resurrect(unsigned short pid); static void SetCharGenStage(unsigned short pid, int start, int end) noexcept; - static void SendBaseInfo(unsigned short pid) noexcept; + + static void SendDynamicStatsBase(unsigned short pid) noexcept; + static void SendDynamicStatsCurrent(unsigned short pid) noexcept; static void SendAttributes(unsigned short pid) noexcept; - static void SendBaseStats(unsigned short pid) noexcept; static void SendSkills(unsigned short pid) noexcept; static void SendLevel(unsigned short pid) noexcept; }; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6b625141b..f01a6179e 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -855,7 +855,7 @@ namespace MWClass if(ptr == MWMechanics::getPlayer()) { - mwmp::Main::get().getLocalPlayer()->updateBaseStats(true); + mwmp::Main::get().getLocalPlayer()->updateDynamicStats(true); mwmp::Main::get().getLocalPlayer()->updatePosition(true); // fix position after getting damage; } } diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 4a68f3f6d..839a16e71 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -49,7 +49,7 @@ void LocalPlayer::Update() updateAttackState(); updateDeadState(); updateInventory(); - updateBaseStats(); + updateDynamicStats(); updateClassStats(); } @@ -58,7 +58,7 @@ MWWorld::Ptr LocalPlayer::GetPlayerPtr() return MWBase::Environment::get().getWorld()->getPlayerPtr(); } -void LocalPlayer::updateBaseStats(bool forceUpdate) +void LocalPlayer::updateDynamicStats(bool forceUpdate) { MWWorld::Ptr player = GetPlayerPtr(); @@ -85,7 +85,7 @@ void LocalPlayer::updateBaseStats(bool forceUpdate) timer = 0; - GetNetworking()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(this); + GetNetworking()->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(this); } } @@ -541,7 +541,7 @@ bool LocalPlayer::CharGenThread() // ToDo: need fix if (CharGenStage()->end != 1) { - updateBaseStats(true); + updateDynamicStats(true); updateClassStats(true); SendClass(); GetNetworking()->GetPacket(ID_GAME_CHARGEN)->Send(this); diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 0c7bb15d9..b7d6710d6 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -20,7 +20,7 @@ namespace mwmp void Update(); - void updateBaseStats(bool forceUpdate = false); + void updateDynamicStats(bool forceUpdate = false); void updatePosition(bool forceUpdate = false); void updateInventory(bool forceUpdate = false); void updateAttackState(bool forceUpdate = false); diff --git a/apps/openmw/mwmp/Main.cpp b/apps/openmw/mwmp/Main.cpp index ebbbb475f..859bdeb5f 100644 --- a/apps/openmw/mwmp/Main.cpp +++ b/apps/openmw/mwmp/Main.cpp @@ -194,7 +194,7 @@ void Main::UpdateWorld(float dt) const mNetworking->GetPacket(ID_GAME_BASE_INFO)->Send(getLocalPlayer()); mNetworking->GetPacket(ID_LOADED)->Send(getLocalPlayer()); - mLocalPlayer->updateBaseStats(true); + mLocalPlayer->updateDynamicStats(true); get().getGUIController()->setChatVisible(true); } else diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 1dca90bdb..cfe0948d6 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -336,11 +336,11 @@ void Networking::ReceiveMessage(RakNet::Packet *packet) } break; } - case ID_GAME_UPDATE_BASESTATS: + case ID_GAME_DYNAMICSTATS_CURRENT: { if (id == myid) { - getLocalPlayer()->updateBaseStats(true); + getLocalPlayer()->updateDynamicStats(true); myPacket->Send(getLocalPlayer(), serverAddr); } else if (pl != 0) @@ -393,8 +393,8 @@ void Networking::ReceiveMessage(RakNet::Packet *packet) (*getLocalPlayer()->GetCell()) = *player.getCell()->getCell(); myPacket->Send(getLocalPlayer(), serverAddr); - getLocalPlayer()->updateBaseStats(true); - controller.GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(getLocalPlayer(), serverAddr); + getLocalPlayer()->updateDynamicStats(true); + controller.GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(getLocalPlayer(), serverAddr); } else if (pl != 0) { diff --git a/apps/openmw/mwmp/Networking.hpp b/apps/openmw/mwmp/Networking.hpp index 0eb97480a..506e0fdf6 100644 --- a/apps/openmw/mwmp/Networking.hpp +++ b/apps/openmw/mwmp/Networking.hpp @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index d6addc297..33717b8d3 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -149,9 +149,9 @@ add_component_dir (openmw-mp Log PacketsController Packets/BasePacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquiped Packets/PacketAttack - Packets/PacketMainStats Packets/PacketCell Packets/PacketDrawState Packets/PacketChatMessage Packets/PacketCharGen - Packets/PacketAttribute Packets/PacketSkill Packets/PacketLevel Packets/PacketHandshake Packets/PacketGUIBoxes - Packets/PacketClass Packets/PacketTime) + Packets/PacketDynamicStatsBase Packets/PacketDynamicStatsCurrent Packets/PacketCell Packets/PacketDrawState + Packets/PacketChatMessage Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketLevel + Packets/PacketHandshake Packets/PacketGUIBoxes Packets/PacketClass Packets/PacketTime) add_component_dir (fallback fallback validate diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index be7f90dd5..1961006da 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -12,7 +12,8 @@ enum GameMessages ID_GAME_BASE_INFO = ID_USER_PACKET_ENUM+1, ID_GAME_CHARGEN, ID_GAME_UPDATE_POS, - ID_GAME_UPDATE_BASESTATS, + ID_GAME_DYNAMICSTATS_BASE, + ID_GAME_DYNAMICSTATS_CURRENT, ID_GAME_ATTACK, ID_USER_MYID, ID_GAME_UPDATE_EQUIPED, diff --git a/components/openmw-mp/Packets/PacketMainStats.cpp b/components/openmw-mp/Packets/PacketDynamicStatsBase.cpp similarity index 50% rename from components/openmw-mp/Packets/PacketMainStats.cpp rename to components/openmw-mp/Packets/PacketDynamicStatsBase.cpp index 3288a69fa..a64b19c4d 100644 --- a/components/openmw-mp/Packets/PacketMainStats.cpp +++ b/components/openmw-mp/Packets/PacketDynamicStatsBase.cpp @@ -1,18 +1,18 @@ // -// Created by koncord on 13.01.16. +// Created by David Cernat on 28.09.16. // -#include "PacketMainStats.hpp" +#include "PacketDynamicStatsBase.hpp" #include using namespace mwmp; -PacketMainStats::PacketMainStats(RakNet::RakPeerInterface *peer) : BasePacket(peer) +PacketDynamicStatsBase::PacketDynamicStatsBase(RakNet::RakPeerInterface *peer) : BasePacket(peer) { - packetID = ID_GAME_UPDATE_BASESTATS; + packetID = ID_GAME_DYNAMICSTATS_BASE; } -void PacketMainStats::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketDynamicStatsBase::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) { BasePacket::Packet(bs, player, send); RW(player->CreatureStats()->mDynamic[0], send); // health diff --git a/components/openmw-mp/Packets/PacketDynamicStatsBase.hpp b/components/openmw-mp/Packets/PacketDynamicStatsBase.hpp new file mode 100644 index 000000000..070b3cf6e --- /dev/null +++ b/components/openmw-mp/Packets/PacketDynamicStatsBase.hpp @@ -0,0 +1,22 @@ +// +// Created by David Cernat on 28.09.16. +// + +#ifndef OPENMW_PACKAGEDYNAMICSTATSBASE_HPP +#define OPENMW_PACKAGEDYNAMICSTATSBASE_HPP + + +#include + +namespace mwmp +{ + class PacketDynamicStatsBase : public BasePacket + { + public: + PacketDynamicStatsBase(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + }; +} + +#endif //OPENMW_PACKAGEDYNAMICSTATSBASE_HPP diff --git a/components/openmw-mp/Packets/PacketDynamicStatsCurrent.cpp b/components/openmw-mp/Packets/PacketDynamicStatsCurrent.cpp new file mode 100644 index 000000000..d2bd4efea --- /dev/null +++ b/components/openmw-mp/Packets/PacketDynamicStatsCurrent.cpp @@ -0,0 +1,21 @@ +// +// Created by David Cernat on 28.09.16. +// + +#include "PacketDynamicStatsCurrent.hpp" +#include + +using namespace mwmp; + +PacketDynamicStatsCurrent::PacketDynamicStatsCurrent(RakNet::RakPeerInterface *peer) : BasePacket(peer) +{ + packetID = ID_GAME_DYNAMICSTATS_CURRENT; +} + +void PacketDynamicStatsCurrent::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +{ + BasePacket::Packet(bs, player, send); + RW(player->CreatureStats()->mDynamic[0], send); // health + RW(player->CreatureStats()->mDynamic[1], send); // magic + RW(player->CreatureStats()->mDynamic[2], send); // fatigue +} \ No newline at end of file diff --git a/components/openmw-mp/Packets/PacketDynamicStatsCurrent.hpp b/components/openmw-mp/Packets/PacketDynamicStatsCurrent.hpp new file mode 100644 index 000000000..aae3023c9 --- /dev/null +++ b/components/openmw-mp/Packets/PacketDynamicStatsCurrent.hpp @@ -0,0 +1,22 @@ +// +// Created by David Cernat on 28.09.16. +// + +#ifndef OPENMW_PACKAGEDYNAMICSTATSCURRENT_HPP +#define OPENMW_PACKAGEDYNAMICSTATSCURRENT_HPP + + +#include + +namespace mwmp +{ + class PacketDynamicStatsCurrent : public BasePacket + { + public: + PacketDynamicStatsCurrent(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + }; +} + +#endif //OPENMW_PACKAGEDYNAMICSTATSCURRENT_HPP diff --git a/components/openmw-mp/Packets/PacketMainStats.hpp b/components/openmw-mp/Packets/PacketMainStats.hpp deleted file mode 100644 index 841c243bb..000000000 --- a/components/openmw-mp/Packets/PacketMainStats.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// -// Created by koncord on 13.01.16. -// - -#ifndef OPENMW_PACKAGEMAINSTATS_HPP -#define OPENMW_PACKAGEMAINSTATS_HPP - - -#include - -namespace mwmp -{ - class PacketMainStats : public BasePacket - { - public: - PacketMainStats(RakNet::RakPeerInterface *peer); - - virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); - }; -} - -#endif //OPENMW_PACKAGEMAINSTATS_HPP diff --git a/components/openmw-mp/PacketsController.cpp b/components/openmw-mp/PacketsController.cpp index 09afcaff2..bfeb02374 100644 --- a/components/openmw-mp/PacketsController.cpp +++ b/components/openmw-mp/PacketsController.cpp @@ -11,7 +11,8 @@ #include "Packets/PacketBaseInfo.hpp" #include "components/openmw-mp/Packets/PacketEquiped.hpp" #include "Packets/PacketAttack.hpp" -#include "Packets/PacketMainStats.hpp" +#include "Packets/PacketDynamicStatsBase.hpp" +#include "Packets/PacketDynamicStatsCurrent.hpp" #include "Packets/PacketResurrect.hpp" #include "Packets/PacketDie.hpp" #include "Packets/PacketCell.hpp" @@ -46,7 +47,8 @@ mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer) AddPacket(&packets, peer); AddPacket(&packets, peer); - AddPacket(&packets, peer); + AddPacket(&packets, peer); + AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer);