src/yapf/yapf_costbase.hpp
author Tero Marttila <terom@fixme.fi>
Sat, 19 Jul 2008 01:38:52 +0300
changeset 11178 aa617a8b4f34
parent 10429 1b99254f9607
permissions -rw-r--r--
a working CheckAvailableNewGRFs that does a metadata search/retreival via HTTP for a given list of GRFs
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
10429
1b99254f9607 (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: 9149
diff changeset
     3
/** @file yapf_costbase.hpp Handling of cost determination. */
1b99254f9607 (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: 9149
diff changeset
     4
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     5
#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
     6
#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
     7
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     8
struct CYapfCostBase {
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
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
    14
				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
    15
				// we are entering the bridge
8875
ffcab947226b (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8579
diff changeset
    16
				Slope tile_slope = GetTileSlope(tile, NULL);
ffcab947226b (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8579
diff changeset
    17
				Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile));
ffcab947226b (svn r11946) -Fix: slope detection of bridge ramps.
frosch
parents: 8579
diff changeset
    18
				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
    19
			} 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
    20
				// 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
    21
				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
    22
				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
    23
				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
    24
			}
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
		return false;
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
};
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
struct CostRailSettings {
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    31
	// 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
    32
};
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    33
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
#endif /* YAPF_COSTBASE_HPP */