author | rubidium |
Fri, 05 Oct 2007 17:53:01 +0000 | |
changeset 7675 | 93f4f0f33c9a |
parent 7582 | 80c8517b08d1 |
child 7678 | 8917067dde87 |
permissions | -rw-r--r-- |
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 |
|
7309
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
3 |
/** @file slope.h Definitions of a slope. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
4 |
* This file defines the enumeration and helper functions for handling |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
5 |
* the slope info of a tile. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
6 |
*/ |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
7 |
|
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
8 |
#ifndef SLOPE_H |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
9 |
#define SLOPE_H |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
10 |
|
7309
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
11 |
/** |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
12 |
* Enumeration for the slope-type. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
13 |
* |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
14 |
* This enumeration use the chars N,E,S,W corresponding the |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
15 |
* direction north, east, south and west. The top corner of a tile |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
16 |
* is the north-part of the tile. The whole slope is encoded with |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
17 |
* 5 bits, 4 bits for each corner and 1 bit for a steep-flag. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
18 |
*/ |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5475
diff
changeset
|
19 |
enum Slope { |
7309
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
20 |
SLOPE_FLAT = 0x00, ///< a flat tile |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
21 |
SLOPE_W = 0x01, ///< the west corner of the tile is raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
22 |
SLOPE_S = 0x02, ///< the south corner of the tile is raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
23 |
SLOPE_E = 0x04, ///< the east corner of the tile is raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
24 |
SLOPE_N = 0x08, ///< the north corner of the tile is raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
25 |
SLOPE_STEEP = 0x10, ///< indicates the slope is steep |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
26 |
SLOPE_NW = SLOPE_N | SLOPE_W, ///< north and west corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
27 |
SLOPE_SW = SLOPE_S | SLOPE_W, ///< south and west corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
28 |
SLOPE_SE = SLOPE_S | SLOPE_E, ///< south and east corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
29 |
SLOPE_NE = SLOPE_N | SLOPE_E, ///< north and east corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
30 |
SLOPE_EW = SLOPE_E | SLOPE_W, ///< east and west corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
31 |
SLOPE_NS = SLOPE_N | SLOPE_S, ///< north and south corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
32 |
SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, ///< all corner are raised, similar to SLOPE_FLAT |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
33 |
SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S, ///< north, west and south corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
34 |
SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E, ///< west, south and east corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
35 |
SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N, ///< south, east and north corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
36 |
SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W, ///< east, north and west corner are raised |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
37 |
SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS, ///< a steep slope falling to east (from west) |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
38 |
SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE, ///< a steep slope falling to north (from south) |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
39 |
SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN, ///< a steep slope falling to west (from east) |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
40 |
SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW ///< a steep slope falling to south (from north) |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5475
diff
changeset
|
41 |
}; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
42 |
|
7309
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
43 |
/** |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
44 |
* Checks if a slope is steep. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
45 |
* |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
46 |
* @param s The given #Slope. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
47 |
* @return True if the slope is steep, else false. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
48 |
*/ |
3636
a36cc46e754d
(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) |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
50 |
{ |
a36cc46e754d
(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; |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
52 |
} |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
53 |
|
7309
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
54 |
/** |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
55 |
* Return the complement of a slope. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
56 |
* |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
57 |
* 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
|
58 |
* 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
|
59 |
* slope. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
60 |
* |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
61 |
* @pre The slope must not be steep. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
62 |
* @param s The #Slope to get the complement. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
63 |
* @return a complement Slope of the given slope. |
223e01a82942
(svn r10661) -Documentation: documented slope.h (Progman)
truelight
parents:
6420
diff
changeset
|
64 |
*/ |
3636
a36cc46e754d
(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) |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
66 |
{ |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
67 |
assert(!IsSteepSlope(s)); |
a36cc46e754d
(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); |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
69 |
} |
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
diff
changeset
|
70 |
|
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
|
71 |
/** |
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
|
72 |
* 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
|
73 |
* |
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
|
74 |
* @pre The slope must be a slope with 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
|
75 |
* @param s The #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
|
76 |
* @return Number of the highest corner. (0 west, 1 south, 2 east, 3 north) |
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 |
*/ |
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
|
78 |
static inline byte GetHighestSlopeCorner(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
|
79 |
{ |
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
|
80 |
switch (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
|
81 |
case SLOPE_W: |
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
|
82 |
case SLOPE_STEEP_W: return 0; |
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
|
83 |
case 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
|
84 |
case SLOPE_STEEP_S: return 1; |
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
|
85 |
case SLOPE_E: |
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
|
86 |
case SLOPE_STEEP_E: return 2; |
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
|
87 |
case SLOPE_N: |
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
|
88 |
case SLOPE_STEEP_N: return 3; |
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
|
89 |
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
|
90 |
} |
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
|
91 |
} |
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
|
92 |
|
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
|
93 |
/** |
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
|
94 |
* 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
|
95 |
* |
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
|
96 |
* @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
|
97 |
* @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
|
98 |
*/ |
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
|
99 |
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
|
100 |
{ |
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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
} |
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
|
105 |
|
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
|
106 |
|
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
|
107 |
/** |
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
|
108 |
* Enumeration for Foundations. |
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
|
109 |
*/ |
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
|
110 |
enum 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
|
111 |
FOUNDATION_NONE, ///< The tile has no foundation, the slope remains unchanged. |
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
|
112 |
FOUNDATION_LEVELED, ///< The tile is leveled up to a flat 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
|
113 |
FOUNDATION_INCLINED_X, ///< The tile has an along X-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
|
114 |
FOUNDATION_INCLINED_Y, ///< The tile has an along Y-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
|
115 |
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. |
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 |
FOUNDATION_STEEP_HIGHER, ///< The tile has a steep slope. Three corners are raised by a foundation to allow building railroad on the higher halftile. |
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
|
117 |
}; |
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 |
|
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
|
119 |
/** |
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 |
* 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
|
121 |
* |
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 |
* @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
|
123 |
* @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
|
124 |
*/ |
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
|
125 |
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
|
126 |
{ |
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
|
127 |
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
|
128 |
} |
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
|
129 |
|
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 |
/** |
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
|
131 |
* 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
|
132 |
* |
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 |
* @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
|
134 |
* @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
|
135 |
*/ |
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
|
136 |
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
|
137 |
{ |
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
|
138 |
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
|
139 |
} |
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
|
140 |
|
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
|
141 |
/** |
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
|
142 |
* 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
|
143 |
* |
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
|
144 |
* @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
|
145 |
* @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
|
146 |
*/ |
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
|
147 |
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
|
148 |
{ |
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
|
149 |
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
|
150 |
} |
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
|
151 |
|
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
|
152 |
/** |
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
|
153 |
* 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
|
154 |
* 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
|
155 |
* |
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
|
156 |
* @pre The slope must not be steep. |
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
|
157 |
* @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
|
158 |
* @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
|
159 |
*/ |
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
|
160 |
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
|
161 |
{ |
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
|
162 |
assert(!IsSteepSlope(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
|
163 |
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
|
164 |
} |
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
|
165 |
|
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
|
166 |
/** |
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
|
167 |
* 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
|
168 |
* |
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
|
169 |
* @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
|
170 |
* @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
|
171 |
*/ |
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
|
172 |
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
|
173 |
{ |
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
|
174 |
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
|
175 |
} |
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
|
176 |
|
4666
172a0cdf28a6
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4344
diff
changeset
|
177 |
#endif /* SLOPE_H */ |