Skip to content

Commit

Permalink
xrGame: Fix logic error in TransferMoney
Browse files Browse the repository at this point in the history
Since both values are unsigned subtracting them from another will never
produce a negative value.

This bug was also present before the previous commit since the `money`
variable was implicitly converted to an `u32` resulting in the same bug.
  • Loading branch information
AMS21 committed May 14, 2024
1 parent 377199e commit a203c65
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/xrGame/script_game_object_inventory_owner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void CScriptGameObject::TransferMoney(u32 money, CScriptGameObject* pForWho)
CInventoryOwner* pOtherOwner = smart_cast<CInventoryOwner*>(&pForWho->object());
VERIFY(pOtherOwner);

if (pOurOwner->get_money() - money < 0)
if (pOurOwner->get_money() < money)
{
GEnv.ScriptEngine->script_log(LuaMessageType::Error, "Character does not have enought money");
return;
Expand Down

0 comments on commit a203c65

Please sign in to comment.