OpenTTD Source  13.2.1
clear_cmd.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "clear_map.h"
12 #include "command_func.h"
13 #include "landscape.h"
14 #include "genworld.h"
15 #include "viewport_func.h"
16 #include "water.h"
17 #include "core/random_func.hpp"
18 #include "newgrf_generic.h"
19 #include "landscape_cmd.h"
20 
21 #include "table/strings.h"
22 #include "table/sprites.h"
23 #include "table/clear_land.h"
24 
25 #include "safeguards.h"
26 
27 static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
28 {
29  static const Price clear_price_table[] = {
30  PR_CLEAR_GRASS,
31  PR_CLEAR_ROUGH,
32  PR_CLEAR_ROCKS,
33  PR_CLEAR_FIELDS,
34  PR_CLEAR_ROUGH,
35  PR_CLEAR_ROUGH,
36  };
38 
39  if (!IsClearGround(tile, CLEAR_GRASS) || GetClearDensity(tile) != 0) {
40  price.AddCost(_price[clear_price_table[GetClearGround(tile)]]);
41  }
42 
43  if (flags & DC_EXEC) DoClearSquare(tile);
44 
45  return price;
46 }
47 
48 void DrawClearLandTile(const TileInfo *ti, byte set)
49 {
50  DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh) + set * 19, PAL_NONE);
51 }
52 
53 void DrawHillyLandTile(const TileInfo *ti)
54 {
55  if (ti->tileh != SLOPE_FLAT) {
56  DrawGroundSprite(SPR_FLAT_ROUGH_LAND + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
57  } else {
58  DrawGroundSprite(_landscape_clear_sprites_rough[GB(TileHash(ti->x, ti->y), 0, 3)], PAL_NONE);
59  }
60 }
61 
62 static void DrawClearLandFence(const TileInfo *ti)
63 {
64  /* combine fences into one sprite object */
66 
67  int maxz = GetSlopeMaxPixelZ(ti->tileh);
68 
69  uint fence_nw = GetFence(ti->tile, DIAGDIR_NW);
70  if (fence_nw != 0) {
71  int z = GetSlopePixelZInCorner(ti->tileh, CORNER_W);
72  SpriteID sprite = _clear_land_fence_sprites[fence_nw - 1] + _fence_mod_by_tileh_nw[ti->tileh];
73  AddSortableSpriteToDraw(sprite, PAL_NONE, ti->x, ti->y - 15, 16, 31, maxz - z + 4, ti->z + z, false, 0, 15, -z);
74  }
75 
76  uint fence_ne = GetFence(ti->tile, DIAGDIR_NE);
77  if (fence_ne != 0) {
78  int z = GetSlopePixelZInCorner(ti->tileh, CORNER_E);
79  SpriteID sprite = _clear_land_fence_sprites[fence_ne - 1] + _fence_mod_by_tileh_ne[ti->tileh];
80  AddSortableSpriteToDraw(sprite, PAL_NONE, ti->x - 15, ti->y, 31, 16, maxz - z + 4, ti->z + z, false, 15, 0, -z);
81  }
82 
83  uint fence_sw = GetFence(ti->tile, DIAGDIR_SW);
84  uint fence_se = GetFence(ti->tile, DIAGDIR_SE);
85 
86  if (fence_sw != 0 || fence_se != 0) {
87  int z = GetSlopePixelZInCorner(ti->tileh, CORNER_S);
88 
89  if (fence_sw != 0) {
90  SpriteID sprite = _clear_land_fence_sprites[fence_sw - 1] + _fence_mod_by_tileh_sw[ti->tileh];
91  AddSortableSpriteToDraw(sprite, PAL_NONE, ti->x, ti->y, 16, 16, maxz - z + 4, ti->z + z, false, 0, 0, -z);
92  }
93 
94  if (fence_se != 0) {
95  SpriteID sprite = _clear_land_fence_sprites[fence_se - 1] + _fence_mod_by_tileh_se[ti->tileh];
96  AddSortableSpriteToDraw(sprite, PAL_NONE, ti->x, ti->y, 16, 16, maxz - z + 4, ti->z + z, false, 0, 0, -z);
97  }
98  }
100 }
101 
102 static void DrawTile_Clear(TileInfo *ti)
103 {
104  switch (GetClearGround(ti->tile)) {
105  case CLEAR_GRASS:
106  DrawClearLandTile(ti, GetClearDensity(ti->tile));
107  break;
108 
109  case CLEAR_ROUGH:
110  DrawHillyLandTile(ti);
111  break;
112 
113  case CLEAR_ROCKS:
114  DrawGroundSprite((HasGrfMiscBit(GMB_SECOND_ROCKY_TILE_SET) && (TileHash(ti->x, ti->y) & 1) ? SPR_FLAT_ROCKY_LAND_2 : SPR_FLAT_ROCKY_LAND_1) + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
115  break;
116 
117  case CLEAR_FIELDS:
118  DrawGroundSprite(_clear_land_sprites_farmland[GetFieldType(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
119  DrawClearLandFence(ti);
120  break;
121 
122  case CLEAR_SNOW:
123  case CLEAR_DESERT:
124  DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
125  break;
126  }
127 
128  DrawBridgeMiddle(ti);
129 }
130 
131 static int GetSlopePixelZ_Clear(TileIndex tile, uint x, uint y)
132 {
133  int z;
134  Slope tileh = GetTilePixelSlope(tile, &z);
135 
136  return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
137 }
138 
139 static Foundation GetFoundation_Clear(TileIndex tile, Slope tileh)
140 {
141  return FOUNDATION_NONE;
142 }
143 
144 static void UpdateFences(TileIndex tile)
145 {
146  assert(IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS));
147  bool dirty = false;
148 
149  bool neighbour = (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 1, 0), CLEAR_FIELDS));
150  if (!neighbour && GetFence(tile, DIAGDIR_SW) == 0) {
151  SetFence(tile, DIAGDIR_SW, 3);
152  dirty = true;
153  }
154 
155  neighbour = (IsTileType(TILE_ADDXY(tile, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, 1), CLEAR_FIELDS));
156  if (!neighbour && GetFence(tile, DIAGDIR_SE) == 0) {
157  SetFence(tile, DIAGDIR_SE, 3);
158  dirty = true;
159  }
160 
161  neighbour = (IsTileType(TILE_ADDXY(tile, -1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, -1, 0), CLEAR_FIELDS));
162  if (!neighbour && GetFence(tile, DIAGDIR_NE) == 0) {
163  SetFence(tile, DIAGDIR_NE, 3);
164  dirty = true;
165  }
166 
167  neighbour = (IsTileType(TILE_ADDXY(tile, 0, -1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, -1), CLEAR_FIELDS));
168  if (!neighbour && GetFence(tile, DIAGDIR_NW) == 0) {
169  SetFence(tile, DIAGDIR_NW, 3);
170  dirty = true;
171  }
172 
173  if (dirty) MarkTileDirtyByTile(tile);
174 }
175 
176 
178 static void TileLoopClearAlps(TileIndex tile)
179 {
180  int k = GetTileZ(tile) - GetSnowLine() + 1;
181 
182  if (k < 0) {
183  /* Below the snow line, do nothing if no snow. */
184  if (!IsSnowTile(tile)) return;
185  } else {
186  /* At or above the snow line, make snow tile if needed. */
187  if (!IsSnowTile(tile)) {
188  MakeSnow(tile);
189  MarkTileDirtyByTile(tile);
190  return;
191  }
192  }
193  /* Update snow density. */
194  uint current_density = GetClearDensity(tile);
195  uint req_density = (k < 0) ? 0u : std::min<uint>(k, 3u);
196 
197  if (current_density < req_density) {
198  AddClearDensity(tile, 1);
199  } else if (current_density > req_density) {
200  AddClearDensity(tile, -1);
201  } else {
202  /* Density at the required level. */
203  if (k >= 0) return;
204  ClearSnow(tile);
205  }
206  MarkTileDirtyByTile(tile);
207 }
208 
214 static inline bool NeighbourIsNormal(TileIndex tile)
215 {
216  for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
217  TileIndex t = tile + TileOffsByDiagDir(dir);
218  if (!IsValidTile(t)) continue;
219  if (GetTropicZone(t) != TROPICZONE_DESERT) return true;
220  if (HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_SEA) return true;
221  }
222  return false;
223 }
224 
225 static void TileLoopClearDesert(TileIndex tile)
226 {
227  /* Current desert level - 0 if it is not desert */
228  uint current = 0;
229  if (IsClearGround(tile, CLEAR_DESERT)) current = GetClearDensity(tile);
230 
231  /* Expected desert level - 0 if it shouldn't be desert */
232  uint expected = 0;
233  if (GetTropicZone(tile) == TROPICZONE_DESERT) {
234  expected = NeighbourIsNormal(tile) ? 1 : 3;
235  }
236 
237  if (current == expected) return;
238 
239  if (expected == 0) {
241  } else {
242  /* Transition from clear to desert is not smooth (after clearing desert tile) */
243  SetClearGroundDensity(tile, CLEAR_DESERT, expected);
244  }
245 
246  MarkTileDirtyByTile(tile);
247 }
248 
249 static void TileLoop_Clear(TileIndex tile)
250 {
251  /* If the tile is at any edge flood it to prevent maps without water. */
253  int z;
254  if (IsTileFlat(tile, &z) && z == 0) {
255  DoFloodTile(tile);
256  MarkTileDirtyByTile(tile);
257  return;
258  }
259  }
260  AmbientSoundEffect(tile);
261 
263  case LT_TROPIC: TileLoopClearDesert(tile); break;
264  case LT_ARCTIC: TileLoopClearAlps(tile); break;
265  }
266 
267  switch (GetClearGround(tile)) {
268  case CLEAR_GRASS:
269  if (GetClearDensity(tile) == 3) return;
270 
271  if (_game_mode != GM_EDITOR) {
272  if (GetClearCounter(tile) < 7) {
273  AddClearCounter(tile, 1);
274  return;
275  } else {
276  SetClearCounter(tile, 0);
277  AddClearDensity(tile, 1);
278  }
279  } else {
280  SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3);
281  }
282  break;
283 
284  case CLEAR_FIELDS:
285  UpdateFences(tile);
286 
287  if (_game_mode == GM_EDITOR) return;
288 
289  if (GetClearCounter(tile) < 7) {
290  AddClearCounter(tile, 1);
291  return;
292  } else {
293  SetClearCounter(tile, 0);
294  }
295 
296  if (GetIndustryIndexOfField(tile) == INVALID_INDUSTRY && GetFieldType(tile) >= 7) {
297  /* This farmfield is no longer farmfield, so make it grass again */
298  MakeClear(tile, CLEAR_GRASS, 2);
299  } else {
300  uint field_type = GetFieldType(tile);
301  field_type = (field_type < 8) ? field_type + 1 : 0;
302  SetFieldType(tile, field_type);
303  }
304  break;
305 
306  default:
307  return;
308  }
309 
310  MarkTileDirtyByTile(tile);
311 }
312 
313 void GenerateClearTile()
314 {
315  uint i, gi;
316  TileIndex tile;
317 
318  /* add rough tiles */
319  i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400);
320  gi = ScaleByMapSize(GB(Random(), 0, 7) + 0x80);
321 
323  do {
325  tile = RandomTile();
327  } while (--i);
328 
329  /* add rocky tiles */
330  i = gi;
331  do {
332  uint32 r = Random();
333  tile = RandomTileSeed(r);
334 
336  if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) {
337  uint j = GB(r, 16, 4) + 5;
338  for (;;) {
339  TileIndex tile_new;
340 
342  MarkTileDirtyByTile(tile);
343  do {
344  if (--j == 0) goto get_out;
345  tile_new = tile + TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
346  } while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT));
347  tile = tile_new;
348  }
349 get_out:;
350  }
351  } while (--i);
352 }
353 
354 static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
355 {
356  return 0;
357 }
358 
359 static const StringID _clear_land_str[] = {
360  STR_LAI_CLEAR_DESCRIPTION_GRASS,
361  STR_LAI_CLEAR_DESCRIPTION_ROUGH_LAND,
362  STR_LAI_CLEAR_DESCRIPTION_ROCKS,
363  STR_LAI_CLEAR_DESCRIPTION_FIELDS,
364  STR_LAI_CLEAR_DESCRIPTION_SNOW_COVERED_LAND,
365  STR_LAI_CLEAR_DESCRIPTION_DESERT
366 };
367 
368 static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
369 {
370  if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) {
371  td->str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
372  } else {
373  td->str = _clear_land_str[GetClearGround(tile)];
374  }
375  td->owner[0] = GetTileOwner(tile);
376 }
377 
378 static void ChangeTileOwner_Clear(TileIndex tile, Owner old_owner, Owner new_owner)
379 {
380  return;
381 }
382 
383 static CommandCost TerraformTile_Clear(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
384 {
385  return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
386 }
387 
388 extern const TileTypeProcs _tile_type_clear_procs = {
389  DrawTile_Clear,
390  GetSlopePixelZ_Clear,
391  ClearTile_Clear,
392  nullptr,
393  GetTileDesc_Clear,
394  GetTileTrackStatus_Clear,
395  nullptr,
396  nullptr,
397  TileLoop_Clear,
398  ChangeTileOwner_Clear,
399  nullptr,
400  nullptr,
401  GetFoundation_Clear,
402  TerraformTile_Clear,
403 };
TileInfo::z
int z
Height.
Definition: tile_cmd.h:47
MP_CLEAR
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition: tile_type.h:48
IsTileFlat
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
Definition: tile_map.cpp:100
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition: direction_type.h:80
CLEAR_SNOW
@ CLEAR_SNOW
0-3
Definition: clear_map.h:24
TROPICZONE_DESERT
@ TROPICZONE_DESERT
Tile is desert.
Definition: tile_type.h:78
AddClearDensity
static void AddClearDensity(TileIndex t, int d)
Increment the density of a non-field clear tile.
Definition: clear_map.h:95
TileOffsByDiagDir
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:341
GetClearCounter
static uint GetClearCounter(TileIndex t)
Get the counter used to advance to the next clear density/field type.
Definition: clear_map.h:120
water.h
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
HasTileWaterClass
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
Definition: water_map.h:106
command_func.h
TileInfo::x
uint x
X position of the tile in unit coordinates.
Definition: tile_cmd.h:43
TileInfo
Tile information, used while rendering the tile.
Definition: tile_cmd.h:42
SetFieldType
static void SetFieldType(TileIndex t, uint f)
Set the field type (production stage) of the field.
Definition: clear_map.h:183
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:328
CLEAR_ROCKS
@ CLEAR_ROCKS
3
Definition: clear_map.h:22
TileDesc::owner
Owner owner[4]
Name of the owner(s)
Definition: tile_cmd.h:53
AmbientSoundEffect
static void AmbientSoundEffect(TileIndex tile)
Play an ambient sound effect for an empty tile.
Definition: newgrf_generic.h:53
Price
Price
Enumeration of all base prices for use with Prices.
Definition: economy_type.h:74
ClearSnow
static void ClearSnow(TileIndex t)
Clear the snow from a tile and return it to its previous type.
Definition: clear_map.h:316
DIAGDIR_END
@ DIAGDIR_END
Used for iterations.
Definition: direction_type.h:83
MakeClear
static void MakeClear(TileIndex t, ClearGround g, uint density)
Make a clear tile.
Definition: clear_map.h:259
GetTileZ
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
Definition: tile_map.cpp:121
CLEAR_GRASS
@ CLEAR_GRASS
0-3
Definition: clear_map.h:20
IsClearGround
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
Definition: clear_map.h:71
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
GetPartialPixelZ
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
Definition: landscape.cpp:219
DrawBridgeMiddle
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
Definition: tunnelbridge_cmd.cpp:1543
TileInfo::y
uint y
Y position of the tile in unit coordinates.
Definition: tile_cmd.h:44
GetFieldType
static uint GetFieldType(TileIndex t)
Get the field type (production stage) of the field.
Definition: clear_map.h:171
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:82
GetSlopePixelZInCorner
static int GetSlopePixelZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
Definition: landscape.h:53
clear_map.h
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
DC_EXEC
@ DC_EXEC
execute the given command
Definition: command_type.h:357
TileDesc
Tile description for the 'land area information' tool.
Definition: tile_cmd.h:51
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:355
SetFence
static void SetFence(TileIndex t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
Definition: clear_map.h:240
genworld.h
Foundation
Foundation
Enumeration for Foundations.
Definition: slope_type.h:93
newgrf_generic.h
IncreaseGeneratingWorldProgress
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Definition: genworld_gui.cpp:1572
GetClearGround
static ClearGround GetClearGround(TileIndex t)
Get the type of clear tile.
Definition: clear_map.h:59
SlopeToSpriteOffset
static uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
Definition: slope_func.h:415
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:587
TileInfo::tileh
Slope tileh
Slope of the tile.
Definition: tile_cmd.h:45
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:48
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition: direction_type.h:81
landscape_cmd.h
GetClearDensity
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
Definition: clear_map.h:83
EXPENSES_CONSTRUCTION
@ EXPENSES_CONSTRUCTION
Construction costs.
Definition: economy_type.h:158
CommandCost
Common return value for all commands.
Definition: command_type.h:24
GetSnowLine
byte GetSnowLine()
Get the current snow line, either variable or static.
Definition: landscape.cpp:656
SetClearCounter
static void SetClearCounter(TileIndex t, uint c)
Sets the counter used to advance to the next clear density/field type.
Definition: clear_map.h:144
HasGrfMiscBit
static bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
Definition: newgrf.h:187
GetFence
static uint GetFence(TileIndex t, DiagDirection side)
Is there a fence at the given border?
Definition: clear_map.h:221
DistanceFromEdge
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
Definition: map.cpp:217
TransportType
TransportType
Available types of transport.
Definition: transport_type.h:19
EndSpriteCombine
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
Definition: viewport.cpp:773
CLEAR_DESERT
@ CLEAR_DESERT
1,3
Definition: clear_map.h:25
clear_land.h
DoFloodTile
void DoFloodTile(TileIndex target)
Floods a tile.
Definition: water_cmd.cpp:1102
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
GetTropicZone
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
Definition: tile_map.h:238
AddClearCounter
static void AddClearCounter(TileIndex t, int c)
Increments the counter used to advance to the next clear density/field type.
Definition: clear_map.h:132
safeguards.h
GWP_ROUGH_ROCKY
@ GWP_ROUGH_ROCKY
Make rough and rocky areas.
Definition: genworld.h:73
IsSnowTile
static bool IsSnowTile(TileIndex t)
Test if a tile is covered with snow.
Definition: clear_map.h:35
IsValidTile
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
Definition: tile_map.h:161
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:354
CLEAR_ROUGH
@ CLEAR_ROUGH
3
Definition: clear_map.h:21
RandomTile
#define RandomTile()
Get a valid random tile.
Definition: map_func.h:435
TileHash
static uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
Definition: tile_map.h:316
StartSpriteCombine
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
Definition: viewport.cpp:763
sprites.h
FOUNDATION_NONE
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
Definition: slope_type.h:94
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
stdafx.h
GetIndustryIndexOfField
static IndustryID GetIndustryIndexOfField(TileIndex t)
Get the industry (farm) that made the field.
Definition: clear_map.h:195
landscape.h
TileTypeProcs
Set of callback functions for performing tile operations of a given tile type.
Definition: tile_cmd.h:145
WATER_CLASS_SEA
@ WATER_CLASS_SEA
Sea.
Definition: water_map.h:48
viewport_func.h
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
GetTileOwner
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:178
AddSortableSpriteToDraw
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
Definition: viewport.cpp:667
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
GetWaterClass
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
Definition: water_map.h:117
MakeSnow
static void MakeSnow(TileIndex t, uint density=0)
Make a snow tile.
Definition: clear_map.h:300
ScaleByMapSize
static uint ScaleByMapSize(uint n)
Scales the given value by the map size, where the given value is for a 256 by 256 map.
Definition: map_func.h:122
SetGeneratingWorldProgress
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
Definition: genworld_gui.cpp:1558
GetSlopeMaxPixelZ
static int GetSlopeMaxPixelZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
Definition: slope_func.h:173
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1998
DIAGDIR_BEGIN
@ DIAGDIR_BEGIN
Used for iterations.
Definition: direction_type.h:78
TileDesc::str
StringID str
Description of the tile.
Definition: tile_cmd.h:52
TILE_ADDXY
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
Definition: map_func.h:258
CommandHelper
Definition: command_func.h:94
random_func.hpp
TileInfo::tile
TileIndex tile
Tile index.
Definition: tile_cmd.h:46
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:588
GetTilePixelSlope
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
Definition: tile_map.h:280
SLOPE_FLAT
@ SLOPE_FLAT
a flat tile
Definition: slope_type.h:49
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:79
CLEAR_FIELDS
@ CLEAR_FIELDS
3
Definition: clear_map.h:23
TileLoopClearAlps
static void TileLoopClearAlps(TileIndex tile)
Convert to or from snowy tiles.
Definition: clear_cmd.cpp:178
DrawGroundSprite
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
Definition: viewport.cpp:583
RandomTileSeed
static TileIndex RandomTileSeed(uint32 r)
Get a random tile out of a given seed.
Definition: map_func.h:424
NeighbourIsNormal
static bool NeighbourIsNormal(TileIndex tile)
Tests if at least one surrounding tile is non-desert.
Definition: clear_cmd.cpp:214
SetClearGroundDensity
static void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
Definition: clear_map.h:158