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

Conversation

AMS21
Copy link
Contributor

@AMS21 AMS21 commented Oct 26, 2023

Since CInventoryOwner already stored money as a u32 it only makes since for us to also treat it like one.

Also fixed a logic bug which would have allowed the object to transfer money which it didn't have.

Since both values are unsigned subtracting them from another will never
produce a negative value.

This bug was also present before changing the function signature since the money
variable was implicitly converted to an u32 resulting in the same problem.

@Xottab-DUTY
Copy link
Member

So, does that fix #1173 by the way?

@Xottab-DUTY Xottab-DUTY added Bug The issue in the run-time. Code Quality good first issue Good start for beginners that want to contribute. labels Oct 26, 2023
@letnull19A
Copy link

wow

@AMS21
Copy link
Contributor Author

AMS21 commented Oct 26, 2023

So, does that fix #1173 by the way?

Well not really. You don't get negative money. The money transfer just does not happen but the dialog still works and you get the information just without losing money.

It does produce a LUA error now so the check definitely works:

! [LUA]  Character does not have enought money
stack traceback:
        ...K.E.R. - Call of Pripyat\gamedata\scripts\dialogs.script:496: in function 'relocate_money_from_actor'
        ... - Call of Pripyat\gamedata\scripts\dialogs_zaton.script:134: in function <... - Call of Pripyat\gamedata\scripts\dialogs_zaton.script:133>

@AMS21 AMS21 force-pushed the refactor/script_game_object_money branch from b73f6b6 to d8f3f00 Compare November 17, 2023 14:12
@AMS21 AMS21 force-pushed the refactor/script_game_object_money branch from d8f3f00 to 5d659b7 Compare November 25, 2023 13:03
@AMS21
Copy link
Contributor Author

AMS21 commented Nov 25, 2023

Any objections to getting this merged? :)

@AMS21 AMS21 force-pushed the refactor/script_game_object_money branch from 5d659b7 to 7caa28f Compare December 4, 2023 11:00
@Xottab-DUTY Xottab-DUTY force-pushed the dev branch 2 times, most recently from 143d1ca to 118d39d Compare December 16, 2023 10:39
@Xottab-DUTY Xottab-DUTY force-pushed the dev branch 2 times, most recently from 5b2ec76 to 6fffce9 Compare May 4, 2024 03:27
AMS21 added 3 commits May 14, 2024 18:20
Since `CInventoryOwner` also uses `u32` for its `money` member
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.
@AMS21 AMS21 force-pushed the refactor/script_game_object_money branch from 7caa28f to 9238c63 Compare May 14, 2024 16:21
@Xottab-DUTY Xottab-DUTY force-pushed the dev branch 2 times, most recently from e89fcc8 to f6fd5cc Compare October 24, 2024 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug The issue in the run-time. Code Quality good first issue Good start for beginners that want to contribute.
Projects
Status: To do
Development

Successfully merging this pull request may close these issues.

3 participants