Skip to content

Commit d39401a

Browse files
authored
Fixed addition of money to player on selling item to one npc (#627)
It solves a small problem added, by mistake, in the pr of the tier, which is to sell a stackable item and receive only the money of a one item. Example: sell 100 mushrooms and receive money for only 1 item. Fixes #577
1 parent ecfaa93 commit d39401a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/creatures/npcs/npc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,13 @@ void Npc::onPlayerSellItem(Player* player, uint16_t itemId,
340340
}
341341
}
342342

343-
uint64_t totalCost = 0;
344343
// We will only add the money if any item has been removed from the player, to ensure that there is no possibility of cloning money
345344
if (removedItems == 0) {
346345
SPDLOG_ERROR("[Npc::onPlayerSellItem] - Player {} have a problem for remove items from id {} on shop for npc {}", player->getName(), itemId, getName());
347346
return;
348347
}
349348

350-
totalCost = static_cast<uint64_t>(sellPrice * removedItems);
349+
auto totalCost = static_cast<uint64_t>(sellPrice * amount);
351350
g_game().addMoney(player, totalCost);
352351

353352
// npc:onSellItem(player, itemId, subType, amount, ignore, itemName, totalCost)

0 commit comments

Comments
 (0)