From 0bd352b50b78ce6391f8bfa403dfc5f8b25047c2 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 30 Jun 2018 11:53:45 +1000 Subject: [PATCH 1/4] create larger stacks correctly, fix indent --- src/servers/sapphire_zone/Inventory/Inventory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/servers/sapphire_zone/Inventory/Inventory.cpp b/src/servers/sapphire_zone/Inventory/Inventory.cpp index e1d2078b..84fa68cc 100644 --- a/src/servers/sapphire_zone/Inventory/Inventory.cpp +++ b/src/servers/sapphire_zone/Inventory/Inventory.cpp @@ -134,7 +134,7 @@ 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 ); - uint8_t itemAmount = quantity; + uint16_t itemAmount = quantity; if( itemInfo->stackSize == 1 ) itemAmount = 1; @@ -146,14 +146,14 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity // std::string itemName( itemInfo->name ); - ItemPtr pItem( new Item( catalogId ) ); + ItemPtr pItem = make_Item( catalogId ); 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 ( " + + pDb->execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " + std::to_string( m_pOwner->getId() ) + ", " + std::to_string( pItem->getUId() ) + ", " + std::to_string( pItem->getId() ) + ", " + From a2caccb2eea20c27a555739088f1faf72b32b183 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 30 Jun 2018 12:45:41 +1000 Subject: [PATCH 2/4] 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; From 37b1500a097bbaafa22fe8fb21c6ac23591f0afd Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 30 Jun 2018 12:49:34 +1000 Subject: [PATCH 3/4] inventory item creation cleanup --- .../sapphire_zone/Inventory/Inventory.cpp | 11 ++++----- src/servers/sapphire_zone/Inventory/Item.cpp | 24 ++++--------------- src/servers/sapphire_zone/Inventory/Item.h | 6 ++--- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/src/servers/sapphire_zone/Inventory/Inventory.cpp b/src/servers/sapphire_zone/Inventory/Inventory.cpp index c3eff997..d3416fc1 100644 --- a/src/servers/sapphire_zone/Inventory/Inventory.cpp +++ b/src/servers/sapphire_zone/Inventory/Inventory.cpp @@ -150,9 +150,7 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity ItemPtr pItem = make_Item( getNextUId(), catalogId, itemInfo->modelMain, - itemInfo->modelSub, - static_cast< ItemUICategory >( itemInfo->itemUICategory ), - false ); + itemInfo->modelSub ); 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 ) ); bool isHq = itemRes->getUInt( 3 ) == 1; - ItemPtr pItem( new Item( uId, + + ItemPtr pItem = make_Item( uId, itemRes->getUInt( 1 ), itemInfo->modelMain, itemInfo->modelSub, - static_cast< ItemUICategory >( itemInfo->itemUICategory ), - isHq ) ); + isHq ); + pItem->setStackSize( itemRes->getUInt( 2 ) ); return pItem; diff --git a/src/servers/sapphire_zone/Inventory/Item.cpp b/src/servers/sapphire_zone/Inventory/Item.cpp index b94b8d0b..73727509 100644 --- a/src/servers/sapphire_zone/Inventory/Item.cpp +++ b/src/servers/sapphire_zone/Inventory/Item.cpp @@ -1,47 +1,31 @@ #include #include +#include #include "Framework.h" #include "Item.h" extern Core::Framework g_fw; -Core::Item::Item() -{ - -} - -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 ) : +Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq ) : m_id( catalogId ), m_uId( uId ), - m_category( categoryId ), m_model1( model1 ), m_model2( model2 ), m_isHq( isHq ) { 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; m_weaponDmg = ( m_physicalDmg != 0 ) ? m_physicalDmg : m_magicalDmg; m_autoAttackDmg = static_cast< float >( m_weaponDmg * m_delayMs ) / 3000; + m_category = static_cast< Common::ItemUICategory >( itemInfo->itemUICategory ); m_itemLevel = itemInfo->levelItem; } -Core::Item::~Item() -{ - -} - float Core::Item::getAutoAttackDmg() const { return m_autoAttackDmg; diff --git a/src/servers/sapphire_zone/Inventory/Item.h b/src/servers/sapphire_zone/Inventory/Item.h index 97df4937..2801adf4 100644 --- a/src/servers/sapphire_zone/Inventory/Item.h +++ b/src/servers/sapphire_zone/Inventory/Item.h @@ -9,10 +9,8 @@ class Item { public: - Item(); - Item( uint32_t catalogId ); - Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId, bool isHq = false ); - ~Item(); + Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq = false ); + ~Item() = default; uint32_t getId() const; From 65c9647591ee7f2225cc922aba0a066b41a2abc6 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 30 Jun 2018 12:49:47 +1000 Subject: [PATCH 4/4] fix formatting --- .../quest/subquest/limsa/SubSea001.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/servers/Scripts/quest/subquest/limsa/SubSea001.cpp b/src/servers/Scripts/quest/subquest/limsa/SubSea001.cpp index 76ba8783..223d2bb7 100644 --- a/src/servers/Scripts/quest/subquest/limsa/SubSea001.cpp +++ b/src/servers/Scripts/quest/subquest/limsa/SubSea001.cpp @@ -79,16 +79,16 @@ public: { Scene00003( player ); }, - nullptr, eventId ); + nullptr, eventId ); } - else if(actor == Eobject1 ) + else if( actor == Eobject1 ) { player.eventActionStart( getId(), 0x0E, [&]( Entity::Player& player, uint32_t eventId, uint64_t additional ) { Scene00005( player ); }, - nullptr, eventId ); + nullptr, eventId ); } else if( actor == Eobject2 ) { @@ -97,7 +97,7 @@ public: { Scene00007( player ); }, - nullptr, eventId ); + nullptr, eventId ); } else if( actor == Eobject3 ) { @@ -106,7 +106,7 @@ public: { Scene00009( player ); }, - nullptr, eventId ); + nullptr, eventId ); } else if( actor == Eobject4 ) { @@ -124,13 +124,13 @@ public: { Scene00013( player ); }, - nullptr, eventId ); + nullptr, eventId ); } }; private: - void checkQuestcompletion( Entity::Player& player ) + void checkQuestCompletion( Entity::Player& player ) { auto currentCC = player.getQuestUI8BH( getId() ); @@ -172,7 +172,7 @@ private: player.playScene( getId(), 2, HIDE_HOTBAR, [&]( Entity::Player& player, const Event::SceneResult& result ) { - if( player.hasQuest( 65644 ) || player.hasQuest( 65645 ) ) + if( player.hasQuest( Quest0 ) || player.hasQuest( Quest1 ) ) { if( result.param2 == 1 ) { @@ -199,7 +199,7 @@ private: player.playScene( getId(), 4, HIDE_HOTBAR, [&]( Entity::Player& player, const Event::SceneResult& result ) { - checkQuestcompletion( player ); + checkQuestCompletion( player ); player.setQuestBitFlag8( getId(), 7, true ); } ); } @@ -218,7 +218,7 @@ private: player.playScene( getId(), 6, HIDE_HOTBAR, [&]( Entity::Player& player, const Event::SceneResult& result ) { - checkQuestcompletion( player ); + checkQuestCompletion( player ); player.setQuestBitFlag8( getId(), 6, true ); } ); } @@ -237,7 +237,7 @@ private: player.playScene( getId(), 8, HIDE_HOTBAR, [&]( Entity::Player& player, const Event::SceneResult& result ) { - checkQuestcompletion( player ); + checkQuestCompletion( player ); player.setQuestBitFlag8( getId(), 5, true ); } ); } @@ -256,7 +256,7 @@ private: player.playScene( getId(), 10, HIDE_HOTBAR, [&]( Entity::Player& player, const Event::SceneResult& result ) { - checkQuestcompletion( player ); + checkQuestCompletion( player ); player.setQuestBitFlag8( getId(), 4, true ); } ); } @@ -275,7 +275,7 @@ private: player.playScene( getId(), 12, HIDE_HOTBAR, [&]( Entity::Player& player, const Event::SceneResult& result ) { - checkQuestcompletion( player ); + checkQuestCompletion( player ); player.setQuestBitFlag8( getId(), 3, true ); } ); } @@ -294,7 +294,7 @@ private: player.playScene( getId(), 14, HIDE_HOTBAR, [&]( Entity::Player& player, const Event::SceneResult& result ) { - checkQuestcompletion( player ); + checkQuestCompletion( player ); player.setQuestBitFlag8( getId(), 2, true ); } ); }