author | rubidium |
Sun, 14 Dec 2008 16:56:28 +0000 | |
changeset 10422 | f5985144f4a6 |
parent 9413 | 7042a8ec3fa8 |
permissions | -rw-r--r-- |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
1 |
/* $Id$ */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
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:
8943
diff
changeset
|
3 |
/** @file newgrf_town.cpp Implementation of the town part of NewGRF houses. */ |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
4 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
6 |
#include "openttd.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8131
diff
changeset
|
7 |
#include "settings_type.h" |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
8 |
#include "debug.h" |
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:
7156
diff
changeset
|
9 |
#include "core/bitmath_func.hpp" |
8610
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
10 |
#include "core/math_func.hpp" |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
11 |
#include "town.h" |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
12 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
13 |
/** This function implements the town variables that newGRF defines. |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
14 |
* @param variable that is queried |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
15 |
* @param parameter unused |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
16 |
* @param available will return false if ever the variable asked for does not exist |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
17 |
* @param t is of course the town we are inquiring |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
18 |
* @return the value stored in the corresponding variable*/ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
19 |
uint32 TownGetVariable(byte variable, byte parameter, bool *available, const Town *t) |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
20 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
21 |
switch (variable) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
22 |
/* Larger towns */ |
6520
978e8f5c009b
(svn r9706) -Codechange: Support NewGRF town var 40 'largertowns' variable properly.
peter1138
parents:
6332
diff
changeset
|
23 |
case 0x40: |
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:
9354
diff
changeset
|
24 |
if (_settings_game.economy.larger_towns == 0) return 2; |
6522
0d36695f5e85
(svn r9709) -Fix (r9706): Larger towns use t->larger_towns, not the town index.
maedhros
parents:
6520
diff
changeset
|
25 |
if (t->larger_town) return 1; |
6520
978e8f5c009b
(svn r9706) -Codechange: Support NewGRF town var 40 'largertowns' variable properly.
peter1138
parents:
6332
diff
changeset
|
26 |
return 0; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
27 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
28 |
/* Town index */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
29 |
case 0x41: return t->index; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
30 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
31 |
/* Town properties */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
32 |
case 0x80: return t->xy; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
33 |
case 0x81: return GB(t->xy, 8, 8); |
8610
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
34 |
case 0x82: return ClampToU16(t->population); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
35 |
case 0x83: return GB(ClampToU16(t->population), 8, 8); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
36 |
case 0x8A: return t->grow_counter; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
37 |
case 0x92: return t->flags12; // In original game, 0x92 and 0x93 are really one word. Since flags12 is a byte, this is to adjust |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
38 |
case 0x93: return 0; |
8943
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
39 |
case 0x94: return ClampToU16(t->squared_town_zone_radius[0]); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
40 |
case 0x95: return GB(ClampToU16(t->squared_town_zone_radius[0]), 8, 8); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
41 |
case 0x96: return ClampToU16(t->squared_town_zone_radius[1]); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
42 |
case 0x97: return GB(ClampToU16(t->squared_town_zone_radius[1]), 8, 8); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
43 |
case 0x98: return ClampToU16(t->squared_town_zone_radius[2]); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
44 |
case 0x99: return GB(ClampToU16(t->squared_town_zone_radius[2]), 8, 8); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
45 |
case 0x9A: return ClampToU16(t->squared_town_zone_radius[3]); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
46 |
case 0x9B: return GB(ClampToU16(t->squared_town_zone_radius[3]), 8, 8); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
47 |
case 0x9C: return ClampToU16(t->squared_town_zone_radius[4]); |
53044ba4676f
(svn r12726) -Fix [FS#1877]: overflow causing strange building behaviour in towns.
rubidium
parents:
8707
diff
changeset
|
48 |
case 0x9D: return GB(ClampToU16(t->squared_town_zone_radius[4]), 8, 8); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
49 |
case 0x9E: return t->ratings[0]; |
8635
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
50 |
case 0x9F: return GB(t->ratings[0], 8, 8); |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
51 |
case 0xA0: return t->ratings[1]; |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
52 |
case 0xA1: return GB(t->ratings[1], 8, 8); |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
53 |
case 0xA2: return t->ratings[2]; |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
54 |
case 0xA3: return GB(t->ratings[2], 8, 8); |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
55 |
case 0xA4: return t->ratings[3]; |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
56 |
case 0xA5: return GB(t->ratings[3], 8, 8); |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
57 |
case 0xA6: return t->ratings[4]; |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
58 |
case 0xA7: return GB(t->ratings[4], 8, 8); |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
59 |
case 0xA8: return t->ratings[5]; |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
60 |
case 0xA9: return GB(t->ratings[5], 8, 8); |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
61 |
case 0xAA: return t->ratings[6]; |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
62 |
case 0xAB: return GB(t->ratings[6], 8, 8); |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
63 |
case 0xAC: return t->ratings[7]; |
74316d58148d
(svn r12247) -Fix (r9315): Town variables 0x9E to 0xAD (company ratings) returned wrong values.
frosch
parents:
8610
diff
changeset
|
64 |
case 0xAD: return GB(t->ratings[7], 8, 8); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
65 |
case 0xAE: return t->have_ratings; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
66 |
case 0xB2: return t->statues; |
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:
8635
diff
changeset
|
67 |
case 0xB6: return ClampToU16(t->num_houses); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
68 |
case 0xB9: return t->growth_rate; |
8610
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
69 |
case 0xBA: return ClampToU16(t->new_max_pass); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
70 |
case 0xBB: return GB(ClampToU16(t->new_max_pass), 8, 8); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
71 |
case 0xBC: return ClampToU16(t->new_max_mail); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
72 |
case 0xBD: return GB(ClampToU16(t->new_max_mail), 8, 8); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
73 |
case 0xBE: return ClampToU16(t->new_act_pass); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
74 |
case 0xBF: return GB(ClampToU16(t->new_act_pass), 8, 8); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
75 |
case 0xC0: return ClampToU16(t->new_act_mail); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
76 |
case 0xC1: return GB(ClampToU16(t->new_act_mail), 8, 8); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
77 |
case 0xC2: return ClampToU16(t->max_pass); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
78 |
case 0xC3: return GB(ClampToU16(t->max_pass), 8, 8); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
79 |
case 0xC4: return ClampToU16(t->max_mail); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
80 |
case 0xC5: return GB(ClampToU16(t->max_mail), 8, 8); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
81 |
case 0xC6: return ClampToU16(t->act_pass); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
82 |
case 0xC7: return GB(ClampToU16(t->act_pass), 8, 8); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
83 |
case 0xC8: return ClampToU16(t->act_mail); |
3d2183c29dc2
(svn r12192) -Fix: clamp various town variables to 16bit prior to returning the value
smatz
parents:
8270
diff
changeset
|
84 |
case 0xC9: return GB(ClampToU16(t->act_mail), 8, 8); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
85 |
case 0xCA: return t->pct_pass_transported; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
86 |
case 0xCB: return t->pct_mail_transported; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
87 |
case 0xCC: return t->new_act_food; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
88 |
case 0xCD: return GB(t->new_act_food, 8, 8); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
89 |
case 0xCE: return t->new_act_water; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
90 |
case 0xCF: return GB(t->new_act_water, 8, 8); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
91 |
case 0xD0: return t->act_food; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
92 |
case 0xD1: return GB(t->act_food, 8, 8); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
93 |
case 0xD2: return t->act_water; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
94 |
case 0xD3: return GB(t->act_water, 8, 8); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
95 |
case 0xD4: return t->road_build_months; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
96 |
case 0xD5: return t->fund_buildings_months; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
97 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
98 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
99 |
DEBUG(grf, 1, "Unhandled town property 0x%X", variable); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
100 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
101 |
*available = false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
102 |
return (uint32)-1; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
103 |
} |