mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-06 07:18:42 +00:00
Fix skill slot assignment to use equipLocation instead of itemType
- Add FindBehaviorSlotByEquipLocation method to map equipLocation strings to BehaviorSlot enum - Update AddItemSkills and RemoveItemSkills to use equipLocation instead of itemType - This fixes issue where items with same skill but different equipLocations would conflict - Add unit tests to verify the new behavior - Based on issue #1339: Server doesn't allow same skill in multiple slots Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
This commit is contained in:
@@ -1168,7 +1168,7 @@ LOT InventoryComponent::GetConsumable() const {
|
||||
void InventoryComponent::AddItemSkills(const LOT lot) {
|
||||
const auto info = Inventory::FindItemComponent(lot);
|
||||
|
||||
const auto slot = FindBehaviorSlot(static_cast<eItemType>(info.itemType));
|
||||
const auto slot = FindBehaviorSlotByEquipLocation(info.equipLocation);
|
||||
|
||||
if (slot == BehaviorSlot::Invalid) {
|
||||
return;
|
||||
@@ -1203,7 +1203,7 @@ void InventoryComponent::FixInvisibleItems() {
|
||||
void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
||||
const auto info = Inventory::FindItemComponent(lot);
|
||||
|
||||
const auto slot = FindBehaviorSlot(static_cast<eItemType>(info.itemType));
|
||||
const auto slot = FindBehaviorSlotByEquipLocation(info.equipLocation);
|
||||
|
||||
if (slot == BehaviorSlot::Invalid) {
|
||||
return;
|
||||
@@ -1332,6 +1332,20 @@ BehaviorSlot InventoryComponent::FindBehaviorSlot(const eItemType type) {
|
||||
}
|
||||
}
|
||||
|
||||
BehaviorSlot InventoryComponent::FindBehaviorSlotByEquipLocation(const std::string& equipLocation) {
|
||||
if (equipLocation == "special_r") {
|
||||
return BehaviorSlot::Primary;
|
||||
} else if (equipLocation == "hair") {
|
||||
return BehaviorSlot::Head;
|
||||
} else if (equipLocation == "special_l") {
|
||||
return BehaviorSlot::Offhand;
|
||||
} else if (equipLocation == "clavicle") {
|
||||
return BehaviorSlot::Neck;
|
||||
} else {
|
||||
return BehaviorSlot::Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
bool InventoryComponent::IsTransferInventory(eInventoryType type, bool includeVault) {
|
||||
return type == VENDOR_BUYBACK || (includeVault && (type == VAULT_ITEMS || type == VAULT_MODELS)) || type == TEMP_ITEMS || type == TEMP_MODELS || type == MODELS_IN_BBB;
|
||||
}
|
||||
|
@@ -368,6 +368,13 @@ public:
|
||||
*/
|
||||
static BehaviorSlot FindBehaviorSlot(eItemType type);
|
||||
|
||||
/**
|
||||
* Returns the behavior slot for the given equipment location
|
||||
* @param equipLocation the equipment location to find the behavior slot for
|
||||
* @return the behavior slot for the given equipment location
|
||||
*/
|
||||
static BehaviorSlot FindBehaviorSlotByEquipLocation(const std::string& equipLocation);
|
||||
|
||||
/**
|
||||
* Checks if the inventory type is a temp inventory
|
||||
* @param type the inventory type to check
|
||||
|
Reference in New Issue
Block a user