summaryrefslogtreecommitdiff
path: root/src/town.h
diff options
context:
space:
mode:
authorPavel Stupnikov <dp@dpointer.org>2018-05-02 22:01:30 +0300
committerfrosch <github@elsenhans.name>2018-05-02 21:01:30 +0200
commitfef8b831a93a0fc772fc8a0b7799ec51cd86a967 (patch)
tree327b1463e2d0828bb5d5036370517c3abdc77709 /src/town.h
parent61515c9abd6fb31e24c5fd610a9f6b3a899c7171 (diff)
downloadopenttd-fef8b831a93a0fc772fc8a0b7799ec51cd86a967.tar.xz
Change: Switch town growth rate and counter to actual game ticks (#6763)
Diffstat (limited to 'src/town.h')
-rw-r--r--src/town.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/town.h b/src/town.h
index 010c7c216..75deb7cca 100644
--- a/src/town.h
+++ b/src/town.h
@@ -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 */