OpenTTD Source  1.11.0-beta2
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 
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)
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 tile, Slope tileh)
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  /* If the tile is at any edge flood it to prevent maps without water. */
252  int z;
253  if (IsTileFlat(tile, &z) && z == 0) {
254  DoFloodTile(tile);
255  MarkTileDirtyByTile(tile);
256  return;
257  }
258  }
259  AmbientSoundEffect(tile);
260 
262  case LT_TROPIC: TileLoopClearDesert(tile); break;
263  case LT_ARCTIC: TileLoopClearAlps(tile); break;
264  }
265 
266  switch (GetClearGround(tile)) {
267  case CLEAR_GRASS:
268  if (GetClearDensity(tile) == 3) return;
269 
270  if (_game_mode != GM_EDITOR) {
271  if (GetClearCounter(tile) < 7) {
272  AddClearCounter(tile, 1);
273  return;
274  } else {
275  SetClearCounter(tile, 0);
276  AddClearDensity(tile, 1);
277  }
278  } else {
279  SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3);
280  }
281  break;
282 
283  case CLEAR_FIELDS:
284  UpdateFences(tile);
285 
286  if (_game_mode == GM_EDITOR) return;
287 
288  if (GetClearCounter(tile) < 7) {
289  AddClearCounter(tile, 1);
290  return;
291  } else {
292  SetClearCounter(tile, 0);
293  }
294 
295  if (GetIndustryIndexOfField(tile) == INVALID_INDUSTRY && GetFieldType(tile) >= 7) {
296  /* This farmfield is no longer farmfield, so make it grass again */
297  MakeClear(tile, CLEAR_GRASS, 2);
298  } else {
299  uint field_type = GetFieldType(tile);
300  field_type = (field_type < 8) ? field_type + 1 : 0;
301  SetFieldType(tile, field_type);
302  }
303  break;
304 
305  default:
306  return;
307  }
308 
309  MarkTileDirtyByTile(tile);
310 }
311 
312 void GenerateClearTile()
313 {
314  uint i, gi;
315  TileIndex tile;
316 
317  /* add rough tiles */
318  i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400);
319  gi = ScaleByMapSize(GB(Random(), 0, 7) + 0x80);
320 
322  do {
324  tile = RandomTile();
326  } while (--i);
327 
328  /* add rocky tiles */
329  i = gi;
330  do {
331  uint32 r = Random();
332  tile = RandomTileSeed(r);
333 
335  if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) {
336  uint j = GB(r, 16, 4) + 5;
337  for (;;) {
338  TileIndex tile_new;
339 
341  do {
342  if (--j == 0) goto get_out;
343  tile_new = tile + TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
344  } while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT));
345  tile = tile_new;
346  }
347 get_out:;
348  }
349  } while (--i);
350 }
351 
352 static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
353 {
354  return 0;
355 }
356 
357 static const StringID _clear_land_str[] = {
358  STR_LAI_CLEAR_DESCRIPTION_GRASS,
359  STR_LAI_CLEAR_DESCRIPTION_ROUGH_LAND,
360  STR_LAI_CLEAR_DESCRIPTION_ROCKS,
361  STR_LAI_CLEAR_DESCRIPTION_FIELDS,
362  STR_LAI_CLEAR_DESCRIPTION_SNOW_COVERED_LAND,
363  STR_LAI_CLEAR_DESCRIPTION_DESERT
364 };
365 
366 static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
367 {
368  if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) {
369  td->str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
370  } else {
371  td->str = _clear_land_str[GetClearGround(tile)];
372  }
373  td->owner[0] = GetTileOwner(tile);
374 }
375 
376 static void ChangeTileOwner_Clear(TileIndex tile, Owner old_owner, Owner new_owner)
377 {
378  return;
379 }
380 
381 static CommandCost TerraformTile_Clear(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
382 {
383  return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
384 }
385 
386 extern const TileTypeProcs _tile_type_clear_procs = {
387  DrawTile_Clear,
388  GetSlopePixelZ_Clear,
389  ClearTile_Clear,
390  nullptr,
391  GetTileDesc_Clear,
392  GetTileTrackStatus_Clear,
393  nullptr,
394  nullptr,
395  TileLoop_Clear,
396  ChangeTileOwner_Clear,
397  nullptr,
398  nullptr,
399  GetFoundation_Clear,
400  TerraformTile_Clear,
401 };
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:41
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
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
TROPICZONE_DESERT
@ TROPICZONE_DESERT
Tile is desert.
Definition: tile_type.h:71
AddClearDensity
static void AddClearDensity(TileIndex t, int d)
Increment the density of a non-field clear tile.
Definition: clear_map.h:95
DoCommand
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:450
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:95
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:295
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
GetPartialPixelZ
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
Definition: landscape.cpp:215
DrawBridgeMiddle
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
Definition: tunnelbridge_cmd.cpp:1540
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
TransportType
TransportType
Available types of transport.
Definition: transport_type.h:19
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:348
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:346
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:1392
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:550
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_FLAT
@ SLOPE_FLAT
a flat tile
Definition: slope_type.h:49
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition: direction_type.h:81
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:23
GetSnowLine
byte GetSnowLine()
Get the current snow line, either variable or static.
Definition: landscape.cpp:644
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:186
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
EndSpriteCombine
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
Definition: viewport.cpp:766
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:1096
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:80
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:71
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:319
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:756
sprites.h
FOUNDATION_NONE
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
Definition: slope_type.h:94
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:48
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
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:660
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:106
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:1378
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:1985
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
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:551
WATER_CLASS_SEA
@ WATER_CLASS_SEA
Sea.
Definition: water_map.h:48
GetTilePixelSlope
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
Definition: tile_map.h:280
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:177
CMD_LANDSCAPE_CLEAR
@ CMD_LANDSCAPE_CLEAR
demolish a tile
Definition: command_type.h:180
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:576
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:213
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