src/autoslope.h
author terom@frrb.lan
Fri, 19 Dec 2008 01:38:09 +0200
changeset 10439 50f056aa3024
parent 10208 72c00af5c95d
permissions -rw-r--r--
industries, unmoveables... everything but the landscape
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
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8962
diff changeset
     3
/** @file autoslope.h Functions related to autoslope. */
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
     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
8211
29a8510dfd62 (svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium
parents: 7640
diff changeset
     8
#include "settings_type.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
     9
#include "company_func.h"
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8254
diff changeset
    10
#include "depot_func.h"
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
    11
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
/**
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
 * 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
    14
 * 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
    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
 * 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
    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
 * @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
    19
 *
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 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
    21
 * @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
    22
 * @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
    23
 * @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
    24
 * @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
    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
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
    27
{
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
	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
    29
	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
    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
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
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9659
diff changeset
    33
 * Tests if autoslope is enabled for _current_company.
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
    34
 *
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9659
diff changeset
    35
 * Autoslope is disabled for town/industry construction and old ai companies.
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
    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
 * @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
    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
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
    40
{
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
    41
	return (_settings_game.construction.autoslope &&
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9659
diff changeset
    42
	        ((_current_company < MAX_COMPANIES && !_is_old_ai_company) ||
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9659
diff changeset
    43
	         (_current_company == 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
    44
}
4896ec945d21 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium
parents:
diff changeset
    45
4896ec945d21 (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 */