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
8 /** @file void_cmd.cpp Handling of void tiles. */
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
16 #include "table/strings.h"
17 #include "table/sprites.h"
18
19 #include "safeguards.h"
20
DrawTile_Void(TileInfo * ti)21 static void DrawTile_Void(TileInfo *ti)
22 {
23 DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh), PALETTE_ALL_BLACK);
24 }
25
26
GetSlopePixelZ_Void(TileIndex tile,uint x,uint y)27 static int GetSlopePixelZ_Void(TileIndex tile, uint x, uint y)
28 {
29 /* This function may be called on tiles outside the map, don't assume
30 * that 'tile' is a valid tile index. See GetSlopePixelZOutsideMap. */
31 int z;
32 Slope tileh = GetTilePixelSlopeOutsideMap(x >> 4, y >> 4, &z);
33
34 return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
35 }
36
GetFoundation_Void(TileIndex tile,Slope tileh)37 static Foundation GetFoundation_Void(TileIndex tile, Slope tileh)
38 {
39 return FOUNDATION_NONE;
40 }
41
ClearTile_Void(TileIndex tile,DoCommandFlag flags)42 static CommandCost ClearTile_Void(TileIndex tile, DoCommandFlag flags)
43 {
44 return_cmd_error(STR_ERROR_OFF_EDGE_OF_MAP);
45 }
46
47
GetTileDesc_Void(TileIndex tile,TileDesc * td)48 static void GetTileDesc_Void(TileIndex tile, TileDesc *td)
49 {
50 td->str = STR_EMPTY;
51 td->owner[0] = OWNER_NONE;
52 }
53
TileLoop_Void(TileIndex tile)54 static void TileLoop_Void(TileIndex tile)
55 {
56 /* not used */
57 }
58
ChangeTileOwner_Void(TileIndex tile,Owner old_owner,Owner new_owner)59 static void ChangeTileOwner_Void(TileIndex tile, Owner old_owner, Owner new_owner)
60 {
61 /* not used */
62 }
63
GetTileTrackStatus_Void(TileIndex tile,TransportType mode,uint sub_mode,DiagDirection side)64 static TrackStatus GetTileTrackStatus_Void(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
65 {
66 return 0;
67 }
68
TerraformTile_Void(TileIndex tile,DoCommandFlag flags,int z_new,Slope tileh_new)69 static CommandCost TerraformTile_Void(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
70 {
71 return_cmd_error(STR_ERROR_OFF_EDGE_OF_MAP);
72 }
73
74 extern const TileTypeProcs _tile_type_void_procs = {
75 DrawTile_Void, // draw_tile_proc
76 GetSlopePixelZ_Void, // get_slope_z_proc
77 ClearTile_Void, // clear_tile_proc
78 nullptr, // add_accepted_cargo_proc
79 GetTileDesc_Void, // get_tile_desc_proc
80 GetTileTrackStatus_Void, // get_tile_track_status_proc
81 nullptr, // click_tile_proc
82 nullptr, // animate_tile_proc
83 TileLoop_Void, // tile_loop_proc
84 ChangeTileOwner_Void, // change_tile_owner_proc
85 nullptr, // add_produced_cargo_proc
86 nullptr, // vehicle_enter_tile_proc
87 GetFoundation_Void, // get_foundation_proc
88 TerraformTile_Void, // terraform_tile_proc
89 };
90