src/autoslope.h
author rubidium
Sat, 12 Jan 2008 14:10:35 +0000
changeset 8750 fdd6054e7bae
parent 8733 9e2d2a2619ff
child 10222 b6919c94cc77
permissions -rw-r--r--
(svn r11818) -Codechange: split player.h into smaller pieces.
8079
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     1
/* $Id$ */
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     2
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     3
/** @file autoslope.h */
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     4
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     5
#ifndef AUTOSLOPE_H
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     6
#define AUTOSLOPE_H
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     7
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     8
#include "depot.h"
8707
55835d8fbfcd (svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium
parents: 8136
diff changeset
     9
#include "settings_type.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8733
diff changeset
    10
#include "player_func.h"
8079
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    11
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    12
/**
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    13
 * Autoslope check for tiles with an entrance on an edge.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    14
 * E.g. depots and non-drive-through-road-stops.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    15
 *
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    16
 * The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    17
 *
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    18
 * @note The test does not check if autoslope is enabled at all.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    19
 *
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    20
 * @param tile The tile.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    21
 * @param z_new New TileZ.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    22
 * @param tileh_new New TileSlope.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    23
 * @param entrance Entrance edge.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    24
 * @return true iff terraforming is allowed.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    25
 */
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    26
static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance)
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    27
{
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    28
	if (IsSteepSlope(tileh_new) || (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new))) return false;
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    29
	return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    30
}
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    31
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    32
/**
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    33
 * Tests if autoslope is enabled for _current_player.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    34
 *
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    35
 * Autoslope is disabled for town/industry construction and old ai players.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    36
 *
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    37
 * @return true iff autoslope is enabled.
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    38
 */
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    39
static inline bool AutoslopeEnabled()
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    40
{
8136
d1a4486be2fd (svn r11171) -Fix [FS#1257]: disable autoslope for automatically changed stuff (like towns and industries) and enable it in the scenario editor. Patch by frosch.
rubidium
parents: 8079
diff changeset
    41
	return (_patches.autoslope &&
d1a4486be2fd (svn r11171) -Fix [FS#1257]: disable autoslope for automatically changed stuff (like towns and industries) and enable it in the scenario editor. Patch by frosch.
rubidium
parents: 8079
diff changeset
    42
	        ((IsValidPlayer(_current_player) && !_is_old_ai_player) ||
d1a4486be2fd (svn r11171) -Fix [FS#1257]: disable autoslope for automatically changed stuff (like towns and industries) and enable it in the scenario editor. Patch by frosch.
rubidium
parents: 8079
diff changeset
    43
	         (_current_player == OWNER_NONE && _game_mode == GM_EDITOR)));
8079
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    44
}
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    45
037a8b09887c (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    46
#endif /* AUTOSLOPE_H */