author | richk |
Tue, 17 Jun 2008 13:41:57 +0000 | |
branch | NewGRF_ports |
changeset 10995 | 311b38c7f9a7 |
parent 10991 | d8811e327d12 |
permissions | -rw-r--r-- |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
1 |
/* $Id$ */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
2 |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10211
diff
changeset
|
3 |
/** @file newgrf_town.cpp Implementation of the town part of NewGRF houses. */ |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
4 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
6 |
#include "openttd.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6720
diff
changeset
|
7 |
#include "settings_type.h" |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
8 |
#include "debug.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6720
diff
changeset
|
9 |
#include "core/bitmath_func.hpp" |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
10 |
#include "core/math_func.hpp" |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
11 |
#include "town.h" |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
12 |
|
59048224be55
(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. |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
14 |
* @param variable that is queried |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
15 |
* @param parameter unused |
59048224be55
(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 |
59048224be55
(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 |
59048224be55
(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*/ |
59048224be55
(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) |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
20 |
{ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
21 |
switch (variable) { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
22 |
/* Larger towns */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6658
diff
changeset
|
23 |
case 0x40: |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
24 |
if (_settings_game.economy.larger_towns == 0) return 2; |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6658
diff
changeset
|
25 |
if (t->larger_town) return 1; |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6658
diff
changeset
|
26 |
return 0; |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
27 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
28 |
/* Town index */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
29 |
case 0x41: return t->index; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
30 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
31 |
/* Town properties */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
32 |
case 0x80: return t->xy; |
59048224be55
(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); |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
34 |
case 0x82: return ClampToU16(t->population); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
35 |
case 0x83: return GB(ClampToU16(t->population), 8, 8); |
6658
59048224be55
(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; |
59048224be55
(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 |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
38 |
case 0x93: return 0; |
10211
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
39 |
case 0x94: return ClampToU16(t->squared_town_zone_radius[0]); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
40 |
case 0x95: return GB(ClampToU16(t->squared_town_zone_radius[0]), 8, 8); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
41 |
case 0x96: return ClampToU16(t->squared_town_zone_radius[1]); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
42 |
case 0x97: return GB(ClampToU16(t->squared_town_zone_radius[1]), 8, 8); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
43 |
case 0x98: return ClampToU16(t->squared_town_zone_radius[2]); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
44 |
case 0x99: return GB(ClampToU16(t->squared_town_zone_radius[2]), 8, 8); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
45 |
case 0x9A: return ClampToU16(t->squared_town_zone_radius[3]); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
46 |
case 0x9B: return GB(ClampToU16(t->squared_town_zone_radius[3]), 8, 8); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
47 |
case 0x9C: return ClampToU16(t->squared_town_zone_radius[4]); |
c1391c8ed5c6
(svn r12743) [NewGRF_ports] -Sync: with trunk r12705:12741.
richk
parents:
10184
diff
changeset
|
48 |
case 0x9D: return GB(ClampToU16(t->squared_town_zone_radius[4]), 8, 8); |
6658
59048224be55
(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]; |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
50 |
case 0x9F: return GB(t->ratings[0], 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
51 |
case 0xA0: return t->ratings[1]; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
52 |
case 0xA1: return GB(t->ratings[1], 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
53 |
case 0xA2: return t->ratings[2]; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
54 |
case 0xA3: return GB(t->ratings[2], 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
55 |
case 0xA4: return t->ratings[3]; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
56 |
case 0xA5: return GB(t->ratings[3], 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
57 |
case 0xA6: return t->ratings[4]; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
58 |
case 0xA7: return GB(t->ratings[4], 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
59 |
case 0xA8: return t->ratings[5]; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
60 |
case 0xA9: return GB(t->ratings[5], 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
61 |
case 0xAA: return t->ratings[6]; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
62 |
case 0xAB: return GB(t->ratings[6], 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
63 |
case 0xAC: return t->ratings[7]; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
64 |
case 0xAD: return GB(t->ratings[7], 8, 8); |
6658
59048224be55
(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; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
66 |
case 0xB2: return t->statues; |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
67 |
case 0xB6: return ClampToU16(t->num_houses); |
6658
59048224be55
(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; |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
69 |
case 0xBA: return ClampToU16(t->new_max_pass); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
70 |
case 0xBB: return GB(ClampToU16(t->new_max_pass), 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
71 |
case 0xBC: return ClampToU16(t->new_max_mail); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
72 |
case 0xBD: return GB(ClampToU16(t->new_max_mail), 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
73 |
case 0xBE: return ClampToU16(t->new_act_pass); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
74 |
case 0xBF: return GB(ClampToU16(t->new_act_pass), 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
75 |
case 0xC0: return ClampToU16(t->new_act_mail); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
76 |
case 0xC1: return GB(ClampToU16(t->new_act_mail), 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
77 |
case 0xC2: return ClampToU16(t->max_pass); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
78 |
case 0xC3: return GB(ClampToU16(t->max_pass), 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
79 |
case 0xC4: return ClampToU16(t->max_mail); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
80 |
case 0xC5: return GB(ClampToU16(t->max_mail), 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
81 |
case 0xC6: return ClampToU16(t->act_pass); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
82 |
case 0xC7: return GB(ClampToU16(t->act_pass), 8, 8); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
83 |
case 0xC8: return ClampToU16(t->act_mail); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
84 |
case 0xC9: return GB(ClampToU16(t->act_mail), 8, 8); |
6658
59048224be55
(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; |
59048224be55
(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; |
59048224be55
(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; |
59048224be55
(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); |
59048224be55
(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; |
59048224be55
(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); |
59048224be55
(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; |
59048224be55
(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); |
59048224be55
(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; |
59048224be55
(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); |
59048224be55
(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; |
59048224be55
(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; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
97 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
98 |
|
59048224be55
(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); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
100 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
101 |
*available = false; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
102 |
return (uint32)-1; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
diff
changeset
|
103 |
} |