Mercurial > hg > openttd
changeset 4297:e61a911371a6 draft
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
-Cleanup: use _cur_year instead of _date for some (year based) comparisons
-Cleanup: remove a magic number in favour of another (less) magic number
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 17 Aug 2006 20:22:35 +0000 |
parents | d73021abd147 |
children | cf32d743128e |
files | currency.c currency.h depot.h engine.c industry_cmd.c newgrf.c openttd.h yapf/yapf_costcache.hpp |
diffstat | 8 files changed, 13 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/currency.c +++ b/currency.c @@ -79,7 +79,7 @@ uint i; for (i = 0; i != lengthof(_currency_specs); i++) { - uint16 to_euro = _currency_specs[i].to_euro; + Year to_euro = _currency_specs[i].to_euro; if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= to_euro) continue; if (to_euro == CF_ISEURO && _cur_year < 2000) continue;
--- a/currency.h +++ b/currency.h @@ -11,7 +11,7 @@ typedef struct { uint16 rate; char separator; - uint16 to_euro; + Year to_euro; char prefix[16]; char suffix[16]; } CurrencySpec;
--- a/depot.h +++ b/depot.h @@ -53,7 +53,7 @@ * within the given bounds. @see MIN_SERVINT_PERCENT ,etc. * @param index proposed service interval */ -static inline uint16 GetServiceIntervalClamped(uint index) +static inline Date GetServiceIntervalClamped(uint index) { return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS); }
--- a/engine.c +++ b/engine.c @@ -88,11 +88,10 @@ static void AdjustAvailAircraft(void) { - uint16 date = _date; byte avail = 0; - if (date >= 12784) avail |= 2; // big airport - if (date < 14610 || _patches.always_small_airport) avail |= 1; // small airport - if (date >= 15706) avail |= 4; // enable heliport + if (_cur_year >= 1955) avail |= 2; // big airport + if (_cur_year < 1960 || _patches.always_small_airport) avail |= 1; // small airport + if (_cur_year >= 1963) avail |= 4; // enable heliport if (avail != _avail_aircraft) { _avail_aircraft = avail; @@ -151,7 +150,7 @@ // base intro date is before 1922 then the random number of days is not // added. r = Random(); - e->intro_date = ei->base_intro <= 729 ? ei->base_intro : GB(r, 0, 9) + ei->base_intro; + e->intro_date = ei->base_intro <= ConvertYMDToDate(1922, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro; if (e->intro_date <= _date) { e->age = (_date - e->intro_date) >> 5; e->player_avail = (byte)-1;
--- a/industry_cmd.c +++ b/industry_cmd.c @@ -1647,8 +1647,8 @@ type = _new_industry_rand[_opt.landscape][GB(r, 16, 5)]; - if (type == IT_OIL_WELL && _date > 10958) return; - if (type == IT_OIL_RIG && _date < 14610) return; + if (type == IT_OIL_WELL && _cur_year > 1950) return; + if (type == IT_OIL_RIG && _cur_year < 1960) return; j = 2000; for (;;) {
--- a/newgrf.c +++ b/newgrf.c @@ -1060,10 +1060,6 @@ FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf); break; - case 0x0F: /* Long year -- must be set after property 8 */ - FOR_EACH_OBJECT _bridge[brid + i].avail_year = grf_load_word(&buf); - break; - default: ret = true; }
--- a/openttd.h +++ b/openttd.h @@ -267,7 +267,7 @@ typedef struct TileDesc { StringID str; byte owner; - uint16 build_date; + Date build_date; uint32 dparam[2]; } TileDesc;
--- a/yapf/yapf_costcache.hpp +++ b/yapf/yapf_costcache.hpp @@ -148,11 +148,11 @@ FORCEINLINE static Cache& stGetGlobalCache() { static int last_rail_change_counter = 0; - static uint32 last_day = 0; + static Date last_date = 0; // some statistics - if (last_day != _date) { - last_day = _date; + if (last_date != _date) { + last_date = _date; DEBUG(yapf, 1)("pf time today:%5d ms\n", _total_pf_time_us / 1000); _total_pf_time_us = 0; }