1
0
Fork 0

(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920

-Codechange: store all year related variables that are _not_ stored in a savegame/transported over the network in the same format as _cur_year
release/0.5
rubidium 2006-08-16 11:39:55 +00:00
parent 50e96f8ff9
commit 3cab5f30c0
32 changed files with 211 additions and 203 deletions

View File

@ -362,7 +362,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->service_interval = _patches.servint_aircraft; v->service_interval = _patches.servint_aircraft;
v->date_of_last_service = _date; v->date_of_last_service = _date;
v->build_year = u->build_year = _cur_year; v->build_year = u->build_year = _cur_year - BASE_YEAR;
v->cur_image = u->cur_image = 0xEA0; v->cur_image = u->cur_image = 0xEA0;

View File

@ -66,7 +66,7 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number)
y += 10; y += 10;
/* Design date - Life length */ /* Design date - Life length */
SetDParam(0, BASE_YEAR + ymd.year); SetDParam(0, ymd.year);
SetDParam(1, e->lifelength); SetDParam(1, e->lifelength);
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
y += 10; y += 10;

View File

@ -12,7 +12,7 @@ enum {
/** Struct containing information about a single bridge type /** Struct containing information about a single bridge type
*/ */
typedef struct Bridge { typedef struct Bridge {
byte avail_year; ///< the year in which the bridge becomes available Year avail_year; ///< the year in which the bridge becomes available
byte min_length; ///< the minimum length of the bridge (not counting start and end tile) byte min_length; ///< the minimum length of the bridge (not counting start and end tile)
byte max_length; ///< the maximum length of the bridge (not counting start and end tile) byte max_length; ///< the maximum length of the bridge (not counting start and end tile)
uint16 price; ///< the relative price of the bridge uint16 price; ///< the relative price of the bridge

View File

@ -81,8 +81,8 @@ uint GetMaskOfAllowedCurrencies(void)
for (i = 0; i != lengthof(_currency_specs); i++) { for (i = 0; i != lengthof(_currency_specs); i++) {
uint16 to_euro = _currency_specs[i].to_euro; uint16 to_euro = _currency_specs[i].to_euro;
if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && BASE_YEAR + _cur_year >= to_euro) continue; if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= to_euro) continue;
if (to_euro == CF_ISEURO && BASE_YEAR + _cur_year < 2000) continue; if (to_euro == CF_ISEURO && _cur_year < 2000) continue;
mask |= (1 << i); mask |= (1 << i);
} }
mask |= (1 << CUSTOM_CURRENCY_ID); // always allow custom currency mask |= (1 << CUSTOM_CURRENCY_ID); // always allow custom currency
@ -94,7 +94,7 @@ void CheckSwitchToEuro(void)
{ {
if (_currency_specs[_opt.currency].to_euro != CF_NOEURO && if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
_currency_specs[_opt.currency].to_euro != CF_ISEURO && _currency_specs[_opt.currency].to_euro != CF_ISEURO &&
BASE_YEAR + _cur_year >= _currency_specs[_opt.currency].to_euro) { _cur_year >= _currency_specs[_opt.currency].to_euro) {
_opt.currency = 2; // this is the index of euro above. _opt.currency = 2; // this is the index of euro above.
AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0); AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0);
} }

17
date.c
View File

@ -88,7 +88,7 @@ void ConvertDateToYMD(Date date, YearMonthDay *ymd)
if (rem >= 31 + 28) rem++; if (rem >= 31 + 28) rem++;
} }
ymd->year = yr; ymd->year = BASE_YEAR + yr;
x = _month_date_from_year_day[rem]; x = _month_date_from_year_day[rem];
ymd->month = x >> 5; ymd->month = x >> 5;
@ -104,15 +104,16 @@ void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Date ConvertYMDToDate(Year year, Month month, Day day) Date ConvertYMDToDate(Year year, Month month, Day day)
{ {
uint rem; uint rem;
uint yr = year - BASE_YEAR;
/* day in the year */ /* day in the year */
rem = _accum_days_for_month[month] + day - 1; rem = _accum_days_for_month[month] + day - 1;
/* remove feb 29 from year 1,2,3 */ /* remove feb 29 from year 1,2,3 */
if (year & 3) rem += (year & 3) * 365 + (rem < 31 + 29); if (yr & 3) rem += (yr & 3) * 365 + (rem < 31 + 29);
/* base date. */ /* base date. */
return (year >> 2) * (365 + 365 + 365 + 366) + rem; return (yr >> 2) * (365 + 365 + 365 + 366) + rem;
} }
/** /**
@ -130,14 +131,14 @@ Date ConvertIntDate(uint date)
Day day = 1; Day day = 1;
if (IS_INT_INSIDE(date, 1920, MAX_YEAR + 1)) { if (IS_INT_INSIDE(date, 1920, MAX_YEAR + 1)) {
year = date - 1920; year = date;
} else if (IS_INT_INSIDE(date, 192001, 209012 + 1)) { } else if (IS_INT_INSIDE(date, 192001, 209012 + 1)) {
month = date % 100 - 1; month = date % 100 - 1;
year = date / 100 - 1920; year = date / 100;
} else if (IS_INT_INSIDE(date, 19200101, 20901231 + 1)) { } else if (IS_INT_INSIDE(date, 19200101, 20901231 + 1)) {
day = date % 100; date /= 100; day = date % 100; date /= 100;
month = date % 100 - 1; month = date % 100 - 1;
year = date / 100 - 1920; year = date / 100;
} else if (IS_INT_INSIDE(date, 2091, 65536)) { } else if (IS_INT_INSIDE(date, 2091, 65536)) {
return date; return date;
} else { } else {
@ -282,10 +283,10 @@ void IncreaseDate(void)
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
/* check if we reached end of the game */ /* check if we reached end of the game */
if (_cur_year == _patches.ending_year - MAX_YEAR) { if (_cur_year == _patches.ending_year) {
ShowEndGameChart(); ShowEndGameChart();
/* check if we reached the maximum year, decrement dates by a year */ /* check if we reached the maximum year, decrement dates by a year */
} else if (BASE_YEAR + _cur_year == MAX_YEAR + 1) { } else if (_cur_year == MAX_YEAR + 1) {
Vehicle *v; Vehicle *v;
_cur_year--; _cur_year--;

View File

@ -951,33 +951,30 @@ static DisasterInitProc * const _disaster_initprocs[] = {
Disaster7_Init, Disaster7_Init,
}; };
#define MK(a, b) { (a) - BASE_YEAR, (b) - BASE_YEAR }
static const struct { static const struct {
byte min; Year min;
byte max; Year max;
} _dis_years[] = { } _dis_years[] = {
MK(1930, 1955), { 1930, 1955 },
MK(1940, 1970), { 1940, 1970 },
MK(1960, 1990), { 1960, 1990 },
MK(1970, 2000), { 1970, 2000 },
MK(2000, 2100), { 2000, 2100 },
MK(1940, 1965), { 1940, 1965 },
MK(1975, 2010), { 1975, 2010 },
MK(1950, 1985) { 1950, 1985 }
}; };
#undef MK
static void DoDisaster(void) static void DoDisaster(void)
{ {
byte buf[lengthof(_dis_years)]; byte buf[lengthof(_dis_years)];
byte year = _cur_year;
uint i; uint i;
uint j; uint j;
j = 0; j = 0;
for (i = 0; i != lengthof(_dis_years); i++) { for (i = 0; i != lengthof(_dis_years); i++) {
if (year >= _dis_years[i].min && year < _dis_years[i].max) buf[j++] = i; if (_cur_year >= _dis_years[i].min && _cur_year < _dis_years[i].max) buf[j++] = i;
} }
if (j == 0) return; if (j == 0) return;

View File

@ -1394,7 +1394,7 @@ int LoadUnloadVehicle(Vehicle *v)
// if last speed is 0, we treat that as if no vehicle has ever visited the station. // if last speed is 0, we treat that as if no vehicle has ever visited the station.
ge->last_speed = min(t, 255); ge->last_speed = min(t, 255);
ge->last_age = _cur_year - v->build_year; ge->last_age = (_cur_year - BASE_YEAR) - v->build_year;
// If there's goods waiting at the station, and the vehicle // If there's goods waiting at the station, and the vehicle
// has capacity for it, load it on the vehicle. // has capacity for it, load it on the vehicle.
@ -1482,7 +1482,7 @@ int LoadUnloadVehicle(Vehicle *v)
void PlayersMonthlyLoop(void) void PlayersMonthlyLoop(void)
{ {
PlayersGenStatistics(); PlayersGenStatistics();
if (_patches.inflation && BASE_YEAR + _cur_year < MAX_YEAR) if (_patches.inflation && _cur_year < MAX_YEAR)
AddInflation(); AddInflation();
PlayersPayInterest(); PlayersPayInterest();
// Reset the _current_player flag // Reset the _current_player flag
@ -1546,7 +1546,7 @@ int32 CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
p = GetPlayer(p1); p = GetPlayer(p1);
/* Protect new companies from hostile takeovers */ /* Protect new companies from hostile takeovers */
if (_cur_year - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED); if ((_cur_year - BASE_YEAR) - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED);
/* Those lines are here for network-protection (clients can be slow) */ /* Those lines are here for network-protection (clients can be slow) */
if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) return 0; if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) return 0;

View File

@ -238,7 +238,7 @@ void EnginesDailyLoop(void)
{ {
EngineID i; EngineID i;
if (_cur_year >= 130) return; if (_cur_year >= 2050) return;
for (i = 0; i != lengthof(_engines); i++) { for (i = 0; i != lengthof(_engines); i++) {
Engine *e = &_engines[i]; Engine *e = &_engines[i];
@ -359,7 +359,7 @@ void EnginesMonthlyLoop(void)
{ {
Engine *e; Engine *e;
if (_cur_year < 130) { if (_cur_year < 2050) {
for (e = _engines; e != endof(_engines); e++) { for (e = _engines; e != endof(_engines); e++) {
// Age the vehicle // Age the vehicle
if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) { if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) {

View File

@ -30,7 +30,7 @@ typedef struct GraphDrawer {
byte num_dataset; byte num_dataset;
byte num_on_x_axis; byte num_on_x_axis;
byte month; byte month;
byte year; Year year;
bool include_neg; bool include_neg;
byte num_vert_lines; byte num_vert_lines;
uint16 unk61A; uint16 unk61A;
@ -151,7 +151,7 @@ static void DrawGraph(const GraphDrawer *gw)
x = gw->left + 44; x = gw->left + 44;
y = gw->top + gw->height + 1; y = gw->top + gw->height + 1;
j = gw->month; j = gw->month;
k = BASE_YEAR + gw->year; k = gw->year;
i = gw->num_on_x_axis;assert(i>0); i = gw->num_on_x_axis;assert(i>0);
do { do {
SetDParam(2, k); SetDParam(2, k);

View File

@ -1330,7 +1330,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
i->total_transported[0] = 0; i->total_transported[0] = 0;
i->total_transported[1] = 0; i->total_transported[1] = 0;
i->was_cargo_delivered = false; i->was_cargo_delivered = false;
i->last_prod_year = _cur_year; i->last_prod_year = _cur_year - BASE_YEAR;
i->total_production[0] = i->production_rate[0] * 8; i->total_production[0] = i->production_rate[0] * 8;
i->total_production[1] = i->production_rate[1] * 8; i->total_production[1] = i->production_rate[1] * 8;
@ -1531,7 +1531,7 @@ static void ExtChangeIndustryProduction(Industry *i)
return; return;
case INDUSTRYLIFE_CLOSABLE: case INDUSTRYLIFE_CLOSABLE:
if ((byte)(_cur_year - i->last_prod_year) < 5 || !CHANCE16(1, 180)) if ((byte)((_cur_year - BASE_YEAR) - i->last_prod_year) < 5 || !CHANCE16(1, 180))
closeit = false; closeit = false;
break; break;
@ -1594,7 +1594,7 @@ static void UpdateIndustryStatistics(Industry *i)
if (i->produced_cargo[0] != CT_INVALID) { if (i->produced_cargo[0] != CT_INVALID) {
pct = 0; pct = 0;
if (i->last_mo_production[0] != 0) { if (i->last_mo_production[0] != 0) {
i->last_prod_year = _cur_year; i->last_prod_year = _cur_year - BASE_YEAR;
pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0],255); pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0],255);
} }
i->pct_transported[0] = pct; i->pct_transported[0] = pct;
@ -1609,7 +1609,7 @@ static void UpdateIndustryStatistics(Industry *i)
if (i->produced_cargo[1] != CT_INVALID) { if (i->produced_cargo[1] != CT_INVALID) {
pct = 0; pct = 0;
if (i->last_mo_production[1] != 0) { if (i->last_mo_production[1] != 0) {
i->last_prod_year = _cur_year; i->last_prod_year = _cur_year - BASE_YEAR;
pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1],255); pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1],255);
} }
i->pct_transported[1] = pct; i->pct_transported[1] = pct;
@ -1721,7 +1721,7 @@ static void ChangeIndustryProduction(Industry *i)
case INDUSTRYLIFE_CLOSABLE: case INDUSTRYLIFE_CLOSABLE:
/* maybe close */ /* maybe close */
if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1,2)) { if ( (byte)((_cur_year - BASE_YEAR) - i->last_prod_year) >= 5 && CHANCE16(1,2)) {
i->prod_level = 0; i->prod_level = 0;
str = indspec->closure_text; str = indspec->closure_text;
} }

View File

@ -1677,7 +1677,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
YearMonthDay ymd; YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd); ConvertDateToYMD(_date, &ymd);
if ((BASE_YEAR + ymd.year == MIN_YEAR && p2 == -1) || (BASE_YEAR + ymd.year == MAX_YEAR && p2 == 1)) return _cur_year; if ((ymd.year == MIN_YEAR && p2 == -1) || (ymd.year == MAX_YEAR && p2 == 1)) return _cur_year;
SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day)); SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
EnginesMonthlyLoop(); EnginesMonthlyLoop();

View File

@ -206,7 +206,7 @@ VARDEF bool _network_autoclean_companies;
VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months
VARDEF uint8 _network_autoclean_protected; // Unprotect a company after X months VARDEF uint8 _network_autoclean_protected; // Unprotect a company after X months
VARDEF uint16 _network_restart_game_year; // If this year is reached, the server automaticly restarts VARDEF Year _network_restart_game_year; // If this year is reached, the server automaticly restarts
NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info); NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info);

View File

@ -1208,7 +1208,7 @@ void NetworkPopulateCompanyInfo(void)
GetString(_network_player_info[p->index].company_name, STR_JUST_STRING); GetString(_network_player_info[p->index].company_name, STR_JUST_STRING);
// Check the income // Check the income
if (_cur_year - 1 == p->inaugurated_year) { if (_cur_year - 1 == BASE_YEAR + p->inaugurated_year) {
// The player is here just 1 year, so display [2], else display[1] // The player is here just 1 year, so display [2], else display[1]
for (i = 0; i < 13; i++) { for (i = 0; i < 13; i++) {
_network_player_info[p->index].income -= p->yearly_expenses[2][i]; _network_player_info[p->index].income -= p->yearly_expenses[2][i];
@ -1313,8 +1313,8 @@ extern void SwitchMode(int new_mode);
/* Check if we want to restart the map */ /* Check if we want to restart the map */
static void NetworkCheckRestartMap(void) static void NetworkCheckRestartMap(void)
{ {
if (_network_restart_game_year != 0 && BASE_YEAR + _cur_year >= _network_restart_game_year) { if (_network_restart_game_year != 0 && _cur_year >= _network_restart_game_year) {
DEBUG(net, 0)("Auto-restarting map. Year %d reached.", BASE_YEAR + _cur_year); DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year);
_random_seeds[0][0] = Random(); _random_seeds[0][0] = Random();
_random_seeds[0][1] = InteractiveRandom(); _random_seeds[0][1] = InteractiveRandom();

View File

@ -23,6 +23,7 @@
#include "vehicle.h" #include "vehicle.h"
#include "newgrf_text.h" #include "newgrf_text.h"
#include "table/sprites.h" #include "table/sprites.h"
#include "date.h"
#include "newgrf_spritegroup.h" #include "newgrf_spritegroup.h"
@ -1006,7 +1007,7 @@ static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int
switch (prop) { switch (prop) {
case 0x08: /* Year of availability */ case 0x08: /* Year of availability */
FOR_EACH_OBJECT _bridge[brid + i].avail_year = grf_load_byte(&buf); FOR_EACH_OBJECT _bridge[brid + i].avail_year = BASE_YEAR + grf_load_byte(&buf);
break; break;
case 0x09: /* Minimum length */ case 0x09: /* Minimum length */
@ -1059,6 +1060,10 @@ static bool BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int
FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf); FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf);
break; 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: default:
ret = true; ret = true;
} }

View File

@ -553,7 +553,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x43: return _current_player; /* Owner information */ case 0x43: return _current_player; /* Owner information */
case 0x46: return 0; /* Motion counter */ case 0x46: return 0; /* Motion counter */
case 0x48: return GetVehicleTypeInfo(object->u.vehicle.self_type); /* Vehicle Type Info */ case 0x48: return GetVehicleTypeInfo(object->u.vehicle.self_type); /* Vehicle Type Info */
case 0xC4: return _cur_year; /* Build year */ case 0xC4: return clamp(_cur_year, BASE_YEAR, MAX_YEAR) - BASE_YEAR; /* Build year */
case 0xDA: return INVALID_VEHICLE; /* Next vehicle */ case 0xDA: return INVALID_VEHICLE; /* Next vehicle */
case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); /* Read GRF parameter */ case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); /* Read GRF parameter */
} }

View File

@ -76,7 +76,7 @@ static inline uint32 GetVariable(const ResolverObject *object, byte variable, by
/* Return common variables */ /* Return common variables */
switch (variable) { switch (variable) {
case 0x00: return _date; case 0x00: return _date;
case 0x01: return _cur_year; case 0x01: return clamp(_cur_year, BASE_YEAR, MAX_YEAR) - BASE_YEAR;
case 0x02: return _cur_month; case 0x02: return _cur_month;
case 0x03: return _opt.landscape; case 0x03: return _opt.landscape;
case 0x09: return _date_fract; case 0x09: return _date_fract;

View File

@ -258,7 +258,7 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
ni->flags = (byte)(flags >> 8) | NF_NOEXPIRE; ni->flags = (byte)(flags >> 8) | NF_NOEXPIRE;
// show this news message in color? // show this news message in color?
if (_date >= ConvertIntDate(_patches.colored_news_year)) if (_cur_year >= _patches.colored_news_year)
ni->flags |= NF_INCOLOR; ni->flags |= NF_INCOLOR;
ni->type = (byte)(flags >> 16); ni->type = (byte)(flags >> 16);

View File

@ -316,7 +316,7 @@ int ttd_main(int argc, char *argv[])
const char *optformat; const char *optformat;
char musicdriver[16], sounddriver[16], videodriver[16]; char musicdriver[16], sounddriver[16], videodriver[16];
int resolution[2] = {0,0}; int resolution[2] = {0,0};
uint startyear = -1; Year startyear = INVALID_YEAR;
bool dedicated = false; bool dedicated = false;
bool network = false; bool network = false;
@ -408,7 +408,7 @@ int ttd_main(int argc, char *argv[])
if (sounddriver[0]) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver)); if (sounddriver[0]) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
if (videodriver[0]) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver)); if (videodriver[0]) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
if (resolution[0]) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; } if (resolution[0]) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
if (startyear != (uint)-1) _patches_newgame.starting_year = startyear; if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
if (_dedicated_forks && !dedicated) _dedicated_forks = false; if (_dedicated_forks && !dedicated) _dedicated_forks = false;

View File

@ -52,7 +52,12 @@ typedef uint16 UnitID; ///< All unitnumber stuff is of this type (or anyway, s
typedef uint32 WindowNumber; typedef uint32 WindowNumber;
typedef byte WindowClass; typedef byte WindowClass;
typedef uint8 Year; enum {
INVALID_YEAR = -1,
INVALID_DATE = (uint16)-1,
};
typedef int16 Year;
typedef uint16 Date; typedef uint16 Date;

View File

@ -46,8 +46,8 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
x = 215; x = 215;
tbl = p->yearly_expenses + 2; tbl = p->yearly_expenses + 2;
do { do {
if (year >= p->inaugurated_year) { if (year >= BASE_YEAR + p->inaugurated_year) {
SetDParam(0, BASE_YEAR + year); SetDParam(0, year);
DrawStringCenterUnderline(x-17, 15, STR_7010, 0); DrawStringCenterUnderline(x-17, 15, STR_7010, 0);
sum = 0; sum = 0;
for (i = 0; i != 13; i++) { for (i = 0; i != 13; i++) {

View File

@ -490,7 +490,7 @@ Player *DoStartupNewPlayer(bool is_ai)
p->share_owners[0] = p->share_owners[1] = p->share_owners[2] = p->share_owners[3] = OWNER_SPECTATOR; p->share_owners[0] = p->share_owners[1] = p->share_owners[2] = p->share_owners[3] = OWNER_SPECTATOR;
p->avail_railtypes = GetPlayerRailtypes(p->index); p->avail_railtypes = GetPlayerRailtypes(p->index);
p->inaugurated_year = _cur_year; p->inaugurated_year = _cur_year - BASE_YEAR;
p->face = Random(); p->face = Random();
/* Engine renewal settings */ /* Engine renewal settings */

View File

@ -184,7 +184,7 @@ int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->service_interval = _patches.servint_roadveh; v->service_interval = _patches.servint_roadveh;
v->date_of_last_service = _date; v->date_of_last_service = _date;
v->build_year = _cur_year; v->build_year = _cur_year - BASE_YEAR;
v->type = VEH_Road; v->type = VEH_Road;
v->cur_image = 0xC15; v->cur_image = 0xC15;

View File

@ -54,7 +54,7 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
y += 10; y += 10;
/* Design date - Life length */ /* Design date - Life length */
SetDParam(0, BASE_YEAR + ymd.year); SetDParam(0, ymd.year);
SetDParam(1, e->lifelength); SetDParam(1, e->lifelength);
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
y += 10; y += 10;

View File

@ -1206,7 +1206,7 @@ static const SettingDescGlobVarList _network_settings[] = {
SDTG_BOOL("autoclean_companies", S, 0, _network_autoclean_companies, false, STR_NULL, NULL), SDTG_BOOL("autoclean_companies", S, 0, _network_autoclean_companies, false, STR_NULL, NULL),
SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0, 60, STR_NULL, NULL), SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0, 60, STR_NULL, NULL),
SDTG_VAR("autoclean_protected", SLE_UINT8, S, 0, _network_autoclean_protected, 36, 0, 180, STR_NULL, NULL), SDTG_VAR("autoclean_protected", SLE_UINT8, S, 0, _network_autoclean_protected, 36, 0, 180, STR_NULL, NULL),
SDTG_VAR("restart_game_year", SLE_UINT16, S,D0, _network_restart_game_year, 0, MIN_YEAR, MAX_YEAR, STR_NULL, NULL), SDTG_VAR("restart_game_year", SLE_INT16, S,D0, _network_restart_game_year, 0, MIN_YEAR, MAX_YEAR, STR_NULL, NULL),
SDTG_END() SDTG_END()
}; };
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
@ -1320,9 +1320,9 @@ const SettingDesc _patch_settings[] = {
SDT_BOOL(Patches, same_industry_close, 0, 0, false, STR_CONFIG_PATCHES_SAMEINDCLOSE, NULL), SDT_BOOL(Patches, same_industry_close, 0, 0, false, STR_CONFIG_PATCHES_SAMEINDCLOSE, NULL),
SDT_BOOL(Patches, bribe, 0, 0, true, STR_CONFIG_PATCHES_BRIBE, NULL), SDT_BOOL(Patches, bribe, 0, 0, true, STR_CONFIG_PATCHES_BRIBE, NULL),
SDT_VAR(Patches, snow_line_height,SLE_UINT8, 0, 0, 7, 2, 13, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT, NULL), SDT_VAR(Patches, snow_line_height,SLE_UINT8, 0, 0, 7, 2, 13, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT, NULL),
SDT_VAR(Patches, colored_news_year,SLE_UINT, 0,NC, 2000, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL), SDT_VAR(Patches, colored_news_year,SLE_FILE_U32 | SLE_VAR_I16, 0,NC, 2000, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL),
SDT_VAR(Patches, starting_year, SLE_UINT, 0,NC, 1950, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_STARTING_YEAR,NULL), SDT_VAR(Patches, starting_year, SLE_FILE_U32 | SLE_VAR_I16, 0,NC, 1950, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
SDT_VAR(Patches, ending_year, SLE_UINT,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_ENDING_YEAR, NULL), SDT_VAR(Patches, ending_year, SLE_FILE_U32 | SLE_VAR_I16,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_ENDING_YEAR, NULL),
SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL), SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL),
SDT_BOOL(Patches, allow_shares, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL), SDT_BOOL(Patches, allow_shares, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL),

View File

@ -901,7 +901,7 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->service_interval = _patches.servint_ships; v->service_interval = _patches.servint_ships;
v->date_of_last_service = _date; v->date_of_last_service = _date;
v->build_year = _cur_year; v->build_year = _cur_year - BASE_YEAR;
v->cur_image = 0x0E5E; v->cur_image = 0x0E5E;
v->type = VEH_Ship; v->type = VEH_Ship;
v->random_bits = VehicleRandomBits(); v->random_bits = VehicleRandomBits();

View File

@ -54,7 +54,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
/* Design date - Life length */ /* Design date - Life length */
e = GetEngine(engine_number); e = GetEngine(engine_number);
ConvertDateToYMD(e->intro_date, &ymd); ConvertDateToYMD(e->intro_date, &ymd);
SetDParam(0, BASE_YEAR + ymd.year); SetDParam(0, ymd.year);
SetDParam(1, e->lifelength); SetDParam(1, e->lifelength);
DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
y += 10; y += 10;

View File

@ -339,7 +339,7 @@ static char *FormatYmdString(char *buff, Date date)
for (src = GetStringPtr(STR_0162_JAN + ymd.month); (*buff++ = *src++) != '\0';) {} for (src = GetStringPtr(STR_0162_JAN + ymd.month); (*buff++ = *src++) != '\0';) {}
buff[-1] = ' '; buff[-1] = ' ';
return FormatNoCommaNumber(buff, BASE_YEAR + ymd.year); return FormatNoCommaNumber(buff, ymd.year);
} }
static char *FormatMonthAndYear(char *buff, Date date) static char *FormatMonthAndYear(char *buff, Date date)
@ -352,7 +352,7 @@ static char *FormatMonthAndYear(char *buff, Date date)
for (src = GetStringPtr(STR_MONTH_JAN + ymd.month); (*buff++ = *src++) != '\0';) {} for (src = GetStringPtr(STR_MONTH_JAN + ymd.month); (*buff++ = *src++) != '\0';) {}
buff[-1] = ' '; buff[-1] = ' ';
return FormatNoCommaNumber(buff, BASE_YEAR + ymd.year); return FormatNoCommaNumber(buff, ymd.year);
} }
static char *FormatTinyDate(char *buff, Date date) static char *FormatTinyDate(char *buff, Date date)
@ -360,7 +360,7 @@ static char *FormatTinyDate(char *buff, Date date)
YearMonthDay ymd; YearMonthDay ymd;
ConvertDateToYMD(date, &ymd); ConvertDateToYMD(date, &ymd);
buff += sprintf(buff, " %02i-%02i-%04i", ymd.day, ymd.month + 1, BASE_YEAR + ymd.year); buff += sprintf(buff, " %02i-%02i-%04i", ymd.day, ymd.month + 1, ymd.year);
return buff; return buff;
} }

View File

@ -2019,120 +2019,120 @@ assert_compile(lengthof(_housetype_remove_ratingmod) == HOUSE_MAX);
typedef struct { typedef struct {
byte min,max; Year min, max;
} HousetypeYear; } HousetypeYear;
static const HousetypeYear _housetype_years[] = { static const HousetypeYear _housetype_years[] = {
{43, 255}, { 1963, MAX_YEAR },
{37, 255}, { 1957, MAX_YEAR },
{48, 255}, { 1968, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{55, 255}, { 1975, MAX_YEAR },
{55, 255}, { 1975, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{39, 255}, { 1959, MAX_YEAR },
{39, 255}, { 1959, MAX_YEAR },
{25, 255}, { 1945, MAX_YEAR },
{25, 255}, { 1945, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{15, 255}, { 1935, MAX_YEAR },
{31, 255}, { 1951, MAX_YEAR },
{10, 40}, { 1930, 1960 },
{10, 40}, { 1930, 1960 },
{10, 40}, { 1930, 1960 },
{57, 255}, { 1977, MAX_YEAR },
{63, 255}, { 1983, MAX_YEAR },
{65, 255}, { 1985, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 31}, { 0, 1951 },
{0, 32}, { 0, 1952 },
{11, 255}, { 1941, MAX_YEAR },
{15, 255}, { 1945, MAX_YEAR },
{43, 255}, { 1963, MAX_YEAR },
{0, 35}, { 0, 1955 },
{53, 255}, { 1973, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{38, 255}, { 1958, MAX_YEAR },
{38, 255}, { 1958, MAX_YEAR },
{38, 255}, { 1958, MAX_YEAR },
{38, 255}, { 1958, MAX_YEAR },
{80, 255}, { 1950, MAX_YEAR },
{0, 40}, { 0, 1960 },
{0, 40}, { 0, 1960 },
{25, 255}, { 1945, MAX_YEAR },
{63, 255}, { 1983, MAX_YEAR },
{63, 255}, { 1983, MAX_YEAR },
{63, 255}, { 1983, MAX_YEAR },
{63, 255}, { 1983, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 43}, { 0, 1963 },
{0, 43}, { 0, 1963 },
{46, 255}, { 1966, MAX_YEAR },
{46, 255}, { 1966, MAX_YEAR },
{50, 255}, { 1970, MAX_YEAR },
{50, 255}, { 1970, MAX_YEAR },
{54, 255}, { 1974, MAX_YEAR },
{54, 255}, { 1974, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 40}, { 0, 1960 },
{0, 40}, { 0, 1960 },
{52, 255}, { 1972, MAX_YEAR },
{52, 255}, { 1972, MAX_YEAR },
{52, 255}, { 1972, MAX_YEAR },
{52, 255}, { 1972, MAX_YEAR },
{43, 255}, { 1963, MAX_YEAR },
{43, 255}, { 1963, MAX_YEAR },
{58, 255}, { 1978, MAX_YEAR },
{58, 255}, { 1978, MAX_YEAR },
{47, 255}, { 1967, MAX_YEAR },
{47, 255}, { 1967, MAX_YEAR },
{47, 255}, { 1967, MAX_YEAR },
{47, 255}, { 1967, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{53, 255}, { 1973, MAX_YEAR },
{42, 255}, { 1962, MAX_YEAR },
{64, 255}, { 1984, MAX_YEAR },
{64, 255}, { 1984, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{73, 255}, { 1993, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
{0, 255}, { 0, MAX_YEAR },
}; };
assert_compile(lengthof(_housetype_years) == HOUSE_MAX); assert_compile(lengthof(_housetype_years) == HOUSE_MAX);

View File

@ -623,7 +623,7 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
v->u.rail.railtype = GetEngine(engine)->railtype; v->u.rail.railtype = GetEngine(engine)->railtype;
v->build_year = _cur_year; v->build_year = _cur_year - BASE_YEAR;
v->type = VEH_Train; v->type = VEH_Train;
v->cur_image = 0xAC2; v->cur_image = 0xAC2;
v->random_bits = VehicleRandomBits(); v->random_bits = VehicleRandomBits();
@ -783,7 +783,7 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->service_interval = _patches.servint_trains; v->service_interval = _patches.servint_trains;
v->date_of_last_service = _date; v->date_of_last_service = _date;
v->build_year = _cur_year; v->build_year = _cur_year - BASE_YEAR;
v->type = VEH_Train; v->type = VEH_Train;
v->cur_image = 0xAC2; v->cur_image = 0xAC2;
v->random_bits = VehicleRandomBits(); v->random_bits = VehicleRandomBits();

View File

@ -73,7 +73,7 @@ void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
y += 10; y += 10;
/* Design date - Life length */ /* Design date - Life length */
SetDParam(0, BASE_YEAR + ymd.year); SetDParam(0, ymd.year);
SetDParam(1, e->lifelength); SetDParam(1, e->lifelength);
DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
y += 10; y += 10;

View File

@ -38,26 +38,26 @@ extern void DrawCanalWater(TileIndex tile);
const Bridge orig_bridge[] = { const Bridge orig_bridge[] = {
/* /*
year of availablity year of availablity
| minimum length | minimum length
| | maximum length | | maximum length
| | | price | | | price
| | | | maximum speed | | | | maximum speed
| | | | | sprite to use in GUI string with description | | | | | sprite to use in GUI string with description
| | | | | | | */ | | | | | | | */
{ 0, 0, 16, 80, 32, 0xA24 , STR_5012_WOODEN , NULL, 0 }, { 0, 0, 16, 80, 32, 0xA24 , STR_5012_WOODEN , NULL, 0 },
{ 0, 0, 2, 112, 48, 0xA26 | PALETTE_TO_STRUCT_RED , STR_5013_CONCRETE , NULL, 0 }, { 0, 0, 2, 112, 48, 0xA26 | PALETTE_TO_STRUCT_RED , STR_5013_CONCRETE , NULL, 0 },
{ 10, 0, 5, 144, 64, 0xA25 , STR_500F_GIRDER_STEEL , NULL, 0 }, { 1930, 0, 5, 144, 64, 0xA25 , STR_500F_GIRDER_STEEL , NULL, 0 },
{ 0, 2, 10, 168, 80, 0xA22 | PALETTE_TO_STRUCT_CONCRETE, STR_5011_SUSPENSION_CONCRETE, NULL, 0 }, { 0, 2, 10, 168, 80, 0xA22 | PALETTE_TO_STRUCT_CONCRETE, STR_5011_SUSPENSION_CONCRETE, NULL, 0 },
{ 10, 3, 16, 185, 96, 0xA22 , STR_500E_SUSPENSION_STEEL , NULL, 0 }, { 1930, 3, 16, 185, 96, 0xA22 , STR_500E_SUSPENSION_STEEL , NULL, 0 },
{ 10, 3, 16, 192, 112, 0xA22 | PALETTE_TO_STRUCT_YELLOW , STR_500E_SUSPENSION_STEEL , NULL, 0 }, { 1930, 3, 16, 192, 112, 0xA22 | PALETTE_TO_STRUCT_YELLOW , STR_500E_SUSPENSION_STEEL , NULL, 0 },
{ 10, 3, 7, 224, 160, 0xA23 , STR_5010_CANTILEVER_STEEL , NULL, 0 }, { 1930, 3, 7, 224, 160, 0xA23 , STR_5010_CANTILEVER_STEEL , NULL, 0 },
{ 10, 3, 8, 232, 208, 0xA23 | PALETTE_TO_STRUCT_BROWN , STR_5010_CANTILEVER_STEEL , NULL, 0 }, { 1930, 3, 8, 232, 208, 0xA23 | PALETTE_TO_STRUCT_BROWN , STR_5010_CANTILEVER_STEEL , NULL, 0 },
{ 10, 3, 9, 248, 240, 0xA23 | PALETTE_TO_STRUCT_RED , STR_5010_CANTILEVER_STEEL , NULL, 0 }, { 1930, 3, 9, 248, 240, 0xA23 | PALETTE_TO_STRUCT_RED , STR_5010_CANTILEVER_STEEL , NULL, 0 },
{ 10, 0, 2, 240, 256, 0xA27 , STR_500F_GIRDER_STEEL , NULL, 0 }, { 1930, 0, 2, 240, 256, 0xA27 , STR_500F_GIRDER_STEEL , NULL, 0 },
{ 75, 2, 16, 255, 320, 0xA28 , STR_5014_TUBULAR_STEEL , NULL, 0 }, { 1995, 2, 16, 255, 320, 0xA28 , STR_5014_TUBULAR_STEEL , NULL, 0 },
{ 85, 2, 32, 380, 512, 0xA28 | PALETTE_TO_STRUCT_YELLOW , STR_5014_TUBULAR_STEEL , NULL, 0 }, { 2005, 2, 32, 380, 512, 0xA28 | PALETTE_TO_STRUCT_YELLOW , STR_5014_TUBULAR_STEEL , NULL, 0 },
{ 90, 2, 32, 510, 608, 0xA28 | PALETTE_TO_STRUCT_GREY , STR_BRIDGE_TUBULAR_SILICON , NULL, 0 } { 2010, 2, 32, 510, 608, 0xA28 | PALETTE_TO_STRUCT_GREY , STR_BRIDGE_TUBULAR_SILICON , NULL, 0 }
}; };
Bridge _bridge[MAX_BRIDGES]; Bridge _bridge[MAX_BRIDGES];

View File

@ -147,9 +147,9 @@ typedef struct Patches {
bool ai_disable_veh_roadveh; // disable types for AI bool ai_disable_veh_roadveh; // disable types for AI
bool ai_disable_veh_aircraft; // disable types for AI bool ai_disable_veh_aircraft; // disable types for AI
bool ai_disable_veh_ship; // disable types for AI bool ai_disable_veh_ship; // disable types for AI
uint32 starting_year; // starting date Year starting_year; // starting date
uint32 ending_year; // end of the game (just show highscore) Year ending_year; // end of the game (just show highscore)
uint32 colored_news_year; // when does newspaper become colored? Year colored_news_year; // when does newspaper become colored?
bool keep_all_autosave; // name the autosave in a different way. bool keep_all_autosave; // name the autosave in a different way.
bool autosave_on_exit; // save an autosave when you quit the game, but do not ask "Do you really want to quit?" bool autosave_on_exit; // save an autosave when you quit the game, but do not ask "Do you really want to quit?"