summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-08-17 20:22:35 +0000
committerrubidium <rubidium@openttd.org>2006-08-17 20:22:35 +0000
commit7cfd3eb61834ee3d4c5037b0a3ffc71089b9564a (patch)
tree0e09fbecef792005a3c390649f7cf774c8c43325
parenta178d2600b02a2c3091d1e185f887d371f4a1feb (diff)
downloadopenttd-7cfd3eb61834ee3d4c5037b0a3ffc71089b9564a.tar.xz
(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
-rw-r--r--currency.c2
-rw-r--r--currency.h2
-rw-r--r--depot.h2
-rw-r--r--engine.c9
-rw-r--r--industry_cmd.c4
-rw-r--r--newgrf.c4
-rw-r--r--openttd.h2
-rw-r--r--yapf/yapf_costcache.hpp6
8 files changed, 13 insertions, 18 deletions
diff --git a/currency.c b/currency.c
index 2954a9973..997303245 100644
--- a/currency.c
+++ b/currency.c
@@ -79,7 +79,7 @@ uint GetMaskOfAllowedCurrencies(void)
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;
diff --git a/currency.h b/currency.h
index a94f85eb2..d1de97e41 100644
--- a/currency.h
+++ b/currency.h
@@ -11,7 +11,7 @@ enum {
typedef struct {
uint16 rate;
char separator;
- uint16 to_euro;
+ Year to_euro;
char prefix[16];
char suffix[16];
} CurrencySpec;
diff --git a/depot.h b/depot.h
index 4947cfc9e..11065e0bf 100644
--- a/depot.h
+++ b/depot.h
@@ -53,7 +53,7 @@ static inline bool IsDepotIndex(uint index)
* 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);
}
diff --git a/engine.c b/engine.c
index 1f96f610f..43e515e7d 100644
--- a/engine.c
+++ b/engine.c
@@ -88,11 +88,10 @@ static void SetupEngineNames(void)
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 @@ void StartupEngines(void)
// 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;
diff --git a/industry_cmd.c b/industry_cmd.c
index 6fce8dc8f..a678ee703 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -1647,8 +1647,8 @@ static void MaybeNewIndustry(uint32 r)
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 (;;) {
diff --git a/newgrf.c b/newgrf.c
index a967849b0..5d557f216 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -1060,10 +1060,6 @@ static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int
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;
}
diff --git a/openttd.h b/openttd.h
index 9e9d26861..21650b922 100644
--- a/openttd.h
+++ b/openttd.h
@@ -267,7 +267,7 @@ typedef uint AcceptedCargo[NUM_CARGO];
typedef struct TileDesc {
StringID str;
byte owner;
- uint16 build_date;
+ Date build_date;
uint32 dparam[2];
} TileDesc;
diff --git a/yapf/yapf_costcache.hpp b/yapf/yapf_costcache.hpp
index ee4029e0c..5ad6f8cdc 100644
--- a/yapf/yapf_costcache.hpp
+++ b/yapf/yapf_costcache.hpp
@@ -148,11 +148,11 @@ protected:
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;
}