Index: src/aircraft_cmd.cpp =================================================================== --- src/aircraft_cmd.cpp (revision 11039) +++ src/aircraft_cmd.cpp (working copy) @@ -730,9 +730,10 @@ CheckIfAircraftNeedsService(v); if (v->vehstatus & VS_STOPPED) return; + + /* running costs */ + CommandCost cost(v->GetRunningCost() * VehRunCostFactor() / 364); - CommandCost cost = CommandCost(GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364); - v->profit_this_year -= cost.GetCost() >> 8; SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN); Index: src/build_vehicle_gui.cpp =================================================================== --- src/build_vehicle_gui.cpp (revision 11039) +++ 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 11039) +++ 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 (v->IsValid()) _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 11039) +++ src/date.h (working copy) @@ -6,6 +6,7 @@ #define DATE_H #include "openttd.h" +#include "variables.h" /** * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On @@ -55,6 +56,8 @@ extern Date _date; extern DateFract _date_fract; +/* This function is used to set the daylength */ +static inline uint16 DayLength() { return DAY_TICKS * _patches.daylength; } void SetDate(Date date); void ConvertDateToYMD(Date date, YearMonthDay *ymd); Index: src/lang/english.txt =================================================================== --- src/lang/english.txt (revision 11039) +++ src/lang/english.txt (working copy) @@ -1181,6 +1181,9 @@ 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_GUI :{BLACK}Interface STR_CONFIG_PATCHES_CONSTRUCTION :{BLACK}Construction STR_CONFIG_PATCHES_VEHICLES :{BLACK}Vehicles Index: src/players.cpp =================================================================== --- src/players.cpp (revision 11039) +++ 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 11039) +++ src/roadveh_cmd.cpp (working copy) @@ -1878,8 +1878,6 @@ void OnNewDay_RoadVeh(Vehicle *v) { - CommandCost cost; - if (!IsRoadVehFront(v)) return; if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v); @@ -1958,12 +1956,13 @@ } } - cost = RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364; + /* running costs */ + CommandCost cost(v->GetRunningCost() * VehRunCostFactor() / 364); v->profit_this_year -= cost.GetCost() >> 8; SET_EXPENSES_TYPE(EXPENSES_ROADVEH_RUN); - SubtractMoneyFromPlayerFract(v->owner, CommandCost(cost)); + SubtractMoneyFromPlayerFract(v->owner, cost); InvalidateWindow(WC_VEHICLE_DETAILS, v->index); InvalidateWindowClasses(WC_ROADVEH_LIST); Index: src/saveload.cpp =================================================================== --- src/saveload.cpp (revision 11039) +++ src/saveload.cpp (working copy) @@ -29,7 +29,7 @@ #include "strings.h" #include -extern const uint16 SAVEGAME_VERSION = 74; +extern const uint16 SAVEGAME_VERSION = 75; 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 11039) +++ src/settings.cpp (working copy) @@ -1436,6 +1436,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, 75, SL_MAX_VERSION, 0, NC, 1, 1, 30, 1, STR_CONFIG_PATCHES_DAYLENGTH, NULL), + SDT_CONDBOOL(Patches, daylength_vrcfactor, 75, 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 11039) +++ src/settings_gui.cpp (working copy) @@ -702,6 +702,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 11039) +++ src/ship_cmd.cpp (working copy) @@ -166,8 +166,6 @@ void OnNewDay_Ship(Vehicle *v) { - CommandCost cost; - if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v); @@ -179,11 +177,13 @@ if (v->vehstatus & VS_STOPPED) return; - cost.AddCost(GetVehicleProperty(v, 0x0F, ShipVehInfo(v->engine_type)->running_cost) * _price.ship_running / 364); + /* running costs */ + CommandCost cost(v->GetRunningCost() * VehRunCostFactor() / 364); + v->profit_this_year -= cost.GetCost() >> 8; SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN); - SubtractMoneyFromPlayerFract(v->owner, CommandCost(cost)); + SubtractMoneyFromPlayerFract(v->owner, cost); InvalidateWindow(WC_VEHICLE_DETAILS, v->index); /* we need this for the profit */ Index: src/timetable_cmd.cpp =================================================================== --- src/timetable_cmd.cpp (revision 11039) +++ src/timetable_cmd.cpp (working copy) @@ -159,8 +159,11 @@ if (timetabled == 0) { /* 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; + * adjusted later by people who aren't. + * Rounding is only done when daylength is set to 1 and thus days are very short. */ + if (_patches.daylength == 1) { + time_taken = (((time_taken - 1) / DAY_TICKS) + 1) * DAY_TICKS; + } ChangeTimetable(v, v->cur_order_index, time_taken, travelling); return; Index: src/timetable_gui.cpp =================================================================== --- src/timetable_gui.cpp (revision 11039) +++ src/timetable_gui.cpp (working copy) @@ -36,7 +36,7 @@ static inline void SetTimetableParams(int param1, int param2, uint32 time) { - if (_patches.timetable_in_ticks) { + if (_patches.timetable_in_ticks || _patches.daylength > 1) { SetDParam(param1, STR_TIMETABLE_TICKS); SetDParam(param2, time); } else { Index: src/train_cmd.cpp =================================================================== --- src/train_cmd.cpp (revision 11039) +++ src/train_cmd.cpp (working copy) @@ -3403,7 +3403,7 @@ if ((v->vehstatus & VS_STOPPED) == 0) { /* running costs */ - CommandCost cost(v->GetRunningCost() / 364); + CommandCost cost(v->GetRunningCost() * VehRunCostFactor() / 364); v->profit_this_year -= cost.GetCost() >> 8; Index: src/variables.h =================================================================== --- src/variables.h (revision 11039) +++ src/variables.h (working copy) @@ -240,6 +240,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. + bool daylength_vrcfactor; ///< Wheter daylength has an effect on vehicle running costs or not. }; VARDEF Patches _patches; Index: src/vehicle.h =================================================================== --- src/vehicle.h (revision 11039) +++ src/vehicle.h (working copy) @@ -11,6 +11,7 @@ #include "road.h" #include "cargopacket.h" #include "texteff.hpp" +#include "variables.h" /** The returned bits of VehicleEnterTile. */ enum VehicleEnterTileStatus { @@ -215,6 +216,12 @@ TrackBitsByte state; }; +/* Function to determine correct vehicle running costs depending on daylength */ +static inline uint16 VehRunCostFactor() +{ + return _patches.daylength_vrcfactor ? _patches.daylength : 1; +} + struct Vehicle; DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125) @@ -463,7 +470,7 @@ * Gets the running cost of a vehicle that can be sent into SetDParam for string processing. * @return the vehicle's running cost */ - Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); } + Money GetDisplayRunningCost() const { return (this->GetRunningCost() * VehRunCostFactor() >> 8); } /** * Is this vehicle a valid vehicle?