author | tron |
Mon, 07 Feb 2005 10:41:45 +0000 | |
changeset 1335 | a635854c23b6 |
parent 1213 | bb9906f67932 |
child 1854 | 8e246ac3d172 |
permissions | -rw-r--r-- |
1213
bb9906f67932
(svn r1717) -Fix: some compilation problems for braindead VS6 and added missing files to project (thx bociusz)
darkvater
parents:
1211
diff
changeset
|
1 |
#include "stdafx.h" |
1211 | 2 |
#include "tile.h" |
3 |
||
4 |
void SetMapExtraBits(TileIndex tile, byte bits) |
|
5 |
{ |
|
6 |
assert(tile < MapSize()); |
|
7 |
_map_extra_bits[tile >> 2] &= ~(3 << ((tile & 3) * 2)); |
|
8 |
_map_extra_bits[tile >> 2] |= (bits&3) << ((tile & 3) * 2); |
|
9 |
} |
|
10 |
||
11 |
uint GetMapExtraBits(TileIndex tile) |
|
12 |
{ |
|
13 |
assert(tile < MapSize()); |
|
14 |
return (_map_extra_bits[tile >> 2] >> (tile & 3) * 2) & 3; |
|
15 |
} |
|
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
16 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
17 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
18 |
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
|
19 |
{ |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
20 |
uint a; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
21 |
uint b; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
22 |
uint c; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
23 |
uint d; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
24 |
uint min; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
25 |
uint r; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
26 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
27 |
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
|
28 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
29 |
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
|
30 |
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
|
31 |
return 0; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
32 |
} |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
33 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
34 |
min = a = TileHeight(tile); |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
35 |
b = TileHeight(tile + TILE_XY(1,0)); |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
36 |
if (min >= b) min = b; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
37 |
c = TileHeight(tile + TILE_XY(0,1)); |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
38 |
if (min >= c) min = c; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
39 |
d = TileHeight(tile + TILE_XY(1,1)); |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
40 |
if (min >= d) min = d; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
41 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
42 |
r = 0; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
43 |
if ((a -= min) != 0) { r += (--a << 4) + 8; } |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
44 |
if ((c -= min) != 0) { r += (--c << 4) + 4; } |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
45 |
if ((d -= min) != 0) { r += (--d << 4) + 2; } |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
46 |
if ((b -= min) != 0) { r += (--b << 4) + 1; } |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
47 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
48 |
if (h != NULL) |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
49 |
*h = min * 8; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
50 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
51 |
return r; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
52 |
} |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
53 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
54 |
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
|
55 |
{ |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
56 |
uint h; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
57 |
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
|
58 |
return h; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
59 |
} |