From bdc9132e7ccc6e52faba9487a15f59158e50a85f Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 9 Apr 2018 19:24:24 +0300 Subject: [PATCH] [General] Add SetResetStats server script function Add reading and writing of resetStats variable to PlayerBaseInfo Packet Fix typos in various server script function descriptions --- apps/openmw-mp/Script/Functions/Mechanics.hpp | 4 ++-- apps/openmw-mp/Script/Functions/Settings.hpp | 14 +++++++------- apps/openmw-mp/Script/Functions/Stats.cpp | 8 ++++++++ apps/openmw-mp/Script/Functions/Stats.hpp | 14 ++++++++++++++ .../Packets/Player/PacketPlayerBaseInfo.cpp | 2 ++ 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Mechanics.hpp b/apps/openmw-mp/Script/Functions/Mechanics.hpp index 0ab87c303..24b91344c 100644 --- a/apps/openmw-mp/Script/Functions/Mechanics.hpp +++ b/apps/openmw-mp/Script/Functions/Mechanics.hpp @@ -201,7 +201,7 @@ public: * does not by itself send a packet. * * \param pid The player ID. - * \param bool The new scale. + * \param scale The new scale. * \return void */ static void SetScale(unsigned short pid, double scale) noexcept; @@ -213,7 +213,7 @@ public: * does not by itself send a packet. * * \param pid The player ID. - * \param bool The new werewolf state. + * \param isWerewolf The new werewolf state. * \return void */ static void SetWerewolfState(unsigned short pid, bool isWerewolf) noexcept; diff --git a/apps/openmw-mp/Script/Functions/Settings.hpp b/apps/openmw-mp/Script/Functions/Settings.hpp index 48437028d..1d5275c58 100644 --- a/apps/openmw-mp/Script/Functions/Settings.hpp +++ b/apps/openmw-mp/Script/Functions/Settings.hpp @@ -26,7 +26,7 @@ public: * send a packet. * * \param pid The player ID. - * \param bool The difficulty. + * \param difficulty The difficulty. * \return void */ static void SetDifficulty(unsigned short pid, int difficulty); @@ -44,7 +44,7 @@ public: * If you do not wish to enforce a log level, simply set enforcedLogLevel to -1 * * \param pid The player ID. - * \param bool The enforced log level. + * \param enforcedLogLevel The enforced log level. * \return void */ static void SetEnforcedLogLevel(unsigned short pid, int enforcedLogLevel); @@ -56,7 +56,7 @@ public: * send a packet. * * \param pid The player ID. - * \param bool The physics framerate. + * \param physicsFramerate The physics framerate. * \return void */ static void SetPhysicsFramerate(unsigned short pid, double physicsFramerate); @@ -68,7 +68,7 @@ public: * by itself send a packet. * * \param pid The player ID. - * \param bool The console permission state. + * \param state The console permission state. * \return void */ static void SetConsoleAllowed(unsigned short pid, bool state); @@ -80,7 +80,7 @@ public: * by itself send a packet. * * \param pid The player ID. - * \param bool The resting permission state. + * \param state The resting permission state. * \return void */ static void SetBedRestAllowed(unsigned short pid, bool state); @@ -92,7 +92,7 @@ public: * by itself send a packet. * * \param pid The player ID. - * \param bool The resting permission state. + * \param state The resting permission state. * \return void */ static void SetWildernessRestAllowed(unsigned short pid, bool state); @@ -104,7 +104,7 @@ public: * by itself send a packet. * * \param pid The player ID. - * \param bool The waiting permission state. + * \param state The waiting permission state. * \return void */ static void SetWaitAllowed(unsigned short pid, bool state); diff --git a/apps/openmw-mp/Script/Functions/Stats.cpp b/apps/openmw-mp/Script/Functions/Stats.cpp index 32b22144a..c39e3f021 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -330,6 +330,14 @@ void StatsFunctions::SetBirthsign(unsigned short pid, const char *sign) noexcept player->birthsign = sign; } +void StatsFunctions::SetResetStats(unsigned short pid, bool resetStats) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + player->resetStats = resetStats; +} + void StatsFunctions::SetLevel(unsigned short pid, int value) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/Functions/Stats.hpp b/apps/openmw-mp/Script/Functions/Stats.hpp index 3d0da464d..f77b44909 100644 --- a/apps/openmw-mp/Script/Functions/Stats.hpp +++ b/apps/openmw-mp/Script/Functions/Stats.hpp @@ -49,6 +49,7 @@ {"SetHair", StatsFunctions::SetHairstyle},\ {"SetIsMale", StatsFunctions::SetIsMale},\ {"SetBirthsign", StatsFunctions::SetBirthsign},\ + {"SetResetStats", StatsFunctions::SetResetStats},\ \ {"SetLevel", StatsFunctions::SetLevel},\ {"SetLevelProgress", StatsFunctions::SetLevelProgress},\ @@ -123,6 +124,19 @@ public: static void SetHairstyle(unsigned short pid, const char *style) noexcept; static void SetIsMale(unsigned short pid, int male) noexcept; static void SetBirthsign(unsigned short pid, const char *name) noexcept; + + /** + * \brief Set whether the player's stats should be reset based on their + * current race as the result of a PlayerBaseInfo packet. + * + * This changes the resetState for that player in the server memory, but does not by itself + * send a packet. + * + * \param pid The player ID. + * \param resetStats The stat reset state. + * \return void + */ + static void SetResetStats(unsigned short pid, bool resetStats) noexcept; static void SetLevel(unsigned short pid, int value) noexcept; static void SetLevelProgress(unsigned short pid, int value) noexcept; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.cpp b/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.cpp index 051c26e83..6247c4bd4 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerBaseInfo.cpp @@ -25,4 +25,6 @@ void PacketPlayerBaseInfo::Packet(RakNet::BitStream *bs, bool send) RW(player->npc.mFlags, send); RW(player->birthsign, send, 1); + + RW(player->resetStats, send); }