OpenTTD Source 20261112-master-gbcbec5e63f
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "stdafx.h"
11#include "bridge.h"
12#include "command_func.h"
13#include "clear_map.h"
14#include "economy_func.h"
15#include "landscape.h"
16#include "genworld.h"
17#include "slope_func.h"
18#include "viewport_func.h"
19#include "water_map.h"
20#include "core/random_func.hpp"
21#include "newgrf_generic.h"
22#include "landscape_cmd.h"
23
24#include "table/strings.h"
25#include "table/sprites.h"
26#include "table/clear_land.h"
27
28#include "safeguards.h"
29
32{
33 static constexpr EnumIndexArray<Price, ClearGround, ClearGround::MaxSize> clear_price_table{
34 Price::ClearGrass, // Base price for clearing grass.
35 Price::ClearRough, // Base price for clearing rough land.
36 Price::ClearRocks, // Base price for clearing rocks.
37 Price::ClearFields, // Base price for clearing fields.
38 Price::ClearRough, // Unused.
39 Price::ClearRough, // Base price for clearing desert.
40 Price::ClearRough, // Unused.
41 Price::ClearRough, // Unused.
42 };
44
45 ClearGround ground = GetClearGround(tile);
46 uint8_t density = GetClearDensity(tile);
47 if (IsSnowTile(tile)) {
48 price.AddCost(_price[clear_price_table[ground]]);
49 /* Add a little more for removing snow. */
51 } else if (ground != ClearGround::Grass || density != 0) {
52 price.AddCost(_price[clear_price_table[ground]]);
53 }
54
55 if (flags.Test(DoCommandFlag::Execute)) {
56 DoClearSquare(tile);
57
58 /* We might want to clear to rocks instead of dirt/grass. */
60 }
61
62 return price;
63}
64
70void DrawClearLandTile(const TileInfo *ti, uint8_t density)
71{
73}
74
80{
81 if (ti->tileh != SLOPE_FLAT) {
83 } else {
84 DrawGroundSprite(_landscape_clear_sprites_rough[GB(TileHash(ti->x, ti->y), 0, 3)], PAL_NONE);
85 }
86}
87
92static void DrawClearLandFence(const TileInfo *ti)
93{
94 /* combine fences into one sprite object */
96
97 SpriteBounds bounds{{}, {TILE_SIZE, TILE_SIZE, 4}, {}};
98
99 bounds.extent.z += GetSlopeMaxPixelZ(ti->tileh);
100
101 uint fence_nw = GetFence(ti->tile, DiagDirection::NW);
102 if (fence_nw != 0) {
103 bounds.offset.x = 0;
104 bounds.offset.y = -static_cast<int>(TILE_SIZE);
107 AddSortableSpriteToDraw(sprite, PAL_NONE, *ti, bounds, false);
108 }
109
110 uint fence_ne = GetFence(ti->tile, DiagDirection::NE);
111 if (fence_ne != 0) {
112 bounds.offset.x = -static_cast<int>(TILE_SIZE);
113 bounds.offset.y = 0;
116 AddSortableSpriteToDraw(sprite, PAL_NONE, *ti, bounds, false);
117 }
118
119 uint fence_sw = GetFence(ti->tile, DiagDirection::SW);
120 uint fence_se = GetFence(ti->tile, DiagDirection::SE);
121
122 if (fence_sw != 0 || fence_se != 0) {
123 bounds.offset.x = 0;
124 bounds.offset.y = 0;
126
127 if (fence_sw != 0) {
129 AddSortableSpriteToDraw(sprite, PAL_NONE, *ti, bounds, false);
130 }
131
132 if (fence_se != 0) {
134 AddSortableSpriteToDraw(sprite, PAL_NONE, *ti, bounds, false);
135
136 }
137 }
139}
140
142static void DrawTile_Clear(TileInfo *ti)
143{
144 if (IsSnowTile(ti->tile)) {
145 uint8_t density = GetClearDensity(ti->tile);
149 }
150
151 DrawBridgeMiddle(ti, {});
152 return;
153 }
154
155 switch (GetClearGround(ti->tile)) {
158 break;
159
162 break;
163
168 } else {
170 }
171 break;
172
176 break;
177
180 break;
181
182 default:
183 NOT_REACHED();
184 }
185
186 DrawBridgeMiddle(ti, {});
187}
188
190static int GetSlopePixelZ_Clear(TileIndex tile, uint x, uint y, [[maybe_unused]] bool ground_vehicle)
191{
192 auto [tileh, z] = GetTilePixelSlope(tile);
193
194 return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
195}
196
197static void UpdateFences(TileIndex tile)
198{
200 bool dirty = false;
201
203 if (GetFence(tile, dir) != 0) continue;
204 TileIndex neighbour = tile + TileOffsByDiagDir(dir);
205 if (IsTileType(neighbour, TileType::Clear) && IsClearGround(neighbour, ClearGround::Fields)) continue;
206 SetFence(tile, dir, 3);
207 dirty = true;
208 }
209
210 if (dirty) MarkTileDirtyByTile(tile);
211}
212
213
219{
220 int k = GetTileZ(tile) - GetSnowLine() + 1;
221
222 if (!IsSnowTile(tile)) {
223 /* Below the snow line, do nothing if no snow. */
224 /* At or above the snow line, make snow tile if needed. */
225 if (k >= 0) {
226 /* Snow density is started at 0 so that it can gradually reach the required density. */
227 MakeSnow(tile, 0);
229 }
230 return;
231 }
232
233 /* Update snow density. */
234 uint current_density = GetClearDensity(tile);
235 uint req_density = (k < 0) ? 0u : std::min<uint>(k, 3u);
236
237 if (current_density == req_density) {
238 /* Density at the required level. */
239 if (k >= 0) return;
240 ClearSnow(tile);
241 } else {
242 AddClearDensity(tile, current_density < req_density ? 1 : -1);
243 }
244
246}
247
253static inline bool NeighbourIsNormal(TileIndex tile)
254{
256 TileIndex t = tile + TileOffsByDiagDir(dir);
257 if (!IsValidTile(t)) continue;
258 if (GetTropicZone(t) != TropicZone::Desert) return true;
259 if (HasTileWaterClass(t) && GetWaterClass(t) == WaterClass::Sea) return true;
260 }
261 return false;
262}
263
264static void TileLoopClearDesert(TileIndex tile)
265{
266 ClearGround ground = GetClearGround(tile);
267
268 /* Current desert level - 0 if it is not desert */
269 uint current = 0;
270 if (ground == ClearGround::Desert || ground == ClearGround::Rocks) current = GetClearDensity(tile);
271
272 /* Expected desert level - 0 if it shouldn't be desert */
273 uint expected = 0;
274 if (GetTropicZone(tile) == TropicZone::Desert) {
275 expected = NeighbourIsNormal(tile) ? 1 : 3;
276 }
277
278 if (current == expected) return;
279
280 if (ground == ClearGround::Rocks) {
282 } else if (expected == 0) {
284 } else {
285 /* Transition from clear to desert is not smooth (after clearing desert tile) */
287 }
288
290}
291
293static void TileLoop_Clear(TileIndex tile)
294{
295 AmbientSoundEffect(tile);
296
297 switch (_settings_game.game_creation.landscape) {
298 case LandscapeType::Tropic: TileLoopClearDesert(tile); break;
299 case LandscapeType::Arctic: TileLoopClearAlps(tile); break;
300 default: break;
301 }
302
303 if (IsSnowTile(tile)) return;
304
305 switch (GetClearGround(tile)) {
307 if (GetClearDensity(tile) == 3) return;
308
309 if (_game_mode != GameMode::Editor) {
310 if (GetClearCounter(tile) < 7) {
311 AddClearCounter(tile, 1);
312 return;
313 } else {
314 SetClearCounter(tile, 0);
315 AddClearDensity(tile, 1);
316 }
317 } else {
318 SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? ClearGround::Grass : ClearGround::Rough, 3);
319 }
320 break;
321
323 UpdateFences(tile);
324
325 if (_game_mode == GameMode::Editor) return;
326
327 if (GetClearCounter(tile) < 7) {
328 AddClearCounter(tile, 1);
329 return;
330 } else {
331 SetClearCounter(tile, 0);
332 }
333
334 if (GetIndustryIndexOfField(tile) == IndustryID::Invalid() && GetFieldType(tile) >= 7) {
335 /* This farmfield is no longer farmfield, so make it grass again */
337 } else {
338 uint field_type = GetFieldType(tile);
339 field_type = (field_type < 8) ? field_type + 1 : 0;
340 SetFieldType(tile, field_type);
341 }
342 break;
343
344 default:
345 return;
346 }
347
349}
350
357static bool TileMayHaveRocks(TileIndex tile, bool allow_water)
358{
359 if (!IsValidTile(tile)) return false;
360 switch (GetTileType(tile)) {
361 case TileType::Clear: return true;
362 case TileType::Water: return IsCoast(tile) || (allow_water && (IsSea(tile) || IsRiver(tile)));
363 default: return false;
364 }
365}
366
371static void TileMakeRocks(TileIndex tile)
372{
373 switch (GetTileType(tile)) {
374 case TileType::Clear:
376 break;
377
378 case TileType::Water:
379 /* Rocks can jump over but not replace rivers. */
380 if (IsRiver(tile)) return;
382 break;
383
384 default:
385 break;
386 }
387}
388
394void GenerateRocks(TileIndex tile, uint32_t count)
395{
396 if (!TileMayHaveRocks(tile, false)) return;
397
398 for (;;) {
399 TileMakeRocks(tile);
401
402 TileIndex tile_new;
403 do {
404 if (--count == 0) return;
406 } while (!TileMayHaveRocks(tile_new, true));
407 tile = tile_new;
408 }
409}
410
417{
419}
420
426static void GenerateRough(TileIndex tile, uint32_t count)
427{
428 if (!TileMayHaveRough(tile)) return;
429
430 for (;;) {
433
434 TileIndex tile_new;
435 do {
436 if (--count == 0) return;
438 } while (!TileMayHaveRough(tile_new));
439 tile = tile_new;
440 }
441}
442
447{
448 uint i = Map::ScaleBySize(GB(Random(), 0, 9) + 0x200);
449 uint gi = Map::ScaleBySize(GB(Random(), 0, 7) + 0x80);
450
452
453 /* Add rough tiles. */
454 do {
455 uint32_t r = Random();
457 GenerateRough(RandomTileSeed(r), GB(r, 24, 3) + 1);
458 } while (--i);
459
460 /* Add rocky tiles. */
461 i = gi;
462 do {
463 uint32_t r = Random();
465 GenerateRocks(RandomTileSeed(r), GB(r, 24, 4) + 5);
466 } while (--i);
467}
468
471{
472 /* Each pair holds a normal and a snowy ClearGround description. */
474 {STR_LAI_CLEAR_DESCRIPTION_GRASS, STR_LAI_CLEAR_DESCRIPTION_SNOWY_GRASS}, // Description for grass.
475 {STR_LAI_CLEAR_DESCRIPTION_ROUGH_LAND, STR_LAI_CLEAR_DESCRIPTION_SNOWY_ROUGH_LAND}, // Description for rough land.
476 {STR_LAI_CLEAR_DESCRIPTION_ROCKS, STR_LAI_CLEAR_DESCRIPTION_SNOWY_ROCKS}, // Description for rocks.
477 {STR_LAI_CLEAR_DESCRIPTION_FIELDS, STR_EMPTY}, // Description for fields.
478 {STR_EMPTY, STR_EMPTY}, // unused entry does not appear in the map.
479 {STR_LAI_CLEAR_DESCRIPTION_DESERT, STR_EMPTY}, // Description for desert.
480 {STR_EMPTY, STR_EMPTY}, // unused entry does not appear in the map.
481 {STR_EMPTY, STR_EMPTY}, // unused entry does not appear in the map.
482 }}};
483
484 if (!IsSnowTile(tile) && IsClearGround(tile, ClearGround::Grass) && GetClearDensity(tile) == 0) {
485 td.str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
486 } else {
487 const auto &[name, snowy_name] = clear_land_str[GetClearGround(tile)];
488 td.str = IsSnowTile(tile) ? snowy_name : name;
489 }
490 td.owner[0] = GetTileOwner(tile);
491}
492
495 .draw_tile_proc = DrawTile_Clear,
496 .get_slope_pixel_z_proc = GetSlopePixelZ_Clear,
497 .clear_tile_proc = ClearTile_Clear,
498 .get_tile_desc_proc = GetTileDesc_Clear,
499 .tile_loop_proc = TileLoop_Clear,
500 .terraform_tile_proc = [](TileIndex tile, DoCommandFlags flags, int, Slope) { return Command<Commands::LandscapeClear>::Do(flags, tile); },
501 .check_build_above_proc = [](TileIndex, DoCommandFlags, Axis, int) { return CommandCost(); }, // Can always build above clear tiles
502};
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Header file for bridges.
void DrawBridgeMiddle(const TileInfo *ti, BridgePillarFlags blocked_pillars)
Draw the middle bits of a bridge.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Common return value for all commands.
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Iterate a range of enum values.
void DrawClearLandTile(const TileInfo *ti, uint8_t density)
Draw a ClearGround::Grass tile.
Definition clear_cmd.cpp:70
static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlags flags)
Tile callback function signature for clearing a tile.
Definition clear_cmd.cpp:31
static bool TileMayHaveRough(TileIndex tile)
Test if a tile may have rough ground on.
static void GetTileDesc_Clear(TileIndex tile, TileDesc &td)
Tile callback function signature for obtaining a tile description.
void DrawRoughLandTile(const TileInfo *ti)
Draw a ClearGround::Rough tile.
Definition clear_cmd.cpp:79
static int GetSlopePixelZ_Clear(TileIndex tile, uint x, uint y, bool ground_vehicle)
Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.
static void GenerateRough(TileIndex tile, uint32_t count)
Generate a cluster of rough ground.
static bool NeighbourIsNormal(TileIndex tile)
Tests if at least one surrounding tile is non-desert.
static void TileMakeRocks(TileIndex tile)
Make a tile that may have rocks on have rocks on.
static void DrawClearLandFence(const TileInfo *ti)
Draw the fences atop a ClearGround::Fields tile.
Definition clear_cmd.cpp:92
static void TileLoopClearAlps(TileIndex tile)
Convert to or from snowy tiles.
static void TileLoop_Clear(TileIndex tile)
Tile callback function signature for running periodic tile updates.
void GenerateRocks(TileIndex tile, uint32_t count)
Generate a cluster of rocks.
static void DrawTile_Clear(TileInfo *ti)
Tile callback function signature for drawing a tile and its contents to the screen.
static bool TileMayHaveRocks(TileIndex tile, bool allow_water)
Test if a tile may have rocks on.
void GenerateClearTile()
Generate rough and rocky features on clear tiles.
const TileTypeProcs _tile_type_clear_procs
TileTypeProcs definitions for TileType::Clear tiles.
Tables with sprites for clear land and fences.
static const SpriteID _landscape_clear_sprites_rough[8]
Sprites of the random variants of rough grass sprites, for flat tiles only.
Definition clear_land.h:13
static constexpr SlopeIndexArray< uint8_t > _fence_mod_by_tileh_se
Sprite offset for sloped fences on the southeast edge of the tile.
Definition clear_land.h:33
static constexpr SlopeIndexArray< uint8_t > _fence_mod_by_tileh_ne
Sprite offset for sloped fences on the northeast edge of the tile.
Definition clear_land.h:41
static const SpriteID _clear_land_sprites_grass[4]
Sprites of the flat tile base for each density of clear -> grass transition.
Definition clear_land.h:80
static const SpriteID _clear_land_fence_sprites[7]
Sprites of the flat tile base for each type of farm field fence.
Definition clear_land.h:57
static constexpr SlopeIndexArray< uint8_t > _fence_mod_by_tileh_sw
Sprite offset for sloped fences on the southwest edge of the tile.
Definition clear_land.h:25
static const SpriteID _clear_land_sprites_snow_desert[4]
Sprites of the flat tile base for each density of grass -> snow/desert transition.
Definition clear_land.h:88
static const SpriteID _clear_land_sprites_farmland[16]
Sprites of the flat tile base for each state of farm fields.
Definition clear_land.h:67
static constexpr SlopeIndexArray< uint8_t > _fence_mod_by_tileh_nw
Sprite offset for sloped fences on the northwest edge of the tile.
Definition clear_land.h:49
static const SpriteID _clear_land_sprites_snowy_rocks[4]
Sprites of the flat tile base for each snow density of rocky land.
Definition clear_land.h:96
Map accessors for 'clear' tiles.
void SetFieldType(Tile t, uint f)
Set the field type (production stage) of the field.
Definition clear_map.h:177
void AddClearCounter(Tile t, int c)
Increments the counter used to advance to the next clear density/field type.
Definition clear_map.h:126
uint GetFieldType(Tile t)
Get the field type (production stage) of the field.
Definition clear_map.h:165
void AddClearDensity(Tile t, int d)
Increment the density of a non-field clear tile.
Definition clear_map.h:89
void ClearSnow(Tile t)
Clear the snow from a tile and return it to its previous type.
Definition clear_map.h:310
bool IsClearGround(Tile t, ClearGround ct)
Set the type of clear tile.
Definition clear_map.h:65
void MakeSnow(Tile t, uint density=0)
Make a snow tile.
Definition clear_map.h:294
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:234
IndustryID GetIndustryIndexOfField(Tile t)
Get the industry (farm) that made the field.
Definition clear_map.h:189
ClearGround
Ground types.
Definition clear_map.h:21
@ Desert
Desert with transition (1,3).
Definition clear_map.h:26
@ MaxSize
The maximum possible number of clear ground types to be stored in map.
Definition clear_map.h:29
@ Rocks
Rocks with snow transition (0-3).
Definition clear_map.h:24
@ Fields
Farm fields (3).
Definition clear_map.h:25
@ Grass
Plain grass with dirt transition (0-3).
Definition clear_map.h:22
@ Rough
Rough mounds (3).
Definition clear_map.h:23
void MakeClear(Tile t, ClearGround g, uint density)
Make a clear tile.
Definition clear_map.h:253
ClearGround GetClearGround(Tile t)
Get the type of clear tile.
Definition clear_map.h:52
void SetClearCounter(Tile t, uint c)
Sets the counter used to advance to the next clear density/field type.
Definition clear_map.h:138
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:152
uint GetFence(Tile t, DiagDirection side)
Is there a fence at the given border?
Definition clear_map.h:215
uint GetClearCounter(Tile t)
Get the counter used to advance to the next clear density/field type.
Definition clear_map.h:114
bool IsSnowTile(Tile t)
Test if a tile is covered with snow.
Definition clear_map.h:40
uint GetClearDensity(Tile t)
Get the density of a non-field clear tile.
Definition clear_map.h:77
Functions related to commands.
@ ClearToRocks
when clearing land, make rocks instead of bare dirt/grass
@ Execute
execute the given command
EnumBitSet< DoCommandFlag, uint16_t > DoCommandFlags
Bitset of DoCommandFlag elements.
Axis
Enumeration for the two axis X and Y.
DiagDirection
Enumeration for diagonal directions.
@ SW
Southwest.
@ NW
Northwest.
@ End
Used for iterations.
@ NE
Northeast, upper right on your monitor.
@ SE
Southeast.
Prices _price
Prices and also the fractional part.
Definition economy.cpp:109
Functions related to the economy.
@ Construction
Construction costs.
@ ClearRough
Price for destroying rough land.
@ ClearRocks
Price for destroying rocks.
@ ClearFields
Price for destroying fields.
@ ClearGrass
Price for destroying grass.
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
Functions related to world/map generation.
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
@ RoughAndRocks
Make rough and rocky areas.
Definition genworld.h:61
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
uint8_t GetSnowLine()
Get the current snow line, either variable or static.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
Functions related to OTTD's landscape.
int GetSlopePixelZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
Definition landscape.h:55
Command definitions related to landscape (slopes etc.).
@ Arctic
Landscape with snow levels.
@ Tropic
Landscape with distinct rainforests and deserts,.
TileIndex RandomTileSeed(uint32_t r)
Get a random tile out of a given seed.
Definition map_func.h:645
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition map_func.h:574
bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
Definition newgrf.h:229
@ SecondRockyTileSet
Enable using the second rocky tile set.
Definition newgrf.h:75
Functions related to generic callbacks.
void AmbientSoundEffect(TileIndex tile)
Play an ambient sound effect for an empty tile.
@ Editor
In the scenario editor.
Definition openttd.h:21
Pseudo random number generator.
uint32_t RandomRange(uint32_t limit, const std::source_location location=std::source_location::current())
Pick a random number between 0 and limit - 1, inclusive.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
Functions related to slopes.
uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
Definition slope_func.h:423
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:183
@ E
East tile corner.
Definition slope_type.h:24
@ S
South tile corner.
Definition slope_type.h:23
@ W
West tile corner.
Definition slope_type.h:22
Slope
Enumeration for the slope-type.
Definition slope_type.h:53
@ SLOPE_FLAT
a flat tile
Definition slope_type.h:54
This file contains all sprite-related enums and defines.
static constexpr SpriteID SPR_OVERLAY_ROCKS_BASE
Rocks overlay with no snow.
Definition sprites.h:361
static const SpriteID SPR_FLAT_ROCKY_LAND_1
Definition sprites.h:683
static const SpriteID SPR_FLAT_ROCKY_LAND_2
Definition sprites.h:684
static const SpriteID SPR_FLAT_ROUGH_LAND
Definition sprites.h:678
Definition of base types and functions in a cross-platform compatible way.
T x
X coordinate.
T y
Y coordinate.
T z
Z coordinate.
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:331
Coord3D< int8_t > offset
Relative position of sprite from bounding box.
Definition sprite.h:21
Coord3D< uint8_t > extent
Size of bounding box.
Definition sprite.h:20
Tile description for the 'land area information' tool.
Definition tile_cmd.h:40
StringID str
Description of the tile.
Definition tile_cmd.h:41
std::array< Owner, 4 > owner
Name of the owner(s).
Definition tile_cmd.h:43
Tile information, used while rendering the tile.
Definition tile_cmd.h:34
Slope tileh
Slope of the tile.
Definition tile_cmd.h:35
TileIndex tile
Tile index.
Definition tile_cmd.h:36
Set of callback functions for performing tile operations of a given tile type.
Definition tile_cmd.h:214
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
Definition tile_map.cpp:115
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
Definition tile_map.h:324
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
Definition tile_map.h:178
std::tuple< Slope, int > GetTilePixelSlope(TileIndex tile)
Return the slope of a given tile.
Definition tile_map.h:289
bool IsValidTile(Tile tile)
Checks if a tile is valid.
Definition tile_map.h:161
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
Definition tile_map.h:238
static TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
Definition tile_map.h:96
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
@ Desert
Tile is desert.
Definition tile_type.h:83
static constexpr uint TILE_SIZE
Tile size in world coordinates.
Definition tile_type.h:15
@ Water
Water tile.
Definition tile_type.h:55
@ Clear
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition tile_type.h:49
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
Definition viewport.cpp:766
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int z, const SpriteBounds &bounds, bool transparent, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
Definition viewport.cpp:665
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
Definition viewport.cpp:776
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:580
Functions related to (drawing on) viewports.
Map accessors for water tiles.
bool IsRiver(Tile t)
Is it a river water tile?
Definition water_map.h:184
@ Sea
Sea.
Definition water_map.h:42
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
Definition water_map.h:105
bool IsCoast(Tile t)
Is it a coast tile?
Definition water_map.h:205
void SetWaterTileType(Tile t, WaterTileType type)
Set the water tile type of a tile.
Definition water_map.h:93
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
Definition water_map.h:116
@ ClearRocks
Rocks on water.
Definition water_map.h:36
@ CoastRocks
Rocks on coast.
Definition water_map.h:37
bool IsSea(Tile t)
Is it a sea water tile?
Definition water_map.h:162