mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 22:57:45 +00:00
commit
f1d059f1e7
10 changed files with 80 additions and 74 deletions
|
@ -153,9 +153,7 @@ struct FFXIVIpcInventoryModifyHandler : FFXIVIpcBasePacket< InventoryModifyHandl
|
|||
{
|
||||
/* 0000 */ uint32_t seq;
|
||||
/* 0004 */ Common::InventoryOperation action;
|
||||
/* 0005 */ char pad_0005[3];
|
||||
/* 0008 */ uint16_t splitCount; // todo: check packet handler in game and see if this is sent as a u16 or u32
|
||||
/* 000A */ char pad_000A[2];
|
||||
/* 0005 */ char pad_0005[7];
|
||||
/* 000C */ uint16_t fromContainer;
|
||||
/* 000E */ char pad_000E[2];
|
||||
/* 0010 */ uint8_t fromSlot;
|
||||
|
@ -163,6 +161,8 @@ struct FFXIVIpcInventoryModifyHandler : FFXIVIpcBasePacket< InventoryModifyHandl
|
|||
/* 0020 */ uint16_t toContainer;
|
||||
/* 0022 */ char pad_0022[2];
|
||||
/* 0024 */ uint8_t toSlot;
|
||||
/* 0025 */ uint8_t pad_0025[3];
|
||||
/* 0028 */ uint32_t splitCount;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -30,27 +30,22 @@ private:
|
|||
auto callback = [this]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
auto questionAnswer = result.param2;
|
||||
int16_t rSlotId;
|
||||
|
||||
uint16_t itemId = 0;
|
||||
|
||||
switch( questionAnswer )
|
||||
{
|
||||
case 1: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4423, 1, false, true ); break;
|
||||
case 2: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4424, 1, false, true ); break;
|
||||
case 3: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4425, 1, false, true ); break;
|
||||
case 4: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4426, 1, false, true ); break;
|
||||
default: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4426, 1, false, true ); break;
|
||||
case 1: itemId = 4423; break;
|
||||
case 2: itemId = 4424; break;
|
||||
case 3: itemId = 4425; break;
|
||||
case 4: itemId = 4426; break;
|
||||
default: itemId = 4426; break;
|
||||
}
|
||||
|
||||
if( rSlotId != -1 )
|
||||
{
|
||||
auto pItem = player.getItemAt( Common::InventoryType::ArmoryRing, rSlotId );
|
||||
auto item = player.addItem( Common::InventoryType::ArmoryRing, -1, itemId, 1, false, true );
|
||||
|
||||
player.sendDebug( std::to_string( rSlotId ) );
|
||||
|
||||
if( pItem )
|
||||
player.equipItem( Common::EquipSlot::Ring2, pItem, true );
|
||||
|
||||
}
|
||||
if( item )
|
||||
player.equipItem( Common::EquipSlot::Ring2, item, true );
|
||||
|
||||
player.setOpeningSequence( 1 );
|
||||
Scene00001( player );
|
||||
|
|
|
@ -45,27 +45,22 @@ private:
|
|||
auto callback = [this]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
auto questionAnswer = result.param2;
|
||||
int16_t rSlotId;
|
||||
|
||||
uint16_t itemId = 0;
|
||||
|
||||
switch( questionAnswer )
|
||||
{
|
||||
case 1: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4423, 1, false, true ); break;
|
||||
case 2: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4424, 1, false, true ); break;
|
||||
case 3: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4425, 1, false, true ); break;
|
||||
case 4: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4426, 1, false, true ); break;
|
||||
default: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4426, 1, false, true ); break;
|
||||
case 1: itemId = 4423; break;
|
||||
case 2: itemId = 4424; break;
|
||||
case 3: itemId = 4425; break;
|
||||
case 4: itemId = 4426; break;
|
||||
default: itemId = 4426; break;
|
||||
}
|
||||
|
||||
if( rSlotId != -1 )
|
||||
{
|
||||
auto pItem = player.getItemAt( Common::InventoryType::ArmoryRing, rSlotId );
|
||||
auto item = player.addItem( Common::InventoryType::ArmoryRing, -1, itemId, 1, false, true );
|
||||
|
||||
player.sendDebug( std::to_string( rSlotId ) );
|
||||
|
||||
if( pItem )
|
||||
player.equipItem( Common::EquipSlot::Ring2, pItem, true );
|
||||
|
||||
}
|
||||
if( item )
|
||||
player.equipItem( Common::EquipSlot::Ring2, item, true );
|
||||
|
||||
player.setOpeningSequence( 1 );
|
||||
Scene00001( player );
|
||||
|
|
|
@ -31,27 +31,22 @@ private:
|
|||
auto callback = [this]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
auto questionAnswer = result.param2;
|
||||
int16_t rSlotId;
|
||||
|
||||
uint16_t itemId = 0;
|
||||
|
||||
switch( questionAnswer )
|
||||
{
|
||||
case 1: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4423, 1, false, true ); break;
|
||||
case 2: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4424, 1, false, true ); break;
|
||||
case 3: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4425, 1, false, true ); break;
|
||||
case 4: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4426, 1, false, true ); break;
|
||||
default: rSlotId = player.addItem( Common::InventoryType::ArmoryRing, -1, 4426, 1, false, true ); break;
|
||||
case 1: itemId = 4423; break;
|
||||
case 2: itemId = 4424; break;
|
||||
case 3: itemId = 4425; break;
|
||||
case 4: itemId = 4426; break;
|
||||
default: itemId = 4426; break;
|
||||
}
|
||||
|
||||
if( rSlotId != -1 )
|
||||
{
|
||||
auto pItem = player.getItemAt( Common::InventoryType::ArmoryRing, rSlotId );
|
||||
auto item = player.addItem( Common::InventoryType::ArmoryRing, -1, itemId, 1, false, true );
|
||||
|
||||
player.sendDebug( std::to_string( rSlotId ) );
|
||||
|
||||
if( pItem )
|
||||
player.equipItem( Common::EquipSlot::Ring2, pItem, true );
|
||||
|
||||
}
|
||||
if( item )
|
||||
player.equipItem( Common::EquipSlot::Ring2, item, true );
|
||||
|
||||
player.setOpeningSequence( 1 );
|
||||
Scene00001( player );
|
||||
|
|
|
@ -612,7 +612,7 @@ public:
|
|||
bool loadInventory();
|
||||
InvSlotPairVec getSlotsOfItemsInInventory( uint32_t catalogId );
|
||||
InvSlotPair getFreeBagSlot();
|
||||
int16_t addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint16_t quantity = 1, bool isHq = false, bool silent = false );
|
||||
Core::ItemPtr addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint16_t quantity = 1, bool isHq = false, bool slient = false );
|
||||
void moveItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot );
|
||||
void swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot );
|
||||
void discardItem( uint16_t fromInventoryId, uint8_t fromSlotId );
|
||||
|
@ -760,7 +760,7 @@ private:
|
|||
// content finder info
|
||||
uint32_t m_cfPenaltyUntil; // unix time
|
||||
|
||||
uint8_t m_mount;
|
||||
uint32_t m_mount;
|
||||
uint32_t m_emoteMode;
|
||||
uint8_t m_pose;
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ using namespace Core::Network::ActorControl;
|
|||
|
||||
void Core::Entity::Player::initInventory()
|
||||
{
|
||||
auto setupContainer = [this]( InventoryType type, uint8_t maxSize, const std::string& tableName, bool isMultiStorage )
|
||||
{ m_storageMap[type] = make_ItemContainer( type, maxSize, tableName, isMultiStorage ); };
|
||||
auto setupContainer = [this]( InventoryType type, uint8_t maxSize, const std::string& tableName, bool isMultiStorage, bool isPersistentStorage = true )
|
||||
{ m_storageMap[type] = make_ItemContainer( type, maxSize, tableName, isMultiStorage, isPersistentStorage ); };
|
||||
|
||||
// main bags
|
||||
setupContainer( Bag0, 34, "charaiteminventory", true );
|
||||
|
@ -102,6 +102,10 @@ void Core::Entity::Player::initInventory()
|
|||
//soul crystals - 13
|
||||
setupContainer( ArmorySoulCrystal, 34, "charaiteminventory", true );
|
||||
|
||||
// item hand in container
|
||||
// non-persistent container, will not save its contents
|
||||
setupContainer( HandIn, 10, "", true, false );
|
||||
|
||||
loadInventory();
|
||||
|
||||
}
|
||||
|
@ -321,7 +325,7 @@ bool Core::Entity::Player::tryAddItem( uint16_t catalogId, uint32_t quantity )
|
|||
|
||||
for( uint16_t i = 0; i < 4; i++ )
|
||||
{
|
||||
if( addItem( i, -1, catalogId, quantity ) != -1 )
|
||||
if( addItem( i, -1, catalogId, quantity ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -445,6 +449,9 @@ void Core::Entity::Player::writeInventory( InventoryType type )
|
|||
|
||||
auto storage = m_storageMap[type];
|
||||
|
||||
if( !storage->isPersistentStorage() )
|
||||
return;
|
||||
|
||||
std::string query = "UPDATE " + storage->getTableName() + " SET ";
|
||||
|
||||
for( int32_t i = 0; i <= storage->getMaxSize(); i++ )
|
||||
|
@ -488,7 +495,7 @@ bool Core::Entity::Player::isObtainable( uint32_t catalogId, uint8_t quantity )
|
|||
}
|
||||
|
||||
|
||||
int16_t Core::Entity::Player::addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint16_t quantity, bool isHq, bool silent )
|
||||
Core::ItemPtr Core::Entity::Player::addItem( uint16_t inventoryId, int8_t slotId, uint32_t catalogId, uint16_t quantity, bool isHq, bool silent )
|
||||
{
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
|
@ -497,7 +504,7 @@ int16_t Core::Entity::Player::addItem( uint16_t inventoryId, int8_t slotId, uint
|
|||
// if item data doesn't exist or it's a blank field
|
||||
if( !itemInfo || itemInfo->levelItem == 0 )
|
||||
{
|
||||
return -1;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int8_t rSlotId = -1;
|
||||
|
@ -515,7 +522,7 @@ int16_t Core::Entity::Player::addItem( uint16_t inventoryId, int8_t slotId, uint
|
|||
rSlotId = freeSlot.second;
|
||||
|
||||
if( rSlotId == -1 )
|
||||
return -1;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto item = createItem( catalogId, quantity );
|
||||
|
@ -533,20 +540,23 @@ int16_t Core::Entity::Player::addItem( uint16_t inventoryId, int8_t slotId, uint
|
|||
" WHERE storageId = " + std::to_string( inventoryId ) +
|
||||
" AND CharacterId = " + std::to_string( getId() ) );
|
||||
|
||||
|
||||
auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(),
|
||||
rSlotId,
|
||||
inventoryId,
|
||||
*item );
|
||||
queuePacket( invUpdate );
|
||||
|
||||
if( !silent )
|
||||
{
|
||||
auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(),
|
||||
rSlotId,
|
||||
inventoryId,
|
||||
*item );
|
||||
|
||||
queuePacket( invUpdate );
|
||||
|
||||
queuePacket( boost::make_shared< ActorControlPacket143 >( getId(), ItemObtainIcon,
|
||||
catalogId, item->getStackSize() ) );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return rSlotId;
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
|
@ -613,6 +623,9 @@ bool Core::Entity::Player::updateContainer( uint16_t storageId, uint8_t slotId,
|
|||
void Core::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t fromSlotId,
|
||||
uint16_t toInventoryId, uint8_t toSlot, uint16_t itemCount )
|
||||
{
|
||||
if( itemCount == 0 )
|
||||
return;
|
||||
|
||||
auto fromItem = m_storageMap[fromInventoryId]->getItem( fromSlotId );
|
||||
if( !fromItem )
|
||||
return;
|
||||
|
@ -628,12 +641,10 @@ void Core::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t fromSlot
|
|||
// todo: correct invalid move? again, not sure what retail does here
|
||||
return;
|
||||
|
||||
auto newSlot = addItem( toInventoryId, toSlot, fromItem->getId(), itemCount, fromItem->isHq(), true );
|
||||
if( newSlot == -1 )
|
||||
auto newItem = addItem( toInventoryId, toSlot, fromItem->getId(), itemCount, fromItem->isHq(), true );
|
||||
if( !newItem )
|
||||
return;
|
||||
|
||||
auto newItem = m_storageMap[toInventoryId]->getItem( static_cast< uint8_t >( newSlot ) );
|
||||
|
||||
fromItem->setStackSize( fromItem->getStackSize() - itemCount );
|
||||
|
||||
updateContainer( fromInventoryId, fromSlotId, fromItem );
|
||||
|
|
|
@ -11,11 +11,12 @@
|
|||
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
Core::ItemContainer::ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName, bool isMultiStorage ) :
|
||||
Core::ItemContainer::ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName, bool isMultiStorage, bool isPersistentStorage ) :
|
||||
m_id( storageId ),
|
||||
m_size( maxSize ),
|
||||
m_tableName( tableName ),
|
||||
m_bMultiStorage( isMultiStorage )
|
||||
m_bMultiStorage( isMultiStorage ),
|
||||
m_isPersistentStorage( isPersistentStorage )
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -43,7 +44,8 @@ void Core::ItemContainer::removeItem( uint8_t slotId )
|
|||
|
||||
if( it != m_itemMap.end() )
|
||||
{
|
||||
pDb->execute( "DELETE FROM charaglobalitem WHERE itemId = " + std::to_string( it->second->getUId() ) );
|
||||
if( m_isPersistentStorage )
|
||||
pDb->execute( "DELETE FROM charaglobalitem WHERE itemId = " + std::to_string( it->second->getUId() ) );
|
||||
|
||||
m_itemMap.erase( it );
|
||||
|
||||
|
@ -113,4 +115,9 @@ bool Core::ItemContainer::isMultiStorage() const
|
|||
return m_bMultiStorage;
|
||||
}
|
||||
|
||||
bool Core::ItemContainer::isPersistentStorage() const
|
||||
{
|
||||
return m_isPersistentStorage;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Core
|
|||
{
|
||||
|
||||
public:
|
||||
ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName, bool isMultiStorage );
|
||||
ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName, bool isMultiStorage, bool isPersistentStorage = true );
|
||||
~ItemContainer();
|
||||
|
||||
uint16_t getId() const;
|
||||
|
@ -40,12 +40,15 @@ namespace Core
|
|||
std::string getTableName() const;
|
||||
|
||||
bool isMultiStorage() const;
|
||||
|
||||
bool isPersistentStorage() const;
|
||||
|
||||
private:
|
||||
uint16_t m_id;
|
||||
uint8_t m_size;
|
||||
std::string m_tableName;
|
||||
bool m_bMultiStorage;
|
||||
bool m_isPersistentStorage;
|
||||
ItemMap m_itemMap;
|
||||
Entity::PlayerPtr m_pOwner;
|
||||
};
|
||||
|
|
|
@ -324,7 +324,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R
|
|||
}
|
||||
|
||||
if( !targetPlayer->addItem( -1, param1, quantity ) )
|
||||
player.sendUrgent( "Item " + std::to_string( param1 ) + " not found..." );
|
||||
player.sendUrgent( "Item " + std::to_string( param1 ) + " could not be added to inventory." );
|
||||
break;
|
||||
}
|
||||
case GmCommand::Gil:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <string>
|
||||
#include <typeinfo>
|
||||
#include <typeindex>
|
||||
#include <sapphire_zone/Event/EventHandler.h>
|
||||
#include <Event/EventHandler.h>
|
||||
#include "Forwards.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
Loading…
Add table
Reference in a new issue