src/town.h
author rubidium
Thu, 18 Dec 2008 12:23:08 +0000
changeset 10436 8d3a9fbe8f19
parent 10270 dea184383ba1
permissions -rw-r--r--
(svn r14689) -Change: make configure die on commonly made user mistakes, like not having SDL development files or zlib headers installed; you can still compile a dedicated server or a binary without zlib, but you have to explicitly force it.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1977
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1977
diff changeset
     2
9111
48ce04029fe4 (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: 9040
diff changeset
     3
/** @file town.h Base of the town class. */
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#ifndef TOWN_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#define TOWN_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
5216
8bd14ee39af2 (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"
8796
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
     9
#include "core/bitmath_func.hpp"
8131
160939e24ed3 (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: 8130
diff changeset
    10
#include "core/random_func.hpp"
160939e24ed3 (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: 8130
diff changeset
    11
#include "cargo_type.h"
8138
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8131
diff changeset
    12
#include "tile_type.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8138
diff changeset
    13
#include "date_type.h"
8213
7bdd7593eb9b (svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium
parents: 8187
diff changeset
    14
#include "town_type.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    15
#include "company_type.h"
8796
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
    16
#include "settings_type.h"
8959
636d242edd89 (svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents: 8943
diff changeset
    17
#include "strings_type.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9111
diff changeset
    18
#include "viewport_type.h"
9463
174d00929d44 (svn r13383) -Codechange: Put the cost of house removal in a class member
belugas
parents: 9450
diff changeset
    19
#include "economy_type.h"
10270
dea184383ba1 (svn r14505) -Fix (r14504): Missing include.
michi_cc
parents: 10269
diff changeset
    20
#include "map_type.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
5299
cf162c141e2f (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
    22
enum {
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    23
	HOUSE_NO_CLASS   = 0,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    24
	NEW_HOUSE_OFFSET = 110,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    25
	HOUSE_MAX        = 512,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    26
	INVALID_TOWN     = 0xFFFF,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    27
	INVALID_HOUSE_ID = 0xFFFF,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    28
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    29
	/* There can only be as many classes as there are new houses, plus one for
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    30
	 * NO_CLASS, as the original houses don't have classes. */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    31
	HOUSE_CLASS_MAX  = HOUSE_MAX - NEW_HOUSE_OFFSET + 1,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    32
};
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    33
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    34
enum BuildingFlags {
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    35
	TILE_NO_FLAG         =       0,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    36
	TILE_SIZE_1x1        = 1U << 0,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    37
	TILE_NOT_SLOPED      = 1U << 1,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    38
	TILE_SIZE_2x1        = 1U << 2,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    39
	TILE_SIZE_1x2        = 1U << 3,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    40
	TILE_SIZE_2x2        = 1U << 4,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    41
	BUILDING_IS_ANIMATED = 1U << 5,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    42
	BUILDING_IS_CHURCH   = 1U << 6,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    43
	BUILDING_IS_STADIUM  = 1U << 7,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    44
	BUILDING_HAS_1_TILE  = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    45
	BUILDING_2_TILES_X   = TILE_SIZE_2x1 | TILE_SIZE_2x2,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    46
	BUILDING_2_TILES_Y   = TILE_SIZE_1x2 | TILE_SIZE_2x2,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    47
	BUILDING_HAS_4_TILES = TILE_SIZE_2x2,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    48
};
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    49
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    50
DECLARE_ENUM_AS_BIT_SET(BuildingFlags)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    51
8308
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    52
enum HouseZonesBits {
8814
bff94f5654b5 (svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents: 8796
diff changeset
    53
	HZB_BEGIN     = 0,
8308
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    54
	HZB_TOWN_EDGE = 0,
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    55
	HZB_TOWN_OUTSKIRT,
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    56
	HZB_TOWN_OUTER_SUBURB,
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    57
	HZB_TOWN_INNER_SUBURB,
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    58
	HZB_TOWN_CENTRE,
8814
bff94f5654b5 (svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents: 8796
diff changeset
    59
	HZB_END,
8308
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    60
};
8814
bff94f5654b5 (svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents: 8796
diff changeset
    61
assert_compile(HZB_END == 5);
bff94f5654b5 (svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents: 8796
diff changeset
    62
bff94f5654b5 (svn r12560) -Cleanup: town_cmd.cpp and header files - variable scope and a bit of coding style
smatz
parents: 8796
diff changeset
    63
DECLARE_POSTFIX_INCREMENT(HouseZonesBits)
8308
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    64
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    65
enum HouseZones {                  ///< Bit  Value       Meaning
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    66
	HZ_NOZNS             = 0x0000,  ///<       0          This is just to get rid of zeros, meaning none
8308
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    67
	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
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    68
	HZ_ZON2              = 1U << HZB_TOWN_OUTSKIRT,
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    69
	HZ_ZON3              = 1U << HZB_TOWN_OUTER_SUBURB,
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    70
	HZ_ZON4              = 1U << HZB_TOWN_INNER_SUBURB,
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
    71
	HZ_ZON5              = 1U << HZB_TOWN_CENTRE,  ///<  center of town
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    72
	HZ_ZONALL            = 0x001F,  ///<       1F         This is just to englobe all above types at once
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    73
	HZ_SUBARTC_ABOVE     = 0x0800,  ///< 11    800        can appear in sub-arctic climate above the snow line
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    74
	HZ_TEMP              = 0x1000,  ///< 12   1000        can appear in temperate climate
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    75
	HZ_SUBARTC_BELOW     = 0x2000,  ///< 13   2000        can appear in sub-arctic climate below the snow line
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    76
	HZ_SUBTROPIC         = 0x4000,  ///< 14   4000        can appear in subtropical climate
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    77
	HZ_TOYLND            = 0x8000   ///< 15   8000        can appear in toyland climate
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    78
};
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    79
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    80
DECLARE_ENUM_AS_BIT_SET(HouseZones)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    81
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    82
enum HouseExtraFlags {
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    83
	NO_EXTRA_FLAG            =       0,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    84
	BUILDING_IS_HISTORICAL   = 1U << 0,  ///< this house will only appear during town generation in random games, thus the historical
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9709
diff changeset
    85
	BUILDING_IS_PROTECTED    = 1U << 1,  ///< towns and AI will not remove this house, while human players will be able to
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    86
	SYNCHRONISED_CALLBACK_1B = 1U << 2,  ///< synchronized callback 1B will be performed, on multi tile houses
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    87
	CALLBACK_1A_RANDOM_BITS  = 1U << 3,  ///< callback 1A needs random bits
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    88
};
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    89
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    90
DECLARE_ENUM_AS_BIT_SET(HouseExtraFlags)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    91
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    92
struct BuildingCounts {
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    93
	uint8 id_count[HOUSE_MAX];
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    94
	uint8 class_count[HOUSE_CLASS_MAX];
5299
cf162c141e2f (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
};
cf162c141e2f (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
    96
7386
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
    97
DECLARE_OLD_POOL(Town, Town, 3, 8000)
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
    98
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
    99
struct Town : PoolItem<Town, TownID, &_Town_pool> {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	TileIndex xy;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   102
	/* Current population of people and amount of houses. */
8707
e57a09994e12 (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: 8308
diff changeset
   103
	uint32 num_houses;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	uint32 population;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 121
diff changeset
   105
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   106
	/* Town name */
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6605
diff changeset
   107
	uint32 townnamegrfid;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
	uint16 townnametype;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
	uint32 townnameparts;
8258
9fa31acb07bc (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8254
diff changeset
   110
	char *name;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 121
diff changeset
   111
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   112
	/* NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
	ViewportSign sign;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 121
diff changeset
   114
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   115
	/* Makes sure we don't build certain house types twice.
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   116
	 * bit 0 = Building funds received
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   117
	 * bit 1 = CHURCH
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   118
	 * bit 2 = STADIUM */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	byte flags12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   121
	/* level of noise that all the airports are generating */
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   122
	uint16 noise_reached;
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   123
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9709
diff changeset
   124
	/* Which companies have a statue? */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	byte statues;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9709
diff changeset
   127
	/* Company ratings as well as a mask that determines which companies have a rating. */
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9709
diff changeset
   128
	CompanyMask have_ratings;
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9709
diff changeset
   129
	uint8 unwanted[MAX_COMPANIES]; ///< how many months companies aren't wanted by towns (bribe)
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9709
diff changeset
   130
	CompanyByte exclusivity;       ///< which company has exclusivity
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9709
diff changeset
   131
	uint8 exclusive_counter;       ///< months till the exclusivity expires
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9709
diff changeset
   132
	int16 ratings[MAX_COMPANIES];
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 121
diff changeset
   133
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   134
	/* Maximum amount of passengers and mail that can be transported. */
1377
7ab329d1fc28 (svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents: 1362
diff changeset
   135
	uint32 max_pass;
7ab329d1fc28 (svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents: 1362
diff changeset
   136
	uint32 max_mail;
7ab329d1fc28 (svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents: 1362
diff changeset
   137
	uint32 new_max_pass;
7ab329d1fc28 (svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents: 1362
diff changeset
   138
	uint32 new_max_mail;
7ab329d1fc28 (svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents: 1362
diff changeset
   139
	uint32 act_pass;
7ab329d1fc28 (svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents: 1362
diff changeset
   140
	uint32 act_mail;
7ab329d1fc28 (svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents: 1362
diff changeset
   141
	uint32 new_act_pass;
7ab329d1fc28 (svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents: 1362
diff changeset
   142
	uint32 new_act_mail;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   144
	/* Amount of passengers that were transported. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
	byte pct_pass_transported;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	byte pct_mail_transported;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   148
	/* Amount of food and paper that was transported. Actually a bit mask would be enough. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
	uint16 act_food;
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   150
	uint16 act_water;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
	uint16 new_act_food;
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   152
	uint16 new_act_water;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 121
diff changeset
   153
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   154
	/* Time until we rebuild a house. */
6454
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   155
	uint16 time_until_rebuild;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   157
	/* When to grow town next time. */
6454
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   158
	uint16 grow_counter;
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   159
	int16 growth_rate;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   161
	/* Fund buildings program in action? */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	byte fund_buildings_months;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 121
diff changeset
   163
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   164
	/* Fund road reconstruction in action? */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	byte road_build_months;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6484
diff changeset
   167
	/* If this is a larger town, and should grow more quickly. */
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6484
diff changeset
   168
	bool larger_town;
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6484
diff changeset
   169
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   170
	/* NOSAVE: UpdateTownRadius updates this given the house count. */
8943
53044ba4676f (svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents: 8814
diff changeset
   171
	uint32 squared_town_zone_radius[HZB_END];
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   172
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   173
	/* NOSAVE: The number of each type of building in the town. */
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   174
	BuildingCounts building_counts;
7386
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   175
8796
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   176
	/* NOSAVE: The town specific road layout */
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   177
	TownLayout layout;
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   178
7386
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   179
	/**
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   180
	 * Creates a new town
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   181
	 */
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   182
	Town(TileIndex tile = 0);
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   183
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   184
	/** Destroy the town */
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   185
	~Town();
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   186
7496
49cec492627b (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: 7413
diff changeset
   187
	inline bool IsValid() const { return this->xy != 0; }
8796
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   188
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   189
	void InitializeLayout();
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   190
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   191
	inline TownLayout GetActiveLayout() const;
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   192
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   193
	/** Calculate the max town noise
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   194
	 * The value is counted using the population divided by the content of the
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   195
	 * entry in town_noise_population corespondig to the town's tolerance.
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   196
	 * To this result, we add 3, which is the noise of the lowest airport.
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   197
	 * So user can at least buld that airport
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   198
	 * @return the maximum noise level the town will tolerate */
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   199
	inline uint16 MaxTownNoise() const {
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   200
		if (this->population == 0) return 0; // no population? no noise
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   201
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9387
diff changeset
   202
		return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
9334
28ac6c8e0795 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas
parents: 9127
diff changeset
   203
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
8796
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   206
/**
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   207
 * Get the current valid layout for the town
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   208
 * @return the active layout for this town
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   209
 */
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   210
inline TownLayout Town::GetActiveLayout() const
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   211
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9387
diff changeset
   212
	return (_settings_game.economy.town_layout == TL_RANDOM) ? this->layout : _settings_game.economy.town_layout;
8796
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   213
}
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   214
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   215
struct HouseSpec {
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   216
	/* Standard properties */
9450
9e7d05b0b1e5 (svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents: 9413
diff changeset
   217
	Year min_year;                     ///< introduction year of the house
9e7d05b0b1e5 (svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents: 9413
diff changeset
   218
	Year max_year;                     ///< last year it can be built
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   219
	byte population;                   ///< population (Zero on other tiles in multi tile house.)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   220
	byte removal_cost;                 ///< cost multiplier for removing it
8959
636d242edd89 (svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents: 8943
diff changeset
   221
	StringID building_name;            ///< building name
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   222
	uint16 remove_rating_decrease;     ///< rating decrease if removed
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   223
	byte mail_generation;              ///< mail generation multiplier (tile based, as the acceptances below)
6341
b670e4765225 (svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents: 6332
diff changeset
   224
	byte cargo_acceptance[3];          ///< acceptance level for the cargo slots
b670e4765225 (svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents: 6332
diff changeset
   225
	CargoID accepts_cargo[3];          ///< 3 input cargo slots
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   226
	BuildingFlags building_flags;      ///< some flags that describe the house (size, stadium etc...)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   227
	HouseZones building_availability;  ///< where can it be built (climates, zones)
6605
d92f454a00a6 (svn r9823) -Feature: Add support for house property 1F - minimum life span.
maedhros
parents: 6486
diff changeset
   228
	bool enabled;                      ///< the house is available to build (true by default, but can be disabled by newgrf)
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   229
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   230
	/* NewHouses properties */
6605
d92f454a00a6 (svn r9823) -Feature: Add support for house property 1F - minimum life span.
maedhros
parents: 6486
diff changeset
   231
	HouseID substitute_id;             ///< which original house this one is based on
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   232
	struct SpriteGroup *spritegroup;   ///< pointer to the different sprites of the house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   233
	HouseID override;                  ///< which house this one replaces
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   234
	uint16 callback_mask;              ///< House callback flags
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   235
	byte random_colour[4];             ///< 4 "random" colours
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   236
	byte probability;                  ///< Relative probability of appearing (16 is the standard value)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   237
	HouseExtraFlags extra_flags;       ///< some more flags
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   238
	HouseClassID class_id;             ///< defines the class this house has (grf file based) @See HouseGetVariable, prop 0x44
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   239
	byte animation_frames;             ///< number of animation frames
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   240
	byte animation_speed;              ///< amount of time between each of those frames
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   241
	byte processing_time;              ///< Periodic refresh multiplier
6605
d92f454a00a6 (svn r9823) -Feature: Add support for house property 1F - minimum life span.
maedhros
parents: 6486
diff changeset
   242
	byte minimum_life;                 ///< The minimum number of years this house will survive before the town rebuilds it
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   243
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   244
	/* grf file related properties*/
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   245
	uint8 local_id;                    ///< id defined by the grf file for this house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   246
	const struct GRFFile *grffile;     ///< grf file that introduced this house
9463
174d00929d44 (svn r13383) -Codechange: Put the cost of house removal in a class member
belugas
parents: 9450
diff changeset
   247
174d00929d44 (svn r13383) -Codechange: Put the cost of house removal in a class member
belugas
parents: 9450
diff changeset
   248
	/**
174d00929d44 (svn r13383) -Codechange: Put the cost of house removal in a class member
belugas
parents: 9450
diff changeset
   249
	 * Get the cost for removing this house
174d00929d44 (svn r13383) -Codechange: Put the cost of house removal in a class member
belugas
parents: 9450
diff changeset
   250
	 * @return the cost (inflation corrected etc)
174d00929d44 (svn r13383) -Codechange: Put the cost of house removal in a class member
belugas
parents: 9450
diff changeset
   251
	 */
174d00929d44 (svn r13383) -Codechange: Put the cost of house removal in a class member
belugas
parents: 9450
diff changeset
   252
	Money GetRemovalCost() const;
174d00929d44 (svn r13383) -Codechange: Put the cost of house removal in a class member
belugas
parents: 9450
diff changeset
   253
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   254
};
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   255
8268
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
   256
extern HouseSpec _house_specs[HOUSE_MAX];
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   257
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5982
diff changeset
   258
uint32 GetWorldPopulation();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
835
f6a341f541d7 (svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents: 820
diff changeset
   260
void UpdateTownVirtCoord(Town *t);
7969
5f1292aa867f (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: 7496
diff changeset
   261
void UpdateAllTownVirtCoords();
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5982
diff changeset
   262
void InitializeTown();
3346
a0d4def7d934 (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
   263
void ShowTownViewWindow(TownID town);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
void ExpandTown(Town *t);
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6484
diff changeset
   265
Town *CreateRandomTown(uint attempts, TownSizeMode mode, uint size);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
	ROAD_REMOVE = 0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
	UNMOVEABLE_REMOVE = 1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
	TUNNELBRIDGE_REMOVE = 1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
	INDUSTRY_REMOVE = 2
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
6454
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   274
/** This is the number of ticks between towns being processed for building new
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   275
 * houses or roads. This value originally came from the size of the town array
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   276
 * in TTD. */
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   277
static const byte TOWN_GROWTH_FREQUENCY = 70;
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   278
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   279
/** Simple value that indicates the house has reached the final stage of
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   280
 * construction. */
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6422
diff changeset
   281
static const byte TOWN_HOUSE_COMPLETED = 3;
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3349
diff changeset
   282
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   283
/** This enum is used in conjonction with town->flags12.
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3349
diff changeset
   284
 * IT simply states what bit is used for.
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3349
diff changeset
   285
 * It is pretty unrealistic (IMHO) to only have one church/stadium
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3349
diff changeset
   286
 * per town, NO MATTER the population of it.
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3349
diff changeset
   287
 * And there are 5 more bits available on flags12...
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3349
diff changeset
   288
 */
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3349
diff changeset
   289
enum {
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   290
	TOWN_IS_FUNDED      = 0,   ///< Town has received some funds for
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   291
	TOWN_HAS_CHURCH     = 1,   ///< There can be only one church by town.
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   292
	TOWN_HAS_STADIUM    = 2    ///< There can be only one stadium by town.
1005
f48b2bdd84fc (svn r1504) enummed town ratings (Jango)
celestar
parents: 919
diff changeset
   293
};
f48b2bdd84fc (svn r1504) enummed town ratings (Jango)
celestar
parents: 919
diff changeset
   294
2958
ac0a9673b522 (svn r3520) Remove unused parameters from some functions
tron
parents: 2817
diff changeset
   295
bool CheckforTownRating(uint32 flags, Town *t, byte type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   297
static inline HouseSpec *GetHouseSpecs(HouseID house_id)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   298
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   299
	assert(house_id < HOUSE_MAX);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   300
	return &_house_specs[house_id];
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   301
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   302
10269
eb8e4225dbc6 (svn r14504) -Cleanup: Use the right variable type for tile offsets.
michi_cc
parents: 10208
diff changeset
   303
TileIndexDiff GetHouseNorthPart(HouseID &house);
9594
8ea48f013588 (svn r13634) -Codechange: Let house var 0x65 ignore the house, the variable is queried for.
frosch
parents: 9463
diff changeset
   304
1260
632f63689178 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents: 1220
diff changeset
   305
/**
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   306
 * Check if a TownID is valid.
6484
79156627e1ba (svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents: 6454
diff changeset
   307
 * @param index to inquiry in the pool of town
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   308
 * @return true if it exists
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6341
diff changeset
   309
 */
5299
cf162c141e2f (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
static inline bool IsValidTownID(TownID index)
cf162c141e2f (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
{
7386
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   312
	return index < GetTownPoolSize() && GetTown(index)->IsValid();
5299
cf162c141e2f (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
}
cf162c141e2f (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
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5982
diff changeset
   315
static inline TownID GetMaxTownIndex()
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   316
{
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   317
	/* TODO - This isn't the real content of the function, but
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   318
	 *  with the new pool-system this will be replaced with one that
5247
1f982de55b88 (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
   319
	 *  _really_ returns the highest index. Now it just returns
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   320
	 *  the next safe value we are sure about everything is below.
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   321
	 */
5298
46eabcb5c2b2 (svn r7451) -Fix (7372): GetNum(Towns|Industries) should return the actual number of towns and industries.
rubidium
parents: 5247
diff changeset
   322
	return GetTownPoolSize() - 1;
5247
1f982de55b88 (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
}
1f982de55b88 (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
   324
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5982
diff changeset
   325
static inline uint GetNumTowns()
5247
1f982de55b88 (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
   326
{
8268
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
   327
	extern uint _total_towns;
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
   328
4357
aaba385fa723 (svn r6058) -Fix: Get(Industry|Town)ArraySize could never return 0
truelight
parents: 4356
diff changeset
   329
	return _total_towns;
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   330
}
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   331
4356
ec4e13f21cd0 (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
/**
ec4e13f21cd0 (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
 * Return a random valid town.
ec4e13f21cd0 (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
   334
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5982
diff changeset
   335
static inline Town *GetRandomTown()
4356
ec4e13f21cd0 (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
   336
{
5299
cf162c141e2f (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
	int num = RandomRange(GetNumTowns());
cf162c141e2f (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
   338
	TownID index = INVALID_TOWN;
4356
ec4e13f21cd0 (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
   339
5299
cf162c141e2f (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
   340
	while (num >= 0) {
4356
ec4e13f21cd0 (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
		num--;
ec4e13f21cd0 (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
ec4e13f21cd0 (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
   343
		index++;
5982
52b4f9d7764b (svn r8681) -Fix (FS#608): wrong comment (rfalke)
rubidium
parents: 5969
diff changeset
   344
		/* Make sure we have a valid town */
5299
cf162c141e2f (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
   345
		while (!IsValidTownID(index)) {
4356
ec4e13f21cd0 (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
   346
			index++;
5299
cf162c141e2f (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
   347
			assert(index <= GetMaxTownIndex());
4356
ec4e13f21cd0 (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
		}
ec4e13f21cd0 (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
	}
ec4e13f21cd0 (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
ec4e13f21cd0 (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
	return GetTown(index);
ec4e13f21cd0 (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
}
ec4e13f21cd0 (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
   353
8268
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
   354
Town *CalcClosestTownFromTile(TileIndex tile, uint threshold);
5969
57cbd6e884f5 (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: 5587
diff changeset
   355
7386
93f6a042d1c3 (svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents: 6956
diff changeset
   356
#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
632f63689178 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents: 1220
diff changeset
   357
#define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
632f63689178 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents: 1220
diff changeset
   358
8268
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
   359
extern Town *_cleared_town;
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
   360
extern int _cleared_town_rating;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   362
void ResetHouses();
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   363
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   364
void ClearTownHouse(Town *t, TileIndex tile);
8131
160939e24ed3 (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: 8130
diff changeset
   365
void AfterLoadTown();
160939e24ed3 (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: 8130
diff changeset
   366
void UpdateTownMaxPass(Town *t);
8707
e57a09994e12 (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: 8308
diff changeset
   367
void UpdateTownRadius(Town *t);
8131
160939e24ed3 (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: 8130
diff changeset
   368
bool CheckIfAuthorityAllows(TileIndex tile);
160939e24ed3 (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: 8130
diff changeset
   369
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
160939e24ed3 (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: 8130
diff changeset
   370
void ChangeTownRating(Town *t, int add, int max);
8308
bc75a4a27ec9 (svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas
parents: 8298
diff changeset
   371
HouseZonesBits GetTownRadiusGroup(const Town* t, TileIndex tile);
8232
a4883a0598db (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents: 8213
diff changeset
   372
void SetTownRatingTestMode(bool mode);
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   373
8796
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   374
/**
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   375
 * Calculate a hash value from a tile position
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   376
 *
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   377
 * @param x The X coordinate
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   378
 * @param y The Y coordinate
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   379
 * @return The hash of the tile
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   380
 */
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   381
static inline uint TileHash(uint x, uint y)
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   382
{
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   383
	uint hash = x >> 4;
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   384
	hash ^= x >> 6;
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   385
	hash ^= y >> 4;
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   386
	hash -= y >> 6;
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   387
	return hash;
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   388
}
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   389
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   390
/**
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   391
 * Get the last two bits of the TileHash
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   392
 *  from a tile position.
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   393
 *
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   394
 * @see TileHash()
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   395
 * @param x The X coordinate
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   396
 * @param y The Y coordinate
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   397
 * @return The last two bits from hash of the tile
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   398
 */
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   399
static inline uint TileHash2Bit(uint x, uint y)
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   400
{
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   401
	return GB(TileHash(x, y), 0, 2);
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   402
}
ccf3ed611354 (svn r12534) -Feature: Add a new type of town road layouts - random for each town
skidd13
parents: 8791
diff changeset
   403
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
#endif /* TOWN_H */