annotate src/autoslope.h @ 8962:322e2779f67a draft

(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.
author rubidium <rubidium@openttd.org>
date Thu, 17 Apr 2008 19:10:30 +0000
parents 7d580c9c41fb
children d48433370037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7583
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1 /* $Id$ */
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
2
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
3 /** @file autoslope.h */
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
4
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
5 #ifndef AUTOSLOPE_H
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
6 #define AUTOSLOPE_H
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
7
8211
165064de4629 (svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium <rubidium@openttd.org>
parents: 7640
diff changeset
8 #include "settings_type.h"
8254
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8237
diff changeset
9 #include "player_func.h"
8962
322e2779f67a (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 <rubidium@openttd.org>
parents: 8254
diff changeset
10 #include "depot_func.h"
7583
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
11
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
12 /**
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
13 * Autoslope check for tiles with an entrance on an edge.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
14 * E.g. depots and non-drive-through-road-stops.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
15 *
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
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.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
17 *
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
18 * @note The test does not check if autoslope is enabled at all.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
19 *
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
20 * @param tile The tile.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
21 * @param z_new New TileZ.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
22 * @param tileh_new New TileSlope.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
23 * @param entrance Entrance edge.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
24 * @return true iff terraforming is allowed.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
25 */
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
26 static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, uint z_new, Slope tileh_new, DiagDirection entrance)
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
27 {
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
28 if (IsSteepSlope(tileh_new) || (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new))) return false;
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
29 return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
30 }
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
31
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
32 /**
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
33 * Tests if autoslope is enabled for _current_player.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
34 *
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
35 * Autoslope is disabled for town/industry construction and old ai players.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
36 *
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
37 * @return true iff autoslope is enabled.
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
38 */
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
39 static inline bool AutoslopeEnabled()
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
40 {
7640
206d9b6e13fc (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 <rubidium@openttd.org>
parents: 7583
diff changeset
41 return (_patches.autoslope &&
206d9b6e13fc (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 <rubidium@openttd.org>
parents: 7583
diff changeset
42 ((IsValidPlayer(_current_player) && !_is_old_ai_player) ||
206d9b6e13fc (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 <rubidium@openttd.org>
parents: 7583
diff changeset
43 (_current_player == OWNER_NONE && _game_mode == GM_EDITOR)));
7583
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
44 }
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
45
9eb4198ab848 (svn r11108) -Fix (r11107): somebody forgot to add some file ;) Spoils the fun of the previous cryptic message though.
rubidium <rubidium@openttd.org>
parents:
diff changeset
46 #endif /* AUTOSLOPE_H */