yapf/yapf_costbase.hpp
author celestar
Tue, 02 Jan 2007 16:43:05 +0000
branchcustombridgeheads
changeset 5640 ccd487181ed5
parent 5573 afa6f92a71fd
permissions -rw-r--r--
(svn r7750) [cbh] - Doc: Updated the documentation for the tiles to reflect recent changes
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     1
/* $Id$ */
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     2
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     3
#ifndef  YAPF_COSTBASE_HPP
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     4
#define  YAPF_COSTBASE_HPP
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     5
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     6
struct CYapfCostBase {
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     7
	static const TrackdirBits   c_upwards_slopes[16];
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     8
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     9
	FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td)
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    10
	{
5139
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    11
		if (IsDiagonalTrackdir(td)) {
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5139
diff changeset
    12
			if (IsBridgeTile(tile)) {
5139
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    13
				// it is bridge ramp, check if we are entering the bridge
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    14
				if (GetBridgeRampDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are living it, no penalty
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    15
				// we are entering the bridge
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    16
				// if the tile slope is downwards, then bridge ramp has not upward slope
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    17
				uint tile_slope = GetTileSlope(tile, NULL) & 0x0F;
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    18
				if ((c_upwards_slopes[tile_slope] & TrackdirToTrackdirBits(ReverseTrackdir(td))) != 0) return false; // tile under ramp goes down, no penalty
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    19
				// tile under ramp isn't going down, so ramp must go up
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    20
				return true;
5139
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    21
			} else {
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    22
				// not bridge ramp
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    23
				if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    24
				uint tile_slope = GetTileSlope(tile, NULL) & 0x0F;
a891653f7092 (svn r7227) -Fix: [YAPF] Bridge YAPF Penalty Incorrect. The penalty for upward slope was incorrectly applied on bridge exit. (Danny)
KUDr
parents: 5018
diff changeset
    25
				if ((c_upwards_slopes[tile_slope] & TrackdirToTrackdirBits(td)) != 0) return true; // slopes uphill => apply penalty
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    26
			}
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    27
		}
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    28
		return false;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    29
	}
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    30
};
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    31
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    32
struct CostRailSettings {
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    33
	// look-ahead signal penalty
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    34
};
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    35
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    36
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    37
#endif /* YAPF_COSTBASE_HPP */