OpenTTD Source  1.11.2
terraform_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 "command_func.h"
12 #include "tunnel_map.h"
13 #include "bridge_map.h"
14 #include "viewport_func.h"
15 #include "genworld.h"
16 #include "object_base.h"
17 #include "company_base.h"
18 #include "company_func.h"
19 
20 #include "table/strings.h"
21 
22 #include <map>
23 #include <set>
24 
25 #include "safeguards.h"
26 
28 typedef std::set<TileIndex> TileIndexSet;
30 typedef std::map<TileIndex, int> TileIndexToHeightMap;
31 
36 };
37 
39 
48 {
49  TileIndexToHeightMap::const_iterator it = ts->tile_to_new_height.find(tile);
50  return it != ts->tile_to_new_height.end() ? it->second : TileHeight(tile);
51 }
52 
60 static void TerraformSetHeightOfTile(TerraformerState *ts, TileIndex tile, int height)
61 {
62  ts->tile_to_new_height[tile] = height;
63 }
64 
73 {
74  ts->dirty_tiles.insert(tile);
75 }
76 
85 {
86  /* Make sure all tiles passed to TerraformAddDirtyTile are within [0, MapSize()] */
87  if (TileY(tile) >= 1) TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1));
88  if (TileY(tile) >= 1 && TileX(tile) >= 1) TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1));
89  if (TileX(tile) >= 1) TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, 0));
90  TerraformAddDirtyTile(ts, tile);
91 }
92 
102 {
103  assert(tile < MapSize());
104 
105  /* Check range of destination height */
106  if (height < 0) return_cmd_error(STR_ERROR_ALREADY_AT_SEA_LEVEL);
107  if (height > _settings_game.construction.map_height_limit) return_cmd_error(STR_ERROR_TOO_HIGH);
108 
109  /*
110  * Check if the terraforming has any effect.
111  * This can only be true, if multiple corners of the start-tile are terraformed (i.e. the terraforming is done by towns/industries etc.).
112  * In this case the terraforming should fail. (Don't know why.)
113  */
114  if (height == TerraformGetHeightOfTile(ts, tile)) return CMD_ERROR;
115 
116  /* Check "too close to edge of map". Only possible when freeform-edges is off. */
117  uint x = TileX(tile);
118  uint y = TileY(tile);
119  if (!_settings_game.construction.freeform_edges && ((x <= 1) || (y <= 1) || (x >= MapMaxX() - 1) || (y >= MapMaxY() - 1))) {
120  /*
121  * Determine a sensible error tile
122  */
123  if (x == 1) x = 0;
124  if (y == 1) y = 0;
125  _terraform_err_tile = TileXY(x, y);
126  return_cmd_error(STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP);
127  }
128 
129  /* Mark incident tiles that are involved in the terraforming. */
130  TerraformAddDirtyTileAround(ts, tile);
131 
132  /* Store the height modification */
133  TerraformSetHeightOfTile(ts, tile, height);
134 
136 
137  /* Increment cost */
138  total_cost.AddCost(_price[PR_TERRAFORM]);
139 
140  /* Recurse to neighboured corners if height difference is larger than 1 */
141  {
142  const TileIndexDiffC *ttm;
143 
144  TileIndex orig_tile = tile;
145  static const TileIndexDiffC _terraform_tilepos[] = {
146  { 1, 0}, // move to tile in SE
147  {-2, 0}, // undo last move, and move to tile in NW
148  { 1, 1}, // undo last move, and move to tile in SW
149  { 0, -2} // undo last move, and move to tile in NE
150  };
151 
152  for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
153  tile += ToTileIndexDiff(*ttm);
154 
155  if (tile >= MapSize()) continue;
156  /* Make sure we don't wrap around the map */
157  if (Delta(TileX(orig_tile), TileX(tile)) == MapSizeX() - 1) continue;
158  if (Delta(TileY(orig_tile), TileY(tile)) == MapSizeY() - 1) continue;
159 
160  /* Get TileHeight of neighboured tile as of current terraform progress */
161  int r = TerraformGetHeightOfTile(ts, tile);
162  int height_diff = height - r;
163 
164  /* Is the height difference to the neighboured corner greater than 1? */
165  if (abs(height_diff) > 1) {
166  /* Terraform the neighboured corner. The resulting height difference should be 1. */
167  height_diff += (height_diff < 0 ? 1 : -1);
168  CommandCost cost = TerraformTileHeight(ts, tile, r + height_diff);
169  if (cost.Failed()) return cost;
170  total_cost.AddCost(cost);
171  }
172  }
173  }
174 
175  return total_cost;
176 }
177 
187 CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
188 {
190 
192  int direction = (p2 != 0 ? 1 : -1);
193  TerraformerState ts;
194 
195  /* Compute the costs and the terraforming result in a model of the landscape */
196  if ((p1 & SLOPE_W) != 0 && tile + TileDiffXY(1, 0) < MapSize()) {
197  TileIndex t = tile + TileDiffXY(1, 0);
198  CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
199  if (cost.Failed()) return cost;
200  total_cost.AddCost(cost);
201  }
202 
203  if ((p1 & SLOPE_S) != 0 && tile + TileDiffXY(1, 1) < MapSize()) {
204  TileIndex t = tile + TileDiffXY(1, 1);
205  CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
206  if (cost.Failed()) return cost;
207  total_cost.AddCost(cost);
208  }
209 
210  if ((p1 & SLOPE_E) != 0 && tile + TileDiffXY(0, 1) < MapSize()) {
211  TileIndex t = tile + TileDiffXY(0, 1);
212  CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
213  if (cost.Failed()) return cost;
214  total_cost.AddCost(cost);
215  }
216 
217  if ((p1 & SLOPE_N) != 0) {
218  TileIndex t = tile + TileDiffXY(0, 0);
219  CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
220  if (cost.Failed()) return cost;
221  total_cost.AddCost(cost);
222  }
223 
224  /* Check if the terraforming is valid wrt. tunnels, bridges and objects on the surface
225  * Pass == 0: Collect tileareas which are caused to be auto-cleared.
226  * Pass == 1: Collect the actual cost. */
227  for (int pass = 0; pass < 2; pass++) {
228  for (TileIndexSet::const_iterator it = ts.dirty_tiles.begin(); it != ts.dirty_tiles.end(); it++) {
229  TileIndex tile = *it;
230 
231  assert(tile < MapSize());
232  /* MP_VOID tiles can be terraformed but as tunnels and bridges
233  * cannot go under / over these tiles they don't need checking. */
234  if (IsTileType(tile, MP_VOID)) continue;
235 
236  /* Find new heights of tile corners */
237  int z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
238  int z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
239  int z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
240  int z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
241 
242  /* Find min and max height of tile */
243  int z_min = std::min({z_N, z_W, z_S, z_E});
244  int z_max = std::max({z_N, z_W, z_S, z_E});
245 
246  /* Compute tile slope */
247  Slope tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT);
248  if (z_W > z_min) tileh |= SLOPE_W;
249  if (z_S > z_min) tileh |= SLOPE_S;
250  if (z_E > z_min) tileh |= SLOPE_E;
251  if (z_N > z_min) tileh |= SLOPE_N;
252 
253  if (pass == 0) {
254  /* Check if bridge would take damage */
255  if (IsBridgeAbove(tile)) {
256  int bridge_height = GetBridgeHeight(GetSouthernBridgeEnd(tile));
257 
258  /* Check if bridge would take damage. */
259  if (direction == 1 && bridge_height <= z_max) {
260  _terraform_err_tile = tile; // highlight the tile under the bridge
261  return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
262  }
263 
264  /* Is the bridge above not too high afterwards? */
265  if (direction == -1 && bridge_height > (z_min + _settings_game.construction.max_bridge_height)) {
266  _terraform_err_tile = tile;
267  return_cmd_error(STR_ERROR_BRIDGE_TOO_HIGH_AFTER_LOWER_LAND);
268  }
269  }
270  /* Check if tunnel would take damage */
271  if (direction == -1 && IsTunnelInWay(tile, z_min)) {
272  _terraform_err_tile = tile; // highlight the tile above the tunnel
273  return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE);
274  }
275  }
276 
277  /* Is the tile already cleared? */
278  const ClearedObjectArea *coa = FindClearedObject(tile);
279  bool indirectly_cleared = coa != nullptr && coa->first_tile != tile;
280 
281  /* Check tiletype-specific things, and add extra-cost */
282  const bool curr_gen = _generating_world;
283  if (_game_mode == GM_EDITOR) _generating_world = true; // used to create green terraformed land
284  DoCommandFlag tile_flags = flags | DC_AUTO | DC_FORCE_CLEAR_TILE;
285  if (pass == 0) {
286  tile_flags &= ~DC_EXEC;
287  tile_flags |= DC_NO_MODIFY_TOWN_RATING;
288  }
289  CommandCost cost;
290  if (indirectly_cleared) {
291  cost = DoCommand(tile, 0, 0, tile_flags, CMD_LANDSCAPE_CLEAR);
292  } else {
293  cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, tile_flags, z_min, tileh);
294  }
295  _generating_world = curr_gen;
296  if (cost.Failed()) {
297  _terraform_err_tile = tile;
298  return cost;
299  }
300  if (pass == 1) total_cost.AddCost(cost);
301  }
302  }
303 
305  if (c != nullptr && GB(c->terraform_limit, 16, 16) < ts.tile_to_new_height.size()) {
306  return_cmd_error(STR_ERROR_TERRAFORM_LIMIT_REACHED);
307  }
308 
309  if (flags & DC_EXEC) {
310  /* Mark affected areas dirty. */
311  for (TileIndexSet::const_iterator it = ts.dirty_tiles.begin(); it != ts.dirty_tiles.end(); it++) {
312  MarkTileDirtyByTile(*it);
313  TileIndexToHeightMap::const_iterator new_height = ts.tile_to_new_height.find(tile);
314  if (new_height == ts.tile_to_new_height.end()) continue;
315  MarkTileDirtyByTile(*it, 0, new_height->second);
316  }
317 
318  /* change the height */
319  for (TileIndexToHeightMap::const_iterator it = ts.tile_to_new_height.begin();
320  it != ts.tile_to_new_height.end(); it++) {
321  TileIndex tile = it->first;
322  int height = it->second;
323 
324  SetTileHeight(tile, (uint)height);
325  }
326 
327  if (c != nullptr) c->terraform_limit -= (uint32)ts.tile_to_new_height.size() << 16;
328  }
329  return total_cost;
330 }
331 
332 
344 CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
345 {
346  if (p1 >= MapSize()) return CMD_ERROR;
347 
349 
350  /* remember level height */
351  uint oldh = TileHeight(p1);
352 
353  /* compute new height */
354  uint h = oldh;
355  LevelMode lm = (LevelMode)GB(p2, 1, 2);
356  switch (lm) {
357  case LM_LEVEL: break;
358  case LM_RAISE: h++; break;
359  case LM_LOWER: h--; break;
360  default: return CMD_ERROR;
361  }
362 
363  /* Check range of destination height */
364  if (h > _settings_game.construction.map_height_limit) return_cmd_error((oldh == 0) ? STR_ERROR_ALREADY_AT_SEA_LEVEL : STR_ERROR_TOO_HIGH);
365 
368  CommandCost last_error(lm == LM_LEVEL ? STR_ERROR_ALREADY_LEVELLED : INVALID_STRING_ID);
369  bool had_success = false;
370 
372  int limit = (c == nullptr ? INT32_MAX : GB(c->terraform_limit, 16, 16));
373  if (limit == 0) return_cmd_error(STR_ERROR_TERRAFORM_LIMIT_REACHED);
374 
375  TileIterator *iter = HasBit(p2, 0) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(tile, p1);
376  for (; *iter != INVALID_TILE; ++(*iter)) {
377  TileIndex t = *iter;
378  uint curh = TileHeight(t);
379  while (curh != h) {
380  CommandCost ret = DoCommand(t, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
381  if (ret.Failed()) {
382  last_error = ret;
383 
384  /* Did we reach the limit? */
385  if (ret.GetErrorMessage() == STR_ERROR_TERRAFORM_LIMIT_REACHED) limit = 0;
386  break;
387  }
388 
389  if (flags & DC_EXEC) {
390  money -= ret.GetCost();
391  if (money < 0) {
392  _additional_cash_required = ret.GetCost();
393  delete iter;
394  return cost;
395  }
396  DoCommand(t, SLOPE_N, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
397  } else {
398  /* When we're at the terraform limit we better bail (unneeded) testing as well.
399  * This will probably cause the terraforming cost to be underestimated, but only
400  * when it's near the terraforming limit. Even then, the estimation is
401  * completely off due to it basically counting terraforming double, so it being
402  * cut off earlier might even give a better estimate in some cases. */
403  if (--limit <= 0) {
404  had_success = true;
405  break;
406  }
407  }
408 
409  cost.AddCost(ret);
410  curh += (curh > h) ? -1 : 1;
411  had_success = true;
412  }
413 
414  if (limit <= 0) break;
415  }
416 
417  delete iter;
418  return had_success ? cost : last_error;
419 }
TerraformerState::dirty_tiles
TileIndexSet dirty_tiles
The tiles that need to be redrawn.
Definition: terraform_cmd.cpp:34
tunnel_map.h
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
DiagonalTileIterator
Iterator to iterate over a diagonal area of the map.
Definition: tilearea_type.h:188
DoCommand
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:450
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
command_func.h
_tile_type_procs
const TileTypeProcs *const _tile_type_procs[16]
Tile callback functions for each type of tile.
Definition: landscape.cpp:61
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:340
CMD_ERROR
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Definition: command_func.h:23
company_base.h
ConstructionSettings::map_height_limit
uint8 map_height_limit
the maximum allowed heightlevel
Definition: settings_type.h:321
GetBridgeHeight
int GetBridgeHeight(TileIndex t)
Get the height ('z') of a bridge.
Definition: bridge_map.cpp:70
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
TerraformAddDirtyTile
static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
Adds a tile to the "tile_table" in a TerraformerState.
Definition: terraform_cmd.cpp:72
CmdTerraformLand
CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Terraform land.
Definition: terraform_cmd.cpp:187
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
TerraformGetHeightOfTile
static int TerraformGetHeightOfTile(const TerraformerState *ts, TileIndex tile)
Gets the TileHeight (height of north corner) of a tile as of current terraforming progress.
Definition: terraform_cmd.cpp:47
DC_EXEC
@ DC_EXEC
execute the given command
Definition: command_type.h:348
CommandCost::GetErrorMessage
StringID GetErrorMessage() const
Returns the error message of a command.
Definition: command_type.h:140
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:346
genworld.h
LM_LEVEL
@ LM_LEVEL
Level the land.
Definition: map_type.h:82
object_base.h
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
TerraformerState
State of the terraforming.
Definition: terraform_cmd.cpp:33
MapSizeX
static uint MapSizeX()
Get the size of the map along the X.
Definition: map_func.h:72
SLOPE_FLAT
@ SLOPE_FLAT
a flat tile
Definition: slope_type.h:49
LevelMode
LevelMode
Argument for CmdLevelLand describing what to do.
Definition: map_type.h:81
TerraformTileHeight
static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
Terraform the north corner of a tile to a specific height.
Definition: terraform_cmd.cpp:101
ToTileIndexDiff
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
Definition: map_func.h:230
OrthogonalTileIterator
Iterator to iterate over a tile area (rectangle) of the map.
Definition: tilearea_type.h:138
return_cmd_error
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
Definition: command_func.h:33
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
EXPENSES_CONSTRUCTION
@ EXPENSES_CONSTRUCTION
Construction costs.
Definition: economy_type.h:158
CommandCost
Common return value for all commands.
Definition: command_type.h:23
CompanyProperties::terraform_limit
uint32 terraform_limit
Amount of tileheights we can (still) terraform (times 65536).
Definition: company_base.h:86
TileHeight
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Definition: tile_map.h:29
CMD_TERRAFORM_LAND
@ CMD_TERRAFORM_LAND
terraform a tile
Definition: command_type.h:186
TileIterator
Base class for tile iterators.
Definition: tilearea_type.h:99
ClearedObjectArea::first_tile
TileIndex first_tile
The first tile being cleared, which then causes the whole object to be cleared.
Definition: object_base.h:85
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:159
IsTunnelInWay
bool IsTunnelInWay(TileIndex tile, int z)
Is there a tunnel in the way in any direction?
Definition: tunnel_map.cpp:68
ConstructionSettings::max_bridge_height
byte max_bridge_height
maximum height of bridges
Definition: settings_type.h:325
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:80
TerraformAddDirtyTileAround
static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile)
Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a Terraf...
Definition: terraform_cmd.cpp:84
safeguards.h
SLOPE_STEEP
@ SLOPE_STEEP
indicates the slope is steep
Definition: slope_type.h:54
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:333
CommandCost::GetCost
Money GetCost() const
The costs as made up to this moment.
Definition: command_type.h:82
GetAvailableMoneyForCommand
Money GetAvailableMoneyForCommand()
Definition: command.cpp:528
GetSouthernBridgeEnd
TileIndex GetSouthernBridgeEnd(TileIndex t)
Finds the southern end of a bridge starting at a middle tile.
Definition: bridge_map.cpp:49
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:48
MapSizeY
static uint MapSizeY()
Get the size of the map along the Y.
Definition: map_func.h:82
CommandCost::AddCost
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Definition: command_type.h:62
stdafx.h
LM_RAISE
@ LM_RAISE
Raise the land.
Definition: map_type.h:84
SetTileHeight
static void SetTileHeight(TileIndex tile, uint height)
Sets the height of a tile.
Definition: tile_map.h:57
viewport_func.h
bridge_map.h
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
TileTypeProcs::terraform_tile_proc
TerraformTileProc * terraform_tile_proc
Called when a terraforming operation is about to take place.
Definition: tile_cmd.h:159
TileIndexSet
std::set< TileIndex > TileIndexSet
Set of tiles.
Definition: terraform_cmd.cpp:28
TileIndexDiffC
A pair-construct of a TileIndexDiff.
Definition: map_type.h:57
_generating_world
bool _generating_world
Whether we are generating the map or not.
Definition: genworld.cpp:61
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
SLOPE_N
@ SLOPE_N
the north corner of the tile is raised
Definition: slope_type.h:53
TerraformerState::tile_to_new_height
TileIndexToHeightMap tile_to_new_height
The tiles for which the height has changed.
Definition: terraform_cmd.cpp:35
DC_FORCE_CLEAR_TILE
@ DC_FORCE_CLEAR_TILE
do not only remove the object on the tile, but also clear any water left on it
Definition: command_type.h:359
MapMaxY
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition: map_func.h:111
FindClearedObject
ClearedObjectArea * FindClearedObject(TileIndex tile)
Find the entry in _cleared_object_areas which occupies a certain tile.
Definition: object_cmd.cpp:456
MP_VOID
@ MP_VOID
Invisible tiles at the SW and SE border.
Definition: tile_type.h:53
_terraform_err_tile
TileIndex _terraform_err_tile
first tile we couldn't terraform
Definition: terraform_cmd.cpp:38
TerraformSetHeightOfTile
static void TerraformSetHeightOfTile(TerraformerState *ts, TileIndex tile, int height)
Stores the TileHeight (height of north corner) of a tile in a TerraformerState.
Definition: terraform_cmd.cpp:60
TileXY
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
Definition: map_func.h:163
endof
#define endof(x)
Get the end element of an fixed size array.
Definition: stdafx.h:377
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1985
TileDiffXY
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:179
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:349
SLOPE_S
@ SLOPE_S
the south corner of the tile is raised
Definition: slope_type.h:51
DC_NO_MODIFY_TOWN_RATING
@ DC_NO_MODIFY_TOWN_RATING
do not change town rating
Definition: command_type.h:358
company_func.h
MapMaxX
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition: map_func.h:102
abs
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:21
CmdLevelLand
CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Levels a selected (rectangle) area of land.
Definition: terraform_cmd.cpp:344
SLOPE_W
@ SLOPE_W
the west corner of the tile is raised
Definition: slope_type.h:50
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:565
TileIndexToHeightMap
std::map< TileIndex, int > TileIndexToHeightMap
Mapping of tiles to their height.
Definition: terraform_cmd.cpp:30
GetTileType
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:96
ClearedObjectArea
Keeps track of removed objects during execution/testruns of commands.
Definition: object_base.h:84
Company
Definition: company_base.h:110
LM_LOWER
@ LM_LOWER
Lower the land.
Definition: map_type.h:83
SLOPE_E
@ SLOPE_E
the east corner of the tile is raised
Definition: slope_type.h:52
CMD_LANDSCAPE_CLEAR
@ CMD_LANDSCAPE_CLEAR
demolish a tile
Definition: command_type.h:180
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
Delta
static T Delta(const T a, const T b)
Returns the (absolute) difference between two (scalar) variables.
Definition: math_func.hpp:170
IsBridgeAbove
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
Definition: bridge_map.h:45