mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r5975) -Cleanup: use ORIGINAL_BASE_YEAR & ORIGINAL_MAX_YEAR where the functions really depend on the original date format.
-Cleanup: use DAYS_TILL_ORIGINAL_BASE_YEAR where the date variables are in the old date format and conversions are needed. -Cleanup: replace one (forgotten) instance of uint16 with Date.
This commit is contained in:
parent
5fb6c9e1cc
commit
e159ada7a2
@ -1457,7 +1457,7 @@ static void AiWantAircraftRoute(Player *p)
|
||||
{
|
||||
uint16 r = (uint16)Random();
|
||||
|
||||
if (r >= 0x2AAA || _date < 0x3912) {
|
||||
if (r >= 0x2AAA || _date < 0x3912 + DAYS_TILL_ORIGINAL_BASE_YEAR) {
|
||||
AiWantPassengerAircraftRoute(p);
|
||||
} else {
|
||||
AiWantOilRigAircraftRoute(p);
|
||||
|
21
date.h
21
date.h
@ -8,7 +8,28 @@
|
||||
*/
|
||||
#define DAY_TICKS 74
|
||||
|
||||
/*
|
||||
* ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
|
||||
* primarily used for loading newgrf and savegame data and returning some
|
||||
* newgrf (callback) functions that were in the original (TTD) inherited
|
||||
* format, where '_date == 0' meant that it was 1920-01-01.
|
||||
*/
|
||||
|
||||
/** The minimum starting year/base year of the original TTD */
|
||||
#define ORIGINAL_BASE_YEAR 1920
|
||||
/** The maximum year of the original TTD */
|
||||
#define ORIGINAL_MAX_YEAR 2090
|
||||
|
||||
/**
|
||||
* The offset in days from the '_date == 0' till
|
||||
* 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)'
|
||||
*/
|
||||
#define DAYS_TILL_ORIGINAL_BASE_YEAR 0
|
||||
|
||||
/* Temporary value to make transition to full past 2090 easier/more clear */
|
||||
#define BASE_YEAR 1920
|
||||
|
||||
/* The absolute minimum & maximum years in OTTD */
|
||||
#define MIN_YEAR 1920
|
||||
#define MAX_YEAR 2090
|
||||
|
||||
|
4
engine.c
4
engine.c
@ -6,7 +6,6 @@
|
||||
#include "functions.h"
|
||||
#include "table/strings.h"
|
||||
#include "engine.h"
|
||||
#include "table/engines.h"
|
||||
#include "gfx.h"
|
||||
#include "player.h"
|
||||
#include "command.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "train.h"
|
||||
#include "newgrf_cargo.h"
|
||||
#include "date.h"
|
||||
#include "table/engines.h"
|
||||
|
||||
EngineInfo _engine_info[TOTAL_NUM_ENGINES];
|
||||
RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES];
|
||||
@ -140,7 +140,7 @@ void StartupEngines(void)
|
||||
Engine *e;
|
||||
const EngineInfo *ei;
|
||||
/* Aging of vehicles stops, so account for that when starting late */
|
||||
const uint16 aging_date = min(_date, ConvertYMDToDate(YEAR_ENGINE_AGING_STOPS, 0, 1));
|
||||
const Date aging_date = min(_date, ConvertYMDToDate(YEAR_ENGINE_AGING_STOPS, 0, 1));
|
||||
|
||||
SetupEngineNames();
|
||||
|
||||
|
4
newgrf.c
4
newgrf.c
@ -1007,7 +1007,7 @@ static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int
|
||||
|
||||
switch (prop) {
|
||||
case 0x08: /* Year of availability */
|
||||
FOR_EACH_OBJECT _bridge[brid + i].avail_year = BASE_YEAR + grf_load_byte(&buf);
|
||||
FOR_EACH_OBJECT _bridge[brid + i].avail_year = ORIGINAL_BASE_YEAR + grf_load_byte(&buf);
|
||||
break;
|
||||
|
||||
case 0x09: /* Minimum length */
|
||||
@ -1177,7 +1177,7 @@ static void FeatureChangeInfo(byte *buf, int len)
|
||||
/* Common properties for vehicles */
|
||||
switch (prop) {
|
||||
case 0x00: /* Introduction date */
|
||||
FOR_EACH_OBJECT ei[i].base_intro = grf_load_word(&buf);
|
||||
FOR_EACH_OBJECT ei[i].base_intro = grf_load_word(&buf) + DAYS_TILL_ORIGINAL_BASE_YEAR;
|
||||
break;
|
||||
|
||||
case 0x02: /* Decay speed */
|
||||
|
@ -553,7 +553,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
case 0x43: return _current_player; /* Owner information */
|
||||
case 0x46: return 0; /* Motion counter */
|
||||
case 0x48: return GetVehicleTypeInfo(object->u.vehicle.self_type); /* Vehicle Type Info */
|
||||
case 0xC4: return clamp(_cur_year, BASE_YEAR, MAX_YEAR) - BASE_YEAR; /* Build year */
|
||||
case 0xC4: return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; /* Build year */
|
||||
case 0xDA: return INVALID_VEHICLE; /* Next vehicle */
|
||||
case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); /* Read GRF parameter */
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ static inline uint32 GetVariable(const ResolverObject *object, byte variable, by
|
||||
/* Return common variables */
|
||||
switch (variable) {
|
||||
case 0x00: return _date;
|
||||
case 0x01: return clamp(_cur_year, BASE_YEAR, MAX_YEAR) - BASE_YEAR;
|
||||
case 0x01: return clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
|
||||
case 0x02: return _cur_month;
|
||||
case 0x03: return _opt.landscape;
|
||||
case 0x09: return _date_fract;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* @param e Rail Type of the vehicle
|
||||
* @param f Bitmask of the climates
|
||||
*/
|
||||
#define MK(a, b, c, d, e, f) { a, b, c, d, e, f, 0, 8, 0, 0 }
|
||||
#define MK(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b, c, d, e, f, 0, 8, 0, 0 }
|
||||
/** Writes the properties of a train carriage into the EngineInfo struct.
|
||||
* @see EngineInfo
|
||||
* @param a Introduction date
|
||||
@ -23,7 +23,7 @@
|
||||
* @param f Bitmask of the climates
|
||||
* @note the 0x80 in parameter b sets the "is carriage bit"
|
||||
*/
|
||||
#define MW(a, b, c, d, e, f) { a, b | 0x80, c, d, e, f, 0, 8, 0, 0 }
|
||||
#define MW(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b | 0x80, c, d, e, f, 0, 8, 0, 0 }
|
||||
|
||||
// Rail types
|
||||
// R = Conventional railway
|
||||
|
Loading…
Reference in New Issue
Block a user