src/slope_func.h
author rubidium
Mon, 31 Mar 2008 22:09:27 +0000
branch0.6
changeset 9357 bafe57f3402a
parent 8909 fa15e9afad2f
child 9297 94a4efa5de6e
permissions -rw-r--r--
(svn r12524) [0.6] -Update: some documentation.
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
     1
/* $Id$ */
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
     2
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
     3
/** @file slope_func.h Functions related to slopes. */
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
     4
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
     5
#ifndef SLOPE_FUNC_H
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
     6
#define SLOPE_FUNC_H
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
     7
8609
8c0c3e9dd6a0 (svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
rubidium
parents: 8604
diff changeset
     8
#include "core/math_func.hpp"
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
     9
#include "slope_type.h"
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
    10
#include "direction_type.h"
8634
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8609
diff changeset
    11
#include "tile_type.h"
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
    12
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
    13
/**
8199
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    14
 * Rangecheck for Corner enumeration.
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    15
 *
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    16
 * @param corner A #Corner.
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    17
 * @return true iff corner is in a valid range.
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    18
 */
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    19
static inline bool IsValidCorner(Corner corner)
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    20
{
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8266
diff changeset
    21
	return IsInsideMM(corner, 0, CORNER_END);
8199
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    22
}
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    23
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
    24
8199
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
    25
/**
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    26
 * Checks if a slope is steep.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    27
 *
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    28
 * @param s The given #Slope.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    29
 * @return True if the slope is steep, else false.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    30
 */
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    31
static inline bool IsSteepSlope(Slope s)
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    32
{
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    33
	return (s & SLOPE_STEEP) != 0;
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    34
}
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    35
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    36
/**
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    37
 * Checks for non-continuous slope on halftile foundations.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    38
 *
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    39
 * @param s The given #Slope.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    40
 * @return True if the slope is non-continuous, else false.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    41
 */
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    42
static inline bool IsHalftileSlope(Slope s)
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    43
{
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    44
	return (s & SLOPE_HALFTILE) != 0;
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    45
}
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    46
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    47
/**
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    48
 * Removes a halftile slope from a slope
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    49
 *
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    50
 * Non-halftile slopes remain unmodified.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    51
 *
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    52
 * @param s A #Slope.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    53
 * @return The slope s without it's halftile slope.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    54
 */
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    55
static inline Slope RemoveHalftileSlope(Slope s)
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    56
{
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    57
	return (Slope)(s & ~SLOPE_HALFTILE_MASK);
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    58
}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    59
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    60
/**
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    61
 * Return the complement of a slope.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    62
 *
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    63
 * This method returns the complement of a slope. The complement of a
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    64
 * slope is a slope with raised corner which aren't raised in the given
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    65
 * slope.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    66
 *
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    67
 * @pre The slope must neither be steep nor a halftile slope.
7805
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    68
 * @param s The #Slope to get the complement.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    69
 * @return a complement Slope of the given slope.
d6b7546a25b1 (svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents: 6916
diff changeset
    70
 */
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    71
static inline Slope ComplementSlope(Slope s)
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    72
{
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
    73
	assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    74
	return (Slope)(0xF ^ s);
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    75
}
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff changeset
    76
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
    77
/**
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    78
 * Tests if a specific slope has exactly one corner raised.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    79
 *
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    80
 * @param s The #Slope
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    81
 * @return true iff exactly one corner is raised
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    82
 */
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    83
static inline bool IsSlopeWithOneCornerRaised(Slope s)
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    84
{
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    85
	return (s == SLOPE_W) || (s == SLOPE_S) || (s == SLOPE_E) || (s == SLOPE_N);
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    86
}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    87
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    88
/**
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    89
 * Returns the slope with a specific corner raised.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    90
 *
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    91
 * @param corner The #Corner.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    92
 * @return The #Slope with corner "corner" raised.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    93
 */
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    94
static inline Slope SlopeWithOneCornerRaised(Corner corner)
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    95
{
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    96
	assert(IsValidCorner(corner));
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    97
	return (Slope)(1 << corner);
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    98
}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
    99
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   100
/**
8199
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   101
 * Tests if a slope has a highest corner (i.e. one corner raised or a steep slope).
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   102
 *
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   103
 * Note: A halftile slope is ignored.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   104
 *
8199
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   105
 * @param s The #Slope.
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   106
 * @return  true iff the slope has a highest corner.
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   107
 */
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   108
static inline bool HasSlopeHighestCorner(Slope s)
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   109
{
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   110
	s = RemoveHalftileSlope(s);
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   111
	return IsSteepSlope(s) || IsSlopeWithOneCornerRaised(s);
8199
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   112
}
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   113
00ee9637c0a0 (svn r11237) -Codechange: reduce code duplication between GetRailFoundation() and CheckRailSlope(). Patch by frosch.
rubidium
parents: 8174
diff changeset
   114
/**
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   115
 * Returns the highest corner of a slope (one corner raised or a steep slope).
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   116
 *
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   117
 * @pre      The slope must be a slope with one corner raised or a steep slope. A halftile slope is ignored.
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   118
 * @param s  The #Slope.
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   119
 * @return   Highest corner.
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   120
 */
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   121
static inline Corner GetHighestSlopeCorner(Slope s)
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   122
{
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   123
	switch (RemoveHalftileSlope(s)) {
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   124
		case SLOPE_W:
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   125
		case SLOPE_STEEP_W: return CORNER_W;
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   126
		case SLOPE_S:
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   127
		case SLOPE_STEEP_S: return CORNER_S;
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   128
		case SLOPE_E:
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   129
		case SLOPE_STEEP_E: return CORNER_E;
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   130
		case SLOPE_N:
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   131
		case SLOPE_STEEP_N: return CORNER_N;
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   132
		default: NOT_REACHED();
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   133
	}
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   134
}
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   135
8078
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   136
/**
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   137
 * Returns the leveled halftile of a halftile slope.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   138
 *
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   139
 * @pre     The slope must be a halftile slope.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   140
 * @param s The #Slope.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   141
 * @return  The corner of the leveled halftile.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   142
 */
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   143
static inline Corner GetHalftileSlopeCorner(Slope s)
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   144
{
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   145
	assert(IsHalftileSlope(s));
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   146
	return (Corner)((s >> 6) & 3);
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   147
}
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   148
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   149
/**
8078
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   150
 * Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   151
 *
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   152
 * @param s The #Slope.
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   153
 * @return Relative height of highest corner.
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   154
 */
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   155
static inline uint GetSlopeMaxZ(Slope s)
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   156
{
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   157
	if (s == SLOPE_FLAT) return 0;
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   158
	if (IsSteepSlope(s)) return 2 * TILE_HEIGHT;
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   159
	return TILE_HEIGHT;
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   160
}
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7831
diff changeset
   161
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   162
/**
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   163
 * Returns the opposite corner.
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   164
 *
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   165
 * @param corner A #Corner.
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   166
 * @return The opposite corner to "corner".
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   167
 */
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   168
static inline Corner OppositeCorner(Corner corner)
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   169
{
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   170
	return (Corner)(corner ^ 2);
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   171
}
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   172
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   173
/**
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   174
 * Tests if a specific slope has exactly three corners raised.
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   175
 *
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   176
 * @param s The #Slope
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   177
 * @return true iff exactly three corners are raised
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   178
 */
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   179
static inline bool IsSlopeWithThreeCornersRaised(Slope s)
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   180
{
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   181
	return !IsHalftileSlope(s) && !IsSteepSlope(s) && IsSlopeWithOneCornerRaised(ComplementSlope(s));
8174
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   182
}
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   183
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   184
/**
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   185
 * Returns the slope with all except one corner raised.
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   186
 *
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   187
 * @param corner The #Corner.
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   188
 * @return The #Slope with all corners but "corner" raised.
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   189
 */
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   190
static inline Slope SlopeWithThreeCornersRaised(Corner corner)
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   191
{
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   192
	return ComplementSlope(SlopeWithOneCornerRaised(corner));
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   193
}
5343705d60f5 (svn r11209) -Codechange: remove some magic numbers and bit magic with appropriate enums and functions. Patch by frosch.
rubidium
parents: 8078
diff changeset
   194
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   195
/**
8909
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   196
 * Returns a specific steep slope
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   197
 *
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   198
 * @param corner A #Corner.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   199
 * @return The steep #Slope with "corner" as highest corner.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   200
 */
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   201
static inline Slope SteepSlope(Corner corner)
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   202
{
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   203
	return (Slope)(SLOPE_STEEP | SlopeWithThreeCornersRaised(OppositeCorner(corner)));
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   204
}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   205
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   206
/**
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   207
 * Tests if a specific slope is an inclined slope.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   208
 *
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   209
 * @param s The #Slope
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   210
 * @return true iff the slope is inclined.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   211
 */
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   212
static inline bool IsInclinedSlope(Slope s)
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   213
{
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   214
	return (s == SLOPE_NW) || (s == SLOPE_SW) || (s == SLOPE_SE) || (s == SLOPE_NE);
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   215
}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   216
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   217
/**
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   218
 * Returns the direction of an inclined slope.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   219
 *
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   220
 * @param s A #Slope
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   221
 * @return The direction the slope goes up in. Or INVALID_DIAGDIR if the slope is not an inclined slope.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   222
 */
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   223
static inline DiagDirection GetInclinedSlopeDirection(Slope s)
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   224
{
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   225
	switch (s) {
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   226
		case SLOPE_NE: return DIAGDIR_NE;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   227
		case SLOPE_SE: return DIAGDIR_SE;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   228
		case SLOPE_SW: return DIAGDIR_SW;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   229
		case SLOPE_NW: return DIAGDIR_NW;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   230
		default: return INVALID_DIAGDIR;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   231
	}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   232
}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   233
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   234
/**
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   235
 * Returns the slope, that is inclined in a specific direction.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   236
 *
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   237
 * @param dir A #DiagDirection
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   238
 * @return The #Slope that goes up in direction dir.
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   239
 */
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   240
static inline Slope InclinedSlope(DiagDirection dir)
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   241
{
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   242
	switch (dir) {
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   243
		case DIAGDIR_NE: return SLOPE_NE;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   244
		case DIAGDIR_SE: return SLOPE_SE;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   245
		case DIAGDIR_SW: return SLOPE_SW;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   246
		case DIAGDIR_NW: return SLOPE_NW;
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   247
		default: NOT_REACHED();
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   248
	}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   249
}
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   250
fa15e9afad2f (svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents: 8634
diff changeset
   251
/**
8260
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   252
 * Adds a halftile slope to a slope.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   253
 *
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   254
 * @param s #Slope without a halftile slope.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   255
 * @param corner The #Corner of the halftile.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   256
 * @return The #Slope s with the halftile slope added.
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   257
 */
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   258
static inline Slope HalftileSlope(Slope s, Corner corner)
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   259
{
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   260
	assert(IsValidCorner(corner));
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   261
	return (Slope)(s | SLOPE_HALFTILE | (corner << 6));
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   262
}
c7d75cebe3f6 (svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents: 8199
diff changeset
   263
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   264
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   265
/**
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   266
 * Tests for FOUNDATION_NONE.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   267
 *
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   268
 * @param f  Maybe a #Foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   269
 * @return   true iff f is a foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   270
 */
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   271
static inline bool IsFoundation(Foundation f)
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   272
{
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   273
	return f != FOUNDATION_NONE;
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   274
}
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   275
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   276
/**
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   277
 * Tests if the foundation is a leveled foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   278
 *
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   279
 * @param f  The #Foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   280
 * @return   true iff f is a leveled foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   281
 */
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   282
static inline bool IsLeveledFoundation(Foundation f)
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   283
{
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   284
	return f == FOUNDATION_LEVELED;
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   285
}
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   286
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   287
/**
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   288
 * Tests if the foundation is an inclined foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   289
 *
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   290
 * @param f  The #Foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   291
 * @return   true iff f is an inclined foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   292
 */
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   293
static inline bool IsInclinedFoundation(Foundation f)
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   294
{
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   295
	return (f == FOUNDATION_INCLINED_X) || (f == FOUNDATION_INCLINED_Y);
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   296
}
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   297
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   298
/**
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   299
 * Tests if a foundation is a non-continuous foundation, i.e. halftile-foundation or FOUNDATION_STEEP_BOTH.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   300
 *
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   301
 * @param f  The #Foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   302
 * @return   true iff f is a non-continuous foundation
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   303
 */
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   304
static inline bool IsNonContinuousFoundation(Foundation f)
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   305
{
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8266
diff changeset
   306
	return IsInsideMM(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1);
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   307
}
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   308
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   309
/**
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   310
 * Returns the halftile corner of a halftile-foundation
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   311
 *
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   312
 * @pre f != FOUNDATION_STEEP_BOTH
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   313
 *
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   314
 * @param f  The #Foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   315
 * @return   The #Corner with track.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   316
 */
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   317
static inline Corner GetHalftileFoundationCorner(Foundation f)
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   318
{
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8266
diff changeset
   319
	assert(IsInsideMM(f, FOUNDATION_HALFTILE_W, FOUNDATION_HALFTILE_N + 1));
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   320
	return (Corner)(f - FOUNDATION_HALFTILE_W);
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   321
}
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   322
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   323
/**
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   324
 * Tests if a foundation is a special rail foundation for single horizontal/vertical track.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   325
 *
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   326
 * @param f  The #Foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   327
 * @return   true iff f is a special rail foundation for single horizontal/vertical track.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   328
 */
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   329
static inline bool IsSpecialRailFoundation(Foundation f)
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   330
{
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8266
diff changeset
   331
	return IsInsideMM(f, FOUNDATION_RAIL_W, FOUNDATION_RAIL_N + 1);
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   332
}
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   333
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   334
/**
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   335
 * Returns the track corner of a special rail foundation
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   336
 *
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   337
 * @param f  The #Foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   338
 * @return   The #Corner with track.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   339
 */
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   340
static inline Corner GetRailFoundationCorner(Foundation f)
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   341
{
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   342
	assert(IsSpecialRailFoundation(f));
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   343
	return (Corner)(f - FOUNDATION_RAIL_W);
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   344
}
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   345
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   346
/**
7831
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   347
 * Returns the foundation needed to flatten a slope.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   348
 * The returned foundation is either FOUNDATION_NONE if the tile was already flat, or FOUNDATION_LEVELED.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   349
 *
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   350
 * @pre      The slope must not be steep.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   351
 * @param s  The current #Slope.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   352
 * @return   The needed #Foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   353
 */
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   354
static inline Foundation FlatteningFoundation(Slope s)
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   355
{
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   356
	assert(!IsSteepSlope(s));
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   357
	return (s == SLOPE_FLAT ? FOUNDATION_NONE : FOUNDATION_LEVELED);
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   358
}
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   359
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   360
/**
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   361
 * Returns the along a specific axis inclined foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   362
 *
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   363
 * @param axis  The #Axis.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   364
 * @return      The needed #Foundation.
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   365
 */
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   366
static inline Foundation InclinedFoundation(Axis axis)
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   367
{
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   368
	return (axis == AXIS_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y);
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   369
}
5dded9b03500 (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents: 7805
diff changeset
   370
8266
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   371
/**
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   372
 * Returns the halftile foundation for single horizontal/vertical track.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   373
 *
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   374
 * @param corner The #Corner with the track.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   375
 * @return       The wanted #Foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   376
 */
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   377
static inline Foundation HalftileFoundation(Corner corner)
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   378
{
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   379
	assert(IsValidCorner(corner));
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   380
	return (Foundation)(FOUNDATION_HALFTILE_W + corner);
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   381
}
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   382
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   383
/**
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   384
 * Returns the special rail foundation for single horizontal/vertical track.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   385
 *
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   386
 * @param corner The #Corner with the track.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   387
 * @return       The wanted #Foundation.
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   388
 */
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   389
static inline Foundation SpecialRailFoundation(Corner corner)
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   390
{
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   391
	assert(IsValidCorner(corner));
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   392
	return (Foundation)(FOUNDATION_RAIL_W + corner);
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   393
}
48fa6a084b98 (svn r11319) -Add: halftile- and anti-zig-zag-foundations. Patch by frosch.
rubidium
parents: 8260
diff changeset
   394
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8450
diff changeset
   395
#endif /* SLOPE_FUNC_H */