Merge e569328f3d4f3349331ec30d6b7a5be939ac1ab6 into 49be5b6405d6ab427e06ed350cf76c715a1f3bdd

This commit is contained in:
Luke Elrod 2024-12-30 19:04:38 -08:00 committed by GitHub
commit 7c4a8e762e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View File

@ -270,6 +270,19 @@ void ItemFunctions::SendItemUse(unsigned short pid) noexcept
packet->Send(false); packet->Send(false);
} }
bool ItemFunctions::SetUsedItem(unsigned short pid, const char* refId) noexcept
{
Player* player;
GET_PLAYER(pid, player, false);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++) {
if (Misc::StringUtils::ciEqual(player->equipmentItems[slot].refId, refId)) {
player->usedItem = player->equipmentItems[slot];
return true;
}
}
return false;
}
// All methods below are deprecated versions of methods from above // All methods below are deprecated versions of methods from above
void ItemFunctions::InitializeInventoryChanges(unsigned short pid) noexcept void ItemFunctions::InitializeInventoryChanges(unsigned short pid) noexcept

View File

@ -39,6 +39,7 @@
{"SendEquipment", ItemFunctions::SendEquipment},\ {"SendEquipment", ItemFunctions::SendEquipment},\
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges},\ {"SendInventoryChanges", ItemFunctions::SendInventoryChanges},\
{"SendItemUse", ItemFunctions::SendItemUse},\ {"SendItemUse", ItemFunctions::SendItemUse},\
{"SetUsedItem", ItemFunctions::SetUsedItem},\
\ \
{"InitializeInventoryChanges", ItemFunctions::InitializeInventoryChanges},\ {"InitializeInventoryChanges", ItemFunctions::InitializeInventoryChanges},\
{"AddItem", ItemFunctions::AddItem} {"AddItem", ItemFunctions::AddItem}
@ -312,6 +313,15 @@ public:
*/ */
static void SendItemUse(unsigned short pid) noexcept; static void SendItemUse(unsigned short pid) noexcept;
/**
* \brief Update a player's recorded usedItem. Only usable on equipped items.
*
* \param pid The player ID affected.
* \param refId The name of the equipped item.
* \return bool
*/
static bool SetUsedItem(unsigned short pid, const char* refId) noexcept;
// All methods below are deprecated versions of methods from above // All methods below are deprecated versions of methods from above
static void InitializeInventoryChanges(unsigned short pid) noexcept; static void InitializeInventoryChanges(unsigned short pid) noexcept;