src/autoslope.h
author skidd13
Sun, 02 Dec 2007 21:43:16 +0000
changeset 8004 1c54bc6f4bdf
parent 7640 8cf1b20cc69f
child 8211 29a8510dfd62
permissions -rw-r--r--
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
7583
4896ec945d21 (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$ */
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     2
4896ec945d21 (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 */
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     4
4896ec945d21 (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
4896ec945d21 (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
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     7
4896ec945d21 (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"
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
     9
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    10
/**
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    11
 * Autoslope check for tiles with an entrance on an edge.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    12
 * E.g. depots and non-drive-through-road-stops.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    13
 *
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    14
 * The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    15
 *
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    16
 * @note The test does not check if autoslope is enabled at all.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    17
 *
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    18
 * @param tile The tile.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    19
 * @param z_new New TileZ.
4896ec945d21 (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 tileh_new New TileSlope.
4896ec945d21 (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 entrance Entrance edge.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    22
 * @return true iff terraforming is allowed.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    23
 */
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    24
static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance)
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    25
{
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    26
	if (IsSteepSlope(tileh_new) || (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new))) return false;
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    27
	return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    28
}
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    29
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    30
/**
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    31
 * Tests if autoslope is enabled for _current_player.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    32
 *
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    33
 * Autoslope is disabled for town/industry construction and old ai players.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    34
 *
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    35
 * @return true iff autoslope is enabled.
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    36
 */
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    37
static inline bool AutoslopeEnabled()
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    38
{
7640
8cf1b20cc69f (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: 7583
diff changeset
    39
	return (_patches.autoslope &&
8cf1b20cc69f (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: 7583
diff changeset
    40
	        ((IsValidPlayer(_current_player) && !_is_old_ai_player) ||
8cf1b20cc69f (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: 7583
diff changeset
    41
	         (_current_player == OWNER_NONE && _game_mode == GM_EDITOR)));
7583
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    42
}
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    43
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    44
#endif /* AUTOSLOPE_H */