Index: ai/trolly/trolly.c =================================================================== --- ai/trolly/trolly.c (revision 7622) +++ ai/trolly/trolly.c (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_TICKS/_patches.day_length) * 2) + (DAY_TICKS/_patches.day_length); if (--p->ainew.idle == 0) { // We are done idling.. what you say? Let's do something! // I mean.. the next tick ;) @@ -877,7 +877,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_TICKS/_patches.day_length) / 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; @@ -893,7 +893,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_TICKS/_patches.day_length) / 256 / 16; if (p->ainew.from_deliver) { max_cargo = GetIndustry(p->ainew.from_ic)->total_production[0]; } else { Index: ai/trolly/trolly.h =================================================================== --- ai/trolly/trolly.h (revision 7622) +++ 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_TICKS/_patches.day_length) // How many days must there between vehicle checks // The more often, the less non-money-making lines there will be Index: aircraft_cmd.c =================================================================== --- aircraft_cmd.c (revision 7622) +++ aircraft_cmd.c (working copy) @@ -708,7 +708,7 @@ if (v->vehstatus & VS_STOPPED) return; - cost = AircraftVehInfo(v->engine_type)->running_cost * _price.aircraft_running / 364; + cost = AircraftVehInfo(v->engine_type)->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.aircraft_running / 364; v->profit_this_year -= cost >> 8; Index: build_vehicle_gui.c =================================================================== --- build_vehicle_gui.c (revision 7622) +++ build_vehicle_gui.c (working copy) @@ -230,7 +230,7 @@ y += 10; /* Running cost */ - SetDParam(0, avi->running_cost * _price.aircraft_running >> 8); + SetDParam(0, avi->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.aircraft_running >> 8); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; Index: date.c =================================================================== --- date.c (revision 7622) +++ date.c (working copy) @@ -199,7 +199,7 @@ uint total = GetMaxVehicleIndex() + 1; uint i; - for (i = daytick; i < total; i += DAY_TICKS) { + for (i = daytick; i < total; i += (DAY_TICKS*_patches.day_length)) { Vehicle *v = GetVehicle(i); if (IsValidVehicle(v)) _on_new_vehicle_day_proc[v->type - 0x10](v); @@ -221,7 +221,7 @@ _tick_counter++; _date_fract++; - if (_date_fract < DAY_TICKS) return; + if (_date_fract < (DAY_TICKS*_patches.day_length)) return; _date_fract = 0; /* yeah, increase day counter and call various daily loops */ Index: engine_gui.c =================================================================== --- engine_gui.c (revision 7622) +++ engine_gui.c (working copy) @@ -128,7 +128,7 @@ SetDParam(3, rvi->power << multihead); SetDParam(1, rvi->weight << multihead); - SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8 << multihead); + SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] * (_patches.daylength_affect_economy?_patches.day_length:1) >> 8 << multihead); if (rvi->capacity != 0) { SetDParam(5, rvi->cargo_type); @@ -175,7 +175,7 @@ SetDParam(1, avi->max_speed * 128 / 10); SetDParam(2, avi->passenger_capacity); SetDParam(3, avi->mail_capacity); - SetDParam(4, avi->running_cost * _price.aircraft_running >> 8); + SetDParam(4, avi->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.aircraft_running >> 8); DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw); } @@ -213,7 +213,7 @@ SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5); SetDParam(1, rvi->max_speed / 2); - SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8); + SetDParam(2, rvi->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.roadveh_running >> 8); SetDParam(3, rvi->cargo_type); SetDParam(4, rvi->capacity); @@ -253,7 +253,7 @@ SetDParam(1, svi->max_speed / 2); SetDParam(2, svi->cargo_type); SetDParam(3, svi->capacity); - SetDParam(4, svi->running_cost * _price.ship_running >> 8); + SetDParam(4, svi->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.ship_running >> 8); DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw); } Index: graph_gui.c =================================================================== --- graph_gui.c (revision 7622) +++ graph_gui.c (working copy) @@ -1051,7 +1051,7 @@ if (p2->is_active) UpdateCompanyRatingAndValue(p2, false); } - w->custom[0] = DAY_TICKS; + w->custom[0] = (DAY_TICKS/_patches.day_length); w->custom[1] = 5; _performance_rating_detail_player = 0; @@ -1064,7 +1064,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_TICKS/_patches.day_length); if (--w->custom[1] == 0) { Player *p2; Index: lang/english.txt =================================================================== --- lang/english.txt (revision 7622) +++ lang/english.txt (working copy) @@ -1123,6 +1123,8 @@ STR_CONFIG_PATCHES_TOOLBAR_POS_RIGHT :Right STR_CONFIG_PATCHES_SNAP_RADIUS :{LTBLUE}Window snap radius: {ORANGE}{STRING1} px STR_CONFIG_PATCHES_SNAP_RADIUS_DISABLED :{LTBLUE}Window snap radius: {ORANGE}disabled +STR_CONFIG_PATCHES_DAY_LENGTH :{LTBLUE}Default day length: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_DAY_LENGTH_ECONOMY :{LTBLUE}Day length affect economy: {ORANGE}{STRING1} STR_CONFIG_PATCHES_GUI :{BLACK}Interface STR_CONFIG_PATCHES_CONSTRUCTION :{BLACK}Construction Index: network.c =================================================================== --- network.c (revision 7622) +++ network.c (working copy) @@ -121,7 +121,7 @@ { char buf[1024]; va_list va; - const int duration = 10; // Game days the messages stay visible + const int duration = 10/_patches.day_length; // Game days the messages stay visible char message[1024]; char temp[1024]; @@ -188,11 +188,11 @@ uint NetworkCalculateLag(const NetworkClientState *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_TICKS/_patches.day_length).. // 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_TICKS/_patches.day_length) + _network_frame_freq < _frame_counter) + lag += _frame_counter - (cs->last_frame_server + (DAY_TICKS/_patches.day_length) + _network_frame_freq); return lag; } Index: network_client.c =================================================================== --- network_client.c (revision 7622) +++ network_client.c (working copy) @@ -548,7 +548,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_TICKS/_patches.day_length); DEBUG(net, 4, "Sent ACK at %d", _frame_counter); SEND_COMMAND(PACKET_CLIENT_ACK)(); } Index: network_server.c =================================================================== --- network_server.c (revision 7622) +++ network_server.c (working copy) @@ -950,7 +950,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_TICKS/_patches.day_length) < _frame_counter) return; /* Now he is! Unpause the game */ cs->status = STATUS_ACTIVE; @@ -1470,7 +1470,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_TICKS/_patches.day_length); if (lag > 0) { if (lag > 3) { // Client did still not report in after 4 game-day, drop him Index: roadveh_cmd.c =================================================================== --- roadveh_cmd.c (revision 7622) +++ roadveh_cmd.c (working copy) @@ -1716,7 +1716,7 @@ } } - cost = RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364; + cost = RoadVehInfo(v->engine_type)->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.roadveh_running / 364; v->profit_this_year -= cost >> 8; Index: roadveh_gui.c =================================================================== --- roadveh_gui.c (revision 7622) +++ roadveh_gui.c (working copy) @@ -42,7 +42,7 @@ y += 10; /* Running cost */ - SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8); + SetDParam(0, rvi->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.roadveh_running >> 8); DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; @@ -103,7 +103,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 * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.roadveh_running >> 8); DrawString(2, 15, STR_900D_AGE_RUNNING_COST_YR, 0); } @@ -545,3 +545,7 @@ } + + + + Index: saveload.c =================================================================== --- saveload.c (revision 7622) +++ saveload.c (working copy) @@ -30,7 +30,7 @@ #include "variables.h" #include -const uint16 SAVEGAME_VERSION = 42; +const uint16 SAVEGAME_VERSION = 43; uint16 _sl_version; /// the major savegame version identifier byte _sl_minor_version; /// the minor savegame version, DO NOT USE! Index: settings.c =================================================================== --- settings.c (revision 7622) +++ settings.c (working copy) @@ -1351,6 +1351,8 @@ SDT_VAR(Patches, ending_year, SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR, 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_CONDVAR(Patches, day_length, SLE_UINT8, 43, SL_MAX_VERSION, 0, 0, 1, 1, 32, 1, STR_CONFIG_PATCHES_DAY_LENGTH, NULL), + SDT_CONDBOOL(Patches, daylength_affect_economy, 43, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_DAY_LENGTH_ECONOMY, NULL), /***************************************************************************/ /* AI section of the GUI-configure patches window */ Index: settings_gui.c =================================================================== --- settings_gui.c (revision 7622) +++ settings_gui.c (working copy) @@ -608,6 +608,8 @@ "ending_year", "smooth_economy", "allow_shares", + "day_length", + "daylength_affect_economy", }; static const char *_patches_ai[] = { Index: ship_cmd.c =================================================================== --- ship_cmd.c (revision 7622) +++ ship_cmd.c (working copy) @@ -151,7 +151,7 @@ if (v->vehstatus & VS_STOPPED) return; - cost = ShipVehInfo(v->engine_type)->running_cost * _price.ship_running / 364; + cost = ShipVehInfo(v->engine_type)->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.ship_running / 364; v->profit_this_year -= cost >> 8; SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN); Index: ship_gui.c =================================================================== --- ship_gui.c (revision 7622) +++ ship_gui.c (working copy) @@ -47,7 +47,7 @@ y += 10; /* Running cost */ - SetDParam(0, svi->running_cost * _price.ship_running >> 8); + SetDParam(0, svi->running_cost * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.ship_running >> 8); DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0); y += 10; @@ -102,7 +102,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 * (_patches.daylength_affect_economy?_patches.day_length:1) * _price.ship_running >> 8); DrawString(2, 15, STR_9812_AGE_RUNNING_COST_YR, 0); } Index: station_gui.c =================================================================== --- station_gui.c (revision 7622) +++ station_gui.c (working copy) @@ -254,7 +254,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_TICKS*_patches.day_length) * PERIODIC_RESORT_DAYS; sl->flags &= ~SL_RESORT; } @@ -281,7 +281,7 @@ sl->sort_list = NULL; sl->flags = SL_REBUILD; sl->sort_type = 0; - sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; + sl->resort_timer = (DAY_TICKS*_patches.day_length) * PERIODIC_RESORT_DAYS; break; } @@ -476,7 +476,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_TICKS*_patches.day_length) * PERIODIC_RESORT_DAYS; sl->flags |= VL_REBUILD; SetWindowDirty(w); } Index: train_cmd.c =================================================================== --- train_cmd.c (revision 7622) +++ train_cmd.c (working copy) @@ -3206,12 +3206,12 @@ v->cur_speed = 0; v->subspeed = 0; v->progress = 255 - 100; - if (++v->load_unload_time_rem < _patches.wait_oneway_signal * 20) return; + if (++v->load_unload_time_rem < _patches.wait_oneway_signal * 20 * _patches.day_length) return; } else if (HasSignalOnTrackdir(gp.new_tile, i)){ v->cur_speed = 0; v->subspeed = 0; v->progress = 255-10; - if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) { + if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73 * _patches.day_length) { TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir); VehicleAtSignalData vasd; vasd.tile = o_tile; Index: variables.h =================================================================== --- variables.h (revision 7622) +++ variables.h (working copy) @@ -216,6 +216,9 @@ uint8 freight_trains; ///< Value to multiply the weight of cargo by + uint8 day_length; //Multiplier for the length of one day + bool daylength_affect_economy; + /** YAPF settings */ YapfSettings yapf;