User defined literals for Money32 #14093
Labels
Comments
|
I'm interested in taking on this issue, but one quick question: Nevermind, figured it out myself, it's because money32 is stored in multiples of 0.10. |
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 1, 2021
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 1, 2021
There should be a better way to do this, that would probably require the casting of the number to a long double, then checking it for overflow.
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 1, 2021
One underscore for UDL, not two
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 1, 2021
expression converts runtime values to money, replaces the function of the MONEY macro. Fixed runtime uses of MONEY that were removed in the initial find and replace
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 1, 2021
…h UDL, helper func
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 1, 2021
Accepting suggestion, will do a proper search and replace later. Co-authored-by: Michael Steenbeek <m.o.steenbeek@gmail.com>
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 1, 2021
Co-authored-by: Michael Steenbeek <m.o.steenbeek@gmail.com>
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 1, 2021
Is the use of auto correct, or should it be in money32? I am fairly new to C++, coming from C.
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 3, 2021
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 3, 2021
There should be a better way to do this, that would probably require the casting of the number to a long double, then checking it for overflow.
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 3, 2021
One underscore for UDL, not two
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 3, 2021
expression converts runtime values to money, replaces the function of the MONEY macro. Fixed runtime uses of MONEY that were removed in the initial find and replace
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 3, 2021
…h UDL, helper func
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 3, 2021
Accepting suggestion, will do a proper search and replace later. Co-authored-by: Michael Steenbeek <m.o.steenbeek@gmail.com>
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 3, 2021
Is the use of auto correct, or should it be in money32? I am fairly new to C++, coming from C.
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 3, 2021
Co-authored-by: Michael Steenbeek <m.o.steenbeek@gmail.com>
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 6, 2021
Replace old fraction and whole with single int, with overflow check Co-Authored-By: Duncan <duncan.p.frost@gmail.com>
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 6, 2021
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 6, 2021
Instead of storing whole and decimal separately in MONEY function, multiply doubles by 10 and cast to int32_t function is not needed at all for ints
geoff-B
added a commit
to geoff-B/OpenRCT2
that referenced
this issue
Mar 6, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We currently use a macro for writing down a money amount as a literal. We should move to a more modern C++ representation with a user defined literal like the below:
Go through the codebase and replace all MONEY macro uses with the equivalent version. You might need to also make a helper function that can convert from a runtime value to money as the macro is currently used in one or two places.
The text was updated successfully, but these errors were encountered: