FS#1233 - OverflowSafeInt template to replace int64 as Money

Attached to Project: OpenTTD
Opened by Noldo (Noldo) - Saturday, 15 September 2007, 18:56 GMT
Type Work in progress
Category Core
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


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.
This task depends upon

Closed by  Remko Bijker (Rubidium)
Saturday, 20 October 2007, 14:51 GMT
Reason for closing:  Implemented
Additional comments about closing:  In r11312 in vastly changed form though.