From 61280baad5018a13218214823e5471b8c9327a6d Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 26 Jul 2018 23:12:02 +1000 Subject: [PATCH 1/7] fix loading of currency/crystal items --- .../sapphire_zone/Actor/PlayerInventory.cpp | 84 ++++--------------- src/servers/sapphire_zone/Actor/PlayerSql.cpp | 63 +------------- 2 files changed, 20 insertions(+), 127 deletions(-) diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index 23220637..c1161064 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -58,10 +58,10 @@ void Core::Entity::Player::initInventory() setupContainer( GearSet0, 13, "charaitemgearset", true ); // gil contianer - setupContainer( Currency, 11, "charaitemcurrency", false ); + setupContainer( Currency, 11, "charaiteminventory", false ); // crystals?? - setupContainer( Crystal, 11, "charaitemcrystal", false ); + setupContainer( Crystal, 11, "charaiteminventory", false ); // armory weapons - 0 setupContainer( ArmoryMain, 34, "charaiteminventory", true ); @@ -219,20 +219,22 @@ void Core::Entity::Player::unequipItem( Common::EquipSlot equipSlotId, ItemPtr p // TODO: these next functions are so similar that they could likely be simplified void Core::Entity::Player::addCurrency( CurrencyType type, uint32_t amount ) { - auto currItem = m_inventoryMap[Currency]->getItem( static_cast< uint8_t >( type ) - 1 ); + auto slot = static_cast< uint8_t >( static_cast< uint8_t >( type ) - 1 ); + auto currItem = m_inventoryMap[Currency]->getItem( slot ); if( !currItem ) { // TODO: map currency type to itemid currItem = createItem( 1 ); - m_inventoryMap[Currency]->setItem( static_cast< uint8_t >( type ) - 1, currItem ); - updateCurrencyDb(); + m_inventoryMap[Currency]->setItem( slot, currItem ); } uint32_t currentAmount = currItem->getStackSize(); currItem->setStackSize( currentAmount + amount ); updateItemDb( currItem ); + updateContainer( Currency, slot, currItem ); + auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), static_cast< uint8_t >( type ) - 1, Common::InventoryType::Currency, @@ -272,7 +274,6 @@ void Core::Entity::Player::addCrystal( Common::CrystalType type, uint32_t amount // TODO: map currency type to itemid currItem = createItem( static_cast< uint8_t >( type ) + 1 ); m_inventoryMap[Crystal]->setItem( static_cast< uint8_t >( type ) - 1, currItem ); - updateCrystalDb(); } uint32_t currentAmount = currItem->getStackSize(); @@ -281,6 +282,8 @@ void Core::Entity::Player::addCrystal( Common::CrystalType type, uint32_t amount updateItemDb( currItem ); + updateBagDb( Crystal ); + auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), static_cast< uint8_t >( type ) - 1, @@ -435,69 +438,16 @@ uint32_t Core::Entity::Player::getCrystal( CrystalType type ) } -void Core::Entity::Player::updateCurrencyDb() -{ - auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); - int32_t firstItemPos = -1; - std::string query = "UPDATE charaitemcurrency SET "; - - for( int32_t i = 0; i <= 11; i++ ) - { - auto currItem = m_inventoryMap[Currency]->getItem( i ); - - if( currItem ) - { - if( firstItemPos == -1 ) - firstItemPos = i; - - if( i > firstItemPos ) - query += ", "; - - query += "container_" + std::to_string( i ) + " = " + std::to_string( currItem->getUId() ); - } - } - - query += " WHERE CharacterId = " + std::to_string( getId() ); - - pDb->execute( query ); -} - - -void Core::Entity::Player::updateCrystalDb() -{ - auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); - int32_t firstItemPos = -1; - std::string query = "UPDATE charaitemcrystal SET "; - - for( int32_t i = 0; i <= 11; i++ ) - { - auto currItem = m_inventoryMap[Crystal]->getItem( i ); - - if( currItem ) - { - if( firstItemPos == -1 ) - firstItemPos = i; - - if( i > firstItemPos ) - query += ", "; - - query += "container_" + std::to_string( i ) + " = " + std::to_string( currItem->getUId() ); - } - } - - query += " WHERE CharacterId = " + std::to_string( getId() ); - - pDb->execute( query ); -} - void Core::Entity::Player::updateBagDb( InventoryType type ) { auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); std::string query = "UPDATE charaiteminventory SET "; - for( int32_t i = 0; i <= 34; i++ ) + auto container = m_inventoryMap[type]; + + for( int32_t i = 0; i <= container->getMaxSize(); i++ ) { - auto currItem = m_inventoryMap[type]->getItem( i ); + auto currItem = container->getItem( i ); if( i > 0 ) query += ", "; @@ -518,9 +468,11 @@ void Core::Entity::Player::updateMannequinDb( InventoryType type ) auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); std::string query = "UPDATE charaitemgearset SET "; - for( int32_t i = 0; i <= 13; i++ ) + auto container = m_inventoryMap[type]; + + for( int32_t i = 0; i <= container->getMaxSize(); i++ ) { - auto currItem = m_inventoryMap[type]->getItem( i ); + auto currItem = container->getItem( i ); if( i > 0 ) query += ", "; @@ -661,8 +613,8 @@ bool Core::Entity::Player::updateContainer( uint16_t containerId, uint8_t slotId switch( containerType ) { case Armory: - case CurrencyCrystal: case Bag: + case CurrencyCrystal: { updateBagDb( static_cast< InventoryType >( containerId ) ); break; diff --git a/src/servers/sapphire_zone/Actor/PlayerSql.cpp b/src/servers/sapphire_zone/Actor/PlayerSql.cpp index bed620ca..98d897de 100644 --- a/src/servers/sapphire_zone/Actor/PlayerSql.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerSql.cpp @@ -627,7 +627,7 @@ bool Core::Entity::Player::loadInventory() } /////////////////////////////////////////////////////////////////////////////////////////////////////// - // Load Bags + // Load everything auto bagRes = pDb->query( "SELECT storageId, " "container_0, container_1, container_2, container_3, container_4, " "container_5, container_6, container_7, container_8, container_9, " @@ -643,7 +643,7 @@ bool Core::Entity::Player::loadInventory() while( bagRes->next() ) { uint16_t storageId = bagRes->getUInt16( 1 ); - for( uint32_t i = 1; i <= 35; i++ ) + for( uint32_t i = 1; i <= m_inventoryMap[storageId]->getMaxSize(); i++ ) { uint64_t uItemId = bagRes->getUInt64( i + 1 ); if( uItemId == 0 ) @@ -658,64 +658,5 @@ bool Core::Entity::Player::loadInventory() } } - - /////////////////////////////////////////////////////////////////////////////////////////////////////// - // Load Currency - auto curRes = pDb->query( "SELECT storageId, " - "container_0, container_1, container_2, container_3, container_4, " - "container_5, container_6, container_7, container_8, container_9, " - "container_10, container_11 " - "FROM charaitemcurrency " \ - "WHERE CharacterId = " + std::to_string( getId() ) + " " \ - "ORDER BY storageId ASC;" ); - - while( curRes->next() ) - { - uint16_t storageId = curRes->getUInt16( 1 ); - for( uint32_t i = 1; i <= 12; i++ ) - { - uint64_t uItemId = curRes->getUInt64( i + 1 ); - if( uItemId == 0 ) - continue; - - ItemPtr pItem = Items::Util::loadItem( uItemId ); - - if( pItem == nullptr ) - continue; - - m_inventoryMap[storageId]->getItemMap()[i - 1] = pItem; - } - } - - - /////////////////////////////////////////////////////////////////////////////////////////////////////// - // Load Crystals - auto crystalRes = pDb->query( "SELECT storageId, " - "container_0, container_1, container_2, container_3, container_4, " - "container_5, container_6, container_7, container_8, container_9, " - "container_10, container_11, container_12, container_13, container_14, " - "container_15, container_16, container_17 " - "FROM charaitemcrystal " \ - "WHERE CharacterId = " + std::to_string( getId() ) + " " \ - "ORDER BY storageId ASC;" ); - - while( crystalRes->next() ) - { - uint16_t storageId = crystalRes->getUInt16( 1 ); - for( int32_t i = 1; i <= 17; i++ ) - { - uint64_t uItemId = crystalRes->getUInt64( i + 1 ); - if( uItemId == 0 ) - continue; - - ItemPtr pItem = Items::Util::loadItem( uItemId ); - - if( pItem == nullptr ) - continue; - - m_inventoryMap[storageId]->getItemMap()[i - 1] = pItem; - } - } - return true; } From f043177719d3a3cb375e9ce0bbc3c9d40289885a Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 26 Jul 2018 23:12:30 +1000 Subject: [PATCH 2/7] remove now unused sql tables --- sql/charaitemcrystal.sql | 74 --------------------------------------- sql/charaitemcurrency.sql | 68 ----------------------------------- 2 files changed, 142 deletions(-) delete mode 100644 sql/charaitemcrystal.sql delete mode 100644 sql/charaitemcurrency.sql diff --git a/sql/charaitemcrystal.sql b/sql/charaitemcrystal.sql deleted file mode 100644 index 1f9c2d57..00000000 --- a/sql/charaitemcrystal.sql +++ /dev/null @@ -1,74 +0,0 @@ --- MySQL dump 10.13 Distrib 5.7.13, for Win64 (x86_64) --- --- Host: localhost Database: sapphire --- ------------------------------------------------------ --- Server version 5.7.13-log - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `charaitemcrystal` --- - -DROP TABLE IF EXISTS `charaitemcrystal`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `charaitemcrystal` ( - `CharacterId` int(20) DEFAULT '0', - `storageId` int(10) DEFAULT '2001', - `type` int(5) DEFAULT '0', - `idx` int(5) NOT NULL AUTO_INCREMENT, - `container_0` int(20) DEFAULT '0', - `container_1` int(20) DEFAULT '0', - `container_2` int(20) DEFAULT '0', - `container_3` int(20) DEFAULT '0', - `container_4` int(20) DEFAULT '0', - `container_5` int(20) DEFAULT '0', - `container_6` int(20) DEFAULT '0', - `container_7` int(20) DEFAULT '0', - `container_8` int(20) DEFAULT '0', - `container_9` int(20) DEFAULT '0', - `container_10` int(20) DEFAULT '0', - `container_11` int(20) DEFAULT '0', - `container_12` int(20) DEFAULT '0', - `container_13` int(20) DEFAULT '0', - `container_14` int(20) DEFAULT '0', - `container_15` int(20) DEFAULT '0', - `container_16` int(20) DEFAULT '0', - `container_17` int(20) DEFAULT '0', - `IS_DELETE` int(3) DEFAULT '0', - `IS_NOT_ACTIVE_FLG` int(3) DEFAULT '0', - `UPDATE_DATE` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`idx`), - KEY `CharacterId` (`CharacterId`) -) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `charaitemcrystal` --- - -LOCK TABLES `charaitemcrystal` WRITE; -/*!40000 ALTER TABLE `charaitemcrystal` DISABLE KEYS */; -/*!40000 ALTER TABLE `charaitemcrystal` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2016-12-09 17:37:10 diff --git a/sql/charaitemcurrency.sql b/sql/charaitemcurrency.sql deleted file mode 100644 index 681dc036..00000000 --- a/sql/charaitemcurrency.sql +++ /dev/null @@ -1,68 +0,0 @@ --- MySQL dump 10.13 Distrib 5.7.13, for Win64 (x86_64) --- --- Host: localhost Database: sapphire --- ------------------------------------------------------ --- Server version 5.7.13-log - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `charaitemcurrency` --- - -DROP TABLE IF EXISTS `charaitemcurrency`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `charaitemcurrency` ( - `CharacterId` int(20) NOT NULL, - `storageId` int(10) DEFAULT '2000', - `type` int(5) DEFAULT '0', - `idx` int(5) NOT NULL AUTO_INCREMENT, - `container_0` int(20) DEFAULT '0', - `container_1` int(20) DEFAULT '0', - `container_2` int(20) DEFAULT '0', - `container_3` int(20) DEFAULT '0', - `container_4` int(20) DEFAULT '0', - `container_5` int(20) DEFAULT '0', - `container_6` int(20) DEFAULT '0', - `container_7` int(20) DEFAULT '0', - `container_8` int(20) NOT NULL DEFAULT '0', - `container_9` int(20) NOT NULL DEFAULT '0', - `container_10` int(20) NOT NULL DEFAULT '0', - `container_11` int(20) NOT NULL DEFAULT '0', - `IS_DELETE` int(3) DEFAULT '0', - `IS_NOT_ACTIVE_FLG` int(3) DEFAULT '0', - `UPDATE_DATE` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`idx`), - UNIQUE KEY `CharacterId` (`CharacterId`) -) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `charaitemcurrency` --- - -LOCK TABLES `charaitemcurrency` WRITE; -/*!40000 ALTER TABLE `charaitemcurrency` DISABLE KEYS */; -/*!40000 ALTER TABLE `charaitemcurrency` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2016-12-09 17:37:11 From c7555878dc6e9e8bb86ac31b47bf849d1a1d9ba0 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 26 Jul 2018 23:17:39 +1000 Subject: [PATCH 3/7] fix CurrencyCrystalInfo opcode --- src/common/Network/PacketDef/Ipcs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index d8010c37..435fc172 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -130,8 +130,8 @@ namespace Packets { ContainerInfo = 0x0192, // updated 4.3 InventoryTransactionFinish = 0x0193, // updated 4.3 InventoryTransaction = 0x0194, // updated 4.3 + CurrencyCrystalInfo = 0x0195, // updated 4.3 InventoryActionAck = 0x0197, // updated 4.3 - CurrencyCrystalInfo = 0xFFFF, // updated 4.3 - wrong opcode UpdateInventorySlot = 0x0198, // updated 4.3 From f702d37bc9c4a5a7019c14dff68fc3bb143cc771 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 26 Jul 2018 23:21:57 +1000 Subject: [PATCH 4/7] currency and crystal are now multistorage containers --- src/servers/sapphire_zone/Actor/PlayerInventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index c1161064..bc1f2313 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -58,10 +58,10 @@ void Core::Entity::Player::initInventory() setupContainer( GearSet0, 13, "charaitemgearset", true ); // gil contianer - setupContainer( Currency, 11, "charaiteminventory", false ); + setupContainer( Currency, 11, "charaiteminventory", true ); // crystals?? - setupContainer( Crystal, 11, "charaiteminventory", false ); + setupContainer( Crystal, 11, "charaiteminventory", true ); // armory weapons - 0 setupContainer( ArmoryMain, 34, "charaiteminventory", true ); From b199036f5ae21b4e1ad59e5f110455c0175ae11b Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 26 Jul 2018 23:29:58 +1000 Subject: [PATCH 5/7] improve behaviour for creating items with correct max stack sizes --- src/servers/sapphire_zone/Actor/PlayerSql.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/servers/sapphire_zone/Actor/PlayerSql.cpp b/src/servers/sapphire_zone/Actor/PlayerSql.cpp index 98d897de..04a3d900 100644 --- a/src/servers/sapphire_zone/Actor/PlayerSql.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerSql.cpp @@ -566,10 +566,7 @@ Core::ItemPtr Core::Entity::Player::createItem( uint32_t catalogId, uint16_t qua if( !itemInfo ) return nullptr; - uint16_t itemAmount = quantity; - - if( itemInfo->stackSize == 1 ) - itemAmount = 1; + auto itemAmount = std::min< uint16_t >( quantity, static_cast< uint16_t >( itemInfo->stackSize ) ); if( !itemInfo ) return nullptr; From e114e9dab9c9037723a29844cd3c6072e48b062f Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 26 Jul 2018 23:37:12 +1000 Subject: [PATCH 6/7] the last commit was shit, now it's done properly --- src/servers/sapphire_zone/Actor/Player.h | 5 +---- src/servers/sapphire_zone/Actor/PlayerSql.cpp | 8 +++----- src/servers/sapphire_zone/Inventory/Item.cpp | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/servers/sapphire_zone/Actor/Player.h b/src/servers/sapphire_zone/Actor/Player.h index cce73edb..6b204d3e 100644 --- a/src/servers/sapphire_zone/Actor/Player.h +++ b/src/servers/sapphire_zone/Actor/Player.h @@ -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(); diff --git a/src/servers/sapphire_zone/Actor/PlayerSql.cpp b/src/servers/sapphire_zone/Actor/PlayerSql.cpp index 04a3d900..e72c0b7f 100644 --- a/src/servers/sapphire_zone/Actor/PlayerSql.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerSql.cpp @@ -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; diff --git a/src/servers/sapphire_zone/Inventory/Item.cpp b/src/servers/sapphire_zone/Inventory/Item.cpp index e16a294a..cf959296 100644 --- a/src/servers/sapphire_zone/Inventory/Item.cpp +++ b/src/servers/sapphire_zone/Inventory/Item.cpp @@ -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 From 50121bf86b9a4295d4549e39e3b8ec4a2d09738e Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 26 Jul 2018 23:38:58 +1000 Subject: [PATCH 7/7] remove a 2nd space in //gm gil output --- .../sapphire_zone/Network/Handlers/GMCommandHandlers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp index 7a05e469..f009e69d 100644 --- a/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp @@ -330,7 +330,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R case GmCommand::Gil: { targetPlayer->addCurrency( CurrencyType::Gil, param1 ); - player.sendNotice( "Added " + std::to_string( param1 ) + " Gil for " + targetPlayer->getName() ); + player.sendNotice( "Added " + std::to_string( param1 ) + " Gil for " + targetPlayer->getName() ); break; } case GmCommand::Collect: