Strong typedef: Use strong typedefs for date, date tick, minutes types

Add delta types
Adjust/add type conversion functions
Add various utility methods on types
Remove the various minute macros
Fix some minute conversion inconsistencies
This commit is contained in:
Jonathan G Rennison
2023-12-19 01:03:18 +00:00
parent 1e7b56e13a
commit 03e0ec8276
80 changed files with 538 additions and 431 deletions

View File

@@ -262,7 +262,7 @@ public:
* settings have to be brutally const-casted in order to populate them.
*/
LinkGraphJob() : settings(_settings_game.linkgraph),
join_date_ticks(INVALID_DATE), start_date_ticks(INVALID_DATE), job_completed(false), job_aborted(false) {}
join_date_ticks(INVALID_DATE_TICKS), start_date_ticks(INVALID_DATE_TICKS), job_completed(false), job_aborted(false) {}
LinkGraphJob(const LinkGraph &orig, uint duration_multiplier);
~LinkGraphJob();
@@ -297,7 +297,7 @@ public:
* @param tick_offset Optional number of ticks to add to the current date
* @return True if job should be finished by now, false if not.
*/
inline bool IsScheduledToBeJoined(int tick_offset = 0) const { return this->join_date_ticks <= (_date * DAY_TICKS) + _date_fract + tick_offset; }
inline bool IsScheduledToBeJoined(int tick_offset = 0) const { return this->join_date_ticks <= NowDateTicks() + tick_offset; }
/**
* Get the date when the job should be finished.
@@ -315,10 +315,10 @@ public:
* Change the start and join dates on date cheating.
* @param interval Number of days to add.
*/
inline void ShiftJoinDate(int interval)
inline void ShiftJoinDate(DateDelta interval)
{
this->join_date_ticks += interval * DAY_TICKS;
this->start_date_ticks += interval * DAY_TICKS;
this->join_date_ticks += DateDeltaToDateTicksDelta(interval);
this->start_date_ticks += DateDeltaToDateTicksDelta(interval);
}
/**