Skip to content

Commit

Permalink
Fixed addition of money to player on selling item to one npc (#627)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dudantas authored Nov 13, 2022
1 parent ecfaa93 commit d39401a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/creatures/npcs/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,13 @@ void Npc::onPlayerSellItem(Player* player, uint16_t itemId,
}
}

uint64_t totalCost = 0;
// 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
if (removedItems == 0) {
SPDLOG_ERROR("[Npc::onPlayerSellItem] - Player {} have a problem for remove items from id {} on shop for npc {}", player->getName(), itemId, getName());
return;
}

totalCost = static_cast<uint64_t>(sellPrice * removedItems);
auto totalCost = static_cast<uint64_t>(sellPrice * amount);
g_game().addMoney(player, totalCost);

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

0 comments on commit d39401a

Please sign in to comment.