1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-24 13:47:46 +00:00

inventory item creation cleanup

This commit is contained in:
NotAdam 2018-06-30 12:49:34 +10:00
parent 820f755f17
commit 200232ceed
3 changed files with 11 additions and 30 deletions

View file

@ -150,9 +150,7 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity
ItemPtr pItem = make_Item( getNextUId(), ItemPtr pItem = make_Item( getNextUId(),
catalogId, catalogId,
itemInfo->modelMain, itemInfo->modelMain,
itemInfo->modelSub, itemInfo->modelSub );
static_cast< ItemUICategory >( itemInfo->itemUICategory ),
false );
pItem->setStackSize( itemAmount ); pItem->setStackSize( itemAmount );
@ -742,12 +740,13 @@ Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
{ {
auto itemInfo = pExdData->get< Core::Data::Item >( itemRes->getUInt( 1 ) ); auto itemInfo = pExdData->get< Core::Data::Item >( itemRes->getUInt( 1 ) );
bool isHq = itemRes->getUInt( 3 ) == 1; bool isHq = itemRes->getUInt( 3 ) == 1;
ItemPtr pItem( new Item( uId,
ItemPtr pItem = make_Item( uId,
itemRes->getUInt( 1 ), itemRes->getUInt( 1 ),
itemInfo->modelMain, itemInfo->modelMain,
itemInfo->modelSub, itemInfo->modelSub,
static_cast< ItemUICategory >( itemInfo->itemUICategory ), isHq );
isHq ) );
pItem->setStackSize( itemRes->getUInt( 2 ) ); pItem->setStackSize( itemRes->getUInt( 2 ) );
return pItem; return pItem;

View file

@ -1,47 +1,31 @@
#include <Common.h> #include <Common.h>
#include <Exd/ExdDataGenerated.h> #include <Exd/ExdDataGenerated.h>
#include <CommonGen.h>
#include "Framework.h" #include "Framework.h"
#include "Item.h" #include "Item.h"
extern Core::Framework g_fw; extern Core::Framework g_fw;
Core::Item::Item() Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq ) :
{
}
Core::Item::Item( uint32_t catalogId ) :
m_id( catalogId ),
m_isHq( false )
{
}
Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId, bool isHq ) :
m_id( catalogId ), m_id( catalogId ),
m_uId( uId ), m_uId( uId ),
m_category( categoryId ),
m_model1( model1 ), m_model1( model1 ),
m_model2( model2 ), m_model2( model2 ),
m_isHq( isHq ) m_isHq( isHq )
{ {
auto pExdData = g_fw.get< Data::ExdDataGenerated >(); auto pExdData = g_fw.get< Data::ExdDataGenerated >();
auto itemInfo = pExdData->get< Core::Data::Item >( catalogId ); auto itemInfo = pExdData->get< Core::Data::Item >( catalogId );
m_delayMs = itemInfo->delayms; m_delayMs = itemInfo->delayms;
m_physicalDmg = itemInfo->damagePhys; m_physicalDmg = itemInfo->damagePhys;
m_magicalDmg = itemInfo->damageMag; m_magicalDmg = itemInfo->damageMag;
m_weaponDmg = ( m_physicalDmg != 0 ) ? m_physicalDmg : m_magicalDmg; m_weaponDmg = ( m_physicalDmg != 0 ) ? m_physicalDmg : m_magicalDmg;
m_autoAttackDmg = static_cast< float >( m_weaponDmg * m_delayMs ) / 3000; m_autoAttackDmg = static_cast< float >( m_weaponDmg * m_delayMs ) / 3000;
m_category = static_cast< Common::ItemUICategory >( itemInfo->itemUICategory );
m_itemLevel = itemInfo->levelItem; m_itemLevel = itemInfo->levelItem;
} }
Core::Item::~Item()
{
}
float Core::Item::getAutoAttackDmg() const float Core::Item::getAutoAttackDmg() const
{ {
return m_autoAttackDmg; return m_autoAttackDmg;

View file

@ -9,10 +9,8 @@ class Item
{ {
public: public:
Item(); Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq = false );
Item( uint32_t catalogId ); ~Item() = default;
Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId, bool isHq = false );
~Item();
uint32_t getId() const; uint32_t getId() const;