From 1e53333c9e323741b766993963dfe4a32b12683c Mon Sep 17 00:00:00 2001 From: collett Date: Mon, 11 May 2020 19:03:52 +0900 Subject: [PATCH] Fix buy back price. --- src/world/Actor/Player.h | 2 +- src/world/Actor/PlayerEvent.cpp | 2 +- src/world/Manager/ShopMgr.cpp | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index 35f602a0..6a26da75 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -37,7 +37,7 @@ namespace Sapphire::Entity { ItemPtr item; uint32_t amount; - uint32_t value; + uint32_t pricePerItem; }; /** Class representing the Player diff --git a/src/world/Actor/PlayerEvent.cpp b/src/world/Actor/PlayerEvent.cpp index 7c7c888b..12f8c626 100644 --- a/src/world/Actor/PlayerEvent.cpp +++ b/src/world/Actor/PlayerEvent.cpp @@ -183,7 +183,7 @@ void Sapphire::Entity::Player::playGilShop( uint32_t eventId, uint32_t flags, ui break; openGilShopPacket->data().params[ index++ ] = entry.item->getId(); openGilShopPacket->data().params[ index++ ] = entry.amount; - openGilShopPacket->data().params[ index++ ] = entry.value; + openGilShopPacket->data().params[ index++ ] = entry.pricePerItem; index += 2; openGilShopPacket->data().params[ index++ ] = eventId; index += 2; diff --git a/src/world/Manager/ShopMgr.cpp b/src/world/Manager/ShopMgr.cpp index 3e3ad10a..8ad8d2d5 100644 --- a/src/world/Manager/ShopMgr.cpp +++ b/src/world/Manager/ShopMgr.cpp @@ -92,15 +92,15 @@ bool Sapphire::World::Manager::ShopMgr::shopBuyBack( Sapphire::Entity::Player& p if( buyBackList.size() > index ) { auto& entry = buyBackList[ index ]; - if( player.getCurrency( Common::CurrencyType::Gil ) < entry.value ) - return false; - auto originalStack = entry.item->getStackSize(); + auto price = entry.pricePerItem * originalStack; + if( player.getCurrency( Common::CurrencyType::Gil ) < price ) + return false; if( !player.addItem( entry.item ) ) return false; - player.removeCurrency( Common::CurrencyType::Gil, entry.value ); + player.removeCurrency( Common::CurrencyType::Gil, price ); buyBackList.erase( buyBackList.begin() + index ); @@ -110,7 +110,7 @@ bool Sapphire::World::Manager::ShopMgr::shopBuyBack( Sapphire::Entity::Player& p packet->data().unknown2 = 3; packet->data().itemId = entry.item->getId(); packet->data().amount = originalStack; - packet->data().price = entry.value * originalStack; + packet->data().price = price; packet->data().unknown6 = 0; packet->data().unknown7 = 0; player.queuePacket( packet );