Index: src/ai/trolly/trolly.cpp =================================================================== --- src/ai/trolly/trolly.cpp (revision 10753) +++ src/ai/trolly/trolly.cpp (working copy) @@ -81,7 +81,7 @@ { assert(p->ainew.state == AI_STATE_NOTHING); // If we are done idling, start over again - if (p->ainew.idle == 0) p->ainew.idle = AI_RandomRange(DAY_TICKS * 2) + DAY_TICKS; + if (p->ainew.idle == 0) p->ainew.idle = AI_RandomRange(DAY_BASE * 2) + DAY_BASE; if (--p->ainew.idle == 0) { // We are done idling.. what you say? Let's do something! // I mean.. the next tick ;) @@ -880,7 +880,7 @@ // Passenger run.. how long is the route? length = p->ainew.path_info.route_length; // Calculating tiles a day a vehicle moves is not easy.. this is how it must be done! - tiles_a_day = RoadVehInfo(i)->max_speed * DAY_TICKS / 256 / 16; + tiles_a_day = RoadVehInfo(i)->max_speed * DAY_BASE / 256 / 16; // We want a vehicle in a station once a month at least, so, calculate it! // (the * 2 is because we have 2 stations ;)) amount = length * 2 * 2 / tiles_a_day / 30; @@ -896,7 +896,7 @@ // Passenger run.. how long is the route? length = p->ainew.path_info.route_length; // Calculating tiles a day a vehicle moves is not easy.. this is how it must be done! - tiles_a_day = RoadVehInfo(i)->max_speed * DAY_TICKS / 256 / 16; + tiles_a_day = RoadVehInfo(i)->max_speed * DAY_BASE / 256 / 16; if (p->ainew.from_deliver) { max_cargo = GetIndustry(p->ainew.from_ic)->last_month_production[0]; } else { Index: src/ai/trolly/trolly.h =================================================================== --- src/ai/trolly/trolly.h (revision 10753) +++ src/ai/trolly/trolly.h (working copy) @@ -139,7 +139,7 @@ #define AI_CHECK_MAX_VEHICLE_PER_STATION 10 // How many thick between building 2 vehicles -#define AI_BUILD_VEHICLE_TIME_BETWEEN DAY_TICKS +#define AI_BUILD_VEHICLE_TIME_BETWEEN DAY_BASE // How many days must there between vehicle checks // The more often, the less non-money-making lines there will be Index: src/aircraft_cmd.cpp =================================================================== --- src/aircraft_cmd.cpp (revision 10753) +++ src/aircraft_cmd.cpp (working copy) @@ -741,7 +741,7 @@ if (v->vehstatus & VS_STOPPED) return; - CommandCost cost = CommandCost(GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364); + CommandCost cost = CommandCost(GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * VehRunCostFactor() * _price.aircraft_running / 364); v->profit_this_year -= cost.GetCost() >> 8; Index: src/aircraft_gui.cpp =================================================================== --- src/aircraft_gui.cpp (revision 10753) +++ src/aircraft_gui.cpp (working copy) @@ -92,7 +92,7 @@ SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); SetDParam(2, v->max_age / 366); - SetDParam(3, _price.aircraft_running * AircraftVehInfo(v->engine_type)->running_cost >> 8); + SetDParam(3, AircraftVehInfo(v->engine_type)->running_cost * VehRunCostFactor() * _price.aircraft_running >> 8); DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0); } Index: src/build_vehicle_gui.cpp =================================================================== --- src/build_vehicle_gui.cpp (revision 10753) +++ src/build_vehicle_gui.cpp (working copy) @@ -485,7 +485,7 @@ } /* Running cost */ - SetDParam(0, (GetEngineProperty(engine_number, 0x0D, rvi->running_cost_base) * _price.running_rail[rvi->running_cost_class] >> 8) << multihead); + SetDParam(0, (GetEngineProperty(engine_number, 0x0D, rvi->running_cost_base) * VehRunCostFactor() * _price.running_rail[rvi->running_cost_class] >> 8) << multihead); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; @@ -512,7 +512,7 @@ y += 10; /* Running cost */ - SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8); + SetDParam(0, rvi->running_cost * VehRunCostFactor() * _price.roadveh_running >> 8); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; @@ -543,7 +543,7 @@ y += 10; /* Running cost */ - SetDParam(0, GetEngineProperty(engine_number, 0x0F, svi->running_cost) * _price.ship_running >> 8); + SetDParam(0, GetEngineProperty(engine_number, 0x0F, svi->running_cost) * VehRunCostFactor() * _price.ship_running >> 8); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; @@ -578,7 +578,7 @@ y += 10; /* Running cost */ - SetDParam(0, GetEngineProperty(engine_number, 0x0E, avi->running_cost) * _price.aircraft_running >> 8); + SetDParam(0, GetEngineProperty(engine_number, 0x0E, avi->running_cost) * VehRunCostFactor() * _price.aircraft_running >> 8); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; Index: src/date.cpp =================================================================== --- src/date.cpp (revision 10753) +++ src/date.cpp (working copy) @@ -210,14 +210,14 @@ }; /** - * Runs the day_proc for every DAY_TICKS vehicle starting at daytick. + * Runs the day_proc for every day, vehicle starting at daytick. */ static void RunVehicleDayProc(uint daytick) { uint total = GetMaxVehicleIndex() + 1; uint i; - for (i = daytick; i < total; i += DAY_TICKS) { + for (i = daytick; i < total; i += Daylength()) { Vehicle *v = GetVehicle(i); if (IsValidVehicle(v)) _on_new_vehicle_day_proc[v->type](v); @@ -239,7 +239,7 @@ _tick_counter++; _date_fract++; - if (_date_fract < DAY_TICKS) return; + if (_date_fract < Daylength()) return; _date_fract = 0; /* yeah, increase day counter and call various daily loops */ Index: src/date.h =================================================================== --- src/date.h (revision 10753) +++ src/date.h (working copy) @@ -8,12 +8,12 @@ #include "openttd.h" /** - * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On - * an overflow the new day begun and 65535 / 885 = 74. + * 1 DAY_BASE is 74 ticks; _date_fract used to be uint16 and incremented by 885. + * On an overflow the new day begun and 65535 / 885 = 74. * 1 tick is approximately 30 ms. - * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally + * 1 DAY_BASE is thus about 2 seconds (74 * 30 = 2220ms) on a machine that runs OpenTTD normally. */ -#define DAY_TICKS 74 +#define DAY_BASE 74 /* * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are Index: src/graph_gui.cpp =================================================================== --- src/graph_gui.cpp (revision 10753) +++ src/graph_gui.cpp (working copy) @@ -1080,7 +1080,7 @@ if (p2->is_active) UpdateCompanyRatingAndValue(p2, false); } - w->custom[0] = DAY_TICKS; + w->custom[0] = DAY_BASE; w->custom[1] = 5; if (_performance_rating_detail_player != INVALID_PLAYER) LowerWindowWidget(w, _performance_rating_detail_player + 13); @@ -1092,7 +1092,7 @@ case WE_TICK: /* Update the player score every 5 days */ if (--w->custom[0] == 0) { - w->custom[0] = DAY_TICKS; + w->custom[0] = DAY_BASE; if (--w->custom[1] == 0) { Player *p2; Index: src/group_gui.cpp =================================================================== --- src/group_gui.cpp (revision 10753) +++ src/group_gui.cpp (working copy) @@ -101,7 +101,7 @@ qsort((void*)gl->sort_list, gl->l.list_length, sizeof(gl->sort_list[0]), GroupNameSorter); - gl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + gl->l.resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; gl->l.flags &= ~VL_RESORT; } @@ -210,11 +210,11 @@ gv->vehicle_type = (VehicleType)GB(w->window_number, 11, 5); gv->l.sort_type = gv->_sorting->criteria; gv->l.flags = VL_REBUILD | (gv->_sorting->order ? VL_DESC : VL_NONE); - gv->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer + gv->l.resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; // Set up resort timer gl->sort_list = NULL; gl->l.flags = VL_REBUILD | VL_NONE; - gl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer + gl->l.resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; // Set up resort timer gv->group_sel = ALL_GROUP; @@ -756,12 +756,12 @@ case WE_TICK: // resort the lists every 20 seconds orso (10 days) if (--gv->l.resort_timer == 0) { - gv->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + gv->l.resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; gv->l.flags |= VL_RESORT; SetWindowDirty(w); } if (--gl->l.resort_timer == 0) { - gl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + gl->l.resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; gl->l.flags |= VL_RESORT; SetWindowDirty(w); } Index: src/industry_gui.cpp =================================================================== --- src/industry_gui.cpp (revision 10753) +++ src/industry_gui.cpp (working copy) @@ -138,7 +138,7 @@ * I'll be damned if there are none available ;) */ WP(w, fnd_d).index = 0; WP(w, fnd_d).select = _fund_gui.index[0]; - WP(w, fnd_d).callback_timer = DAY_TICKS; + WP(w, fnd_d).callback_timer = DAY_BASE; } break; case WE_PAINT: { @@ -328,7 +328,7 @@ if (--WP(w, fnd_d).callback_timer == 0) { /* We have just passed another day. * See if we need to update availability of currently selected industry */ - WP(w, fnd_d).callback_timer = DAY_TICKS; //restart counter + WP(w, fnd_d).callback_timer = DAY_BASE; //restart counter const IndustrySpec *indsp = GetIndustrySpec(WP(w, fnd_d).select); Index: src/lang/english.txt =================================================================== --- src/lang/english.txt (revision 10753) +++ src/lang/english.txt (working copy) @@ -1176,6 +1176,10 @@ STR_CONFIG_PATCHES_LARGER_TOWNS_DISABLED :{LTBLUE}Proportion of towns that will become cities: {ORANGE}None STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER :{LTBLUE}Initial city size multiplier: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_DAYLENGTH :{LTBLUE}Daylength factor: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_DAYLENGTH_VRCFACTOR :{LTBLUE}Daylength affects vehicle running costs +STR_CONFIG_PATCHES_DAYLENGTH_ECONOMY :{LTBLUE}Daylength affects cargo payment rates + STR_CONFIG_PATCHES_GUI :{BLACK}Interface STR_CONFIG_PATCHES_CONSTRUCTION :{BLACK}Construction STR_CONFIG_PATCHES_VEHICLES :{BLACK}Vehicles Index: src/network/network.cpp =================================================================== --- src/network/network.cpp (revision 10753) +++ src/network/network.cpp (working copy) @@ -207,11 +207,11 @@ uint NetworkCalculateLag(const NetworkTCPSocketHandler *cs) { int lag = cs->last_frame_server - cs->last_frame; - // This client has missed his ACK packet after 1 DAY_TICKS.. + // This client has missed his ACK packet after 1 DAY_BASE.. // so we increase his lag for every frame that passes! // The packet can be out by a max of _net_frame_freq - if (cs->last_frame_server + DAY_TICKS + _network_frame_freq < _frame_counter) - lag += _frame_counter - (cs->last_frame_server + DAY_TICKS + _network_frame_freq); + if (cs->last_frame_server + DAY_BASE + _network_frame_freq < _frame_counter) + lag += _frame_counter - (cs->last_frame_server + DAY_BASE + _network_frame_freq); return lag; } Index: src/network/network.h =================================================================== --- src/network/network.h (revision 10753) +++ src/network/network.h (working copy) @@ -3,7 +3,7 @@ #ifndef NETWORK_H #define NETWORK_H -#define NOREV_STRING "norev000" +#define NOREV_STRING "r10753-daypatch" #ifdef ENABLE_NETWORK Index: src/network/network_client.cpp =================================================================== --- src/network/network_client.cpp (revision 10753) +++ src/network/network_client.cpp (working copy) @@ -599,7 +599,7 @@ // Let the server know that we received this frame correctly // We do this only once per day, to save some bandwidth ;) if (!_network_first_time && last_ack_frame < _frame_counter) { - last_ack_frame = _frame_counter + DAY_TICKS; + last_ack_frame = _frame_counter + DAY_BASE; DEBUG(net, 4, "Sent ACK at %d", _frame_counter); SEND_COMMAND(PACKET_CLIENT_ACK)(); } Index: src/network/network_server.cpp =================================================================== --- src/network/network_server.cpp (revision 10753) +++ src/network/network_server.cpp (working copy) @@ -1002,7 +1002,7 @@ /* The client is trying to catch up with the server */ if (cs->status == STATUS_PRE_ACTIVE) { /* The client is not yet catched up? */ - if (frame + DAY_TICKS < _frame_counter) return; + if (frame + DAY_BASE < _frame_counter) return; /* Now he is! Unpause the game */ cs->status = STATUS_ACTIVE; @@ -1523,7 +1523,7 @@ // Check if the speed of the client is what we can expect from a client if (cs->status == STATUS_ACTIVE) { // 1 lag-point per day - int lag = NetworkCalculateLag(cs) / DAY_TICKS; + int lag = NetworkCalculateLag(cs) / DAY_BASE; if (lag > 0) { if (lag > 3) { // Client did still not report in after 4 game-day, drop him @@ -1549,8 +1549,8 @@ } } else if (cs->status == STATUS_INACTIVE) { int lag = NetworkCalculateLag(cs); - if (lag > 4 * DAY_TICKS) { - IConsolePrintF(_icolour_err,"Client #%d is dropped because it took longer than %d ticks to start the joining process", cs->index, 4 * DAY_TICKS); + if (lag > 4 * DAY_BASE) { + IConsolePrintF(_icolour_err,"Client #%d is dropped because it took longer than %d ticks to start the joining process", cs->index, 4 * DAY_BASE); NetworkCloseClient(cs); } } Index: src/players.cpp =================================================================== --- src/players.cpp (revision 10753) +++ src/players.cpp (working copy) @@ -504,7 +504,7 @@ void StartupPlayers() { /* The AI starts like in the setting with +2 month max */ - _next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1; + _next_competitor_start = _opt.diff.competitor_start_time * 90 * Daylength() + RandomRange(60 * Daylength()) + 1; } static void MaybeStartNewPlayer() @@ -530,8 +530,8 @@ } /* The next AI starts like the difficulty setting said, with +2 month max */ - _next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + 1; - _next_competitor_start += _network_server ? InteractiveRandomRange(60 * DAY_TICKS) : RandomRange(60 * DAY_TICKS); + _next_competitor_start = _opt.diff.competitor_start_time * 90 * Daylength() + 1; + _next_competitor_start += _network_server ? InteractiveRandomRange(60 * Daylength()) : RandomRange(60 * Daylength()); } void InitializePlayers() Index: src/roadveh_cmd.cpp =================================================================== --- src/roadveh_cmd.cpp (revision 10753) +++ src/roadveh_cmd.cpp (working copy) @@ -1970,7 +1970,7 @@ } } - cost = RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364; + cost = RoadVehInfo(v->engine_type)->running_cost * VehRunCostFactor() * _price.roadveh_running / 364; v->profit_this_year -= cost.GetCost() >> 8; Index: src/roadveh_gui.cpp =================================================================== --- src/roadveh_gui.cpp (revision 10753) +++ src/roadveh_gui.cpp (working copy) @@ -91,7 +91,7 @@ SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); SetDParam(2, v->max_age / 366); - SetDParam(3, RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running >> 8); + SetDParam(3, RoadVehInfo(v->engine_type)->running_cost * VehRunCostFactor() * _price.roadveh_running >> 8); DrawString(2, 15, STR_900D_AGE_RUNNING_COST_YR, 0); } Index: src/saveload.cpp =================================================================== --- src/saveload.cpp (revision 10753) +++ src/saveload.cpp (working copy) @@ -30,7 +30,7 @@ #include #include -extern const uint16 SAVEGAME_VERSION = 72; +extern const uint16 SAVEGAME_VERSION = 73; uint16 _sl_version; ///< the major savegame version identifier byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! Index: src/settings.cpp =================================================================== --- src/settings.cpp (revision 10753) +++ src/settings.cpp (working copy) @@ -1432,6 +1432,8 @@ SDT_CONDVAR(Patches, town_growth_rate, SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0, 4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH, NULL), SDT_CONDVAR(Patches, larger_towns, SLE_UINT8, 54, SL_MAX_VERSION, 0, D0, 4, 0, 255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS, NULL), SDT_CONDVAR(Patches, initial_city_size, SLE_UINT8, 56, SL_MAX_VERSION, 0, 0, 2, 1, 10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER, NULL), + SDT_CONDVAR(Patches, daylength, SLE_UINT8, 73, SL_MAX_VERSION, 0, NC, 1, 1, 30, 1, STR_CONFIG_PATCHES_DAYLENGTH, NULL), + SDT_CONDBOOL(Patches, daylength_vrcfactor, 73, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_DAYLENGTH_VRCFACTOR, NULL), /***************************************************************************/ /* AI section of the GUI-configure patches window */ Index: src/settings_gui.cpp =================================================================== --- src/settings_gui.cpp (revision 10753) +++ src/settings_gui.cpp (working copy) @@ -698,6 +698,8 @@ "town_growth_rate", "larger_towns", "initial_city_size", + "daylength", + "daylength_vrcfactor", }; static const char *_patches_ai[] = { Index: src/ship_cmd.cpp =================================================================== --- src/ship_cmd.cpp (revision 10753) +++ src/ship_cmd.cpp (working copy) @@ -190,7 +190,7 @@ if (v->vehstatus & VS_STOPPED) return; - cost.AddCost(GetVehicleProperty(v, 0x0F, ShipVehInfo(v->engine_type)->running_cost) * _price.ship_running / 364); + cost.AddCost(GetVehicleProperty(v, 0x0F, ShipVehInfo(v->engine_type)->running_cost) * VehRunCostFactor() * _price.ship_running / 364); v->profit_this_year -= cost.GetCost() >> 8; SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN); Index: src/ship_gui.cpp =================================================================== --- src/ship_gui.cpp (revision 10753) +++ src/ship_gui.cpp (working copy) @@ -50,7 +50,7 @@ SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); SetDParam(2, v->max_age / 366); - SetDParam(3, ShipVehInfo(v->engine_type)->running_cost * _price.ship_running >> 8); + SetDParam(3, ShipVehInfo(v->engine_type)->running_cost * VehRunCostFactor() * _price.ship_running >> 8); DrawString(2, 15, STR_9812_AGE_RUNNING_COST_YR, 0); } Index: src/station_gui.cpp =================================================================== --- src/station_gui.cpp (revision 10753) +++ src/station_gui.cpp (working copy) @@ -268,7 +268,7 @@ _last_station = NULL; // used for "cache" in namesorting qsort((void*)sl->sort_list, sl->list_length, sizeof(sl->sort_list[0]), _station_sorter[sl->sort_type]); - sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + sl->resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; sl->flags &= ~SL_RESORT; } @@ -299,7 +299,7 @@ sl->flags = SL_REBUILD; sl->sort_type = station_sort.criteria; if (station_sort.order) sl->flags |= SL_ORDER; - sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + sl->resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; break; case WE_PAINT: { @@ -521,7 +521,7 @@ case WE_TICK: if (--sl->resort_timer == 0) { DEBUG(misc, 3, "Periodic rebuild station list player %d", owner); - sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + sl->resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; sl->flags |= SL_REBUILD; SetWindowDirty(w); } Index: src/timetable_cmd.cpp =================================================================== --- src/timetable_cmd.cpp (revision 10753) +++ src/timetable_cmd.cpp (working copy) @@ -160,7 +160,7 @@ /* Round the time taken up to the nearest day, as this will avoid * confusion for people who are timetabling in days, and can be * adjusted later by people who aren't. */ - time_taken = (((time_taken - 1) / DAY_TICKS) + 1) * DAY_TICKS; + time_taken = (((time_taken - 1) / Daylength()) + 1) * Daylength(); ChangeTimetable(v, v->cur_order_index, time_taken, travelling); return; Index: src/timetable_gui.cpp =================================================================== --- src/timetable_gui.cpp (revision 10753) +++ src/timetable_gui.cpp (working copy) @@ -41,7 +41,7 @@ SetDParam(param2, time); } else { SetDParam(param1, STR_TIMETABLE_DAYS); - SetDParam(param2, time / DAY_TICKS); + SetDParam(param2, time / Daylength()); } } @@ -191,7 +191,7 @@ } y += 10; - if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) { + if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / Daylength() == 0)) { DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, 0x10); } else { SetTimetableParams(0, 1, abs(v->lateness_counter)); @@ -243,7 +243,7 @@ if (order != NULL) { uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time; - if (!_patches.timetable_in_ticks) time /= DAY_TICKS; + if (!_patches.timetable_in_ticks) time /= Daylength(); if (time != 0) { SetDParam(0, time); @@ -277,7 +277,7 @@ uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel); uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10); - if (!_patches.timetable_in_ticks) time *= DAY_TICKS; + if (!_patches.timetable_in_ticks) time *= Daylength(); uint32 p2 = minu(time, MAX_UVALUE(uint16)); Index: src/train_cmd.cpp =================================================================== --- src/train_cmd.cpp (revision 10753) +++ src/train_cmd.cpp (working copy) @@ -3395,7 +3395,7 @@ byte cost_factor = GetVehicleProperty(v, 0x0D, rvi->running_cost_base); if (cost_factor == 0) continue; - cost += cost_factor * _price.running_rail[rvi->running_cost_class]; + cost += cost_factor * VehRunCostFactor() * _price.running_rail[rvi->running_cost_class]; } while ((v = GetNextVehicle(v)) != NULL); return cost; Index: src/variables.h =================================================================== --- src/variables.h (revision 10753) +++ src/variables.h (working copy) @@ -10,6 +10,7 @@ /* ********* START OF SAVE REGION */ #include "gfx.h" +#include "date.h" /* Prices and also the fractional part. */ VARDEF Prices _price; @@ -238,6 +239,9 @@ bool timetabling; ///< Whether to allow timetabling. bool timetable_in_ticks; ///< Whether to show the timetable in ticks rather than days. + + byte daylength; ///< Allows to set the daylength in seconds. + bool daylength_vrcfactor; ///< Wheter daylength has an effect on vehicle running costs or not. }; VARDEF Patches _patches; @@ -340,4 +344,11 @@ /* Forking stuff */ VARDEF bool _dedicated_forks; +/* Daylength Patch Version 3 + * Daylength can be set in 2,22 seconds steps (74 * 30 = 2220ms if the machine runs OpenTTD at normal speed) + * Vehicle running costs will be adjusted with a factor equal to the daylength if desired + */ +static inline uint16 Daylength() { return DAY_BASE * _patches.daylength; } +static inline uint16 VehRunCostFactor() { return _patches.daylength_vrcfactor ? _patches.daylength : 1; } + #endif /* VARIABLES_H */ Index: src/vehicle_gui.cpp =================================================================== --- src/vehicle_gui.cpp (revision 10753) +++ src/vehicle_gui.cpp (working copy) @@ -146,7 +146,7 @@ qsort((void*)vl->sort_list, vl->l.list_length, sizeof(vl->sort_list[0]), _vehicle_sorter[vl->l.sort_type]); - vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + vl->l.resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; vl->l.flags &= ~VL_RESORT; } @@ -903,7 +903,7 @@ vl->l.flags = VL_REBUILD | (vl->_sorting->order ? VL_DESC : VL_NONE); vl->l.sort_type = vl->_sorting->criteria; vl->sort_list = NULL; - vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer + vl->l.resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; // Set up resort timer } void DrawSmallOrderList(const Vehicle *v, int x, int y) @@ -1170,7 +1170,7 @@ PlayerID owner = (PlayerID)w->caption_color; DEBUG(misc, 3, "Periodic resort %d list player %d at station %d", vl->vehicle_type, owner, station); - vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + vl->l.resort_timer = DAY_BASE * PERIODIC_RESORT_DAYS; vl->l.flags |= VL_RESORT; SetWindowDirty(w); }