author | tron |
Mon, 13 Feb 2006 21:15:00 +0000 | |
changeset 3017 | 915fae59d5e0 |
parent 2549 | f1d3b383d557 |
child 3279 | 7c642c5c501c |
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 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
18 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
19 |
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
|
20 |
{ |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
21 |
uint a; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
22 |
uint b; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
23 |
uint c; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
24 |
uint d; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
25 |
uint min; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
26 |
uint r; |
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
27 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
28 |
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
|
29 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
30 |
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
|
31 |
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
|
32 |
return 0; |
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 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
35 |
min = a = TileHeight(tile); |
1981 | 36 |
b = TileHeight(tile + TileDiffXY(1, 0)); |
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
37 |
if (min >= b) min = b; |
1981 | 38 |
c = TileHeight(tile + TileDiffXY(0, 1)); |
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
39 |
if (min >= c) min = c; |
1981 | 40 |
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
|
41 |
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
|
42 |
|
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
43 |
r = 0; |
2549 | 44 |
if ((a -= min) != 0) r += (--a << 4) + 8; |
45 |
if ((c -= min) != 0) r += (--c << 4) + 4; |
|
46 |
if ((d -= min) != 0) r += (--d << 4) + 2; |
|
47 |
if ((b -= min) != 0) r += (--b << 4) + 1; |
|
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1213
diff
changeset
|
48 |
|
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2549
diff
changeset
|
49 |
if (h != NULL) *h = min * 8; |
1335
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 |
} |