Codechange: make use of Tile in for all direct map accesses

This commit is contained in:
Rubidium
2023-01-21 16:40:28 +01:00
committed by rubidium42
parent 7a6452d3ef
commit 580d0a6343
30 changed files with 963 additions and 946 deletions

View File

@@ -70,10 +70,10 @@ enum TreeGround {
* @return The treetype of the given tile with trees
* @pre Tile t must be of type MP_TREES
*/
static inline TreeType GetTreeType(TileIndex t)
static inline TreeType GetTreeType(Tile t)
{
assert(IsTileType(t, MP_TREES));
return (TreeType)_m[t].m3;
return (TreeType)t.m3();
}
/**
@@ -85,10 +85,10 @@ static inline TreeType GetTreeType(TileIndex t)
* @return The groundtype of the tile
* @pre Tile must be of type MP_TREES
*/
static inline TreeGround GetTreeGround(TileIndex t)
static inline TreeGround GetTreeGround(Tile t)
{
assert(IsTileType(t, MP_TREES));
return (TreeGround)GB(_m[t].m2, 6, 3);
return (TreeGround)GB(t.m2(), 6, 3);
}
/**
@@ -110,10 +110,10 @@ static inline TreeGround GetTreeGround(TileIndex t)
* @pre Tile must be of type MP_TREES
* @see GetTreeCount
*/
static inline uint GetTreeDensity(TileIndex t)
static inline uint GetTreeDensity(Tile t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m2, 4, 2);
return GB(t.m2(), 4, 2);
}
/**
@@ -127,11 +127,11 @@ static inline uint GetTreeDensity(TileIndex t)
* @param d The density to save with
* @pre Tile must be of type MP_TREES
*/
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
static inline void SetTreeGroundDensity(Tile t, TreeGround g, uint d)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m2, 4, 2, d);
SB(_m[t].m2, 6, 3, g);
SB(t.m2(), 4, 2, d);
SB(t.m2(), 6, 3, g);
SetWaterClass(t, g == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
}
@@ -146,10 +146,10 @@ static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
* @return The number of trees (1-4)
* @pre Tile must be of type MP_TREES
*/
static inline uint GetTreeCount(TileIndex t)
static inline uint GetTreeCount(Tile t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m5, 6, 2) + 1;
return GB(t.m5(), 6, 2) + 1;
}
/**
@@ -163,10 +163,10 @@ static inline uint GetTreeCount(TileIndex t)
* @param c The value to add (or reduce) on the tree-count value
* @pre Tile must be of type MP_TREES
*/
static inline void AddTreeCount(TileIndex t, int c)
static inline void AddTreeCount(Tile t, int c)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
_m[t].m5 += c << 6;
t.m5() += c << 6;
}
/**
@@ -178,10 +178,10 @@ static inline void AddTreeCount(TileIndex t, int c)
* @return The tree growth status
* @pre Tile must be of type MP_TREES
*/
static inline uint GetTreeGrowth(TileIndex t)
static inline uint GetTreeGrowth(Tile t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m5, 0, 3);
return GB(t.m5(), 0, 3);
}
/**
@@ -193,10 +193,10 @@ static inline uint GetTreeGrowth(TileIndex t)
* @param a The value to add on the tree growth status
* @pre Tile must be of type MP_TREES
*/
static inline void AddTreeGrowth(TileIndex t, int a)
static inline void AddTreeGrowth(Tile t, int a)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
_m[t].m5 += a;
t.m5() += a;
}
/**
@@ -209,10 +209,10 @@ static inline void AddTreeGrowth(TileIndex t, int a)
* @param g The new value
* @pre Tile must be of type MP_TREES
*/
static inline void SetTreeGrowth(TileIndex t, uint g)
static inline void SetTreeGrowth(Tile t, uint g)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m5, 0, 3, g);
SB(t.m5(), 0, 3, g);
}
/**
@@ -227,17 +227,17 @@ static inline void SetTreeGrowth(TileIndex t, uint g)
* @param ground the ground type
* @param density the density (not the number of trees)
*/
static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
static inline void MakeTree(Tile t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
{
SetTileType(t, MP_TREES);
SetTileOwner(t, OWNER_NONE);
SetWaterClass(t, ground == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
_m[t].m2 = ground << 6 | density << 4 | 0;
_m[t].m3 = type;
_m[t].m4 = 0 << 5 | 0 << 2;
_m[t].m5 = count << 6 | growth;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = 0;
t.m2() = ground << 6 | density << 4 | 0;
t.m3() = type;
t.m4() = 0 << 5 | 0 << 2;
t.m5() = count << 6 | growth;
SB(t.m6(), 2, 4, 0);
t.m7() = 0;
}
#endif /* TREE_MAP_H */