(svn r22482) -Codechange: Add some contants for the number of ticks between certain cyclical tasks.

pull/155/head
frosch 13 years ago
parent f761b7249c
commit 62b6d0eb0e

@ -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.
*/

@ -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

@ -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;

@ -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);

@ -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.

@ -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] = {

@ -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();

Loading…
Cancel
Save