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