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

OverflowSafeInt template to replace int64 as Money #1233

Closed
DorpsGek opened this issue Sep 15, 2007 · 1 comment
Closed

OverflowSafeInt template to replace int64 as Money #1233

DorpsGek opened this issue Sep 15, 2007 · 1 comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

Noldo opened the ticket and wrote:

I wanted to make Money into class and Rubidium said I should do it this way.

OverflowSafeInt<> is a class template that defines some operators
naturally related to int. * and + with overflowprotection.

There are some places in the code where operators aren't enough to make it compile.
To fix these there is .tovaluetype() function which returns the internal value int the type is is stored in.
Also I added SetDParam(uint n,Money v) that calls the original to remove the need to use .tovaluetype() in every call.

ClampToI32 caused the most of the .tovaluetype() calls so maybe something could be done to make that neater.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/1233
@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Implemented

In r11312 in vastly changed form though.


This comment was imported from FlySpray: https://bugs.openttd.org/task/1233

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant