From 1ee2458f6eba67b20ff5765c5225faed9be58963 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 26 Sep 2016 13:19:01 +0300 Subject: [PATCH] Add packet for player levels, part 2 --- apps/openmw-mp/Script/Functions/Stats.cpp | 10 +++++++++- apps/openmw-mp/Script/Functions/Stats.hpp | 8 +++++--- apps/openmw/mwmp/LocalPlayer.cpp | 4 +++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Stats.cpp b/apps/openmw-mp/Script/Functions/Stats.cpp index d37b8a92a..f2654ce3e 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -372,7 +372,6 @@ void StatsFunctions::SetCurrentSkill(unsigned short pid, unsigned short skill, i player->NpcStats()->mSkills[skill].mCurrent = value; } - int StatsFunctions::GetIncreaseSkill(unsigned short pid, unsigned int pos) noexcept { Player *player; @@ -447,3 +446,12 @@ void StatsFunctions::SendSkills(unsigned short pid) noexcept mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_SKILL)->Send(player, false); mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_SKILL)->Send(player, true); } + +void StatsFunctions::SendLevel(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_LEVEL)->Send(player, false); + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_LEVEL)->Send(player, true); +} diff --git a/apps/openmw-mp/Script/Functions/Stats.hpp b/apps/openmw-mp/Script/Functions/Stats.hpp index 5e4d178a3..0c7e8a5c5 100644 --- a/apps/openmw-mp/Script/Functions/Stats.hpp +++ b/apps/openmw-mp/Script/Functions/Stats.hpp @@ -21,8 +21,8 @@ {"GetIsMale", StatsFunctions::GetIsMale},\ {"SetIsMale", StatsFunctions::SetIsMale},\ \ - {"GetLevel", StatsFunctions::GetLevel},\ - {"SetLevel", StatsFunctions::SetLevel},\ + {"GetLevel", StatsFunctions::GetLevel},\ + {"SetLevel", StatsFunctions::SetLevel},\ \ {"GetBirthsign", StatsFunctions::GetBirthsign},\ {"SetBirthsign", StatsFunctions::SetBirthsign},\ @@ -63,7 +63,8 @@ {"SendBaseInfo", StatsFunctions::SendBaseInfo},\ {"SendAttributes", StatsFunctions::SendAttributes},\ {"SendBaseStats", StatsFunctions::SendBaseStats},\ - {"SendSkills", StatsFunctions::SendSkills} + {"SendSkills", StatsFunctions::SendSkills},\ + {"SendLevel", StatsFunctions::SendLevel} class StatsFunctions { @@ -132,6 +133,7 @@ public: 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; }; #endif //OPENMW_STATS_HPP diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 95a7c9ce6..a8c387c00 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -115,8 +115,10 @@ void LocalPlayer::updateClassStats(bool forceUpdate) } } - if (_npcStats.getLevel() != CreatureStats()->mLevel) + if (_npcStats.getLevel() != CreatureStats()->mLevel) { + CreatureStats()->mLevel = _npcStats.getLevel(); GetNetworking()->GetPacket(ID_GAME_LEVEL)->Send(this); + } if (isUpdatingSkills) { GetNetworking()->GetPacket(ID_GAME_SKILL)->Send(this);