1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00

the last commit was shit, now it's done properly

This commit is contained in:
NotAdam 2018-07-26 23:37:12 +10:00
parent 47f86e13c7
commit 460d4c79b7
3 changed files with 5 additions and 10 deletions

View file

@ -605,7 +605,7 @@ public:
using InvSlotPair = std::pair< uint16_t, int8_t >;
using InvSlotPairVec = std::vector< InvSlotPair >;
ItemPtr createItem( uint32_t catalogId, uint16_t quantity = 1 );
ItemPtr createItem( uint32_t catalogId, uint32_t quantity = 1 );
bool loadInventory();
InvSlotPairVec getSlotsOfItemsInInventory( uint32_t catalogId );
InvSlotPair getFreeBagSlot();
@ -625,7 +625,6 @@ public:
/*! return the current amount of currency of type */
uint32_t getCurrency( Common::CurrencyType type );
void updateCurrencyDb();
void updateBagDb( Common::InventoryType type );
void updateMannequinDb( Common::InventoryType type );
void updateItemDb( ItemPtr pItem ) const;
@ -639,8 +638,6 @@ public:
void removeCrystal( Common::CrystalType type, uint32_t amount );
bool isObtainable( uint32_t catalogId, uint8_t quantity );
void updateCrystalDb();
void send();
uint8_t getFreeSlotsInBags();

View file

@ -557,7 +557,7 @@ void Core::Entity::Player::insertQuest( uint16_t questId, uint8_t index, uint8_t
pDb->execute( stmt );
}
Core::ItemPtr Core::Entity::Player::createItem( uint32_t catalogId, uint16_t quantity )
Core::ItemPtr Core::Entity::Player::createItem( uint32_t catalogId, uint32_t quantity )
{
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
@ -566,8 +566,6 @@ Core::ItemPtr Core::Entity::Player::createItem( uint32_t catalogId, uint16_t qua
if( !itemInfo )
return nullptr;
auto itemAmount = std::min< uint16_t >( quantity, static_cast< uint16_t >( itemInfo->stackSize ) );
if( !itemInfo )
return nullptr;
@ -578,13 +576,13 @@ Core::ItemPtr Core::Entity::Player::createItem( uint32_t catalogId, uint16_t qua
itemInfo->modelMain,
itemInfo->modelSub );
pItem->setStackSize( itemAmount );
pItem->setStackSize( quantity );
pDb->execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
std::to_string( getId() ) + ", " +
std::to_string( pItem->getUId() ) + ", " +
std::to_string( pItem->getId() ) + ", " +
std::to_string( itemAmount ) + ", " +
std::to_string( quantity ) + ", " +
std::to_string( flags ) + ");" );
return pItem;

View file

@ -84,7 +84,7 @@ void Core::Item::setUId( uint64_t id )
void Core::Item::setStackSize( uint32_t size )
{
m_stackSize = size;
m_stackSize = std::min< uint32_t >( size, m_maxStackSize );
}
uint32_t Core::Item::getStackSize() const