From b6086ab015fe75cc0ca286c039d68248423d232b Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 28 Sep 2016 14:13:24 +0300 Subject: [PATCH] Rename ID_GAME_DYNAMICSTATS_CURRENT into ID_GAME_DYNAMICSTATS --- apps/openmw-mp/Networking.cpp | 10 ++++----- apps/openmw-mp/Script/Functions/Items.cpp | 6 +---- apps/openmw-mp/Script/Functions/Stats.cpp | 14 +++--------- apps/openmw-mp/Script/Functions/Stats.hpp | 6 ++--- apps/openmw/mwmp/LocalPlayer.cpp | 2 +- apps/openmw/mwmp/Networking.cpp | 4 ++-- apps/openmw/mwmp/Networking.hpp | 3 +-- components/CMakeLists.txt | 6 ++--- components/openmw-mp/NetworkMessages.hpp | 3 +-- ...icStatsBase.cpp => PacketDynamicStats.cpp} | 8 +++---- .../openmw-mp/Packets/PacketDynamicStats.hpp | 22 +++++++++++++++++++ .../Packets/PacketDynamicStatsBase.hpp | 22 ------------------- .../Packets/PacketDynamicStatsCurrent.cpp | 21 ------------------ .../Packets/PacketDynamicStatsCurrent.hpp | 22 ------------------- .../openmw-mp/Packets/PacketEquipment.hpp | 6 ++--- components/openmw-mp/PacketsController.cpp | 6 ++--- 16 files changed, 50 insertions(+), 111 deletions(-) rename components/openmw-mp/Packets/{PacketDynamicStatsBase.cpp => PacketDynamicStats.cpp} (57%) create mode 100644 components/openmw-mp/Packets/PacketDynamicStats.hpp delete mode 100644 components/openmw-mp/Packets/PacketDynamicStatsBase.hpp delete mode 100644 components/openmw-mp/Packets/PacketDynamicStatsCurrent.cpp delete mode 100644 components/openmw-mp/Packets/PacketDynamicStatsCurrent.hpp diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index f59a8f6fc..7a2533c54 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_DYNAMICSTATS_CURRENT)->RequestData(player->GetAttack()->target); + controller->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(player->GetAttack()->target); } break; } - case ID_GAME_DYNAMICSTATS_CURRENT: + case ID_GAME_DYNAMICSTATS: { - DEBUG_PRINTF("ID_GAME_DYNAMICSTATS_CURRENT\n"); + DEBUG_PRINTF("ID_GAME_DYNAMICSTATS\n"); myPacket->Read(player); myPacket->Send(player, true); break; @@ -362,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_DYNAMICSTATS_CURRENT)->RequestData(guid); + controller->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(guid); controller->GetPacket(ID_GAME_POS)->RequestData(guid); controller->GetPacket(ID_GAME_CELL)->RequestData(guid); controller->GetPacket(ID_GAME_EQUIPMENT)->RequestData(guid); @@ -372,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_DYNAMICSTATS_CURRENT)->Send(pl->second, guid); + controller->GetPacket(ID_GAME_DYNAMICSTATS)->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_POS)->Send(pl->second, guid); diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index 3338f3260..77d3b6466 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -11,13 +11,9 @@ void ItemFunctions::AddItem(unsigned short pid, const char* itemName, unsigned short count) noexcept { - /*Player *player; + 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);*/ 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 13b093545..5207e8213 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -437,20 +437,12 @@ 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 +void StatsFunctions::SendDynamicStats(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); + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, false); + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, true); } void StatsFunctions::SendAttributes(unsigned short pid) noexcept diff --git a/apps/openmw-mp/Script/Functions/Stats.hpp b/apps/openmw-mp/Script/Functions/Stats.hpp index 0a9542486..7d10a9244 100644 --- a/apps/openmw-mp/Script/Functions/Stats.hpp +++ b/apps/openmw-mp/Script/Functions/Stats.hpp @@ -65,8 +65,7 @@ {"Resurrect", StatsFunctions::Resurrect},\ {"SendBaseInfo", StatsFunctions::SendBaseInfo},\ \ - {"SendDynamicStatsBase", StatsFunctions::SendDynamicStatsBase}, \ - {"SendDynamicStatsCurrent", StatsFunctions::SendDynamicStatsCurrent}, \ + {"SendDynamicStats", StatsFunctions::SendDynamicStats}, \ {"SendAttributes", StatsFunctions::SendAttributes},\ {"SendSkills", StatsFunctions::SendSkills},\ {"SendLevel", StatsFunctions::SendLevel} @@ -134,8 +133,7 @@ public: 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 SendDynamicStats(unsigned short pid) noexcept; static void SendAttributes(unsigned short pid) noexcept; static void SendSkills(unsigned short pid) noexcept; static void SendLevel(unsigned short pid) noexcept; diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 4ac8bf9cf..fef3fdfd5 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -85,7 +85,7 @@ void LocalPlayer::updateDynamicStats(bool forceUpdate) timer = 0; - GetNetworking()->GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(this); + GetNetworking()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(this); } } diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index f2065ae04..6bcf919a6 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -335,7 +335,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet) } break; } - case ID_GAME_DYNAMICSTATS_CURRENT: + case ID_GAME_DYNAMICSTATS: { if (id == myid) { @@ -393,7 +393,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet) myPacket->Send(getLocalPlayer(), serverAddr); getLocalPlayer()->updateDynamicStats(true); - controller.GetPacket(ID_GAME_DYNAMICSTATS_CURRENT)->Send(getLocalPlayer(), serverAddr); + controller.GetPacket(ID_GAME_DYNAMICSTATS)->Send(getLocalPlayer(), serverAddr); } else if (pl != 0) { diff --git a/apps/openmw/mwmp/Networking.hpp b/apps/openmw/mwmp/Networking.hpp index 969b61fd0..41e6338ae 100644 --- a/apps/openmw/mwmp/Networking.hpp +++ b/apps/openmw/mwmp/Networking.hpp @@ -14,8 +14,7 @@ #include #include #include -#include -#include +#include #include #include #include diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 87c3f24ae..dee4f4a54 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/PacketEquipment Packets/PacketAttack - 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) + Packets/PacketDynamicStats 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 5a4a27e96..d6177a7d2 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -12,8 +12,7 @@ enum GameMessages ID_GAME_BASE_INFO = ID_USER_PACKET_ENUM+1, ID_GAME_CHARGEN, ID_GAME_POS, - ID_GAME_DYNAMICSTATS_BASE, - ID_GAME_DYNAMICSTATS_CURRENT, + ID_GAME_DYNAMICSTATS, ID_GAME_ATTACK, ID_USER_MYID, ID_GAME_EQUIPMENT, diff --git a/components/openmw-mp/Packets/PacketDynamicStatsBase.cpp b/components/openmw-mp/Packets/PacketDynamicStats.cpp similarity index 57% rename from components/openmw-mp/Packets/PacketDynamicStatsBase.cpp rename to components/openmw-mp/Packets/PacketDynamicStats.cpp index a64b19c4d..a9efdb3ee 100644 --- a/components/openmw-mp/Packets/PacketDynamicStatsBase.cpp +++ b/components/openmw-mp/Packets/PacketDynamicStats.cpp @@ -2,17 +2,17 @@ // Created by David Cernat on 28.09.16. // -#include "PacketDynamicStatsBase.hpp" +#include "PacketDynamicStats.hpp" #include using namespace mwmp; -PacketDynamicStatsBase::PacketDynamicStatsBase(RakNet::RakPeerInterface *peer) : BasePacket(peer) +PacketDynamicStats::PacketDynamicStats(RakNet::RakPeerInterface *peer) : BasePacket(peer) { - packetID = ID_GAME_DYNAMICSTATS_BASE; + packetID = ID_GAME_DYNAMICSTATS; } -void PacketDynamicStatsBase::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +void PacketDynamicStats::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/PacketDynamicStats.hpp b/components/openmw-mp/Packets/PacketDynamicStats.hpp new file mode 100644 index 000000000..67e634043 --- /dev/null +++ b/components/openmw-mp/Packets/PacketDynamicStats.hpp @@ -0,0 +1,22 @@ +// +// Created by David Cernat on 28.09.16. +// + +#ifndef OPENMW_PACKAGEDYNAMICSTATS_HPP +#define OPENMW_PACKAGEDYNAMICSTATS_HPP + + +#include + +namespace mwmp +{ + class PacketDynamicStats : public BasePacket + { + public: + PacketDynamicStats(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + }; +} + +#endif //OPENMW_PACKAGEDYNAMICSTATS_HPP diff --git a/components/openmw-mp/Packets/PacketDynamicStatsBase.hpp b/components/openmw-mp/Packets/PacketDynamicStatsBase.hpp deleted file mode 100644 index 070b3cf6e..000000000 --- a/components/openmw-mp/Packets/PacketDynamicStatsBase.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// -// 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 deleted file mode 100644 index d2bd4efea..000000000 --- a/components/openmw-mp/Packets/PacketDynamicStatsCurrent.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -// 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 deleted file mode 100644 index aae3023c9..000000000 --- a/components/openmw-mp/Packets/PacketDynamicStatsCurrent.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// -// 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/PacketEquipment.hpp b/components/openmw-mp/Packets/PacketEquipment.hpp index c33c0891d..6ad05e4da 100644 --- a/components/openmw-mp/Packets/PacketEquipment.hpp +++ b/components/openmw-mp/Packets/PacketEquipment.hpp @@ -2,8 +2,8 @@ // Created by koncord on 07.01.16. // -#ifndef OPENMW_PACKETCONTAINER_HPP -#define OPENMW_PACKETCONTAINER_HPP +#ifndef OPENMW_PACKETEQUIPMENT_HPP +#define OPENMW_PACKETEQUIPMENT_HPP #include @@ -18,4 +18,4 @@ namespace mwmp }; } -#endif //OPENMW_PACKETCONTAINER_HPP +#endif //OPENMW_PACKETEQUIPMENT_HPP diff --git a/components/openmw-mp/PacketsController.cpp b/components/openmw-mp/PacketsController.cpp index 80f8cbce8..c53ba388b 100644 --- a/components/openmw-mp/PacketsController.cpp +++ b/components/openmw-mp/PacketsController.cpp @@ -11,8 +11,7 @@ #include "Packets/PacketBaseInfo.hpp" #include "components/openmw-mp/Packets/PacketEquipment.hpp" #include "Packets/PacketAttack.hpp" -#include "Packets/PacketDynamicStatsBase.hpp" -#include "Packets/PacketDynamicStatsCurrent.hpp" +#include "Packets/PacketDynamicStats.hpp" #include "Packets/PacketResurrect.hpp" #include "Packets/PacketDie.hpp" #include "Packets/PacketCell.hpp" @@ -47,8 +46,7 @@ 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);