From 977e93288ebb781dd74259b3850879ed19810a12 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 17 Nov 2016 23:07:29 +0200 Subject: [PATCH] Add GetEquipmentSlotCount() to item script functions --- apps/openmw-mp/Script/Functions/Items.cpp | 6 +++++ apps/openmw-mp/Script/Functions/Items.hpp | 31 +++++++++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index 34e3090dd..6fdd2cf6c 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include using namespace mwmp; @@ -40,6 +41,11 @@ void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcep //ItemFunctions::EquipItem(pid, slot, "", 0); } +int ItemFunctions::GetEquipmentSlotCount() noexcept +{ + return MWWorld::InventoryStore::Slots; +} + const char *ItemFunctions::GetItemSlot(unsigned short pid, unsigned short slot) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/Functions/Items.hpp b/apps/openmw-mp/Script/Functions/Items.hpp index 0a9acf723..d3691f5c8 100644 --- a/apps/openmw-mp/Script/Functions/Items.hpp +++ b/apps/openmw-mp/Script/Functions/Items.hpp @@ -6,19 +6,22 @@ #define OPENMW_ITEMS_HPP #define ITEMAPI \ - {"AddItem", ItemFunctions::AddItem},\ - {"RemoveItem", ItemFunctions::RemoveItem},\ - {"GetItemCount", ItemFunctions::GetItemCount2},\ - {"EquipItem", ItemFunctions::EquipItem},\ - {"UnequipItem", ItemFunctions::UnequipItem},\ - {"GetItemSlot", ItemFunctions::GetItemSlot},\ - {"HasItemEquipped", ItemFunctions::HasItemEquipped},\ - {"GetItemName", ItemFunctions::GetItemName},\ - {"GetItemHealth", ItemFunctions::GetItemHealth},\ - {"GetInventorySize", ItemFunctions::GetInventorySize},\ + {"AddItem", ItemFunctions::AddItem},\ + {"RemoveItem", ItemFunctions::RemoveItem},\ + {"GetItemCount", ItemFunctions::GetItemCount2},\ \ - {"SendEquipment", ItemFunctions::SendEquipment},\ - {"SendInventory", ItemFunctions::SendInventory}\ + {"EquipItem", ItemFunctions::EquipItem},\ + {"UnequipItem", ItemFunctions::UnequipItem},\ + {"GetEquipmentSlotCount", ItemFunctions::GetEquipmentSlotCount},\ + {"HasItemEquipped", ItemFunctions::HasItemEquipped},\ + \ + {"GetItemSlot", ItemFunctions::GetItemSlot},\ + {"GetItemName", ItemFunctions::GetItemName},\ + {"GetItemHealth", ItemFunctions::GetItemHealth},\ + {"GetInventorySize", ItemFunctions::GetInventorySize},\ + \ + {"SendEquipment", ItemFunctions::SendEquipment},\ + {"SendInventory", ItemFunctions::SendInventory} class ItemFunctions { @@ -26,11 +29,13 @@ public: static void AddItem(unsigned short pid, const char* itemName, unsigned int count, int health) noexcept; static void RemoveItem(unsigned short pid, const char* itemName, unsigned short count) noexcept; static void GetItemCount(unsigned short pid, const char* itemName) noexcept; + static void EquipItem(unsigned short pid, unsigned short slot, const char* itemName, unsigned int count, int health) noexcept; static void UnequipItem(unsigned short pid, unsigned short slot) noexcept; + static int GetEquipmentSlotCount() noexcept; static bool HasItemEquipped(unsigned short pid, const char* itemName); - static const char *GetItemSlot(unsigned short pid, unsigned short slot) noexcept; + static const char *GetItemSlot(unsigned short pid, unsigned short slot) noexcept; static const char *GetItemName(unsigned short pid, unsigned int i) noexcept; static int GetItemCount2(unsigned short pid, unsigned int i) noexcept; static int GetItemHealth(unsigned short pid, unsigned int i) noexcept;