diff options
author | frosch <frosch@openttd.org> | 2016-12-20 12:35:36 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2016-12-20 12:35:36 +0000 |
commit | 4b8b9e1cb1ceb0aecbfcce607aef566cd233b2ed (patch) | |
tree | fd71f34b6e9b0e9cc89d4e88b17bee4bd959563f | |
parent | aa88218d8616ac81b0b57f1ffd54e69d936a03f1 (diff) | |
download | openttd-4b8b9e1cb1ceb0aecbfcce607aef566cd233b2ed.tar.xz |
(svn r27700) -Codechange: Simplify railtype date introduction. A check that is safe to run every day before the last railtype has been introduced, is also safe to run after the last railtype has been introduced.
-rw-r--r-- | src/engine.cpp | 46 |
1 files changed, 4 insertions, 42 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 56fab3e65..3e69c4ac8 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -48,11 +48,6 @@ EngineOverrideManager _engine_mngr; */ static Year _year_engine_aging_stops; -/** - * The railtypes that have been or never will be introduced, or - * an inverse bitmap of rail types that have to be introduced. */ -static uint16 _introduced_railtypes; - /** Number of engines of each vehicle type in original engine data */ const uint8 _engine_counts[4] = { lengthof(_orig_rail_vehicle_info), @@ -543,29 +538,6 @@ void SetupEngines() const Engine *e = new Engine(eid->type, eid->internal_id); assert(e->index == index); } - - _introduced_railtypes = 0; -} - -/** - * Check whether the railtypes should be introduced. - */ -static void CheckRailIntroduction() -{ - /* All railtypes have been introduced. */ - if (_introduced_railtypes == UINT16_MAX || Company::GetPoolSize() == 0) return; - - /* We need to find the railtypes that are known to all companies. */ - RailTypes rts = (RailTypes)UINT16_MAX; - - /* We are at, or past the introduction date of the rail. */ - Company *c; - FOR_ALL_COMPANIES(c) { - c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes, _date); - rts &= c->avail_railtypes; - } - - _introduced_railtypes |= rts; } void ShowEnginePreviewWindow(EngineID engine); @@ -711,19 +683,6 @@ void StartupEngines() c->avail_roadtypes = GetCompanyRoadtypes(c->index); } - /* Rail types that are invalid or never introduced are marked as - * being introduced upon start. That way we can easily check whether - * there is any date related introduction that is still going to - * happen somewhere in the future. */ - for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) { - const RailtypeInfo *rti = GetRailTypeInfo(rt); - if (rti->label != 0 && IsInsideMM(rti->introduction_date, 0, MAX_DAY)) continue; - - SetBit(_introduced_railtypes, rt); - } - - CheckRailIntroduction(); - /* Invalidate any open purchase lists */ InvalidateWindowClassesData(WC_BUILD_VEHICLE); } @@ -820,7 +779,10 @@ static bool IsVehicleTypeDisabled(VehicleType type, bool ai) /** Daily check to offer an exclusive engine preview to the companies. */ void EnginesDailyLoop() { - CheckRailIntroduction(); + Company *c; + FOR_ALL_COMPANIES(c) { + c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes, _date); + } if (_cur_year >= _year_engine_aging_stops) return; |