author | rubidium |
Wed, 07 May 2008 21:45:27 +0000 | |
changeset 10457 | ea18877d8eba |
parent 10445 | 2dd7d9d0a957 |
child 10682 | 3b753d908205 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10318
diff
changeset
|
3 |
/** @file town.h Base of the town class. */ |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
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" |
9292
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
9 |
#include "core/bitmath_func.hpp" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
10 |
#include "core/random_func.hpp" |
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
11 |
#include "cargo_type.h" |
8634
5ffca02f9115
(svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents:
8627
diff
changeset
|
12 |
#include "tile_type.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8634
diff
changeset
|
13 |
#include "date_type.h" |
8709
4187ad809fe7
(svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium
parents:
8683
diff
changeset
|
14 |
#include "town_type.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8728
diff
changeset
|
15 |
#include "player_type.h" |
9292
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
16 |
#include "settings_type.h" |
10219
2ff2b0f7643e
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
10195
diff
changeset
|
17 |
#include "strings_type.h" |
10445
2dd7d9d0a957
(svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents:
10429
diff
changeset
|
18 |
#include "viewport_type.h" |
0 | 19 |
|
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
|
20 |
enum { |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
21 |
HOUSE_NO_CLASS = 0, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
22 |
NEW_HOUSE_OFFSET = 110, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
23 |
HOUSE_MAX = 512, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
24 |
INVALID_TOWN = 0xFFFF, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
25 |
INVALID_HOUSE_ID = 0xFFFF, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
26 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
27 |
/* There can only be as many classes as there are new houses, plus one for |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
28 |
* NO_CLASS, as the original houses don't have classes. */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
29 |
HOUSE_CLASS_MAX = HOUSE_MAX - NEW_HOUSE_OFFSET + 1, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
30 |
}; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
31 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
32 |
enum BuildingFlags { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
33 |
TILE_NO_FLAG = 0, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
34 |
TILE_SIZE_1x1 = 1U << 0, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
35 |
TILE_NOT_SLOPED = 1U << 1, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
36 |
TILE_SIZE_2x1 = 1U << 2, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
37 |
TILE_SIZE_1x2 = 1U << 3, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
38 |
TILE_SIZE_2x2 = 1U << 4, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
39 |
BUILDING_IS_ANIMATED = 1U << 5, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
40 |
BUILDING_IS_CHURCH = 1U << 6, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
41 |
BUILDING_IS_STADIUM = 1U << 7, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
42 |
BUILDING_HAS_1_TILE = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
43 |
BUILDING_2_TILES_X = TILE_SIZE_2x1 | TILE_SIZE_2x2, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
44 |
BUILDING_2_TILES_Y = TILE_SIZE_1x2 | TILE_SIZE_2x2, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
45 |
BUILDING_HAS_4_TILES = TILE_SIZE_2x2, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
46 |
}; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
47 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
48 |
DECLARE_ENUM_AS_BIT_SET(BuildingFlags) |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
49 |
|
8804
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
50 |
enum HouseZonesBits { |
9310
08b3b745d299
(svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents:
9292
diff
changeset
|
51 |
HZB_BEGIN = 0, |
8804
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
52 |
HZB_TOWN_EDGE = 0, |
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
53 |
HZB_TOWN_OUTSKIRT, |
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
54 |
HZB_TOWN_OUTER_SUBURB, |
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
55 |
HZB_TOWN_INNER_SUBURB, |
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
56 |
HZB_TOWN_CENTRE, |
9310
08b3b745d299
(svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents:
9292
diff
changeset
|
57 |
HZB_END, |
8804
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
58 |
}; |
9310
08b3b745d299
(svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents:
9292
diff
changeset
|
59 |
assert_compile(HZB_END == 5); |
08b3b745d299
(svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents:
9292
diff
changeset
|
60 |
|
08b3b745d299
(svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents:
9292
diff
changeset
|
61 |
DECLARE_POSTFIX_INCREMENT(HouseZonesBits) |
8804
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
62 |
|
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
63 |
enum HouseZones { ///< Bit Value Meaning |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
64 |
HZ_NOZNS = 0x0000, ///< 0 This is just to get rid of zeros, meaning none |
8804
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
65 |
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 |
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
66 |
HZ_ZON2 = 1U << HZB_TOWN_OUTSKIRT, |
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
67 |
HZ_ZON3 = 1U << HZB_TOWN_OUTER_SUBURB, |
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
68 |
HZ_ZON4 = 1U << HZB_TOWN_INNER_SUBURB, |
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
69 |
HZ_ZON5 = 1U << HZB_TOWN_CENTRE, ///< center of town |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
70 |
HZ_ZONALL = 0x001F, ///< 1F This is just to englobe all above types at once |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
71 |
HZ_SUBARTC_ABOVE = 0x0800, ///< 11 800 can appear in sub-arctic climate above the snow line |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
72 |
HZ_TEMP = 0x1000, ///< 12 1000 can appear in temperate climate |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
73 |
HZ_SUBARTC_BELOW = 0x2000, ///< 13 2000 can appear in sub-arctic climate below the snow line |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
74 |
HZ_SUBTROPIC = 0x4000, ///< 14 4000 can appear in subtropical climate |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
75 |
HZ_TOYLND = 0x8000 ///< 15 8000 can appear in toyland climate |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
76 |
}; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
77 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
78 |
DECLARE_ENUM_AS_BIT_SET(HouseZones) |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
79 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
80 |
enum HouseExtraFlags { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
81 |
NO_EXTRA_FLAG = 0, |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
82 |
BUILDING_IS_HISTORICAL = 1U << 0, ///< this house will only appear during town generation in random games, thus the historical |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
83 |
BUILDING_IS_PROTECTED = 1U << 1, ///< towns and AI will not remove this house, while human players will be able tp |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
84 |
SYNCHRONISED_CALLBACK_1B = 1U << 2, ///< synchronized callback 1B will be performed, on multi tile houses |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
85 |
CALLBACK_1A_RANDOM_BITS = 1U << 3, ///< callback 1A needs random bits |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
86 |
}; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
87 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
88 |
DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags) |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
89 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
90 |
struct BuildingCounts { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
91 |
uint8 id_count[HOUSE_MAX]; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
92 |
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
|
93 |
}; |
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 |
|
7882
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
95 |
DECLARE_OLD_POOL(Town, Town, 3, 8000) |
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
96 |
|
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
97 |
struct Town : PoolItem<Town, TownID, &_Town_pool> { |
0 | 98 |
TileIndex xy; |
99 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
100 |
/* Current population of people and amount of houses. */ |
9203
55b0289562a8
(svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13
parents:
8804
diff
changeset
|
101 |
uint32 num_houses; |
0 | 102 |
uint32 population; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
103 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
104 |
/* Town name */ |
7452
f6fd23727af0
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
7101
diff
changeset
|
105 |
uint32 townnamegrfid; |
0 | 106 |
uint16 townnametype; |
107 |
uint32 townnameparts; |
|
8754
5dae65402806
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
8750
diff
changeset
|
108 |
char *name; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
109 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
110 |
/* NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. */ |
0 | 111 |
ViewportSign sign; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
112 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
113 |
/* Makes sure we don't build certain house types twice. |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
114 |
* bit 0 = Building funds received |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
115 |
* bit 1 = CHURCH |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
116 |
* bit 2 = STADIUM */ |
0 | 117 |
byte flags12; |
118 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
119 |
/* Which players have a statue? */ |
0 | 120 |
byte statues; |
121 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
122 |
/* Player ratings as well as a mask that determines which players have a rating. */ |
0 | 123 |
byte have_ratings; |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
124 |
uint8 unwanted[MAX_PLAYERS]; ///< how many months companies aren't wanted by towns (bribe) |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
125 |
PlayerByte exclusivity; ///< which player has exslusivity |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
126 |
uint8 exclusive_counter; ///< months till the exclusivity expires |
0 | 127 |
int16 ratings[MAX_PLAYERS]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
128 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
129 |
/* 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
|
130 |
uint32 max_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
131 |
uint32 max_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
132 |
uint32 new_max_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
133 |
uint32 new_max_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
134 |
uint32 act_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
135 |
uint32 act_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
136 |
uint32 new_act_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
137 |
uint32 new_act_mail; |
0 | 138 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
139 |
/* Amount of passengers that were transported. */ |
0 | 140 |
byte pct_pass_transported; |
141 |
byte pct_mail_transported; |
|
142 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
143 |
/* Amount of food and paper that was transported. Actually a bit mask would be enough. */ |
0 | 144 |
uint16 act_food; |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
145 |
uint16 act_water; |
0 | 146 |
uint16 new_act_food; |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
147 |
uint16 new_act_water; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
148 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
149 |
/* Time until we rebuild a house. */ |
6950
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
150 |
uint16 time_until_rebuild; |
0 | 151 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
152 |
/* When to grow town next time. */ |
6950
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
153 |
uint16 grow_counter; |
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
154 |
int16 growth_rate; |
0 | 155 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
156 |
/* Fund buildings program in action? */ |
0 | 157 |
byte fund_buildings_months; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
158 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
159 |
/* Fund road reconstruction in action? */ |
0 | 160 |
byte road_build_months; |
161 |
||
6982
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6980
diff
changeset
|
162 |
/* If this is a larger town, and should grow more quickly. */ |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6980
diff
changeset
|
163 |
bool larger_town; |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6980
diff
changeset
|
164 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
165 |
/* NOSAVE: UpdateTownRadius updates this given the house count. */ |
10195
a4ffa2310bd8
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
9310
diff
changeset
|
166 |
uint32 squared_town_zone_radius[HZB_END]; |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
167 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
168 |
/* NOSAVE: The number of each type of building in the town. */ |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
169 |
BuildingCounts building_counts; |
7882
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
170 |
|
9292
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
171 |
/* NOSAVE: The town specific road layout */ |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
172 |
TownLayout layout; |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
173 |
|
7882
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
174 |
/** |
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
175 |
* Creates a new town |
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
176 |
*/ |
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
177 |
Town(TileIndex tile = 0); |
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
178 |
|
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
179 |
/** Destroy the town */ |
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
180 |
~Town(); |
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
181 |
|
7992
8ac3fcd8d570
(svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents:
7909
diff
changeset
|
182 |
inline bool IsValid() const { return this->xy != 0; } |
9292
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
183 |
|
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
184 |
void InitializeLayout(); |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
185 |
|
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
186 |
inline TownLayout GetActiveLayout() const; |
0 | 187 |
}; |
188 |
||
9292
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
189 |
/** |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
190 |
* Get the current valid layout for the town |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
191 |
* @return the active layout for this town |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
192 |
*/ |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
193 |
inline TownLayout Town::GetActiveLayout() const |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
194 |
{ |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
195 |
return (_patches.town_layout == TL_RANDOM) ? this->layout : _patches.town_layout; |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
196 |
} |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
197 |
|
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
198 |
struct HouseSpec { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
199 |
/* Standard properties */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
200 |
Year min_date; ///< introduction year of the house |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
201 |
Year max_date; ///< last year it can be built |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
202 |
byte population; ///< population (Zero on other tiles in multi tile house.) |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
203 |
byte removal_cost; ///< cost multiplier for removing it |
10219
2ff2b0f7643e
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
10195
diff
changeset
|
204 |
StringID building_name; ///< building name |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
205 |
uint16 remove_rating_decrease; ///< rating decrease if removed |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
206 |
byte mail_generation; ///< mail generation multiplier (tile based, as the acceptances below) |
6667
437af4c23305
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6658
diff
changeset
|
207 |
byte cargo_acceptance[3]; ///< acceptance level for the cargo slots |
437af4c23305
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6658
diff
changeset
|
208 |
CargoID accepts_cargo[3]; ///< 3 input cargo slots |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
209 |
BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...) |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
210 |
HouseZones building_availability; ///< where can it be built (climates, zones) |
7101
ff1b42bfd622
(svn r9823) -Feature: Add support for house property 1F - minimum life span.
maedhros
parents:
6982
diff
changeset
|
211 |
bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf) |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
212 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
213 |
/* NewHouses properties */ |
7101
ff1b42bfd622
(svn r9823) -Feature: Add support for house property 1F - minimum life span.
maedhros
parents:
6982
diff
changeset
|
214 |
HouseID substitute_id; ///< which original house this one is based on |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
215 |
struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the house |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
216 |
HouseID override; ///< which house this one replaces |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
217 |
uint16 callback_mask; ///< House callback flags |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
218 |
byte random_colour[4]; ///< 4 "random" colours |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
219 |
byte probability; ///< Relative probability of appearing (16 is the standard value) |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
220 |
HouseExtraFlags extra_flags; ///< some more flags |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
221 |
HouseClassID class_id; ///< defines the class this house has (grf file based) @See HouseGetVariable, prop 0x44 |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
222 |
byte animation_frames; ///< number of animation frames |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
223 |
byte animation_speed; ///< amount of time between each of those frames |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
224 |
byte processing_time; ///< Periodic refresh multiplier |
7101
ff1b42bfd622
(svn r9823) -Feature: Add support for house property 1F - minimum life span.
maedhros
parents:
6982
diff
changeset
|
225 |
byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
226 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
227 |
/* grf file related properties*/ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
228 |
uint8 local_id; ///< id defined by the grf file for this house |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
229 |
const struct GRFFile *grffile; ///< grf file that introduced this house |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
230 |
}; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
231 |
|
8764
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
232 |
extern HouseSpec _house_specs[HOUSE_MAX]; |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
233 |
|
6573 | 234 |
uint32 GetWorldPopulation(); |
0 | 235 |
|
835
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
820
diff
changeset
|
236 |
void UpdateTownVirtCoord(Town *t); |
8465
d5faf7afaafd
(svn r11525) -Fix: do not do all kinds of 'updates' for town, waypoint, station and other signs when you haven't converted the map to the 'current' format as that means you are going to read data in the 'old' format when you assume that it is in the 'current' format.
rubidium
parents:
7992
diff
changeset
|
237 |
void UpdateAllTownVirtCoords(); |
6573 | 238 |
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
|
239 |
void ShowTownViewWindow(TownID town); |
0 | 240 |
void ExpandTown(Town *t); |
6982
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6980
diff
changeset
|
241 |
Town *CreateRandomTown(uint attempts, TownSizeMode mode, uint size); |
0 | 242 |
|
243 |
enum { |
|
244 |
ROAD_REMOVE = 0, |
|
245 |
UNMOVEABLE_REMOVE = 1, |
|
246 |
TUNNELBRIDGE_REMOVE = 1, |
|
247 |
INDUSTRY_REMOVE = 2 |
|
248 |
}; |
|
249 |
||
6950
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
250 |
/** This is the number of ticks between towns being processed for building new |
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
251 |
* houses or roads. This value originally came from the size of the town array |
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
252 |
* in TTD. */ |
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
253 |
static const byte TOWN_GROWTH_FREQUENCY = 70; |
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
254 |
|
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
255 |
/** Simple value that indicates the house has reached the final stage of |
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
256 |
* construction. */ |
c572b218bf2f
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents:
6918
diff
changeset
|
257 |
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
|
258 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
259 |
/** 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
|
260 |
* 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
|
261 |
* 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
|
262 |
* 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
|
263 |
* 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
|
264 |
*/ |
507fa7fd189d
(svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents:
3349
diff
changeset
|
265 |
enum { |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
266 |
TOWN_IS_FUNDED = 0, ///< Town has received some funds for |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
267 |
TOWN_HAS_CHURCH = 1, ///< There can be only one church by town. |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
268 |
TOWN_HAS_STADIUM = 2 ///< There can be only one stadium by town. |
1005 | 269 |
}; |
270 |
||
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2817
diff
changeset
|
271 |
bool CheckforTownRating(uint32 flags, Town *t, byte type); |
0 | 272 |
|
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
273 |
static inline HouseSpec *GetHouseSpecs(HouseID house_id) |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
274 |
{ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
275 |
assert(house_id < HOUSE_MAX); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
276 |
return &_house_specs[house_id]; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
277 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
278 |
|
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
279 |
/** |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
280 |
* Check if a TownID is valid. |
6980
6b5dee376733
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6950
diff
changeset
|
281 |
* @param index to inquiry in the pool of town |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
282 |
* @return true if it exists |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6667
diff
changeset
|
283 |
*/ |
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
|
284 |
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
|
285 |
{ |
7882
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
286 |
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
|
287 |
} |
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
|
288 |
|
6573 | 289 |
static inline TownID GetMaxTownIndex() |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
290 |
{ |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
291 |
/* 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
|
292 |
* 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
|
293 |
* _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
|
294 |
* 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
|
295 |
*/ |
5298
6d4c150bdd94
(svn r7451) -Fix (7372): GetNum(Towns|Industries) should return the actual number of towns and industries.
rubidium
parents:
5247
diff
changeset
|
296 |
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
|
297 |
} |
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
|
298 |
|
6573 | 299 |
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
|
300 |
{ |
8764
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
301 |
extern uint _total_towns; |
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
302 |
|
4357
3d72606e9192
(svn r6058) -Fix: Get(Industry|Town)ArraySize could never return 0
truelight
parents:
4356
diff
changeset
|
303 |
return _total_towns; |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
304 |
} |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
305 |
|
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
|
306 |
/** |
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
|
307 |
* 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
|
308 |
*/ |
6573 | 309 |
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
|
310 |
{ |
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
|
311 |
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
|
312 |
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
|
313 |
|
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
|
314 |
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
|
315 |
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
|
316 |
|
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
|
317 |
index++; |
6233
57721387461b
(svn r8681) -Fix (FS#608): wrong comment (rfalke)
rubidium
parents:
6220
diff
changeset
|
318 |
/* 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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
} |
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
|
323 |
} |
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
|
324 |
|
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
|
325 |
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
|
326 |
} |
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
|
327 |
|
8764
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
328 |
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
|
329 |
|
7882
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7452
diff
changeset
|
330 |
#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
|
331 |
#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
|
332 |
|
8764
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
333 |
extern bool _town_sort_dirty; |
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
334 |
extern byte _town_sort_order; |
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
335 |
extern const Town **_town_sort; |
0 | 336 |
|
8764
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
337 |
extern Town *_cleared_town; |
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
338 |
extern int _cleared_town_rating; |
0 | 339 |
|
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
340 |
void ResetHouses(); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
341 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
342 |
void ClearTownHouse(Town *t, TileIndex tile); |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
343 |
void AfterLoadTown(); |
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
344 |
void UpdateTownMaxPass(Town *t); |
9203
55b0289562a8
(svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13
parents:
8804
diff
changeset
|
345 |
void UpdateTownRadius(Town *t); |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
346 |
bool CheckIfAuthorityAllows(TileIndex tile); |
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
347 |
Town *ClosestTownFromTile(TileIndex tile, uint threshold); |
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8626
diff
changeset
|
348 |
void ChangeTownRating(Town *t, int add, int max); |
8804
6d7e8b85529e
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents:
8794
diff
changeset
|
349 |
HouseZonesBits GetTownRadiusGroup(const Town* t, TileIndex tile); |
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8709
diff
changeset
|
350 |
void SetTownRatingTestMode(bool mode); |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
351 |
|
9292
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
352 |
/** |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
353 |
* Calculate a hash value from a tile position |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
354 |
* |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
355 |
* @param x The X coordinate |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
356 |
* @param y The Y coordinate |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
357 |
* @return The hash of the tile |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
358 |
*/ |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
359 |
static inline uint TileHash(uint x, uint y) |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
360 |
{ |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
361 |
uint hash = x >> 4; |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
362 |
hash ^= x >> 6; |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
363 |
hash ^= y >> 4; |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
364 |
hash -= y >> 6; |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
365 |
return hash; |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
366 |
} |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
367 |
|
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
368 |
/** |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
369 |
* Get the last two bits of the TileHash |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
370 |
* from a tile position. |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
371 |
* |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
372 |
* @see TileHash() |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
373 |
* @param x The X coordinate |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
374 |
* @param y The Y coordinate |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
375 |
* @return The last two bits from hash of the tile |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
376 |
*/ |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
377 |
static inline uint TileHash2Bit(uint x, uint y) |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
378 |
{ |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
379 |
return GB(TileHash(x, y), 0, 2); |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
380 |
} |
4f5612017238
(svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents:
9287
diff
changeset
|
381 |
|
0 | 382 |
#endif /* TOWN_H */ |