author | rubidium |
Fri, 03 Aug 2007 22:09:42 +0000 | |
branch | noai |
changeset 9694 | e72987579514 |
parent 9574 | 698395509d12 |
child 6870 | ca3fd1fbe311 |
child 9703 | d2a6acdbd665 |
permissions | -rw-r--r-- |
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 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
3 |
/** @file slope.h Definitions of a slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
4 |
* This file defines the enumeration and helper functions for handling |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
5 |
* the slope info of a tile. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
6 |
*/ |
9574 | 7 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
8 |
#ifndef SLOPE_H |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
9 |
#define SLOPE_H |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
10 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
11 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
12 |
* Enumeration for the slope-type. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
13 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
14 |
* This enumeration use the chars N,E,S,W corresponding the |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
15 |
* direction north, east, south and west. The top corner of a tile |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
16 |
* is the north-part of the tile. The whole slope is encoded with |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
17 |
* 5 bits, 4 bits for each corner and 1 bit for a steep-flag. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
18 |
*/ |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5726
diff
changeset
|
19 |
enum Slope { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
20 |
SLOPE_FLAT = 0x00, ///< a flat tile |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
21 |
SLOPE_W = 0x01, ///< the west corner of the tile is raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
22 |
SLOPE_S = 0x02, ///< the south corner of the tile is raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
23 |
SLOPE_E = 0x04, ///< the east corner of the tile is raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
24 |
SLOPE_N = 0x08, ///< the north corner of the tile is raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
25 |
SLOPE_STEEP = 0x10, ///< indicates the slope is steep |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
26 |
SLOPE_NW = SLOPE_N | SLOPE_W, ///< north and west corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
27 |
SLOPE_SW = SLOPE_S | SLOPE_W, ///< south and west corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
28 |
SLOPE_SE = SLOPE_S | SLOPE_E, ///< south and east corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
29 |
SLOPE_NE = SLOPE_N | SLOPE_E, ///< north and east corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
30 |
SLOPE_EW = SLOPE_E | SLOPE_W, ///< east and west corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
31 |
SLOPE_NS = SLOPE_N | SLOPE_S, ///< north and south corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
32 |
SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
33 |
SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S, ///< north, west and south corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
34 |
SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E, ///< west, south and east corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
35 |
SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N, ///< south, east and north corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
36 |
SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W, ///< east, north and west corner are raised |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
37 |
SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS, ///< a steep slope falling to east (from west) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
38 |
SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE, ///< a steep slope falling to north (from south) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
39 |
SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN, ///< a steep slope falling to west (from east) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
40 |
SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW ///< a steep slope falling to south (from north) |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5726
diff
changeset
|
41 |
}; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
42 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
43 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
44 |
* Checks if a slope is steep. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
45 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
46 |
* @param s The given #Slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
47 |
* @return True if the slope is steep, else false. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
48 |
*/ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
49 |
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
|
50 |
{ |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
51 |
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
|
52 |
} |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
53 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
54 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
55 |
* Return the complement of a slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
56 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
57 |
* This method returns the complement of a slope. The complement of a |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
58 |
* slope is a slope with raised corner which aren't raised in the given |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
59 |
* slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
60 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
61 |
* @pre The slope must not be steep. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
62 |
* @param s The #Slope to get the complement. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
63 |
* @return a complement Slope of the given slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
64 |
*/ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
65 |
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
|
66 |
{ |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
67 |
assert(!IsSteepSlope(s)); |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
68 |
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
|
69 |
} |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
70 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
71 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
72 |
* Returns the highest corner of a slope (one corner raised or a steep slope). |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
73 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
74 |
* @pre The slope must be a slope with one corner raised or a steep slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
75 |
* @param s The #Slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
76 |
* @return Number of the highest corner. (0 west, 1 south, 2 east, 3 north) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
77 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
78 |
static inline byte GetHighestSlopeCorner(Slope s) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
79 |
{ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
80 |
switch (s) { |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
81 |
case SLOPE_W: |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
82 |
case SLOPE_STEEP_W: return 0; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
83 |
case SLOPE_S: |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
84 |
case SLOPE_STEEP_S: return 1; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
85 |
case SLOPE_E: |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
86 |
case SLOPE_STEEP_E: return 2; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
87 |
case SLOPE_N: |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
88 |
case SLOPE_STEEP_N: return 3; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
89 |
default: NOT_REACHED(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
90 |
} |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
91 |
} |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
92 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
93 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
94 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
95 |
* Enumeration for Foundations. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
96 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
97 |
enum Foundation { |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
98 |
FOUNDATION_NONE, ///< The tile has no foundation, the slope remains unchanged. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
99 |
FOUNDATION_LEVELED, ///< The tile is leveled up to a flat slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
100 |
FOUNDATION_INCLINED_X, ///< The tile has an along X-axis inclined foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
101 |
FOUNDATION_INCLINED_Y, ///< The tile has an along Y-axis inclined foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
102 |
FOUNDATION_STEEP_LOWER, ///< The tile has a steep slope. The lowerst corner is raised by a foundation to allow building railroad on the lower halftile. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
103 |
FOUNDATION_STEEP_HIGHER, ///< The tile has a steep slope. Three corners are raised by a foundation to allow building railroad on the higher halftile. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
104 |
}; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
105 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
106 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
107 |
* Tests for FOUNDATION_NONE. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
108 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
109 |
* @param f Maybe a #Foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
110 |
* @return true iff f is a foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
111 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
112 |
static inline bool IsFoundation(Foundation f) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
113 |
{ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
114 |
return f != FOUNDATION_NONE; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
115 |
} |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
116 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
117 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
118 |
* Tests if the foundation is a leveled foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
119 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
120 |
* @param f The #Foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
121 |
* @return true iff f is a leveled foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
122 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
123 |
static inline bool IsLeveledFoundation(Foundation f) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
124 |
{ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
125 |
return f == FOUNDATION_LEVELED; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
126 |
} |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
127 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
128 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
129 |
* Tests if the foundation is an inclined foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
130 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
131 |
* @param f The #Foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
132 |
* @return true iff f is an inclined foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
133 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
134 |
static inline bool IsInclinedFoundation(Foundation f) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
135 |
{ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
136 |
return (f == FOUNDATION_INCLINED_X) || (f == FOUNDATION_INCLINED_Y); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
137 |
} |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
138 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
139 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
140 |
* Returns the foundation needed to flatten a slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
141 |
* The returned foundation is either FOUNDATION_NONE if the tile was already flat, or FOUNDATION_LEVELED. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
142 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
143 |
* @pre The slope must not be steep. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
144 |
* @param s The current #Slope. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
145 |
* @return The needed #Foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
146 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
147 |
static inline Foundation FlatteningFoundation(Slope s) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
148 |
{ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
149 |
assert(!IsSteepSlope(s)); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
150 |
return (s == SLOPE_FLAT ? FOUNDATION_NONE : FOUNDATION_LEVELED); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
151 |
} |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
152 |
|
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
153 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
154 |
* Returns the along a specific axis inclined foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
155 |
* |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
156 |
* @param axis The #Axis. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
157 |
* @return The needed #Foundation. |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
158 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
159 |
static inline Foundation InclinedFoundation(Axis axis) |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
160 |
{ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
161 |
return (axis == AXIS_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
162 |
} |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9574
diff
changeset
|
163 |
|
4666
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4344
diff
changeset
|
164 |
#endif /* SLOPE_H */ |