From a2caccb2eea20c27a555739088f1faf72b32b183 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 30 Jun 2018 12:45:41 +1000 Subject: [PATCH] fix added items having incorrect data --- .../sapphire_zone/Inventory/Inventory.cpp | 18 ++++++++++-------- src/servers/sapphire_zone/Inventory/Item.cpp | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/servers/sapphire_zone/Inventory/Inventory.cpp b/src/servers/sapphire_zone/Inventory/Inventory.cpp index 84fa68cc..c3eff997 100644 --- a/src/servers/sapphire_zone/Inventory/Inventory.cpp +++ b/src/servers/sapphire_zone/Inventory/Inventory.cpp @@ -134,6 +134,9 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); auto itemInfo = pExdData->get< Core::Data::Item >( catalogId ); + if( !itemInfo ) + return nullptr; + uint16_t itemAmount = quantity; if( itemInfo->stackSize == 1 ) @@ -144,14 +147,14 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity uint8_t flags = 0; -// std::string itemName( itemInfo->name ); - - ItemPtr pItem = make_Item( catalogId ); + ItemPtr pItem = make_Item( getNextUId(), + catalogId, + itemInfo->modelMain, + itemInfo->modelSub, + static_cast< ItemUICategory >( itemInfo->itemUICategory ), + false ); pItem->setStackSize( itemAmount ); - pItem->setUId( getNextUId() ); - pItem->setModelIds( itemInfo->modelMain, itemInfo->modelSub ); - pItem->setCategory( static_cast< ItemUICategory >( itemInfo->itemUICategory ) ); pDb->execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " + std::to_string( m_pOwner->getId() ) + ", " + @@ -161,7 +164,6 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity std::to_string( flags ) + ");" ); return pItem; - } @@ -739,7 +741,7 @@ Core::ItemPtr Core::Inventory::loadItem( uint64_t uId ) try { auto itemInfo = pExdData->get< Core::Data::Item >( itemRes->getUInt( 1 ) ); - bool isHq = itemRes->getUInt( 3 ) == 1 ? true : false; + bool isHq = itemRes->getUInt( 3 ) == 1; ItemPtr pItem( new Item( uId, itemRes->getUInt( 1 ), itemInfo->modelMain, diff --git a/src/servers/sapphire_zone/Inventory/Item.cpp b/src/servers/sapphire_zone/Inventory/Item.cpp index a264f77a..b94b8d0b 100644 --- a/src/servers/sapphire_zone/Inventory/Item.cpp +++ b/src/servers/sapphire_zone/Inventory/Item.cpp @@ -28,6 +28,7 @@ Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t mo { auto pExdData = g_fw.get< Data::ExdDataGenerated >(); auto itemInfo = pExdData->get< Core::Data::Item >( catalogId ); + m_delayMs = itemInfo->delayms; m_physicalDmg = itemInfo->damagePhys; m_magicalDmg = itemInfo->damageMag;