Change: Switch town growth rate and counter to actual game ticks (#6763)

This commit is contained in:
Pavel Stupnikov
2018-05-02 22:01:30 +03:00
committed by frosch
parent 61515c9abd
commit fef8b831a9
8 changed files with 68 additions and 37 deletions

View File

@@ -35,8 +35,8 @@ static const uint INVALID_TOWN = 0xFFFF;
static const uint TOWN_GROWTH_WINTER = 0xFFFFFFFE; ///< The town only needs this cargo in the winter (any amount)
static const uint TOWN_GROWTH_DESERT = 0xFFFFFFFF; ///< The town needs the cargo for growth when on desert (any amount)
static const uint16 TOWN_GROW_RATE_CUSTOM = 0x8000; ///< If this mask is applied to Town::growth_rate, the grow_counter will not be calculated by the system (but assumed to be set by scripts)
static const uint16 TOWN_GROW_RATE_CUSTOM_NONE = 0xFFFF; ///< Special value for Town::growth_rate to disable town growth.
static const uint16 TOWN_GROWTH_RATE_NONE = 0xFFFF; ///< Special value for Town::growth_rate to disable town growth.
static const uint16 MAX_TOWN_GROWTH_TICKS = 930; ///< Max amount of original town ticks that still fit into uint16, about equal to UINT16_MAX / TOWN_GROWTH_TICKS but sligtly less to simplify calculations
typedef Pool<Town, TownID, 64, 64000> TownPool;
extern TownPool _town_pool;
@@ -165,6 +165,7 @@ enum TownFlags {
TOWN_IS_GROWING = 0, ///< Conditions for town growth are met. Grow according to Town::growth_rate.
TOWN_HAS_CHURCH = 1, ///< There can be only one church by town.
TOWN_HAS_STADIUM = 2, ///< There can be only one stadium by town.
TOWN_CUSTOM_GROWTH = 3, ///< Growth rate is controlled by GS.
};
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type);
@@ -194,7 +195,6 @@ uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t);
bool GenerateTowns(TownLayout layout);
const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect);
/** Town actions of a company. */
enum TownActions {
TACT_NONE = 0x00, ///< Empty action set.
@@ -284,6 +284,15 @@ void MakeDefaultName(T *obj)
obj->town_cn = (uint16)next; // set index...
}
/*
* Converts original town ticks counters to plain game ticks. Note that
* tick 0 is a valid tick so actual amount is one more than the counter value.
*/
static inline uint16 TownTicksToGameTicks(uint16 ticks) {
return (min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * TOWN_GROWTH_TICKS - 1;
}
extern uint32 _town_cargoes_accepted;
#endif /* TOWN_H */