mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-08 21:07:14 +00:00
feat: deletion restrictions
Deleting an item now follows the item's DeletionRestrictions row (ItemComponent.delResIndex), as the client's LWOInventoryComponent_Common::CanRemoveFromInventory (0x00ce0d20) and CheckDeletionRestrictionIndex (0x00c94c20) do: an item the player is driving or riding can't be deleted, an operator can delete anything, and otherwise the row decides: - LOTS_INCLUDED: only while the player has another item of any of the LOTs (the last rocket can't be deleted) - LOTS_EXCLUDED: only while the player has other items of all of the LOTs - ANY_RESTRICTION / ALL_RESTRICTIONS: any / all of the listed rows allow it (a row that names itself again allows it) - ZONE: only in the listed zones - ALWAYS_RESTRICTED: never A missing, unrestricted or bad row (no valid ids, unknown check type) allows it. The client checks first and shows the row's failure reason; the server checks again and ignores a client's forceDeletion. Refs issue 960 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#define INVENTORYCOMPONENT_H
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
|
||||
|
||||
@@ -182,6 +183,32 @@ public:
|
||||
*/
|
||||
Item* FindItemById(LWOOBJID id) const;
|
||||
|
||||
/**
|
||||
* Whether the player may remove (delete) an item, as the client's LWOInventoryComponent_Common::CanRemoveFromInventory
|
||||
* (0x00ce0d20): not what they are driving or riding, always for an operator, otherwise as the item's
|
||||
* DeletionRestrictions row says (ItemComponent.delResIndex)
|
||||
* @param itemId the item's id
|
||||
* @param lot the item's LOT
|
||||
*/
|
||||
bool CanRemoveFromInventory(LWOOBJID itemId, LOT lot) const;
|
||||
|
||||
/**
|
||||
* Whether a DeletionRestrictions row allows removing an item (CheckDeletionRestrictionIndex 0x00c94c20)
|
||||
* @param itemId the item being removed
|
||||
* @param restrictionId the row
|
||||
* @param checked the rows being checked further up (ANY_RESTRICTION / ALL_RESTRICTIONS), so a row that names
|
||||
* itself again does not loop
|
||||
*/
|
||||
bool CheckDeletionRestriction(LWOOBJID itemId, uint32_t restrictionId, std::set<uint32_t>& checked) const;
|
||||
|
||||
/**
|
||||
* Whether the player has items of the given LOTs other than one item (HasOtherItemsOfLots 0x00c02db0)
|
||||
* @param lots the LOTs
|
||||
* @param excludedItemId the item not to count
|
||||
* @param any true: an item of any of the LOTs is enough; false: one of each LOT is needed
|
||||
*/
|
||||
bool HasOtherItemsOfLots(const std::vector<uint32_t>& lots, LWOOBJID excludedItemId, bool any) const;
|
||||
|
||||
/**
|
||||
* Returns an item in the inventory that matches the specified LOT
|
||||
* @param lot the lot of the item to find
|
||||
|
||||
Reference in New Issue
Block a user