OpenTTD Source 20260304-master-g1baaa74679
void_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 "landscape.h"
12#include "command_func.h"
13#include "viewport_func.h"
14#include "slope_func.h"
15#include "water.h"
16
17#include "table/strings.h"
18#include "table/sprites.h"
19
20#include "safeguards.h"
21
23static void DrawTile_Void(TileInfo *ti)
24{
25 /* If freeform edges are off, draw infinite water off the edges of the map. */
26 if (!_settings_game.construction.freeform_edges) {
27 DrawGroundSprite(SPR_FLAT_WATER_TILE + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
28 } else {
30 }
31}
32
34static int GetSlopePixelZ_Void([[maybe_unused]] TileIndex tile, uint x, uint y, [[maybe_unused]] bool ground_vehicle)
35{
36 /* This function may be called on tiles outside the map, don't assume
37 * that 'tile' is a valid tile index. See GetSlopePixelZOutsideMap. */
38 auto [tileh, z] = GetTilePixelSlopeOutsideMap(x >> 4, y >> 4);
39
40 return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
41}
42
44static void GetTileDesc_Void([[maybe_unused]] TileIndex tile, TileDesc &td)
45{
46 td.str = STR_EMPTY;
47 td.owner[0] = OWNER_NONE;
48}
49
51static void TileLoop_Void(TileIndex tile)
52{
53 /* Floods adjacent edge tile to prevent maps without water. */
54 TileLoop_Water(tile);
55}
56
59 .draw_tile_proc = DrawTile_Void,
60 .get_slope_pixel_z_proc = GetSlopePixelZ_Void,
61 .clear_tile_proc = [](TileIndex, DoCommandFlags) { return CommandCost(STR_ERROR_OFF_EDGE_OF_MAP); },
62 .get_tile_desc_proc = GetTileDesc_Void,
63 .tile_loop_proc = TileLoop_Void,
64 .terraform_tile_proc = [](TileIndex, DoCommandFlags, int, Slope) { return CommandCost(STR_ERROR_OFF_EDGE_OF_MAP); },
65};
Common return value for all commands.
Functions related to commands.
static constexpr Owner OWNER_NONE
The tile has no ownership.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
const TileTypeProcs _tile_type_void_procs
TileTypeProcs definitions for TileType::Void tiles.
Definition landscape.cpp:59
Functions related to OTTD's landscape.
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:415
Slope
Enumeration for the slope-type.
Definition slope_type.h:47
This file contains all sprite-related enums and defines.
static const PaletteID PALETTE_ALL_BLACK
Exchange any colour by black, needed for painting fictive tiles outside map.
Definition sprites.h:1625
Definition of base types and functions in a cross-platform compatible way.
Tile description for the 'land area information' tool.
Definition tile_cmd.h:38
StringID str
Description of the tile.
Definition tile_cmd.h:39
std::array< Owner, 4 > owner
Name of the owner(s).
Definition tile_cmd.h:41
Tile information, used while rendering the tile.
Definition tile_cmd.h:32
Slope tileh
Slope of the tile.
Definition tile_cmd.h:33
Set of callback functions for performing tile operations of a given tile type.
Definition tile_cmd.h:212
std::tuple< Slope, int > GetTilePixelSlopeOutsideMap(int x, int y)
Return the slope of a given tile, also for tiles outside the map (virtual "black" tiles).
Definition tile_map.cpp:77
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
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:579
Functions related to (drawing on) viewports.
static void TileLoop_Void(TileIndex tile)
Tile callback function signature for running periodic tile updates.
Definition void_cmd.cpp:51
static void GetTileDesc_Void(TileIndex tile, TileDesc &td)
Tile callback function signature for obtaining a tile description.
Definition void_cmd.cpp:44
static void DrawTile_Void(TileInfo *ti)
Tile callback function signature for drawing a tile and its contents to the screen.
Definition void_cmd.cpp:23
static int GetSlopePixelZ_Void(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.
Definition void_cmd.cpp:34
Functions related to water management.
void TileLoop_Water(TileIndex tile)
Tile callback function signature for running periodic tile updates.