OpenTTD
void_cmd.cpp
Go to the documentation of this file.
1 /* $Id: void_cmd.cpp 26870 2014-09-21 08:19:32Z rubidium $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #include "stdafx.h"
13 #include "tile_cmd.h"
14 #include "command_func.h"
15 #include "viewport_func.h"
16 #include "slope_func.h"
17 
18 #include "table/strings.h"
19 #include "table/sprites.h"
20 
21 #include "safeguards.h"
22 
23 static void DrawTile_Void(TileInfo *ti)
24 {
25  DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh), PALETTE_ALL_BLACK);
26 }
27 
28 
29 static int GetSlopePixelZ_Void(TileIndex tile, uint x, uint y)
30 {
31  return TilePixelHeight(tile);
32 }
33 
34 static Foundation GetFoundation_Void(TileIndex tile, Slope tileh)
35 {
36  return FOUNDATION_NONE;
37 }
38 
39 static CommandCost ClearTile_Void(TileIndex tile, DoCommandFlag flags)
40 {
41  return_cmd_error(STR_ERROR_OFF_EDGE_OF_MAP);
42 }
43 
44 
45 static void GetTileDesc_Void(TileIndex tile, TileDesc *td)
46 {
47  td->str = STR_EMPTY;
48  td->owner[0] = OWNER_NONE;
49 }
50 
51 static void TileLoop_Void(TileIndex tile)
52 {
53  /* not used */
54 }
55 
56 static void ChangeTileOwner_Void(TileIndex tile, Owner old_owner, Owner new_owner)
57 {
58  /* not used */
59 }
60 
61 static TrackStatus GetTileTrackStatus_Void(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
62 {
63  return 0;
64 }
65 
66 static CommandCost TerraformTile_Void(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
67 {
68  return_cmd_error(STR_ERROR_OFF_EDGE_OF_MAP);
69 }
70 
71 extern const TileTypeProcs _tile_type_void_procs = {
72  DrawTile_Void, // draw_tile_proc
73  GetSlopePixelZ_Void, // get_slope_z_proc
74  ClearTile_Void, // clear_tile_proc
75  NULL, // add_accepted_cargo_proc
76  GetTileDesc_Void, // get_tile_desc_proc
77  GetTileTrackStatus_Void, // get_tile_track_status_proc
78  NULL, // click_tile_proc
79  NULL, // animate_tile_proc
80  TileLoop_Void, // tile_loop_proc
81  ChangeTileOwner_Void, // change_tile_owner_proc
82  NULL, // add_produced_cargo_proc
83  NULL, // vehicle_enter_tile_proc
84  GetFoundation_Void, // get_foundation_proc
85  TerraformTile_Void, // terraform_tile_proc
86 };
Tile information, used while rendering the tile.
Definition: tile_cmd.h:44
static const PaletteID PALETTE_ALL_BLACK
Exchange any color by black, needed for painting fictive tiles outside map.
Definition: sprites.h:1575
Slope tileh
Slope of the tile.
Definition: tile_cmd.h:47
Tile description for the &#39;land area information&#39; tool.
Definition: tile_cmd.h:53
Common return value for all commands.
Definition: command_type.h:25
Owner owner[4]
Name of the owner(s)
Definition: tile_cmd.h:55
Functions related to (drawing on) viewports.
Foundation
Enumeration for Foundations.
Definition: slope_type.h:95
DoCommandFlag
List of flags for a command.
Definition: command_type.h:340
Functions related to slopes.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
The tile has no ownership.
Definition: company_type.h:27
DiagDirection
Enumeration for diagonal directions.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
Definition: command_func.h:35
Set of callback functions for performing tile operations of a given tile type.
Definition: tile_cmd.h:144
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
The tile has no foundation, the slope remains unchanged.
Definition: slope_type.h:96
TransportType
Available types of transport.
Slope
Enumeration for the slope-type.
Definition: slope_type.h:50
Functions related to commands.
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:604
static uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
Definition: slope_func.h:417
StringID str
Description of the tile.
Definition: tile_cmd.h:54
Owner
Enum for all companies/owners.
Definition: company_type.h:20
This file contains all sprite-related enums and defines.
static uint TilePixelHeight(TileIndex tile)
Returns the height of a tile in pixels.
Definition: tile_map.h:64
Generic &#39;commands&#39; that can be performed on all tiles.