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