author | Darkvater |
Wed, 22 Mar 2006 20:46:07 +0000 | |
branch | 0.4.5 |
changeset 9950 | 88a936946fc8 |
parent 9942 | 56446313309e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
1213
bb9906f67932
(svn r1717) -Fix: some compilation problems for braindead VS6 and added missing files to project (thx bociusz)
darkvater
parents:
1211
diff
changeset
|
3 |
#include "stdafx.h" |
1211 | 4 |
#include "tile.h" |
5 |
||
6 |
void SetMapExtraBits(TileIndex tile, byte bits) |
|
7 |
{ |
|
8 |
assert(tile < MapSize()); |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1981
diff
changeset
|
9 |
SB(_m[tile].extra, 0, 2, bits & 3); |
1211 | 10 |
} |
11 |
||
12 |
uint GetMapExtraBits(TileIndex tile) |
|
13 |
{ |
|
14 |
assert(tile < MapSize()); |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1981
diff
changeset
|
15 |
return GB(_m[tile].extra, 0, 2); |
1211 | 16 |
} |
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
17 |
|
9942
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
18 |
/** Converts the heights of 4 corners into a tileh, and returns the minimum height of the tile |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
19 |
* @param n,w,e,s the four corners |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
20 |
* @param h uint pointer to write the height to |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
21 |
* @return the tileh |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
22 |
*/ |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
23 |
uint GetTileh(uint n, uint w, uint e, uint s, uint *h) |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
24 |
{ |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
25 |
uint min = n; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
26 |
uint r; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
27 |
|
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
28 |
if (min >= w) min = w; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
29 |
if (min >= e) min = e; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
30 |
if (min >= s) min = s; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
31 |
|
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
32 |
r = 0; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
33 |
if ((n -= min) != 0) r += (--n << 4) + 8; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
34 |
if ((e -= min) != 0) r += (--e << 4) + 4; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
35 |
if ((s -= min) != 0) r += (--s << 4) + 2; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
36 |
if ((w -= min) != 0) r += (--w << 4) + 1; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
37 |
|
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
38 |
if (h != NULL) *h = min * 8; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
39 |
|
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
40 |
return r; |
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
41 |
} |
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
42 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
43 |
uint GetTileSlope(TileIndex tile, uint *h) |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
44 |
{ |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
45 |
uint a; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
46 |
uint b; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
47 |
uint c; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
48 |
uint d; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
49 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
50 |
assert(tile < MapSize()); |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
51 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
52 |
if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) { |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
53 |
if (h != NULL) *h = 0; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
54 |
return 0; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
55 |
} |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
56 |
|
9942
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
57 |
a = TileHeight(tile); |
1981 | 58 |
b = TileHeight(tile + TileDiffXY(1, 0)); |
59 |
c = TileHeight(tile + TileDiffXY(0, 1)); |
|
60 |
d = TileHeight(tile + TileDiffXY(1, 1)); |
|
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
61 |
|
9942
56446313309e
(svn r4012) -Backport from trunk (3992, 3995): Rewrote the code to determine whether a rail-tile can be terraformed.
celestar
parents:
2549
diff
changeset
|
62 |
return GetTileh(a, b, c, d, h); |
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
63 |
} |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
64 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
65 |
uint GetTileZ(TileIndex tile) |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
66 |
{ |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
67 |
uint h; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
68 |
GetTileSlope(tile, &h); |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
69 |
return h; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
70 |
} |