src/yapf/yapf_costbase.hpp
author belugas
Tue, 04 Mar 2008 17:07:33 +0000
changeset 9168 a35d94d8501c
parent 9149 cd335504407b
child 10429 1b99254f9607
permissions -rw-r--r--
(svn r12337) -Change: update some documentation.
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
	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
     8
	{
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
     9
		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
    10
			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
    11
				// it is bridge ramp, check if we are entering the bridge
8579
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents: 5726
diff changeset
    12
				if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are living it, no penalty
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
				// we are entering the bridge
8875
ffcab947226b (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8579
diff changeset
    14
				Slope tile_slope = GetTileSlope(tile, NULL);
ffcab947226b (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8579
diff changeset
    15
				Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile));
ffcab947226b (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8579
diff changeset
    16
				return !HasBridgeFlatRamp(tile_slope, axis);
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
    17
			} 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
    18
				// 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
    19
				if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope
9149
cd335504407b (svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents: 8875
diff changeset
    20
				Slope tile_slope = GetTileSlope(tile, NULL);
cd335504407b (svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
frosch
parents: 8875
diff changeset
    21
				return IsUphillTrackdir(tile_slope, td); // 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
    22
			}
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    23
		}
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    24
		return false;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    25
	}
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
struct CostRailSettings {
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    29
	// 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
    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
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    33
#endif /* YAPF_COSTBASE_HPP */