Add NewGRF object property/flag to use land as object ground sprite
This handles variable ground densities, snow/desert, etc.
This commit is contained in:
@@ -13,6 +13,11 @@
|
||||
#include "water_map.h"
|
||||
#include "object_type.h"
|
||||
|
||||
enum ObjectGround {
|
||||
OBJECT_GROUND_GRASS = 0, ///< Grass or bare
|
||||
OBJECT_GROUND_SNOW_DESERT = 1, ///< Snow or desert
|
||||
};
|
||||
|
||||
ObjectType GetObjectType(TileIndex t);
|
||||
|
||||
/**
|
||||
@@ -62,6 +67,93 @@ static inline byte GetObjectRandomBits(TileIndex t)
|
||||
return _m[t].m3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ground type of ths tile.
|
||||
* @param t The tile to get the ground type of.
|
||||
* @pre IsTileType(t, MP_OBJECT)
|
||||
* @return The ground type.
|
||||
*/
|
||||
static inline ObjectGround GetObjectGroundType(TileIndex t)
|
||||
{
|
||||
assert_tile(IsTileType(t, MP_OBJECT), t);
|
||||
return (ObjectGround)GB(_m[t].m4, 2, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ground density of this tile.
|
||||
* Only meaningful for some ground types.
|
||||
* @param t The tile to get the density of.
|
||||
* @pre IsTileType(t, MP_OBJECT)
|
||||
* @return the density
|
||||
*/
|
||||
static inline uint GetObjectGroundDensity(TileIndex t)
|
||||
{
|
||||
assert_tile(IsTileType(t, MP_OBJECT), t);
|
||||
return GB(_m[t].m4, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ground density of this tile.
|
||||
* Only meaningful for some ground types.
|
||||
* @param t The tile to set the density of.
|
||||
* @param d the new density
|
||||
* @pre IsTileType(t, MP_OBJECT)
|
||||
*/
|
||||
static inline void SetObjectGroundDensity(TileIndex t, uint d)
|
||||
{
|
||||
assert_tile(IsTileType(t, MP_OBJECT), t);
|
||||
SB(_m[t].m4, 0, 2, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the counter used to advance to the next ground density type.
|
||||
* @param t The tile to get the counter of.
|
||||
* @pre IsTileType(t, MP_OBJECT)
|
||||
* @return The value of the counter
|
||||
*/
|
||||
static inline uint GetObjectGroundCounter(TileIndex t)
|
||||
{
|
||||
assert_tile(IsTileType(t, MP_OBJECT), t);
|
||||
return GB(_m[t].m4, 5, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the counter used to advance to the next ground density type.
|
||||
* @param t the tile to increment the counter of
|
||||
* @param c the amount to increment the counter with
|
||||
* @pre IsTileType(t, MP_OBJECT)
|
||||
*/
|
||||
static inline void AddObjectGroundCounter(TileIndex t, int c)
|
||||
{
|
||||
assert_tile(IsTileType(t, MP_OBJECT), t);
|
||||
_m[t].m4 += c << 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the counter used to advance to the next ground density type.
|
||||
* @param t The tile to set the counter of.
|
||||
* @param c The amount to set the counter to.
|
||||
* @pre IsTileType(t, MP_OBJECT)
|
||||
*/
|
||||
static inline void SetObjectGroundCounter(TileIndex t, uint c)
|
||||
{
|
||||
assert_tile(IsTileType(t, MP_OBJECT), t);
|
||||
SB(_m[t].m4, 5, 3, c);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets ground type and density in one go, also sets the counter to 0
|
||||
* @param t the tile to set the ground type and density for
|
||||
* @param type the new ground type of the tile
|
||||
* @param density the density of the ground tile
|
||||
* @pre IsTileType(t, MP_OBJECT)
|
||||
*/
|
||||
static inline void SetObjectGroundTypeDensity(TileIndex t, ObjectGround type, uint density)
|
||||
{
|
||||
assert_tile(IsTileType(t, MP_OBJECT), t);
|
||||
_m[t].m4 = 0 << 5 | type << 2 | density;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an Object tile.
|
||||
|
||||
Reference in New Issue
Block a user