OpenTTD Source 20241224-master-gee860a5c8e
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 <http://www.gnu.org/licenses/>.
6 */
7
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
22static void DrawTile_Void(TileInfo *ti)
23{
25}
26
27
28static int GetSlopePixelZ_Void(TileIndex, uint x, uint y, bool)
29{
30 /* This function may be called on tiles outside the map, don't assume
31 * that 'tile' is a valid tile index. See GetSlopePixelZOutsideMap. */
32 auto [tileh, z] = GetTilePixelSlopeOutsideMap(x >> 4, y >> 4);
33
34 return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
35}
36
37static Foundation GetFoundation_Void(TileIndex, Slope)
38{
39 return FOUNDATION_NONE;
40}
41
42static CommandCost ClearTile_Void(TileIndex, DoCommandFlag)
43{
44 return CommandCost(STR_ERROR_OFF_EDGE_OF_MAP);
45}
46
47
48static void GetTileDesc_Void(TileIndex, TileDesc *td)
49{
50 td->str = STR_EMPTY;
51 td->owner[0] = OWNER_NONE;
52}
53
54static void TileLoop_Void(TileIndex tile)
55{
56 /* Floods adjacent edge tile to prevent maps without water. */
57 TileLoop_Water(tile);
58}
59
60static void ChangeTileOwner_Void(TileIndex, Owner, Owner)
61{
62 /* not used */
63}
64
65static TrackStatus GetTileTrackStatus_Void(TileIndex, TransportType, uint, DiagDirection)
66{
67 return 0;
68}
69
70static CommandCost TerraformTile_Void(TileIndex, DoCommandFlag, int, Slope)
71{
72 return CommandCost(STR_ERROR_OFF_EDGE_OF_MAP);
73}
74
75extern const TileTypeProcs _tile_type_void_procs = {
76 DrawTile_Void, // draw_tile_proc
77 GetSlopePixelZ_Void, // get_slope_z_proc
78 ClearTile_Void, // clear_tile_proc
79 nullptr, // add_accepted_cargo_proc
80 GetTileDesc_Void, // get_tile_desc_proc
81 GetTileTrackStatus_Void, // get_tile_track_status_proc
82 nullptr, // click_tile_proc
83 nullptr, // animate_tile_proc
84 TileLoop_Void, // tile_loop_proc
85 ChangeTileOwner_Void, // change_tile_owner_proc
86 nullptr, // add_produced_cargo_proc
87 nullptr, // vehicle_enter_tile_proc
88 GetFoundation_Void, // get_foundation_proc
89 TerraformTile_Void, // terraform_tile_proc
90};
Common return value for all commands.
Functions related to commands.
DoCommandFlag
List of flags for a command.
Owner
Enum for all companies/owners.
@ OWNER_NONE
The tile has no ownership.
DiagDirection
Enumeration for diagonal directions.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
Functions related to OTTD's landscape.
A number of safeguards to prevent using unsafe methods.
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:48
Foundation
Enumeration for Foundations.
Definition slope_type.h:93
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
Definition slope_type.h:94
This file contains all sprite-related enums and defines.
static const PaletteID PALETTE_ALL_BLACK
Exchange any color by black, needed for painting fictive tiles outside map.
Definition sprites.h:1611
Definition of base types and functions in a cross-platform compatible way.
Tile description for the 'land area information' tool.
Definition tile_cmd.h:52
StringID str
Description of the tile.
Definition tile_cmd.h:53
Owner owner[4]
Name of the owner(s)
Definition tile_cmd.h:55
Tile information, used while rendering the tile.
Definition tile_cmd.h:43
Slope tileh
Slope of the tile.
Definition tile_cmd.h:46
Set of callback functions for performing tile operations of a given tile type.
Definition tile_cmd.h:158
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:78
TransportType
Available types of transport.
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:587
Functions related to (drawing on) viewports.
Functions related to water (management)
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...