From 474b4799e8792d4b4bd00aee512327c682796d66 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 21 May 2011 11:26:37 +0000 Subject: (svn r22482) -Codechange: Add some contants for the number of ticks between certain cyclical tasks. --- src/cargopacket.h | 2 +- src/date_type.h | 7 +++++++ src/industry_cmd.cpp | 2 +- src/station_cmd.cpp | 6 +++--- src/town.h | 7 ------- src/town_cmd.cpp | 4 ++-- src/vehicle.cpp | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cargopacket.h b/src/cargopacket.h index 0f2e46177..1e3008475 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -86,7 +86,7 @@ public: /** * Gets the number of days this cargo has been in transit. - * This number isn't really in days, but in 2.5 days (185 ticks) and + * This number isn't really in days, but in 2.5 days (CARGO_AGING_TICKS = 185 ticks) and * it is capped at 255. * @return Length this cargo has been in transit. */ diff --git a/src/date_type.h b/src/date_type.h index 4930979cd..bff1d6577 100644 --- a/src/date_type.h +++ b/src/date_type.h @@ -31,6 +31,13 @@ static const int DAY_TICKS = 74; ///< ticks per day static const int DAYS_IN_YEAR = 365; ///< days per year static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more... +static const int STATION_RATING_TICKS = 185; ///< cycle duration for updating station rating +static const int STATION_ACCEPTANCE_TICKS = 250; ///< cycle duration for updating station acceptance +static const int CARGO_AGING_TICKS = 185; ///< cycle duration for aging cargo +static const int INDUSTRY_PRODUCE_TICKS = 256; ///< cycle duration for industry production +static const int TOWN_GROWTH_TICKS = 70; ///< cycle duration for towns trying to grow. (this originates from the size of the town array in TTD + + /* * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are * primarily used for loading newgrf and savegame data and returning some diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 84b9ef931..dde262085 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1068,7 +1068,7 @@ static void ProduceIndustryGoods(Industry *i) i->counter--; /* produce some cargo */ - if ((i->counter & 0xFF) == 0) { + if ((i->counter % INDUSTRY_PRODUCE_TICKS) == 0) { if (HasBit(indsp->callback_mask, CBM_IND_PRODUCTION_256_TICKS)) IndustryProductionCallback(i, 1); IndustryBehaviour indbehav = indsp->behaviour; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 0f39e7211..7cd32972d 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3131,7 +3131,7 @@ static void StationHandleSmallTick(BaseStation *st) if ((st->facilities & FACIL_WAYPOINT) != 0 || !st->IsInUse()) return; byte b = st->delete_ctr + 1; - if (b >= 185) b = 0; + if (b >= STATION_RATING_TICKS) b = 0; st->delete_ctr = b; if (b == 0) UpdateStationRating(Station::From(st)); @@ -3145,10 +3145,10 @@ void OnTick_Station() FOR_ALL_BASE_STATIONS(st) { StationHandleSmallTick(st); - /* Run 250 tick interval trigger for station animation. + /* Run STATION_ACCEPTANCE_TICKS = 250 tick interval trigger for station animation. * Station index is included so that triggers are not all done * at the same time. */ - if ((_tick_counter + st->index) % 250 == 0) { + if ((_tick_counter + st->index) % STATION_ACCEPTANCE_TICKS == 0) { /* Stop processing this station if it was deleted */ if (!StationHandleBigTick(st)) continue; TriggerStationAnimation(st, st->xy, SAT_250_TICKS); diff --git a/src/town.h b/src/town.h index d2f0ba143..0f6229a89 100644 --- a/src/town.h +++ b/src/town.h @@ -163,13 +163,6 @@ enum TownRatingCheckType { TOWN_RATING_CHECK_TYPE_COUNT, ///< Number of town checking action types. }; -/** - * This is the number of ticks between towns being processed for building new - * houses or roads. This value originally came from the size of the town array - * in TTD. - */ -static const byte TOWN_GROWTH_FREQUENCY = 70; - /** * This enum is used in conjunction with town->flags. * IT simply states what bit is used for. diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index ddf86e1f7..e1c013a44 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -704,7 +704,7 @@ void OnTick_Town() Town *t; FOR_ALL_TOWNS(t) { /* Run town tick at regular intervals, but not all at once. */ - if ((_tick_counter + t->index) % TOWN_GROWTH_FREQUENCY == 0) { + if ((_tick_counter + t->index) % TOWN_GROWTH_TICKS == 0) { TownTickHandler(t); } } @@ -2737,7 +2737,7 @@ static void UpdateTownGrowRate(Town *t) if (_settings_game.economy.town_growth_rate == 0 && t->fund_buildings_months == 0) return; /** - * Towns are processed every TOWN_GROWTH_FREQUENCY ticks, and this is the + * Towns are processed every TOWN_GROWTH_TICKS ticks, and this is the * number of times towns are processed before a new building is built. */ static const uint16 _grow_count_values[2][6] = { diff --git a/src/vehicle.cpp b/src/vehicle.cpp index f2d391f23..41aebff10 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -801,7 +801,7 @@ void CallVehicleTicks() { _vehicles_to_autoreplace.Clear(); - _age_cargo_skip_counter = (_age_cargo_skip_counter == 0) ? 184 : (_age_cargo_skip_counter - 1); + _age_cargo_skip_counter = (_age_cargo_skip_counter == 0) ? CARGO_AGING_TICKS - 1 : (_age_cargo_skip_counter - 1); RunVehicleDayProc(); -- cgit v1.2.3-70-g09d2