From b43893d560d3a07e8ff85eaff740dfd6690d1761 Mon Sep 17 00:00:00 2001 From: collett Date: Wed, 17 Jun 2020 02:19:34 +0900 Subject: [PATCH 1/3] prevent empty quest reward slot (id == 0) being added as items --- src/world/Actor/PlayerQuest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/world/Actor/PlayerQuest.cpp b/src/world/Actor/PlayerQuest.cpp index fc1ff9ac..6eaafc91 100644 --- a/src/world/Actor/PlayerQuest.cpp +++ b/src/world/Actor/PlayerQuest.cpp @@ -1065,7 +1065,11 @@ bool Sapphire::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t opti { for( uint32_t i = 0; i < rewardItemCount; i++ ) { - addItem( questInfo->itemReward0.at( i ), questInfo->itemCountReward0.at( i ), false, false, true, true ); + auto itemId = questInfo->itemReward0.at( i ); + if( itemId > 0 ) + { + addItem( itemId, questInfo->itemCountReward0.at( i ), false, false, true, true ); + } } } @@ -1074,7 +1078,7 @@ bool Sapphire::Entity::Player::giveQuestRewards( uint32_t questId, uint32_t opti for( uint32_t i = 0; i < optionalItemCount; i++ ) { auto itemId = questInfo->itemReward1.at( i ); - if( itemId == optionalChoice ) + if( itemId > 0 && itemId == optionalChoice ) { addItem( itemId, questInfo->itemCountReward1.at( i ), false, false, true, true ); break; From 031d354bbd492d2ec646bb0cf54b4f66e1a1093c Mon Sep 17 00:00:00 2001 From: collett Date: Wed, 17 Jun 2020 02:28:39 +0900 Subject: [PATCH 2/3] add id check in addItem as well --- src/world/Actor/PlayerInventory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index fbff6d66..ccb4847b 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -694,6 +694,8 @@ Sapphire::ItemPtr Sapphire::Entity::Player::addItem( ItemPtr itemToAdd, bool sil Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_t quantity, bool isHq, bool silent, bool canMerge, bool sendLootMessage ) { + if( catalogId == 0 ) + return false; auto item = createItem( catalogId, quantity ); item->setHq( isHq ); return addItem( item, silent, canMerge, sendLootMessage ); From 00f0adf620a5fa84ee25af0db69dcd8ad5575e24 Mon Sep 17 00:00:00 2001 From: collett Date: Wed, 17 Jun 2020 02:30:44 +0900 Subject: [PATCH 3/3] typo --- src/world/Actor/PlayerInventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index ccb4847b..9d5c3656 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -695,7 +695,7 @@ Sapphire::ItemPtr Sapphire::Entity::Player::addItem( ItemPtr itemToAdd, bool sil Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_t quantity, bool isHq, bool silent, bool canMerge, bool sendLootMessage ) { if( catalogId == 0 ) - return false; + return nullptr; auto item = createItem( catalogId, quantity ); item->setHq( isHq ); return addItem( item, silent, canMerge, sendLootMessage );