From eba7d8408fad3c49634ed614fab2b9461d89addf Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 16 Feb 2017 14:23:27 +0200 Subject: [PATCH] [Server] Use script function to get spellbook action --- apps/openmw-mp/Networking.cpp | 2 +- apps/openmw-mp/Script/Functions/Spells.cpp | 8 ++++++++ apps/openmw-mp/Script/Functions/Spells.hpp | 2 ++ apps/openmw-mp/Script/ScriptFunctions.hpp | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 7f75eda1e..bf7c3888d 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -250,7 +250,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet) DEBUG_PRINTF("ID_PLAYER_SPELLBOOK\n"); myPacket->Read(player); - Script::Call(player->getId(), player->spellbookChanges.action); + Script::Call(player->getId()); break; } diff --git a/apps/openmw-mp/Script/Functions/Spells.cpp b/apps/openmw-mp/Script/Functions/Spells.cpp index 6cacdbd85..fa6c6f2e8 100644 --- a/apps/openmw-mp/Script/Functions/Spells.cpp +++ b/apps/openmw-mp/Script/Functions/Spells.cpp @@ -14,6 +14,14 @@ unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcep return player->spellbookChanges.count; } +unsigned int SpellFunctions::GetSpellbookAction(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0); + + return player->spellbookChanges.action; +} + void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/Functions/Spells.hpp b/apps/openmw-mp/Script/Functions/Spells.hpp index 8e21e7297..b163b1e9f 100644 --- a/apps/openmw-mp/Script/Functions/Spells.hpp +++ b/apps/openmw-mp/Script/Functions/Spells.hpp @@ -3,6 +3,7 @@ #define SPELLAPI \ {"GetSpellbookChangesSize", SpellFunctions::GetSpellbookChangesSize},\ + {"GetSpellbookAction", SpellFunctions::GetSpellbookAction},\ \ {"AddSpell", SpellFunctions::AddSpell},\ {"RemoveSpell", SpellFunctions::RemoveSpell},\ @@ -17,6 +18,7 @@ class SpellFunctions public: static unsigned int GetSpellbookChangesSize(unsigned short pid) noexcept; + static unsigned int GetSpellbookAction(unsigned short pid) noexcept; static void AddSpell(unsigned short pid, const char* spellId) noexcept; static void RemoveSpell(unsigned short pid, const char* spellId) noexcept; diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 0412ad10e..3960c7971 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -115,7 +115,7 @@ public: {"OnPlayerLevelChange", Function()}, {"OnPlayerEquipmentChange", Function()}, {"OnPlayerInventoryChange", Function()}, - {"OnPlayerSpellbookChange", Function()}, + {"OnPlayerSpellbookChange", Function()}, {"OnPlayerJournalChange", Function()}, {"OnObjectPlace", Function()}, {"OnObjectDelete", Function()},