Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor script_game_object money functions to use u32 #1479

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/xrGame/script_game_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ class CScriptGameObject
void DropItemAndTeleport(CScriptGameObject* pItem, Fvector position);
void ForEachInventoryItems(const luabind::functor<void>& functor);
void TransferItem(CScriptGameObject* pItem, CScriptGameObject* pForWho);
void TransferMoney(int money, CScriptGameObject* pForWho);
void GiveMoney(int money);
void TransferMoney(u32 money, CScriptGameObject* pForWho);
void GiveMoney(u32 money);
u32 Money();
void MakeItemActive(CScriptGameObject* pItem);

Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/script_game_object_inventory_owner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ u32 CScriptGameObject::Money()
return pOurOwner->get_money();
}

void CScriptGameObject::TransferMoney(int money, CScriptGameObject* pForWho)
void CScriptGameObject::TransferMoney(u32 money, CScriptGameObject* pForWho)
{
if (!pForWho)
{
Expand All @@ -486,17 +486,17 @@ void CScriptGameObject::TransferMoney(int 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");
GEnv.ScriptEngine->script_log(LuaMessageType::Error, "Character does not have enough money");
return;
}

pOurOwner->set_money(pOurOwner->get_money() - money, true);
pOtherOwner->set_money(pOtherOwner->get_money() + money, true);
}

void CScriptGameObject::GiveMoney(int money)
void CScriptGameObject::GiveMoney(u32 money)
{
CInventoryOwner* pOurOwner = smart_cast<CInventoryOwner*>(&object());
VERIFY(pOurOwner);
Expand Down
Loading