author | truebrain |
Fri, 18 Jul 2008 10:15:16 +0000 | |
branch | noai |
changeset 11168 | 3842648184cd |
parent 11126 | 72d4c9314c72 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
3 |
/** @file town.h Base of the town class. */ |
9574 | 4 |
|
0 | 5 |
#ifndef TOWN_H |
6 |
#define TOWN_H |
|
7 |
||
5216
d581e4db95b6
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
4983
diff
changeset
|
8 |
#include "oldpool.h" |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
9 |
#include "core/bitmath_func.hpp" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
10 |
#include "core/random_func.hpp" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
11 |
#include "cargo_type.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
12 |
#include "tile_type.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
13 |
#include "date_type.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
14 |
#include "town_type.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
15 |
#include "player_type.h" |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
16 |
#include "settings_type.h" |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
9869
diff
changeset
|
17 |
#include "strings_type.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
18 |
#include "viewport_type.h" |
10867
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
19 |
#include "economy_type.h" |
0 | 20 |
|
5299
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
21 |
enum { |
9476 | 22 |
HOUSE_NO_CLASS = 0, |
23 |
NEW_HOUSE_OFFSET = 110, |
|
24 |
HOUSE_MAX = 512, |
|
25 |
INVALID_TOWN = 0xFFFF, |
|
26 |
INVALID_HOUSE_ID = 0xFFFF, |
|
27 |
||
28 |
/* There can only be as many classes as there are new houses, plus one for |
|
29 |
* NO_CLASS, as the original houses don't have classes. */ |
|
30 |
HOUSE_CLASS_MAX = HOUSE_MAX - NEW_HOUSE_OFFSET + 1, |
|
31 |
}; |
|
32 |
||
33 |
enum BuildingFlags { |
|
34 |
TILE_NO_FLAG = 0, |
|
35 |
TILE_SIZE_1x1 = 1U << 0, |
|
36 |
TILE_NOT_SLOPED = 1U << 1, |
|
37 |
TILE_SIZE_2x1 = 1U << 2, |
|
38 |
TILE_SIZE_1x2 = 1U << 3, |
|
39 |
TILE_SIZE_2x2 = 1U << 4, |
|
40 |
BUILDING_IS_ANIMATED = 1U << 5, |
|
41 |
BUILDING_IS_CHURCH = 1U << 6, |
|
42 |
BUILDING_IS_STADIUM = 1U << 7, |
|
43 |
BUILDING_HAS_1_TILE = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2, |
|
44 |
BUILDING_2_TILES_X = TILE_SIZE_2x1 | TILE_SIZE_2x2, |
|
45 |
BUILDING_2_TILES_Y = TILE_SIZE_1x2 | TILE_SIZE_2x2, |
|
46 |
BUILDING_HAS_4_TILES = TILE_SIZE_2x2, |
|
47 |
}; |
|
48 |
||
49 |
DECLARE_ENUM_AS_BIT_SET(BuildingFlags) |
|
50 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
51 |
enum HouseZonesBits { |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
52 |
HZB_BEGIN = 0, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
53 |
HZB_TOWN_EDGE = 0, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
54 |
HZB_TOWN_OUTSKIRT, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
55 |
HZB_TOWN_OUTER_SUBURB, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
56 |
HZB_TOWN_INNER_SUBURB, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
57 |
HZB_TOWN_CENTRE, |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
58 |
HZB_END, |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
59 |
}; |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
60 |
assert_compile(HZB_END == 5); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
61 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
62 |
DECLARE_POSTFIX_INCREMENT(HouseZonesBits) |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
63 |
|
9476 | 64 |
enum HouseZones { ///< Bit Value Meaning |
65 |
HZ_NOZNS = 0x0000, ///< 0 This is just to get rid of zeros, meaning none |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
66 |
HZ_ZON1 = 1U << HZB_TOWN_EDGE, ///< 0..4 1,2,4,8,10 which town zones the building can be built in, Zone1 been the further suburb |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
67 |
HZ_ZON2 = 1U << HZB_TOWN_OUTSKIRT, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
68 |
HZ_ZON3 = 1U << HZB_TOWN_OUTER_SUBURB, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
69 |
HZ_ZON4 = 1U << HZB_TOWN_INNER_SUBURB, |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
70 |
HZ_ZON5 = 1U << HZB_TOWN_CENTRE, ///< center of town |
9476 | 71 |
HZ_ZONALL = 0x001F, ///< 1F This is just to englobe all above types at once |
72 |
HZ_SUBARTC_ABOVE = 0x0800, ///< 11 800 can appear in sub-arctic climate above the snow line |
|
73 |
HZ_TEMP = 0x1000, ///< 12 1000 can appear in temperate climate |
|
74 |
HZ_SUBARTC_BELOW = 0x2000, ///< 13 2000 can appear in sub-arctic climate below the snow line |
|
75 |
HZ_SUBTROPIC = 0x4000, ///< 14 4000 can appear in subtropical climate |
|
76 |
HZ_TOYLND = 0x8000 ///< 15 8000 can appear in toyland climate |
|
77 |
}; |
|
78 |
||
79 |
DECLARE_ENUM_AS_BIT_SET(HouseZones) |
|
80 |
||
81 |
enum HouseExtraFlags { |
|
82 |
NO_EXTRA_FLAG = 0, |
|
83 |
BUILDING_IS_HISTORICAL = 1U << 0, ///< this house will only appear during town generation in random games, thus the historical |
|
84 |
BUILDING_IS_PROTECTED = 1U << 1, ///< towns and AI will not remove this house, while human players will be able tp |
|
85 |
SYNCHRONISED_CALLBACK_1B = 1U << 2, ///< synchronized callback 1B will be performed, on multi tile houses |
|
86 |
CALLBACK_1A_RANDOM_BITS = 1U << 3, ///< callback 1A needs random bits |
|
87 |
}; |
|
88 |
||
89 |
DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags) |
|
90 |
||
91 |
struct BuildingCounts { |
|
92 |
uint8 id_count[HOUSE_MAX]; |
|
93 |
uint8 class_count[HOUSE_CLASS_MAX]; |
|
5299
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
94 |
}; |
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
95 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
96 |
DECLARE_OLD_POOL(Town, Town, 3, 8000) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
97 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
98 |
struct Town : PoolItem<Town, TownID, &_Town_pool> { |
0 | 99 |
TileIndex xy; |
100 |
||
9574 | 101 |
/* Current population of people and amount of houses. */ |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9724
diff
changeset
|
102 |
uint32 num_houses; |
0 | 103 |
uint32 population; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
104 |
|
9574 | 105 |
/* Town name */ |
9629 | 106 |
uint32 townnamegrfid; |
0 | 107 |
uint16 townnametype; |
108 |
uint32 townnameparts; |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
109 |
char *name; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
110 |
|
9574 | 111 |
/* NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. */ |
0 | 112 |
ViewportSign sign; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
113 |
|
9574 | 114 |
/* Makes sure we don't build certain house types twice. |
115 |
* bit 0 = Building funds received |
|
116 |
* bit 1 = CHURCH |
|
117 |
* bit 2 = STADIUM */ |
|
0 | 118 |
byte flags12; |
119 |
||
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
120 |
/* level of noise that all the airports are generating */ |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
121 |
uint16 noise_reached; |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
122 |
|
9574 | 123 |
/* Which players have a statue? */ |
0 | 124 |
byte statues; |
125 |
||
9574 | 126 |
/* Player ratings as well as a mask that determines which players have a rating. */ |
0 | 127 |
byte have_ratings; |
9574 | 128 |
uint8 unwanted[MAX_PLAYERS]; ///< how many months companies aren't wanted by towns (bribe) |
129 |
PlayerByte exclusivity; ///< which player has exslusivity |
|
130 |
uint8 exclusive_counter; ///< months till the exclusivity expires |
|
0 | 131 |
int16 ratings[MAX_PLAYERS]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
132 |
|
9574 | 133 |
/* Maximum amount of passengers and mail that can be transported. */ |
1377
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
134 |
uint32 max_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
135 |
uint32 max_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
136 |
uint32 new_max_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
137 |
uint32 new_max_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
138 |
uint32 act_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
139 |
uint32 act_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
140 |
uint32 new_act_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
141 |
uint32 new_act_mail; |
0 | 142 |
|
9574 | 143 |
/* Amount of passengers that were transported. */ |
0 | 144 |
byte pct_pass_transported; |
145 |
byte pct_mail_transported; |
|
146 |
||
9574 | 147 |
/* Amount of food and paper that was transported. Actually a bit mask would be enough. */ |
0 | 148 |
uint16 act_food; |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
149 |
uint16 act_water; |
0 | 150 |
uint16 new_act_food; |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
151 |
uint16 new_act_water; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
152 |
|
9574 | 153 |
/* Time until we rebuild a house. */ |
9599 | 154 |
uint16 time_until_rebuild; |
0 | 155 |
|
9574 | 156 |
/* When to grow town next time. */ |
9599 | 157 |
uint16 grow_counter; |
158 |
int16 growth_rate; |
|
0 | 159 |
|
9574 | 160 |
/* Fund buildings program in action? */ |
0 | 161 |
byte fund_buildings_months; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
162 |
|
9574 | 163 |
/* Fund road reconstruction in action? */ |
0 | 164 |
byte road_build_months; |
165 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
166 |
/* If this is a larger town, and should grow more quickly. */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
167 |
bool larger_town; |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
168 |
|
9574 | 169 |
/* NOSAVE: UpdateTownRadius updates this given the house count. */ |
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
9869
diff
changeset
|
170 |
uint32 squared_town_zone_radius[HZB_END]; |
9476 | 171 |
|
9574 | 172 |
/* NOSAVE: The number of each type of building in the town. */ |
9476 | 173 |
BuildingCounts building_counts; |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
174 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
175 |
/* NOSAVE: The town specific road layout */ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
176 |
TownLayout layout; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
177 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
178 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
179 |
* Creates a new town |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
180 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
181 |
Town(TileIndex tile = 0); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
182 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
183 |
/** Destroy the town */ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
184 |
~Town(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
185 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
186 |
inline bool IsValid() const { return this->xy != 0; } |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
187 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
188 |
void InitializeLayout(); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
189 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
190 |
inline TownLayout GetActiveLayout() const; |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
191 |
|
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
192 |
/** Calculate the max town noise |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
193 |
* The value is counted using the population divided by the content of the |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
194 |
* entry in town_noise_population corespondig to the town's tolerance. |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
195 |
* To this result, we add 3, which is the noise of the lowest airport. |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
196 |
* So user can at least buld that airport |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
197 |
* @return the maximum noise level the town will tolerate */ |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
198 |
inline uint16 MaxTownNoise() const { |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
199 |
if (this->population == 0) return 0; // no population? no noise |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
200 |
|
10776 | 201 |
return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3); |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10455
diff
changeset
|
202 |
} |
0 | 203 |
}; |
204 |
||
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
205 |
/** |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
206 |
* Get the current valid layout for the town |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
207 |
* @return the active layout for this town |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
208 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
209 |
inline TownLayout Town::GetActiveLayout() const |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
210 |
{ |
10776 | 211 |
return (_settings_game.economy.town_layout == TL_RANDOM) ? this->layout : _settings_game.economy.town_layout; |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
212 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
213 |
|
9476 | 214 |
struct HouseSpec { |
215 |
/* Standard properties */ |
|
10829 | 216 |
Year min_year; ///< introduction year of the house |
217 |
Year max_year; ///< last year it can be built |
|
9476 | 218 |
byte population; ///< population (Zero on other tiles in multi tile house.) |
219 |
byte removal_cost; ///< cost multiplier for removing it |
|
10249
58810805030e
(svn r12781) [NoAI] -Sync: with trunk r12711:12780.
rubidium
parents:
9869
diff
changeset
|
220 |
StringID building_name; ///< building name |
9476 | 221 |
uint16 remove_rating_decrease; ///< rating decrease if removed |
222 |
byte mail_generation; ///< mail generation multiplier (tile based, as the acceptances below) |
|
9505 | 223 |
byte cargo_acceptance[3]; ///< acceptance level for the cargo slots |
224 |
CargoID accepts_cargo[3]; ///< 3 input cargo slots |
|
9476 | 225 |
BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...) |
226 |
HouseZones building_availability; ///< where can it be built (climates, zones) |
|
9624 | 227 |
bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf) |
9476 | 228 |
|
229 |
/* NewHouses properties */ |
|
9624 | 230 |
HouseID substitute_id; ///< which original house this one is based on |
9476 | 231 |
struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the house |
232 |
HouseID override; ///< which house this one replaces |
|
233 |
uint16 callback_mask; ///< House callback flags |
|
234 |
byte random_colour[4]; ///< 4 "random" colours |
|
235 |
byte probability; ///< Relative probability of appearing (16 is the standard value) |
|
236 |
HouseExtraFlags extra_flags; ///< some more flags |
|
237 |
HouseClassID class_id; ///< defines the class this house has (grf file based) @See HouseGetVariable, prop 0x44 |
|
238 |
byte animation_frames; ///< number of animation frames |
|
239 |
byte animation_speed; ///< amount of time between each of those frames |
|
240 |
byte processing_time; ///< Periodic refresh multiplier |
|
9624 | 241 |
byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it |
9476 | 242 |
|
243 |
/* grf file related properties*/ |
|
244 |
uint8 local_id; ///< id defined by the grf file for this house |
|
245 |
const struct GRFFile *grffile; ///< grf file that introduced this house |
|
10867
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
246 |
|
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
247 |
/** |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
248 |
* Get the cost for removing this house |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
249 |
* @return the cost (inflation corrected etc) |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
250 |
*/ |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
251 |
Money GetRemovalCost() const; |
5de2923d6e59
(svn r13418) [NoAI] -Sync: with trunk r13380:13417.
rubidium
parents:
10829
diff
changeset
|
252 |
|
9476 | 253 |
}; |
254 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
255 |
extern HouseSpec _house_specs[HOUSE_MAX]; |
9476 | 256 |
|
6573 | 257 |
uint32 GetWorldPopulation(); |
0 | 258 |
|
835
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
820
diff
changeset
|
259 |
void UpdateTownVirtCoord(Town *t); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
260 |
void UpdateAllTownVirtCoords(); |
6573 | 261 |
void InitializeTown(); |
3346
96c5db77aa83
(svn r4130) - CodeChange: Add proper semantics for TownID for such variables instead of using the general uint16-type. We probably need to change GetTown() and IsTownIndex() as well to use TownID.
Darkvater
parents:
2958
diff
changeset
|
262 |
void ShowTownViewWindow(TownID town); |
0 | 263 |
void ExpandTown(Town *t); |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
264 |
Town *CreateRandomTown(uint attempts, TownSizeMode mode, uint size); |
0 | 265 |
|
266 |
enum { |
|
267 |
ROAD_REMOVE = 0, |
|
268 |
UNMOVEABLE_REMOVE = 1, |
|
269 |
TUNNELBRIDGE_REMOVE = 1, |
|
270 |
INDUSTRY_REMOVE = 2 |
|
271 |
}; |
|
272 |
||
9599 | 273 |
/** This is the number of ticks between towns being processed for building new |
274 |
* houses or roads. This value originally came from the size of the town array |
|
275 |
* in TTD. */ |
|
276 |
static const byte TOWN_GROWTH_FREQUENCY = 70; |
|
277 |
||
278 |
/** Simple value that indicates the house has reached the final stage of |
|
279 |
* construction. */ |
|
280 |
static const byte TOWN_HOUSE_COMPLETED = 3; |
|
3432
507fa7fd189d
(svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents:
3349
diff
changeset
|
281 |
|
9574 | 282 |
/** This enum is used in conjonction with town->flags12. |
3432
507fa7fd189d
(svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents:
3349
diff
changeset
|
283 |
* IT simply states what bit is used for. |
507fa7fd189d
(svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents:
3349
diff
changeset
|
284 |
* It is pretty unrealistic (IMHO) to only have one church/stadium |
507fa7fd189d
(svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents:
3349
diff
changeset
|
285 |
* per town, NO MATTER the population of it. |
507fa7fd189d
(svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents:
3349
diff
changeset
|
286 |
* And there are 5 more bits available on flags12... |
507fa7fd189d
(svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents:
3349
diff
changeset
|
287 |
*/ |
507fa7fd189d
(svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents:
3349
diff
changeset
|
288 |
enum { |
9574 | 289 |
TOWN_IS_FUNDED = 0, ///< Town has received some funds for |
290 |
TOWN_HAS_CHURCH = 1, ///< There can be only one church by town. |
|
291 |
TOWN_HAS_STADIUM = 2 ///< There can be only one stadium by town. |
|
1005 | 292 |
}; |
293 |
||
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2817
diff
changeset
|
294 |
bool CheckforTownRating(uint32 flags, Town *t, byte type); |
0 | 295 |
|
9476 | 296 |
static inline HouseSpec *GetHouseSpecs(HouseID house_id) |
297 |
{ |
|
298 |
assert(house_id < HOUSE_MAX); |
|
299 |
return &_house_specs[house_id]; |
|
300 |
} |
|
301 |
||
11126
72d4c9314c72
(svn r13684) [NoAI] -Sync: with trunk r13599:13683.
rubidium
parents:
10867
diff
changeset
|
302 |
TileIndex GetHouseNorthPart(HouseID &house); |
72d4c9314c72
(svn r13684) [NoAI] -Sync: with trunk r13599:13683.
rubidium
parents:
10867
diff
changeset
|
303 |
|
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
304 |
/** |
9574 | 305 |
* Check if a TownID is valid. |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
306 |
* @param index to inquiry in the pool of town |
9574 | 307 |
* @return true if it exists |
308 |
*/ |
|
5299
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
309 |
static inline bool IsValidTownID(TownID index) |
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
310 |
{ |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
311 |
return index < GetTownPoolSize() && GetTown(index)->IsValid(); |
5299
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
312 |
} |
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
313 |
|
6573 | 314 |
static inline TownID GetMaxTownIndex() |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
315 |
{ |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
316 |
/* TODO - This isn't the real content of the function, but |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
317 |
* with the new pool-system this will be replaced with one that |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
318 |
* _really_ returns the highest index. Now it just returns |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
319 |
* the next safe value we are sure about everything is below. |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
320 |
*/ |
5298
6d4c150bdd94
(svn r7451) -Fix (7372): GetNum(Towns|Industries) should return the actual number of towns and industries.
rubidium
parents:
5247
diff
changeset
|
321 |
return GetTownPoolSize() - 1; |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
322 |
} |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
323 |
|
6573 | 324 |
static inline uint GetNumTowns() |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
325 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
326 |
extern uint _total_towns; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
327 |
|
4357
3d72606e9192
(svn r6058) -Fix: Get(Industry|Town)ArraySize could never return 0
truelight
parents:
4356
diff
changeset
|
328 |
return _total_towns; |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
329 |
} |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
330 |
|
4356
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
331 |
/** |
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
332 |
* Return a random valid town. |
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
333 |
*/ |
6573 | 334 |
static inline Town *GetRandomTown() |
4356
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
335 |
{ |
5299
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
336 |
int num = RandomRange(GetNumTowns()); |
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
337 |
TownID index = INVALID_TOWN; |
4356
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
338 |
|
5299
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
339 |
while (num >= 0) { |
4356
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
340 |
num--; |
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
341 |
|
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
342 |
index++; |
6233
57721387461b
(svn r8681) -Fix (FS#608): wrong comment (rfalke)
rubidium
parents:
6220
diff
changeset
|
343 |
/* Make sure we have a valid town */ |
5299
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
344 |
while (!IsValidTownID(index)) { |
4356
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
345 |
index++; |
5299
5d613241ee5e
(svn r7452) -Fix: GetRandom(Industry|Town) must return a valid industry/town and should not need to loop over the pool for a second time.
rubidium
parents:
5298
diff
changeset
|
346 |
assert(index <= GetMaxTownIndex()); |
4356
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
347 |
} |
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
348 |
} |
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
349 |
|
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
350 |
return GetTown(index); |
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
351 |
} |
bc52a48e2590
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
352 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
353 |
Town *CalcClosestTownFromTile(TileIndex tile, uint threshold); |
6220
0c2371b1edda
(svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents:
5838
diff
changeset
|
354 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
355 |
#define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (t->IsValid()) |
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
356 |
#define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0) |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
357 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
358 |
extern Town *_cleared_town; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
359 |
extern int _cleared_town_rating; |
0 | 360 |
|
9476 | 361 |
void ResetHouses(); |
362 |
||
363 |
void ClearTownHouse(Town *t, TileIndex tile); |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
364 |
void AfterLoadTown(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
365 |
void UpdateTownMaxPass(Town *t); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9724
diff
changeset
|
366 |
void UpdateTownRadius(Town *t); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
367 |
bool CheckIfAuthorityAllows(TileIndex tile); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
368 |
Town *ClosestTownFromTile(TileIndex tile, uint threshold); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
369 |
void ChangeTownRating(Town *t, int add, int max); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
370 |
HouseZonesBits GetTownRadiusGroup(const Town* t, TileIndex tile); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9701
diff
changeset
|
371 |
void SetTownRatingTestMode(bool mode); |
9476 | 372 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
373 |
/** |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
374 |
* Calculate a hash value from a tile position |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
375 |
* |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
376 |
* @param x The X coordinate |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
377 |
* @param y The Y coordinate |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
378 |
* @return The hash of the tile |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
379 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
380 |
static inline uint TileHash(uint x, uint y) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
381 |
{ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
382 |
uint hash = x >> 4; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
383 |
hash ^= x >> 6; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
384 |
hash ^= y >> 4; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
385 |
hash -= y >> 6; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
386 |
return hash; |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
387 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
388 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
389 |
/** |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
390 |
* Get the last two bits of the TileHash |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
391 |
* from a tile position. |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
392 |
* |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
393 |
* @see TileHash() |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
394 |
* @param x The X coordinate |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
395 |
* @param y The Y coordinate |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
396 |
* @return The last two bits from hash of the tile |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
397 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
398 |
static inline uint TileHash2Bit(uint x, uint y) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
399 |
{ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
400 |
return GB(TileHash(x, y), 0, 2); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
401 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
402 |
|
0 | 403 |
#endif /* TOWN_H */ |