author | celestar |
Tue, 19 Jun 2007 07:21:01 +0000 | |
branch | gamebalance |
changeset 9913 | e79cd19772dd |
parent 9912 | 1ac8aac92385 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
3 |
/** @file clear_cmd.cpp */ |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1878
diff
changeset
|
6 |
#include "openttd.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
2989
diff
changeset
|
7 |
#include "clear_map.h" |
4041
caf4fcb4e05b
(svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents:
4031
diff
changeset
|
8 |
#include "rail_map.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
473
diff
changeset
|
9 |
#include "table/strings.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2154
diff
changeset
|
10 |
#include "functions.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
507
diff
changeset
|
11 |
#include "map.h" |
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2153
diff
changeset
|
12 |
#include "player.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1202
diff
changeset
|
13 |
#include "tile.h" |
0 | 14 |
#include "viewport.h" |
15 |
#include "command.h" |
|
3156
028b6756b279
(svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents:
3144
diff
changeset
|
16 |
#include "tunnel_map.h" |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
17 |
#include "bridge_map.h" |
6486
4f8af35b11eb
(svn r8908) -Codechange: declaration of DrawBridgeMiddle does not belong in a map accessors header.
rubidium
parents:
6449
diff
changeset
|
18 |
#include "bridge.h" |
9906
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
19 |
#include "landscape.h" |
2153
91e89aa8c299
(svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents:
2150
diff
changeset
|
20 |
#include "variables.h" |
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2436
diff
changeset
|
21 |
#include "table/sprites.h" |
3310
7339b2b1e957
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3279
diff
changeset
|
22 |
#include "unmovable_map.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
23 |
#include "genworld.h" |
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4300
diff
changeset
|
24 |
#include "industry.h" |
9899
cde52f745560
(svn r9386) [gamebalance] -Feature: Selling and buying land costs now take proximity to town centers into account. Move some code around while I'm at it. Also selling land gives as much money as buying land costs.
celestar
parents:
9895
diff
changeset
|
25 |
#include "town.h" |
0 | 26 |
|
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6486
diff
changeset
|
27 |
struct TerraformerHeightMod { |
0 | 28 |
TileIndex tile; |
29 |
byte height; |
|
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6486
diff
changeset
|
30 |
}; |
0 | 31 |
|
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6486
diff
changeset
|
32 |
struct TerraformerState { |
0 | 33 |
int height[4]; |
34 |
uint32 flags; |
|
35 |
||
36 |
int direction; |
|
37 |
int modheight_count; |
|
38 |
int tile_table_count; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
39 |
|
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
40 |
CommandCost cost; |
0 | 41 |
|
42 |
TileIndex *tile_table; |
|
43 |
TerraformerHeightMod *modheight; |
|
44 |
||
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6486
diff
changeset
|
45 |
}; |
0 | 46 |
|
47 |
static int TerraformAllowTileProcess(TerraformerState *ts, TileIndex tile) |
|
48 |
{ |
|
49 |
TileIndex *t; |
|
50 |
int count; |
|
51 |
||
2639 | 52 |
if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return -1; |
0 | 53 |
|
54 |
t = ts->tile_table; |
|
2639 | 55 |
for (count = ts->tile_table_count; count != 0; count--, t++) { |
56 |
if (*t == tile) return 0; |
|
0 | 57 |
} |
58 |
||
59 |
return 1; |
|
60 |
} |
|
61 |
||
62 |
static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile) |
|
63 |
{ |
|
64 |
TerraformerHeightMod *mod = ts->modheight; |
|
65 |
int count; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
66 |
|
2639 | 67 |
for (count = ts->modheight_count; count != 0; count--, mod++) { |
68 |
if (mod->tile == tile) return mod->height; |
|
0 | 69 |
} |
70 |
||
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
71 |
return TileHeight(tile); |
0 | 72 |
} |
73 |
||
74 |
static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile) |
|
75 |
{ |
|
76 |
int count; |
|
77 |
TileIndex *t; |
|
78 |
||
79 |
count = ts->tile_table_count; |
|
80 |
||
2639 | 81 |
if (count >= 625) return; |
0 | 82 |
|
9910
0b2aebc8283e
(svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents:
9906
diff
changeset
|
83 |
for (t = ts->tile_table; count != 0; count--, t++) { |
2639 | 84 |
if (*t == tile) return; |
0 | 85 |
} |
86 |
||
87 |
ts->tile_table[ts->tile_table_count++] = tile; |
|
88 |
} |
|
89 |
||
90 |
static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile) |
|
91 |
{ |
|
1981 | 92 |
TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1)); |
93 |
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1)); |
|
94 |
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, 0)); |
|
0 | 95 |
TerraformAddDirtyTile(ts, tile); |
96 |
} |
|
97 |
||
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
98 |
static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode) |
0 | 99 |
{ |
100 |
int r; |
|
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
101 |
CommandCost ret; |
0 | 102 |
|
863
8d09f9331a80
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
856
diff
changeset
|
103 |
assert(tile < MapSize()); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
104 |
|
4068 | 105 |
r = TerraformAllowTileProcess(ts, tile); |
106 |
if (r <= 0) return r; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
107 |
|
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
108 |
if (IsTileType(tile, MP_RAILWAY)) { |
4068 | 109 |
static const TrackBits safe_track[] = { TRACK_BIT_LOWER, TRACK_BIT_LEFT, TRACK_BIT_UPPER, TRACK_BIT_RIGHT }; |
110 |
static const Slope unsafe_slope[] = { SLOPE_S, SLOPE_W, SLOPE_N, SLOPE_E }; |
|
0 | 111 |
|
4069
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
112 |
Slope tileh; |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
113 |
uint z; |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
114 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
115 |
/* Nothing could be built at the steep slope - this avoids a bug |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
116 |
* when you have a single diagonal track in one corner on a |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
117 |
* basement and then you raise/lower the other corner. */ |
4069
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
118 |
tileh = GetTileSlope(tile, &z); |
4068 | 119 |
if (tileh == unsafe_slope[mode] || |
120 |
tileh == ComplementSlope(unsafe_slope[mode])) { |
|
2686
a3e667057607
(svn r3228) - Fix: [ 1327011 ] Fix: don't lower land on tunnel, even with diag tracks on it (based on patch by glx)
peter1138
parents:
2639
diff
changeset
|
121 |
_terraform_err_tile = tile; |
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
122 |
_error_message = STR_1008_MUST_REMOVE_RAILROAD_TRACK; |
2686
a3e667057607
(svn r3228) - Fix: [ 1327011 ] Fix: don't lower land on tunnel, even with diag tracks on it (based on patch by glx)
peter1138
parents:
2639
diff
changeset
|
123 |
return -1; |
a3e667057607
(svn r3228) - Fix: [ 1327011 ] Fix: don't lower land on tunnel, even with diag tracks on it (based on patch by glx)
peter1138
parents:
2639
diff
changeset
|
124 |
} |
a3e667057607
(svn r3228) - Fix: [ 1327011 ] Fix: don't lower land on tunnel, even with diag tracks on it (based on patch by glx)
peter1138
parents:
2639
diff
changeset
|
125 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
126 |
/* If we have a single diagonal track there, the other side of |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
127 |
* tile can be terraformed. */ |
4068 | 128 |
if (IsPlainRailTile(tile) && GetTrackBits(tile) == safe_track[mode]) { |
4069
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
129 |
/* If terraforming downwards prevent damaging a potential tunnel below. |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
130 |
* This check is only necessary for flat tiles, because if the tile is |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
131 |
* non-flat, then the corner opposing the rail is raised. Only this corner |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
132 |
* can be lowered and this is a safe action |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
133 |
*/ |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
134 |
if (tileh == SLOPE_FLAT && |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
135 |
ts->direction == -1 && |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
136 |
IsTunnelInWay(tile, z - TILE_HEIGHT)) { |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
137 |
_terraform_err_tile = tile; |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
138 |
_error_message = STR_1002_EXCAVATION_WOULD_DAMAGE; |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
139 |
return -1; |
d2139f621c74
(svn r5365) -Fix: It was possible to dig into a tunnel if certain rail combinations were ontop of it
tron
parents:
4068
diff
changeset
|
140 |
} |
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
141 |
return 0; |
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
142 |
} |
0 | 143 |
} |
144 |
||
9910
0b2aebc8283e
(svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents:
9906
diff
changeset
|
145 |
ret = DoCommand(tile, 0, 0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR); |
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
146 |
|
4560
f744bf3dd85a
(svn r6407) -Fix: Check return values of DoCommand() with CmdFailed and that of DoCommandP
Darkvater
parents:
4559
diff
changeset
|
147 |
if (CmdFailed(ret)) { |
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
148 |
_terraform_err_tile = tile; |
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
149 |
return -1; |
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
150 |
} |
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
151 |
|
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
152 |
ts->cost += ret; |
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
153 |
|
2639 | 154 |
if (ts->tile_table_count >= 625) return -1; |
0 | 155 |
ts->tile_table[ts->tile_table_count++] = tile; |
156 |
||
157 |
return 0; |
|
158 |
} |
|
159 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
160 |
static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height) |
0 | 161 |
{ |
162 |
int nh; |
|
163 |
TerraformerHeightMod *mod; |
|
164 |
int count; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
165 |
|
863
8d09f9331a80
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
856
diff
changeset
|
166 |
assert(tile < MapSize()); |
0 | 167 |
|
168 |
if (height < 0) { |
|
169 |
_error_message = STR_1003_ALREADY_AT_SEA_LEVEL; |
|
170 |
return false; |
|
171 |
} |
|
172 |
||
173 |
_error_message = STR_1004_TOO_HIGH; |
|
174 |
||
2639 | 175 |
if (height > 15) return false; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
176 |
|
0 | 177 |
nh = TerraformGetHeightOfTile(ts, tile); |
2639 | 178 |
if (nh < 0 || height == nh) return false; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
179 |
|
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
180 |
if (TerraformProc(ts, tile, 0) < 0) return false; |
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
181 |
if (TerraformProc(ts, tile + TileDiffXY( 0, -1), 1) < 0) return false; |
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
182 |
if (TerraformProc(ts, tile + TileDiffXY(-1, -1), 2) < 0) return false; |
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
183 |
if (TerraformProc(ts, tile + TileDiffXY(-1, 0), 3) < 0) return false; |
0 | 184 |
|
185 |
mod = ts->modheight; |
|
186 |
count = ts->modheight_count; |
|
187 |
||
2639 | 188 |
for (;;) { |
0 | 189 |
if (count == 0) { |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
190 |
if (ts->modheight_count >= 576) return false; |
0 | 191 |
ts->modheight_count++; |
192 |
break; |
|
193 |
} |
|
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1981
diff
changeset
|
194 |
if (mod->tile == tile) break; |
0 | 195 |
mod++; |
196 |
count--; |
|
197 |
} |
|
198 |
||
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1981
diff
changeset
|
199 |
mod->tile = tile; |
0 | 200 |
mod->height = (byte)height; |
201 |
||
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
202 |
ts->cost += _eco->GetPrice(CEconomy::TERRAFORM); |
0 | 203 |
|
204 |
{ |
|
205 |
int direction = ts->direction, r; |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
206 |
const TileIndexDiffC *ttm; |
0 | 207 |
|
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
208 |
static const TileIndexDiffC _terraform_tilepos[] = { |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
209 |
{ 1, 0}, |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
210 |
{-2, 0}, |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
211 |
{ 1, 1}, |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
212 |
{ 0, -2} |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
213 |
}; |
0 | 214 |
|
2952 | 215 |
for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) { |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
216 |
tile += ToTileIndexDiff(*ttm); |
0 | 217 |
|
218 |
r = TerraformGetHeightOfTile(ts, tile); |
|
9910
0b2aebc8283e
(svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents:
9906
diff
changeset
|
219 |
if (r != height && r - direction != height && r + direction != height) { |
0b2aebc8283e
(svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents:
9906
diff
changeset
|
220 |
if (!TerraformTileHeight(ts, tile, r + direction)) |
0 | 221 |
return false; |
222 |
} |
|
223 |
} |
|
224 |
} |
|
225 |
||
226 |
return true; |
|
227 |
} |
|
228 |
||
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1571
diff
changeset
|
229 |
/** Terraform land |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
230 |
* @param tile tile to terraform |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
231 |
* @param flags for this command type |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
232 |
* @param p1 corners to terraform. |
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1571
diff
changeset
|
233 |
* @param p2 direction; eg up or down |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
234 |
* @return error or cost of terraforming |
0 | 235 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
236 |
CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 237 |
{ |
238 |
TerraformerState ts; |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
239 |
TileIndex t; |
0 | 240 |
int direction; |
241 |
||
242 |
TerraformerHeightMod modheight_data[576]; |
|
243 |
TileIndex tile_table_data[625]; |
|
244 |
||
245 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
246 |
||
247 |
_terraform_err_tile = 0; |
|
248 |
||
249 |
ts.direction = direction = p2 ? 1 : -1; |
|
250 |
ts.flags = flags; |
|
251 |
ts.modheight_count = ts.tile_table_count = 0; |
|
252 |
ts.cost = 0; |
|
253 |
ts.modheight = modheight_data; |
|
254 |
ts.tile_table = tile_table_data; |
|
255 |
||
1878
622765748231
(svn r2384) - Fix: Check selling land and setting player colour. Also an extra map-bounds check for terraforming; inspired by the monkey (and Tron :) )
Darkvater
parents:
1796
diff
changeset
|
256 |
/* Make an extra check for map-bounds cause we add tiles to the originating tile */ |
2934
3b7eef9871f8
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
tron
parents:
2705
diff
changeset
|
257 |
if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR; |
1878
622765748231
(svn r2384) - Fix: Check selling land and setting player colour. Also an extra map-bounds check for terraforming; inspired by the monkey (and Tron :) )
Darkvater
parents:
1796
diff
changeset
|
258 |
|
0 | 259 |
if (p1 & 1) { |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
260 |
t = tile + TileDiffXY(1, 0); |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
261 |
if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) { |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
262 |
return CMD_ERROR; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
263 |
} |
0 | 264 |
} |
265 |
||
266 |
if (p1 & 2) { |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
267 |
t = tile + TileDiffXY(1, 1); |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
268 |
if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) { |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
269 |
return CMD_ERROR; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
270 |
} |
0 | 271 |
} |
272 |
||
273 |
if (p1 & 4) { |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
274 |
t = tile + TileDiffXY(0, 1); |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
275 |
if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) { |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
276 |
return CMD_ERROR; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
277 |
} |
0 | 278 |
} |
279 |
||
280 |
if (p1 & 8) { |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
281 |
t = tile + TileDiffXY(0, 0); |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
282 |
if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) { |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
283 |
return CMD_ERROR; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
284 |
} |
0 | 285 |
} |
286 |
||
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
287 |
{ |
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4043
diff
changeset
|
288 |
/* Check if tunnel would take damage */ |
0 | 289 |
int count; |
290 |
TileIndex *ti = ts.tile_table; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
291 |
|
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1571
diff
changeset
|
292 |
for (count = ts.tile_table_count; count != 0; count--, ti++) { |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
293 |
TileIndex tile = *ti; |
0 | 294 |
|
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
295 |
uint z_min = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0)); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
296 |
uint z_max = z_min; |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
297 |
uint t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0)); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
298 |
z_min = min(z_min, t); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
299 |
z_max = max(z_max, t); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
300 |
t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1)); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
301 |
z_min = min(z_min, t); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
302 |
z_max = max(z_max, t); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
303 |
t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1)); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
304 |
z_min = min(z_min, t); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
305 |
z_max = max(z_max, t); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
306 |
|
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
307 |
if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) && |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
308 |
GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max * TILE_HEIGHT) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
309 |
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
310 |
} |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
311 |
if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) { |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
312 |
return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE); |
2639 | 313 |
} |
0 | 314 |
} |
315 |
} |
|
316 |
||
317 |
if (flags & DC_EXEC) { |
|
318 |
/* Clear the landscape at the tiles */ |
|
319 |
{ |
|
320 |
int count; |
|
321 |
TileIndex *ti = ts.tile_table; |
|
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1571
diff
changeset
|
322 |
for (count = ts.tile_table_count; count != 0; count--, ti++) { |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
323 |
DoCommand(*ti, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
0 | 324 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
325 |
} |
0 | 326 |
|
327 |
/* change the height */ |
|
328 |
{ |
|
329 |
int count; |
|
330 |
TerraformerHeightMod *mod; |
|
331 |
||
332 |
mod = ts.modheight; |
|
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1571
diff
changeset
|
333 |
for (count = ts.modheight_count; count != 0; count--, mod++) { |
1979
f4462d4e8e62
(svn r2485) Missed two uint -> TileIndex, thanks _Luca_
tron
parents:
1977
diff
changeset
|
334 |
TileIndex til = mod->tile; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
335 |
|
1059
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
336 |
SetTileHeight(til, mod->height); |
0 | 337 |
TerraformAddDirtyTileAround(&ts, til); |
338 |
} |
|
339 |
} |
|
340 |
||
341 |
/* finally mark the dirty tiles dirty */ |
|
342 |
{ |
|
343 |
int count; |
|
344 |
TileIndex *ti = ts.tile_table; |
|
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1571
diff
changeset
|
345 |
for (count = ts.tile_table_count; count != 0; count--, ti++) { |
0 | 346 |
MarkTileDirtyByTile(*ti); |
347 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
348 |
} |
0 | 349 |
} |
350 |
return ts.cost; |
|
351 |
} |
|
352 |
||
353 |
||
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
354 |
/** Levels a selected (rectangle) area of land |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
355 |
* @param tile end tile of area-drag |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
356 |
* @param flags for this command type |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
357 |
* @param p1 start tile of area drag |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
358 |
* @param p2 unused |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
359 |
* @return error or cost of terraforming |
0 | 360 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
361 |
CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 362 |
{ |
363 |
int size_x, size_y; |
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
364 |
int ex; |
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
365 |
int ey; |
0 | 366 |
int sx, sy; |
367 |
uint h, curh; |
|
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
368 |
int32 money; |
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
369 |
CommandCost ret; |
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
370 |
CommandCost cost; |
0 | 371 |
|
2934
3b7eef9871f8
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
tron
parents:
2705
diff
changeset
|
372 |
if (p1 >= MapSize()) return CMD_ERROR; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
373 |
|
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
863
diff
changeset
|
374 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
863
diff
changeset
|
375 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
376 |
/* remember level height */ |
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
377 |
h = TileHeight(p1); |
0 | 378 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
379 |
/* make sure sx,sy are smaller than ex,ey */ |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
380 |
ex = TileX(tile); |
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
381 |
ey = TileY(tile); |
926
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
382 |
sx = TileX(p1); |
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
383 |
sy = TileY(p1); |
6432 | 384 |
if (ex < sx) Swap(ex, sx); |
385 |
if (ey < sy) Swap(ey, sy); |
|
1981 | 386 |
tile = TileXY(sx, sy); |
0 | 387 |
|
9910
0b2aebc8283e
(svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents:
9906
diff
changeset
|
388 |
size_x = ex - sx + 1; |
0b2aebc8283e
(svn r10134) [gamebalance] -Sync: r9670:9700 from trunk
celestar
parents:
9906
diff
changeset
|
389 |
size_y = ey - sy + 1; |
0 | 390 |
|
391 |
money = GetAvailableMoneyForCommand(); |
|
392 |
cost = 0; |
|
393 |
||
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
394 |
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) { |
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
395 |
curh = TileHeight(tile2); |
0 | 396 |
while (curh != h) { |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
397 |
ret = DoCommand(tile2, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND); |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
398 |
if (CmdFailed(ret)) break; |
0 | 399 |
cost += ret; |
400 |
||
401 |
if (flags & DC_EXEC) { |
|
402 |
if ((money -= ret) < 0) { |
|
403 |
_additional_cash_required = ret; |
|
404 |
return cost - ret; |
|
405 |
} |
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
406 |
DoCommand(tile2, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND); |
0 | 407 |
} |
408 |
||
409 |
curh += (curh > h) ? -1 : 1; |
|
410 |
} |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
411 |
} END_TILE_LOOP(tile2, size_x, size_y, tile) |
0 | 412 |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
413 |
return (cost == 0) ? CMD_ERROR : cost; |
0 | 414 |
} |
415 |
||
9899
cde52f745560
(svn r9386) [gamebalance] -Feature: Selling and buying land costs now take proximity to town centers into account. Move some code around while I'm at it. Also selling land gives as much money as buying land costs.
celestar
parents:
9895
diff
changeset
|
416 |
/** |
cde52f745560
(svn r9386) [gamebalance] -Feature: Selling and buying land costs now take proximity to town centers into account. Move some code around while I'm at it. Also selling land gives as much money as buying land costs.
celestar
parents:
9895
diff
changeset
|
417 |
* Purchase a single tile |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
418 |
* @param tile the tile the player is purchasing |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
419 |
* @param flags for this command type |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
420 |
* @param p1 unused |
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
421 |
* @param p2 unused |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
422 |
* @return error of cost of operation |
0 | 423 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
424 |
CommandCost CmdPurchaseTile(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 425 |
{ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
426 |
CommandCost cost; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
427 |
|
0 | 428 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
429 |
|
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
430 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
0 | 431 |
|
3310
7339b2b1e957
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3279
diff
changeset
|
432 |
if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) { |
0 | 433 |
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT); |
3310
7339b2b1e957
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3279
diff
changeset
|
434 |
} |
0 | 435 |
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
436 |
cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
437 |
if (CmdFailed(cost)) return CMD_ERROR; |
0 | 438 |
|
439 |
if (flags & DC_EXEC) { |
|
3310
7339b2b1e957
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3279
diff
changeset
|
440 |
MakeOwnedLand(tile, _current_player); |
7339b2b1e957
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3279
diff
changeset
|
441 |
MarkTileDirtyByTile(tile); |
0 | 442 |
} |
443 |
||
9902
ed8f92929297
(svn r9414) [gamebalance] -Feature: The cost of purchasing land off a town depends on the wealth level of a town.
celestar
parents:
9899
diff
changeset
|
444 |
return cost + Town::GetTilePrice(tile); |
0 | 445 |
} |
446 |
||
447 |
||
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
448 |
static CommandCost ClearTile_Clear(TileIndex tile, byte flags) |
1095 | 449 |
{ |
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
450 |
static const int32 clear_price_table[] = { |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
451 |
_eco->GetPrice(CEconomy::CLEAR_1), |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
452 |
_eco->GetPrice(CEconomy::PURCHASE_LAND), |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
453 |
_eco->GetPrice(CEconomy::CLEAR_2), |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
454 |
_eco->GetPrice(CEconomy::CLEAR_3), |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
455 |
_eco->GetPrice(CEconomy::PURCHASE_LAND), |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
456 |
_eco->GetPrice(CEconomy::PURCHASE_LAND), |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
457 |
_eco->GetPrice(CEconomy::CLEAR_2), // XXX unused? |
0 | 458 |
}; |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
459 |
CommandCost price; |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
460 |
|
3447 | 461 |
if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) { |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
462 |
price = 0; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
463 |
} else { |
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9902
diff
changeset
|
464 |
price = clear_price_table[GetClearGround(tile)]; |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
465 |
} |
0 | 466 |
|
2220 | 467 |
if (flags & DC_EXEC) DoClearSquare(tile); |
0 | 468 |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
469 |
return price; |
0 | 470 |
} |
471 |
||
9899
cde52f745560
(svn r9386) [gamebalance] -Feature: Selling and buying land costs now take proximity to town centers into account. Move some code around while I'm at it. Also selling land gives as much money as buying land costs.
celestar
parents:
9895
diff
changeset
|
472 |
/** |
cde52f745560
(svn r9386) [gamebalance] -Feature: Selling and buying land costs now take proximity to town centers into account. Move some code around while I'm at it. Also selling land gives as much money as buying land costs.
celestar
parents:
9895
diff
changeset
|
473 |
* Sell a tile |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
474 |
* @param tile the tile the player is selling |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
475 |
* @param flags for this command type |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
476 |
* @param p1 unused |
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
477 |
* @param p2 unused |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
478 |
* @return error or cost of operation |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
479 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
480 |
CommandCost CmdSellTile(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 481 |
{ |
482 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
483 |
||
3310
7339b2b1e957
(svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
3279
diff
changeset
|
484 |
if (!IsOwnedLandTile(tile)) return CMD_ERROR; |
1878
622765748231
(svn r2384) - Fix: Check selling land and setting player colour. Also an extra map-bounds check for terraforming; inspired by the monkey (and Tron :) )
Darkvater
parents:
1796
diff
changeset
|
485 |
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; |
622765748231
(svn r2384) - Fix: Check selling land and setting player colour. Also an extra map-bounds check for terraforming; inspired by the monkey (and Tron :) )
Darkvater
parents:
1796
diff
changeset
|
486 |
|
0 | 487 |
|
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1775
diff
changeset
|
488 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
0 | 489 |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3977
diff
changeset
|
490 |
if (flags & DC_EXEC) DoClearSquare(tile); |
0 | 491 |
|
9902
ed8f92929297
(svn r9414) [gamebalance] -Feature: The cost of purchasing land off a town depends on the wealth level of a town.
celestar
parents:
9899
diff
changeset
|
492 |
return -Town::GetTilePrice(tile); |
0 | 493 |
} |
494 |
||
495 |
||
496 |
#include "table/clear_land.h" |
|
497 |
||
498 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2221
diff
changeset
|
499 |
void DrawClearLandTile(const TileInfo *ti, byte set) |
0 | 500 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
501 |
DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19, PAL_NONE); |
0 | 502 |
} |
503 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2221
diff
changeset
|
504 |
void DrawHillyLandTile(const TileInfo *ti) |
0 | 505 |
{ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
506 |
if (ti->tileh != SLOPE_FLAT) { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
507 |
DrawGroundSprite(SPR_FLAT_ROUGH_LAND + _tileh_to_sprite[ti->tileh], PAL_NONE); |
0 | 508 |
} else { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
509 |
DrawGroundSprite(_landscape_clear_sprites[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE); |
0 | 510 |
} |
511 |
} |
|
512 |
||
2220 | 513 |
void DrawClearLandFence(const TileInfo *ti) |
0 | 514 |
{ |
515 |
byte z = ti->z; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
516 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
517 |
if (ti->tileh & SLOPE_S) { |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
518 |
z += TILE_HEIGHT; |
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
519 |
if (ti->tileh == SLOPE_STEEP_S) z += TILE_HEIGHT; |
0 | 520 |
} |
521 |
||
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2956
diff
changeset
|
522 |
if (GetFenceSW(ti->tile) != 0) { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
523 |
DrawGroundSpriteAt(_clear_land_fence_sprites_1[GetFenceSW(ti->tile) - 1] + _fence_mod_by_tileh[ti->tileh], PAL_NONE, ti->x, ti->y, z); |
0 | 524 |
} |
525 |
||
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2956
diff
changeset
|
526 |
if (GetFenceSE(ti->tile) != 0) { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
527 |
DrawGroundSpriteAt(_clear_land_fence_sprites_1[GetFenceSE(ti->tile) - 1] + _fence_mod_by_tileh_2[ti->tileh], PAL_NONE, ti->x, ti->y, z); |
0 | 528 |
} |
529 |
} |
|
530 |
||
531 |
static void DrawTile_Clear(TileInfo *ti) |
|
532 |
{ |
|
3166
747e74d236f0
(svn r3794) Use already available accessor functions instead of GB()
tron
parents:
3156
diff
changeset
|
533 |
switch (GetClearGround(ti->tile)) { |
3447 | 534 |
case CLEAR_GRASS: |
3166
747e74d236f0
(svn r3794) Use already available accessor functions instead of GB()
tron
parents:
3156
diff
changeset
|
535 |
DrawClearLandTile(ti, GetClearDensity(ti->tile)); |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
536 |
break; |
0 | 537 |
|
3447 | 538 |
case CLEAR_ROUGH: |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
539 |
DrawHillyLandTile(ti); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
540 |
break; |
0 | 541 |
|
3447 | 542 |
case CLEAR_ROCKS: |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
543 |
DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[ti->tileh], PAL_NONE); |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
544 |
break; |
0 | 545 |
|
3447 | 546 |
case CLEAR_FIELDS: |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
547 |
DrawGroundSprite(_clear_land_sprites_1[GetFieldType(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
548 |
break; |
0 | 549 |
|
3447 | 550 |
case CLEAR_SNOW: |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
551 |
DrawGroundSprite(_clear_land_sprites_2[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
552 |
break; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
553 |
|
3447 | 554 |
case CLEAR_DESERT: |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
555 |
DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
556 |
break; |
0 | 557 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
558 |
|
2220 | 559 |
DrawClearLandFence(ti); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4815
diff
changeset
|
560 |
DrawBridgeMiddle(ti); |
0 | 561 |
} |
562 |
||
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4157
diff
changeset
|
563 |
static uint GetSlopeZ_Clear(TileIndex tile, uint x, uint y) |
1095 | 564 |
{ |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4157
diff
changeset
|
565 |
uint z; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
566 |
Slope tileh = GetTileSlope(tile, &z); |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4157
diff
changeset
|
567 |
|
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4157
diff
changeset
|
568 |
return z + GetPartialZ(x & 0xF, y & 0xF, tileh); |
1095 | 569 |
} |
0 | 570 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
571 |
static Slope GetSlopeTileh_Clear(TileIndex tile, Slope tileh) |
39 | 572 |
{ |
3418
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3379
diff
changeset
|
573 |
return tileh; |
39 | 574 |
} |
575 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
576 |
static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac) |
0 | 577 |
{ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
578 |
/* unused */ |
0 | 579 |
} |
580 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
581 |
static void AnimateTile_Clear(TileIndex tile) |
0 | 582 |
{ |
583 |
/* unused */ |
|
584 |
} |
|
585 |
||
1293 | 586 |
void TileLoopClearHelper(TileIndex tile) |
0 | 587 |
{ |
2221
a25240840b32
(svn r2739) -Fix(?): Change the fence algorithm so it removes fences when no farm tile is adjacent
tron
parents:
2220
diff
changeset
|
588 |
byte self; |
a25240840b32
(svn r2739) -Fix(?): Change the fence algorithm so it removes fences when no farm tile is adjacent
tron
parents:
2220
diff
changeset
|
589 |
byte neighbour; |
1293 | 590 |
TileIndex dirty = INVALID_TILE; |
0 | 591 |
|
3447 | 592 |
self = (IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS)); |
0 | 593 |
|
3447 | 594 |
neighbour = (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 1, 0), CLEAR_FIELDS)); |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2956
diff
changeset
|
595 |
if (GetFenceSW(tile) == 0) { |
2221
a25240840b32
(svn r2739) -Fix(?): Change the fence algorithm so it removes fences when no farm tile is adjacent
tron
parents:
2220
diff
changeset
|
596 |
if (self != neighbour) { |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2956
diff
changeset
|
597 |
SetFenceSW(tile, 3); |
0 | 598 |
dirty = tile; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
599 |
} |
0 | 600 |
} else { |
2221
a25240840b32
(svn r2739) -Fix(?): Change the fence algorithm so it removes fences when no farm tile is adjacent
tron
parents:
2220
diff
changeset
|
601 |
if (self == 0 && neighbour == 0) { |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2956
diff
changeset
|
602 |
SetFenceSW(tile, 0); |
0 | 603 |
dirty = tile; |
604 |
} |
|
605 |
} |
|
606 |
||
3447 | 607 |
neighbour = (IsTileType(TILE_ADDXY(tile, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, 1), CLEAR_FIELDS)); |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2956
diff
changeset
|
608 |
if (GetFenceSE(tile) == 0) { |
2221
a25240840b32
(svn r2739) -Fix(?): Change the fence algorithm so it removes fences when no farm tile is adjacent
tron
parents:
2220
diff
changeset
|
609 |
if (self != neighbour) { |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2956
diff
changeset
|
610 |
SetFenceSE(tile, 3); |
0 | 611 |
dirty = tile; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
612 |
} |
0 | 613 |
} else { |
2221
a25240840b32
(svn r2739) -Fix(?): Change the fence algorithm so it removes fences when no farm tile is adjacent
tron
parents:
2220
diff
changeset
|
614 |
if (self == 0 && neighbour == 0) { |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2956
diff
changeset
|
615 |
SetFenceSE(tile, 0); |
0 | 616 |
dirty = tile; |
617 |
} |
|
618 |
} |
|
619 |
||
2221
a25240840b32
(svn r2739) -Fix(?): Change the fence algorithm so it removes fences when no farm tile is adjacent
tron
parents:
2220
diff
changeset
|
620 |
if (dirty != INVALID_TILE) MarkTileDirtyByTile(dirty); |
0 | 621 |
} |
622 |
||
623 |
||
624 |
/* convert into snowy tiles */ |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
625 |
static void TileLoopClearAlps(TileIndex tile) |
0 | 626 |
{ |
9906
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
627 |
int k = GetTileZ(tile) - GetSnowLine() + TILE_HEIGHT; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
628 |
|
4157
0c3210247472
(svn r5581) Slightly alter some snow line related calculations to make them a bit clearer
tron
parents:
4069
diff
changeset
|
629 |
if (k < 0) { // well below the snow line |
3447 | 630 |
if (!IsClearGround(tile, CLEAR_SNOW)) return; |
631 |
if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CLEAR_GRASS, 3); |
|
0 | 632 |
} else { |
3447 | 633 |
if (!IsClearGround(tile, CLEAR_SNOW)) { |
634 |
SetClearGroundDensity(tile, CLEAR_SNOW, 0); |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
635 |
} else { |
4157
0c3210247472
(svn r5581) Slightly alter some snow line related calculations to make them a bit clearer
tron
parents:
4069
diff
changeset
|
636 |
uint density = min((uint)k / TILE_HEIGHT, 3); |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
637 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
638 |
if (GetClearDensity(tile) < density) { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
639 |
AddClearDensity(tile, 1); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
640 |
} else if (GetClearDensity(tile) > density) { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
641 |
AddClearDensity(tile, -1); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
642 |
} else { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
643 |
return; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
644 |
} |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
645 |
} |
0 | 646 |
} |
647 |
||
648 |
MarkTileDirtyByTile(tile); |
|
649 |
} |
|
650 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
651 |
static void TileLoopClearDesert(TileIndex tile) |
0 | 652 |
{ |
3447 | 653 |
if (IsClearGround(tile, CLEAR_DESERT)) return; |
0 | 654 |
|
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3310
diff
changeset
|
655 |
if (GetTropicZone(tile) == TROPICZONE_DESERT) { |
3447 | 656 |
SetClearGroundDensity(tile, CLEAR_DESERT, 3); |
0 | 657 |
} else { |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3310
diff
changeset
|
658 |
if (GetTropicZone(tile + TileDiffXY( 1, 0)) != TROPICZONE_DESERT && |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3310
diff
changeset
|
659 |
GetTropicZone(tile + TileDiffXY(-1, 0)) != TROPICZONE_DESERT && |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3310
diff
changeset
|
660 |
GetTropicZone(tile + TileDiffXY( 0, 1)) != TROPICZONE_DESERT && |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3310
diff
changeset
|
661 |
GetTropicZone(tile + TileDiffXY( 0, -1)) != TROPICZONE_DESERT) |
1981 | 662 |
return; |
3447 | 663 |
SetClearGroundDensity(tile, CLEAR_DESERT, 1); |
0 | 664 |
} |
665 |
||
666 |
MarkTileDirtyByTile(tile); |
|
667 |
} |
|
668 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
669 |
static void TileLoop_Clear(TileIndex tile) |
0 | 670 |
{ |
671 |
TileLoopClearHelper(tile); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
672 |
|
2989 | 673 |
switch (_opt.landscape) { |
9906
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
674 |
case LT_TROPIC: TileLoopClearDesert(tile); break; |
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
675 |
case LT_ARCTIC: TileLoopClearAlps(tile); break; |
0 | 676 |
} |
677 |
||
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
678 |
switch (GetClearGround(tile)) { |
3447 | 679 |
case CLEAR_GRASS: |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
680 |
if (GetClearDensity(tile) == 3) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
681 |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
682 |
if (_game_mode != GM_EDITOR) { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
683 |
if (GetClearCounter(tile) < 7) { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
684 |
AddClearCounter(tile, 1); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
685 |
return; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
686 |
} else { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
687 |
SetClearCounter(tile, 0); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
688 |
AddClearDensity(tile, 1); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
689 |
} |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
690 |
} else { |
3447 | 691 |
SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3); |
0 | 692 |
} |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
693 |
break; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
694 |
|
3447 | 695 |
case CLEAR_FIELDS: { |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
696 |
uint field_type; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
697 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
698 |
if (_game_mode == GM_EDITOR) return; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
699 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
700 |
if (GetClearCounter(tile) < 7) { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
701 |
AddClearCounter(tile, 1); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
702 |
return; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
703 |
} else { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
704 |
SetClearCounter(tile, 0); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
705 |
} |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
706 |
|
4333
2ff83c9c81fa
(svn r6032) -Fix: when a farm is gone, remove the fields when it is full grown and should be harvest (not before that)
truelight
parents:
4328
diff
changeset
|
707 |
if (GetIndustryIndexOfField(tile) == INVALID_INDUSTRY && GetFieldType(tile) >= 7) { |
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4300
diff
changeset
|
708 |
/* This farmfield is no longer farmfield, so make it grass again */ |
4815
c2a54b213fde
(svn r6739) -Fix (r6001): Crash on removing farmland belonging to a farm. The search would loop
Darkvater
parents:
4560
diff
changeset
|
709 |
MakeClear(tile, CLEAR_GRASS, 2); |
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4300
diff
changeset
|
710 |
} else { |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4300
diff
changeset
|
711 |
field_type = GetFieldType(tile); |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4300
diff
changeset
|
712 |
field_type = (field_type < 8) ? field_type + 1 : 0; |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4300
diff
changeset
|
713 |
SetFieldType(tile, field_type); |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4300
diff
changeset
|
714 |
} |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
715 |
break; |
0 | 716 |
} |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
717 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
718 |
default: |
0 | 719 |
return; |
720 |
} |
|
721 |
||
722 |
MarkTileDirtyByTile(tile); |
|
723 |
} |
|
724 |
||
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6486
diff
changeset
|
725 |
void GenerateClearTile() |
0 | 726 |
{ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
727 |
uint i, gi; |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
728 |
TileIndex tile; |
0 | 729 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
730 |
/* add rough tiles */ |
2635 | 731 |
i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
732 |
gi = ScaleByMapSize(GB(Random(), 0, 7) + 0x80); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
733 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
734 |
SetGeneratingWorldProgress(GWP_ROUGH_ROCKY, gi + i); |
0 | 735 |
do { |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
736 |
IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY); |
2051 | 737 |
tile = RandomTile(); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
738 |
if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) SetClearGroundDensity(tile, CLEAR_ROUGH, 3); |
0 | 739 |
} while (--i); |
740 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
741 |
/* add rocky tiles */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
742 |
i = gi; |
0 | 743 |
do { |
2150
010d923a81a9
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2140
diff
changeset
|
744 |
uint32 r = Random(); |
2051 | 745 |
tile = RandomTileSeed(r); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
746 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
747 |
IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
748 |
if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) { |
2150
010d923a81a9
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2140
diff
changeset
|
749 |
uint j = GB(r, 16, 4) + 5; |
2951 | 750 |
for (;;) { |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
751 |
TileIndex tile_new; |
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
752 |
|
3447 | 753 |
SetClearGroundDensity(tile, CLEAR_ROCKS, 3); |
0 | 754 |
do { |
755 |
if (--j == 0) goto get_out; |
|
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4344
diff
changeset
|
756 |
tile_new = tile + TileOffsByDiagDir(GB(Random(), 0, 2)); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4231
diff
changeset
|
757 |
} while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT)); |
0 | 758 |
tile = tile_new; |
759 |
} |
|
760 |
get_out:; |
|
761 |
} |
|
762 |
} while (--i); |
|
763 |
} |
|
764 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
765 |
static void ClickTile_Clear(TileIndex tile) |
0 | 766 |
{ |
767 |
/* not used */ |
|
768 |
} |
|
769 |
||
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9910
diff
changeset
|
770 |
static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode) |
0 | 771 |
{ |
772 |
return 0; |
|
773 |
} |
|
774 |
||
2220 | 775 |
static const StringID _clear_land_str[] = { |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
776 |
STR_080D_GRASS, |
0 | 777 |
STR_080B_ROUGH_LAND, |
778 |
STR_080A_ROCKS, |
|
779 |
STR_080E_FIELDS, |
|
780 |
STR_080F_SNOW_COVERED_LAND, |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
781 |
STR_0810_DESERT |
0 | 782 |
}; |
783 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1901
diff
changeset
|
784 |
static void GetTileDesc_Clear(TileIndex tile, TileDesc *td) |
0 | 785 |
{ |
3447 | 786 |
if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) { |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
787 |
td->str = STR_080C_BARE_LAND; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
788 |
} else { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
789 |
td->str = _clear_land_str[GetClearGround(tile)]; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
790 |
} |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
791 |
td->owner = GetTileOwner(tile); |
0 | 792 |
} |
793 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2221
diff
changeset
|
794 |
static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 795 |
{ |
796 |
return; |
|
797 |
} |
|
798 |
||
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6486
diff
changeset
|
799 |
void InitializeClearLand() |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1059
diff
changeset
|
800 |
{ |
3422
12cdb13ddb56
(svn r4249) -Codechange: Replace more occurences of 16 by TILE_SIZE and of 8 by TILE_HEIGHT. Reverted one change from the previous commit because it was faulty
celestar
parents:
3418
diff
changeset
|
801 |
_opt.snow_line = _patches.snow_line_height * TILE_HEIGHT; |
0 | 802 |
} |
803 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
804 |
extern const TileTypeProcs _tile_type_clear_procs = { |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
805 |
DrawTile_Clear, ///< draw_tile_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
806 |
GetSlopeZ_Clear, ///< get_slope_z_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
807 |
ClearTile_Clear, ///< clear_tile_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
808 |
GetAcceptedCargo_Clear, ///< get_accepted_cargo_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
809 |
GetTileDesc_Clear, ///< get_tile_desc_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
810 |
GetTileTrackStatus_Clear, ///< get_tile_track_status_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
811 |
ClickTile_Clear, ///< click_tile_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
812 |
AnimateTile_Clear, ///< animate_tile_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
813 |
TileLoop_Clear, ///< tile_loop_clear |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
814 |
ChangeTileOwner_Clear, ///< change_tile_owner_clear |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
815 |
NULL, ///< get_produced_cargo_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
816 |
NULL, ///< vehicle_enter_tile_proc |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6432
diff
changeset
|
817 |
GetSlopeTileh_Clear, ///< get_slope_tileh_proc |
0 | 818 |
}; |