src/autoslope.h
author rubidium
Sun, 23 Sep 2007 11:05:11 +0000
changeset 7620 e6b07f259eff
parent 7583 4896ec945d21
child 7640 8cf1b20cc69f
permissions -rw-r--r--
(svn r11150) -Fix [FS#1202]: NewGRF action 3 does not necessarily need an action 1 to be defined. Patch by frosch.
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
{
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    39
	return (_patches.autoslope && IsValidPlayer(_current_player) && !_is_old_ai_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
    40
}
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    41
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
#endif /* AUTOSLOPE_H */