From 1f5a8903248bea1c1e8fd3879528ef3d14b986a5 Mon Sep 17 00:00:00 2001 From: Mordred Admin Date: Wed, 25 Jul 2018 09:48:54 +0200 Subject: [PATCH] Finished removing old inventory class and moving stuff into player --- src/servers/sapphire_zone/Actor/Player.h | 10 +++------- src/servers/sapphire_zone/Actor/PlayerInventory.cpp | 13 +++---------- .../Network/Handlers/GMCommandHandlers.cpp | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/servers/sapphire_zone/Actor/Player.h b/src/servers/sapphire_zone/Actor/Player.h index 3feb94d5..cce73edb 100644 --- a/src/servers/sapphire_zone/Actor/Player.h +++ b/src/servers/sapphire_zone/Actor/Player.h @@ -248,13 +248,9 @@ public: /*! add amount to the currency of type */ void addCurrency( Common::CurrencyType type, uint32_t amount ); /*! remove amount from the currency of type */ - void removeCurrency( uint8_t type, uint32_t amount ); + void removeCurrency( Common::CurrencyType type, uint32_t amount ); /*! return the current amount of crystals of type */ uint32_t getCrystal( uint8_t type ) const; - /*! add amount to the crystals of type */ - void addCrystal( uint8_t type, uint32_t amount ); - /*! remove amount from the crystals of type */ - void removeCrystal( uint8_t type, uint32_t amount ); // Class / Job / Exp ////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -638,9 +634,9 @@ public: /*! return the crystal amount of currency of type */ uint32_t getCrystal( Common::CrystalType type ); /*! add amount to the crystal of type */ - bool addCrystal( Common::CrystalType type, uint32_t amount ); + void addCrystal( Common::CrystalType type, uint32_t amount ); /*! remove amount from the crystals of type */ - bool removeCrystal( Common::CrystalType type, uint32_t amount ); + void removeCrystal( Common::CrystalType type, uint32_t amount ); bool isObtainable( uint32_t catalogId, uint8_t quantity ); void updateCrystalDb(); diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index fce1dbcd..40a853df 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -249,7 +249,7 @@ void Core::Entity::Player::removeCurrency( Common::CurrencyType type, uint32_t a auto currItem = m_inventoryMap[Currency]->getItem( static_cast< uint8_t >( type ) - 1 ); if( !currItem ) - return false; + return; uint32_t currentAmount = currItem->getStackSize(); if( amount > currentAmount ) @@ -316,7 +316,7 @@ void Core::Entity::Player::removeCrystal( Common::CrystalType type, uint32_t amo auto invUpPacket = makeZonePacket< FFXIVIpcUpdateInventorySlot >( getId() ); invUpPacket->data().containerId = Common::InventoryType::Crystal; invUpPacket->data().catalogId = static_cast< uint8_t >( type ) + 1; - invUpPacket->data().quantity = getCrystal( static_cast< Common::CrystalType >( type ) ); + invUpPacket->data().quantity = getCrystal( type ); invUpPacket->data().slot = static_cast< uint8_t >( type ) - 1; queuePacket( invUpPacket ); @@ -333,14 +333,6 @@ bool Core::Entity::Player::tryAddItem( uint16_t catalogId, uint32_t quantity ) return false; } -/*bool Core::Entity::Player::addItem( uint16_t containerId, uint16_t catalogId, uint32_t quantity ) -{ - if( addItem( containerId, -1, catalogId, quantity ) != -1 ) - return true; - - return false; -}*/ - void Core::Entity::Player::sendInventory() { InventoryMap::iterator it; @@ -863,6 +855,7 @@ uint8_t Core::Entity::Player::getFreeSlotsInBags() uint8_t slots = 0; for( uint8_t container : { 0, 1, 2, 3 } ) { + // TODO: this feels hackish at best slots += 34 - m_inventoryMap[container]->getEntryCount(); } return slots; diff --git a/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp b/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp index 27950719..7a05e469 100644 --- a/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/GMCommandHandlers.cpp @@ -343,7 +343,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R } else { - targetPlayer->removeCurrency( 1, param1 ); + targetPlayer->removeCurrency( CurrencyType::Gil, param1 ); player.sendNotice( "Removed " + std::to_string( param1 ) + " Gil from " + targetPlayer->getName() + "(" + std::to_string( gil ) + " before)" );