Split date types into calendar and economy dates

See: 735abfe1
This commit is contained in:
Jonathan G Rennison
2024-02-13 21:34:09 +00:00
parent fad5ee56e7
commit 7ce06e22b8
141 changed files with 1325 additions and 1082 deletions

View File

@@ -57,7 +57,7 @@ public:
uint demand; ///< Acceptance at the station.
StationID station; ///< Station ID.
TileIndex xy; ///< Location of the station referred to by the node.
Date last_update; ///< When the supply was last updated.
EconTime::Date last_update; ///< When the supply was last updated.
void Init(TileIndex xy = INVALID_TILE, StationID st = INVALID_STATION, uint demand = 0);
};
@@ -71,18 +71,18 @@ public:
uint capacity; ///< Capacity of the link.
uint usage; ///< Usage of the link.
uint64_t travel_time_sum; ///< Sum of the travel times of the link, in ticks.
Date last_unrestricted_update; ///< When the unrestricted part of the link was last updated.
Date last_restricted_update; ///< When the restricted part of the link was last updated.
Date last_aircraft_update; ///< When aircraft capacity of the link was last updated.
EconTime::Date last_unrestricted_update; ///< When the unrestricted part of the link was last updated.
EconTime::Date last_restricted_update; ///< When the restricted part of the link was last updated.
EconTime::Date last_aircraft_update; ///< When aircraft capacity of the link was last updated.
void Init()
{
this->capacity = 0;
this->usage = 0;
this->travel_time_sum = 0;
this->last_unrestricted_update = INVALID_DATE;
this->last_restricted_update = INVALID_DATE;
this->last_aircraft_update = INVALID_DATE;
this->last_unrestricted_update = EconTime::INVALID_DATE;
this->last_restricted_update = EconTime::INVALID_DATE;
this->last_aircraft_update = EconTime::INVALID_DATE;
}
BaseEdge() { this->Init(); }
@@ -130,25 +130,25 @@ public:
* Get the date of the last update to the edge's unrestricted capacity.
* @return Last update.
*/
Date LastUnrestrictedUpdate() const { return this->edge->last_unrestricted_update; }
EconTime::Date LastUnrestrictedUpdate() const { return this->edge->last_unrestricted_update; }
/**
* Get the date of the last update to the edge's restricted capacity.
* @return Last update.
*/
Date LastRestrictedUpdate() const { return this->edge->last_restricted_update; }
EconTime::Date LastRestrictedUpdate() const { return this->edge->last_restricted_update; }
/**
* Get the date of the last update to the edge's aircraft capacity.
* @return Last update.
*/
Date LastAircraftUpdate() const { return this->edge->last_aircraft_update; }
EconTime::Date LastAircraftUpdate() const { return this->edge->last_aircraft_update; }
/**
* Get the date of the last update to any part of the edge's capacity.
* @return Last update.
*/
Date LastUpdate() const { return std::max(this->edge->last_unrestricted_update, this->edge->last_restricted_update); }
EconTime::Date LastUpdate() const { return std::max(this->edge->last_unrestricted_update, this->edge->last_restricted_update); }
};
/**
@@ -192,7 +192,7 @@ public:
* Get node's last update.
* @return Last update.
*/
Date LastUpdate() const { return this->node.last_update; }
EconTime::Date LastUpdate() const { return this->node.last_update; }
/**
* Get the location of the station associated with the node.
@@ -219,9 +219,9 @@ public:
*/
Edge(BaseEdge &edge) : EdgeWrapper<BaseEdge>(edge) {}
void Update(uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode);
void Restrict() { this->edge->last_unrestricted_update = INVALID_DATE; }
void Release() { this->edge->last_restricted_update = INVALID_DATE; }
void ClearAircraft() { this->edge->last_aircraft_update = INVALID_DATE; }
void Restrict() { this->edge->last_unrestricted_update = EconTime::INVALID_DATE; }
void Release() { this->edge->last_restricted_update = EconTime::INVALID_DATE; }
void ClearAircraft() { this->edge->last_aircraft_update = EconTime::INVALID_DATE; }
};
/**
@@ -261,7 +261,7 @@ public:
void UpdateSupply(uint supply)
{
this->node.supply += supply;
this->node.last_update = _date;
this->node.last_update = EconTime::CurDate();
}
/**