mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 16:37:45 +00:00
correctly store items in armory/inventory based on client flag
This commit is contained in:
parent
7c5c39cd42
commit
55ae5290f6
5 changed files with 92 additions and 22 deletions
|
@ -62,6 +62,46 @@ namespace Common {
|
|||
SoulCrystal = 13,
|
||||
};
|
||||
|
||||
enum EquipSlotCategory : uint8_t
|
||||
{
|
||||
Unequippbale = 0,
|
||||
|
||||
// main slots
|
||||
|
||||
CharaMainHand = 1,
|
||||
CharaOffHand = 2,
|
||||
CharaHead = 3,
|
||||
CharaBody = 4,
|
||||
CharaHands = 5,
|
||||
CharaWaist = 6,
|
||||
CharaLegs = 7,
|
||||
CharaFeet = 8,
|
||||
CharaEars = 9,
|
||||
CharaNeck = 10,
|
||||
CharaWrist = 11,
|
||||
CharaRing = 12,
|
||||
CharaSoulCrystal = 17,
|
||||
|
||||
// specials
|
||||
|
||||
/*! Cannot equip gear to offhand slot */
|
||||
MainTwoHandedWeapon = 13,
|
||||
/*! Can be equipped in either main or offhand slot */
|
||||
MainOrOffHand = 14, // unused
|
||||
/*! Cannot equip gear to head */
|
||||
BodyAndHead = 15,
|
||||
/*! Cannot equip gear to hands, legs and feet slots */
|
||||
BodyDisallowHandsLegsFeet = 16,
|
||||
/*! Cannot equip gear to feet slot */
|
||||
LegsDisallowFeet = 18,
|
||||
/*! Cannot equp gear to head, hands, legs, feet slots */
|
||||
BodyDisallowAll = 19,
|
||||
/*! Cannot equip gear to hands slot */
|
||||
BodyDisallowHands = 20,
|
||||
/*! Cannot equip gear to legs & feet slots */
|
||||
BodyDisallowLegsFeet = 21,
|
||||
};
|
||||
|
||||
enum InventoryType : uint16_t
|
||||
{
|
||||
Bag0 = 0,
|
||||
|
@ -87,7 +127,7 @@ namespace Common {
|
|||
ArmoryWaist = 3204,
|
||||
ArmoryLegs = 3205,
|
||||
ArmoryFeet = 3206,
|
||||
ArmotyNeck = 3207,
|
||||
ArmoryNeck = 3207,
|
||||
ArmoryEar = 3208,
|
||||
ArmoryWrist = 3209,
|
||||
ArmoryRing = 3300,
|
||||
|
@ -600,8 +640,8 @@ namespace Common {
|
|||
HideWeapon = 0x2,
|
||||
HideLegacyMark = 0x4,
|
||||
|
||||
StoreNewItemsInArmouryChest = 0x5,
|
||||
StoreCraftedItemsInInventory = 0x6,
|
||||
StoreNewItemsInArmouryChest = 0x10,
|
||||
StoreCraftedItemsInInventory = 0x20,
|
||||
|
||||
Visor = 0x40,
|
||||
};
|
||||
|
|
|
@ -289,7 +289,7 @@ namespace Core {
|
|||
createInvDbContainer( InventoryType::ArmoryLegs );
|
||||
createInvDbContainer( InventoryType::ArmoryFeet );
|
||||
|
||||
createInvDbContainer( InventoryType::ArmotyNeck );
|
||||
createInvDbContainer( InventoryType::ArmoryNeck );
|
||||
createInvDbContainer( InventoryType::ArmoryEar );
|
||||
createInvDbContainer( InventoryType::ArmoryWrist );
|
||||
createInvDbContainer( InventoryType::ArmoryRing );
|
||||
|
|
|
@ -88,7 +88,7 @@ void Core::Entity::Player::initInventory()
|
|||
setupContainer( ArmoryFeet, 34, "charaiteminventory", true );
|
||||
|
||||
//neck
|
||||
setupContainer( ArmotyNeck, 34, "charaiteminventory", true );
|
||||
setupContainer( ArmoryNeck, 34, "charaiteminventory", true );
|
||||
|
||||
//earring
|
||||
setupContainer( ArmoryEar, 34, "charaiteminventory", true );
|
||||
|
@ -503,10 +503,22 @@ Core::ItemPtr Core::Entity::Player::addItem( uint32_t catalogId, uint32_t quanti
|
|||
|
||||
// todo: for now we're just going to add any items to main inv
|
||||
|
||||
std::pair< uint8_t, uint8_t > freeBagSlot;
|
||||
std::pair< uint16_t, uint8_t > freeBagSlot;
|
||||
bool foundFreeSlot = false;
|
||||
|
||||
for( auto bag : { Bag0, Bag1, Bag2, Bag3 } )
|
||||
std::vector< uint16_t > bags = { Bag0, Bag1, Bag2, Bag3 };
|
||||
|
||||
// add the related armoury bag to the applicable bags and try and fill a free slot there before falling back to regular inventory
|
||||
if( itemInfo->isEquippable && getEquipDisplayFlags() & StoreNewItemsInArmouryChest )
|
||||
{
|
||||
auto bag = Items::Util::getCharaEquipSlotCategoryToArmoryId( itemInfo->equipSlotCategory );
|
||||
|
||||
sendDebug( "Got bag: " + std::to_string( bag ) + " for cat: " + std::to_string( itemInfo->equipSlotCategory ) );
|
||||
|
||||
bags.insert( bags.begin(), bag );
|
||||
}
|
||||
|
||||
for( auto bag : bags )
|
||||
{
|
||||
auto storage = m_storageMap[bag];
|
||||
|
||||
|
@ -727,7 +739,7 @@ void Core::Entity::Player::swapItem( uint16_t fromInventoryId, uint8_t fromSlotI
|
|||
&& !Items::Util::isArmory( fromInventoryId ) )
|
||||
{
|
||||
updateContainer( fromInventoryId, fromSlotId, nullptr );
|
||||
fromInventoryId = Items::Util::getArmoryToEquipSlot( toSlot );
|
||||
fromInventoryId = Items::Util::getCharaEquipSlotCategoryToArmoryId( toSlot );
|
||||
fromSlotId = static_cast < uint8_t >( m_storageMap[fromInventoryId]->getFreeSlot() );
|
||||
}
|
||||
|
||||
|
|
|
@ -25,44 +25,62 @@ bool Core::Items::Util::isArmory( uint16_t containerId )
|
|||
containerId == Common::ArmoryOff ||
|
||||
containerId == Common::ArmoryRing ||
|
||||
containerId == Common::ArmoryWaist ||
|
||||
containerId == Common::ArmoryWrist;
|
||||
containerId == Common::ArmoryWrist ||
|
||||
containerId == Common::ArmorySoulCrystal;
|
||||
}
|
||||
|
||||
uint16_t Core::Items::Util::getArmoryToEquipSlot( uint8_t slotId )
|
||||
uint16_t Core::Items::Util::getCharaEquipSlotCategoryToArmoryId( uint8_t slotId )
|
||||
{
|
||||
|
||||
switch( slotId )
|
||||
{
|
||||
case Common::Body:
|
||||
case Common::CharaHead:
|
||||
return Common::ArmoryHead;
|
||||
|
||||
case Common::CharaBody:
|
||||
case Common::BodyAndHead:
|
||||
case Common::BodyDisallowHandsLegsFeet:
|
||||
case Common::BodyDisallowAll:
|
||||
case Common::BodyDisallowHands:
|
||||
case Common::BodyDisallowLegsFeet:
|
||||
return Common::ArmoryBody;
|
||||
|
||||
case Common::Ear:
|
||||
case Common::CharaEars:
|
||||
return Common::ArmoryEar;
|
||||
|
||||
case Common::Feet:
|
||||
case Common::CharaFeet:
|
||||
return Common::ArmoryFeet;
|
||||
|
||||
case Common::Hands:
|
||||
case Common::CharaHands:
|
||||
return Common::ArmoryHand;
|
||||
|
||||
case Common::Legs:
|
||||
case Common::CharaLegs:
|
||||
case Common::LegsDisallowFeet:
|
||||
return Common::ArmoryLegs;
|
||||
|
||||
case Common::MainHand:
|
||||
case Common::CharaMainHand:
|
||||
case Common::MainTwoHandedWeapon:
|
||||
case Common::MainOrOffHand:
|
||||
return Common::ArmoryMain;
|
||||
|
||||
case Common::OffHand:
|
||||
case Common::CharaOffHand:
|
||||
return Common::ArmoryOff;
|
||||
|
||||
case Common::Ring2:
|
||||
case Common::Ring1:
|
||||
case Common::CharaRing:
|
||||
return Common::ArmoryRing;
|
||||
|
||||
case Common::Waist:
|
||||
case Common::CharaWaist:
|
||||
return Common::ArmoryWaist;
|
||||
|
||||
case Common::Wrist:
|
||||
case Common::CharaWrist:
|
||||
return Common::ArmoryWrist;
|
||||
|
||||
case Common::CharaNeck:
|
||||
return Common::ArmoryNeck;
|
||||
|
||||
case Common::CharaSoulCrystal:
|
||||
return Common::ArmorySoulCrystal;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Util {
|
|||
|
||||
bool isArmory( uint16_t containerId );
|
||||
bool isEquipment( uint16_t containerId );
|
||||
uint16_t getArmoryToEquipSlot( uint8_t slotId );
|
||||
uint16_t getCharaEquipSlotCategoryToArmoryId( uint8_t slotId );
|
||||
|
||||
Common::ContainerType getContainerType( uint32_t containerId );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue