|
|
|
@ -8,28 +8,15 @@
|
|
|
|
|
#include "core/bitmath_func.hpp"
|
|
|
|
|
#include "tile_map.h"
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
HQ_NUM_TILE = 4, ///< Number of HQ tiles
|
|
|
|
|
HQ_NUM_SIZE = 5 ///< Number of stages of an HQ
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Types of unmovable structure */
|
|
|
|
|
enum UnmovableType {
|
|
|
|
|
UNMOVABLE_TRANSMITTER = 0, ///< The large antenna
|
|
|
|
|
UNMOVABLE_LIGHTHOUSE = 1, ///< The nice lighthouse
|
|
|
|
|
UNMOVABLE_STATUE = 2, ///< Statue in towns
|
|
|
|
|
UNMOVABLE_OWNED_LAND = 3, ///< Owned land 'flag'
|
|
|
|
|
UNMOVABLE_HQ_NORTH = 0x80, ///< Offset for the northern HQ tile
|
|
|
|
|
UNMOVABLE_HQ_WEST = 0x81, ///< Offset for the western HQ tile
|
|
|
|
|
UNMOVABLE_HQ_EAST = 0x82, ///< Offset for the eastern HQ tile
|
|
|
|
|
UNMOVABLE_HQ_SOUTH = 0x83, ///< Offset for the southern HQ tile
|
|
|
|
|
|
|
|
|
|
/** End of the HQ (rather end + 1 for IsInside) */
|
|
|
|
|
UNMOVABLE_HQ_END = UNMOVABLE_HQ_NORTH + HQ_NUM_SIZE * HQ_NUM_TILE
|
|
|
|
|
UNMOVABLE_HQ = 4, ///< HeadQuarter of a player
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the UnmovableType of the given unmovable tile
|
|
|
|
|
* @param t the tile to get the type from.
|
|
|
|
@ -83,7 +70,7 @@ static inline bool IsOwnedLandTile(TileIndex t)
|
|
|
|
|
static inline bool IsCompanyHQ(TileIndex t)
|
|
|
|
|
{
|
|
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
|
|
|
|
return HasBit(_m[t].m5, 7);
|
|
|
|
|
return _m[t].m5 == UNMOVABLE_HQ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -129,11 +116,24 @@ static inline TownID GetStatueTownID(TileIndex t)
|
|
|
|
|
static inline byte GetCompanyHQSize(TileIndex t)
|
|
|
|
|
{
|
|
|
|
|
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
|
|
|
|
|
return GB(_m[t].m5, 2, 3);
|
|
|
|
|
return GB(_m[t].m3, 2, 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the 'stage' of the HQ.
|
|
|
|
|
* @param t a tile of the HQ.
|
|
|
|
|
* @param size the actual stage of the HQ
|
|
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
|
|
|
|
|
*/
|
|
|
|
|
static inline void SetCompanyHQSize(TileIndex t, uint8 size)
|
|
|
|
|
{
|
|
|
|
|
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
|
|
|
|
|
SB(_m[t].m3, 2, 3, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the 'section' (including stage) of the HQ.
|
|
|
|
|
* Get the 'section' of the HQ.
|
|
|
|
|
* The scetion is in fact which side of teh HQ the tile represent
|
|
|
|
|
* @param t a tile of the HQ.
|
|
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
|
|
|
|
|
* @return the 'section' of the HQ.
|
|
|
|
@ -141,7 +141,19 @@ static inline byte GetCompanyHQSize(TileIndex t)
|
|
|
|
|
static inline byte GetCompanyHQSection(TileIndex t)
|
|
|
|
|
{
|
|
|
|
|
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
|
|
|
|
|
return GB(_m[t].m5, 0, 5);
|
|
|
|
|
return GB(_m[t].m3, 0, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the 'section' of the HQ.
|
|
|
|
|
* @param t a tile of the HQ.
|
|
|
|
|
* param section to be set.
|
|
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
|
|
|
|
|
*/
|
|
|
|
|
static inline void SetCompanyHQSection(TileIndex t, uint8 section)
|
|
|
|
|
{
|
|
|
|
|
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
|
|
|
|
|
SB(_m[t].m3, 0, 2, section);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -153,15 +165,15 @@ static inline byte GetCompanyHQSection(TileIndex t)
|
|
|
|
|
*/
|
|
|
|
|
static inline void EnlargeCompanyHQ(TileIndex t, byte size)
|
|
|
|
|
{
|
|
|
|
|
assert(GB(GetCompanyHQSection(t), 0, 2) == 0);
|
|
|
|
|
assert(GetCompanyHQSection(t) == 0);
|
|
|
|
|
|
|
|
|
|
size *= 4;
|
|
|
|
|
if (size <= _m[t].m5 - UNMOVABLE_HQ_NORTH) return;
|
|
|
|
|
size++;
|
|
|
|
|
if (size <= GetCompanyHQSize(t)) return;
|
|
|
|
|
|
|
|
|
|
_m[t + TileDiffXY(0, 0)].m5 = UNMOVABLE_HQ_NORTH + size;
|
|
|
|
|
_m[t + TileDiffXY(0, 1)].m5 = UNMOVABLE_HQ_WEST + size;
|
|
|
|
|
_m[t + TileDiffXY(1, 0)].m5 = UNMOVABLE_HQ_EAST + size;
|
|
|
|
|
_m[t + TileDiffXY(1, 1)].m5 = UNMOVABLE_HQ_SOUTH + size;
|
|
|
|
|
SetCompanyHQSize(t , size);
|
|
|
|
|
SetCompanyHQSize(t + TileDiffXY(0, 1), size);
|
|
|
|
|
SetCompanyHQSize(t + TileDiffXY(1, 0), size);
|
|
|
|
|
SetCompanyHQSize(t + TileDiffXY(1, 1), size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -223,6 +235,18 @@ static inline void MakeOwnedLand(TileIndex t, Owner o)
|
|
|
|
|
MakeUnmovable(t, UNMOVABLE_OWNED_LAND, o);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Make a HeadQuarter tile after making it an Unmovable
|
|
|
|
|
* @param t the tile to make an HQ.
|
|
|
|
|
* @param section the part of the HQ this one will be.
|
|
|
|
|
* @param o the new owner of the tile.
|
|
|
|
|
*/
|
|
|
|
|
static inline void MakeUnmovableHQHelper(TileIndex t, uint8 section, Owner o)
|
|
|
|
|
{
|
|
|
|
|
MakeUnmovable(t, UNMOVABLE_HQ, o);
|
|
|
|
|
SetCompanyHQSection(t, section);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Make an HQ with the give tile as it's northern tile.
|
|
|
|
|
* @param t the tile to make the northern tile of a HQ.
|
|
|
|
@ -230,10 +254,10 @@ static inline void MakeOwnedLand(TileIndex t, Owner o)
|
|
|
|
|
*/
|
|
|
|
|
static inline void MakeCompanyHQ(TileIndex t, Owner o)
|
|
|
|
|
{
|
|
|
|
|
MakeUnmovable(t + TileDiffXY(0, 0), UNMOVABLE_HQ_NORTH, o);
|
|
|
|
|
MakeUnmovable(t + TileDiffXY(0, 1), UNMOVABLE_HQ_WEST, o);
|
|
|
|
|
MakeUnmovable(t + TileDiffXY(1, 0), UNMOVABLE_HQ_EAST, o);
|
|
|
|
|
MakeUnmovable(t + TileDiffXY(1, 1), UNMOVABLE_HQ_SOUTH, o);
|
|
|
|
|
MakeUnmovableHQHelper(t , 0, o);
|
|
|
|
|
MakeUnmovableHQHelper(t + TileDiffXY(0, 1), 1, o);
|
|
|
|
|
MakeUnmovableHQHelper(t + TileDiffXY(1, 0), 2, o);
|
|
|
|
|
MakeUnmovableHQHelper(t + TileDiffXY(1, 1), 3, o);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* UNMOVABLE_MAP_H */
|
|
|
|
|