Codechange: make use of Tile in for all direct map accesses
This commit is contained in:
118
src/town_map.h
118
src/town_map.h
@@ -19,10 +19,10 @@
|
||||
* @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
|
||||
* @return TownID
|
||||
*/
|
||||
static inline TownID GetTownIndex(TileIndex t)
|
||||
static inline TownID GetTownIndex(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
|
||||
return _m[t].m2;
|
||||
return t.m2();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,10 +31,10 @@ static inline TownID GetTownIndex(TileIndex t)
|
||||
* @param index the index of the town
|
||||
* @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
|
||||
*/
|
||||
static inline void SetTownIndex(TileIndex t, TownID index)
|
||||
static inline void SetTownIndex(Tile t, TownID index)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
|
||||
_m[t].m2 = index;
|
||||
t.m2() = index;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +44,10 @@ static inline void SetTownIndex(TileIndex t, TownID index)
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
* @return house type
|
||||
*/
|
||||
static inline HouseID GetCleanHouseType(TileIndex t)
|
||||
static inline HouseID GetCleanHouseType(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return _m[t].m4 | (GB(_m[t].m3, 6, 1) << 8);
|
||||
return t.m4() | (GB(t.m3(), 6, 1) << 8);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ static inline HouseID GetCleanHouseType(TileIndex t)
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
* @return house type
|
||||
*/
|
||||
static inline HouseID GetHouseType(TileIndex t)
|
||||
static inline HouseID GetHouseType(Tile t)
|
||||
{
|
||||
return GetTranslatedHouseID(GetCleanHouseType(t));
|
||||
}
|
||||
@@ -67,11 +67,11 @@ static inline HouseID GetHouseType(TileIndex t)
|
||||
* @param house_id the new house type
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
*/
|
||||
static inline void SetHouseType(TileIndex t, HouseID house_id)
|
||||
static inline void SetHouseType(Tile t, HouseID house_id)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
_m[t].m4 = GB(house_id, 0, 8);
|
||||
SB(_m[t].m3, 6, 1, GB(house_id, 8, 1));
|
||||
t.m4() = GB(house_id, 0, 8);
|
||||
SB(t.m3(), 6, 1, GB(house_id, 8, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,9 +79,9 @@ static inline void SetHouseType(TileIndex t, HouseID house_id)
|
||||
* @param t the tile
|
||||
* @return has destination
|
||||
*/
|
||||
static inline bool LiftHasDestination(TileIndex t)
|
||||
static inline bool LiftHasDestination(Tile t)
|
||||
{
|
||||
return HasBit(_me[t].m7, 0);
|
||||
return HasBit(t.m7(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,10 +90,10 @@ static inline bool LiftHasDestination(TileIndex t)
|
||||
* @param t the tile
|
||||
* @param dest new destination
|
||||
*/
|
||||
static inline void SetLiftDestination(TileIndex t, byte dest)
|
||||
static inline void SetLiftDestination(Tile t, byte dest)
|
||||
{
|
||||
SetBit(_me[t].m7, 0);
|
||||
SB(_me[t].m7, 1, 3, dest);
|
||||
SetBit(t.m7(), 0);
|
||||
SB(t.m7(), 1, 3, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,9 +101,9 @@ static inline void SetLiftDestination(TileIndex t, byte dest)
|
||||
* @param t the tile
|
||||
* @return destination
|
||||
*/
|
||||
static inline byte GetLiftDestination(TileIndex t)
|
||||
static inline byte GetLiftDestination(Tile t)
|
||||
{
|
||||
return GB(_me[t].m7, 1, 3);
|
||||
return GB(t.m7(), 1, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,9 +112,9 @@ static inline byte GetLiftDestination(TileIndex t)
|
||||
* and the destination.
|
||||
* @param t the tile
|
||||
*/
|
||||
static inline void HaltLift(TileIndex t)
|
||||
static inline void HaltLift(Tile t)
|
||||
{
|
||||
SB(_me[t].m7, 0, 4, 0);
|
||||
SB(t.m7(), 0, 4, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,9 +122,9 @@ static inline void HaltLift(TileIndex t)
|
||||
* @param t the tile
|
||||
* @return position, from 0 to 36
|
||||
*/
|
||||
static inline byte GetLiftPosition(TileIndex t)
|
||||
static inline byte GetLiftPosition(Tile t)
|
||||
{
|
||||
return GB(_me[t].m6, 2, 6);
|
||||
return GB(t.m6(), 2, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,9 +132,9 @@ static inline byte GetLiftPosition(TileIndex t)
|
||||
* @param t the tile
|
||||
* @param pos position, from 0 to 36
|
||||
*/
|
||||
static inline void SetLiftPosition(TileIndex t, byte pos)
|
||||
static inline void SetLiftPosition(Tile t, byte pos)
|
||||
{
|
||||
SB(_me[t].m6, 2, 6, pos);
|
||||
SB(t.m6(), 2, 6, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,10 +142,10 @@ static inline void SetLiftPosition(TileIndex t, byte pos)
|
||||
* @param t the tile
|
||||
* @return true if it is, false if it is not
|
||||
*/
|
||||
static inline bool IsHouseCompleted(TileIndex t)
|
||||
static inline bool IsHouseCompleted(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return HasBit(_m[t].m3, 7);
|
||||
return HasBit(t.m3(), 7);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,10 +153,10 @@ static inline bool IsHouseCompleted(TileIndex t)
|
||||
* @param t the tile
|
||||
* @param status
|
||||
*/
|
||||
static inline void SetHouseCompleted(TileIndex t, bool status)
|
||||
static inline void SetHouseCompleted(Tile t, bool status)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
SB(_m[t].m3, 7, 1, !!status);
|
||||
SB(t.m3(), 7, 1, !!status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,10 +180,10 @@ static inline void SetHouseCompleted(TileIndex t, bool status)
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
* @return the building stage of the house
|
||||
*/
|
||||
static inline byte GetHouseBuildingStage(TileIndex t)
|
||||
static inline byte GetHouseBuildingStage(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(_m[t].m5, 3, 2);
|
||||
return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(t.m5(), 3, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,10 +192,10 @@ static inline byte GetHouseBuildingStage(TileIndex t)
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
* @return the construction stage of the house
|
||||
*/
|
||||
static inline byte GetHouseConstructionTick(TileIndex t)
|
||||
static inline byte GetHouseConstructionTick(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return IsHouseCompleted(t) ? 0 : GB(_m[t].m5, 0, 3);
|
||||
return IsHouseCompleted(t) ? 0 : GB(t.m5(), 0, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,12 +205,12 @@ static inline byte GetHouseConstructionTick(TileIndex t)
|
||||
* @param t the tile of the house to increment the construction stage of
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
*/
|
||||
static inline void IncHouseConstructionTick(TileIndex t)
|
||||
static inline void IncHouseConstructionTick(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
AB(_m[t].m5, 0, 5, 1);
|
||||
AB(t.m5(), 0, 5, 1);
|
||||
|
||||
if (GB(_m[t].m5, 3, 2) == TOWN_HOUSE_COMPLETED) {
|
||||
if (GB(t.m5(), 3, 2) == TOWN_HOUSE_COMPLETED) {
|
||||
/* House is now completed.
|
||||
* Store the year of construction as well, for newgrf house purpose */
|
||||
SetHouseCompleted(t, true);
|
||||
@@ -223,10 +223,10 @@ static inline void IncHouseConstructionTick(TileIndex t)
|
||||
* @param t the tile of this house
|
||||
* @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
|
||||
*/
|
||||
static inline void ResetHouseAge(TileIndex t)
|
||||
static inline void ResetHouseAge(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t));
|
||||
_m[t].m5 = 0;
|
||||
t.m5() = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,10 +234,10 @@ static inline void ResetHouseAge(TileIndex t)
|
||||
* @param t the tile of this house
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
*/
|
||||
static inline void IncrementHouseAge(TileIndex t)
|
||||
static inline void IncrementHouseAge(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
if (IsHouseCompleted(t) && _m[t].m5 < 0xFF) _m[t].m5++;
|
||||
if (IsHouseCompleted(t) && t.m5() < 0xFF) t.m5()++;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,10 +246,10 @@ static inline void IncrementHouseAge(TileIndex t)
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
* @return year
|
||||
*/
|
||||
static inline Year GetHouseAge(TileIndex t)
|
||||
static inline Year GetHouseAge(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return IsHouseCompleted(t) ? _m[t].m5 : 0;
|
||||
return IsHouseCompleted(t) ? t.m5() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,10 +259,10 @@ static inline Year GetHouseAge(TileIndex t)
|
||||
* @param random the new random bits
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
*/
|
||||
static inline void SetHouseRandomBits(TileIndex t, byte random)
|
||||
static inline void SetHouseRandomBits(Tile t, byte random)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
_m[t].m1 = random;
|
||||
t.m1() = random;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,10 +272,10 @@ static inline void SetHouseRandomBits(TileIndex t, byte random)
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
* @return random bits
|
||||
*/
|
||||
static inline byte GetHouseRandomBits(TileIndex t)
|
||||
static inline byte GetHouseRandomBits(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return _m[t].m1;
|
||||
return t.m1();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,10 +285,10 @@ static inline byte GetHouseRandomBits(TileIndex t)
|
||||
* @param triggers the activated triggers
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
*/
|
||||
static inline void SetHouseTriggers(TileIndex t, byte triggers)
|
||||
static inline void SetHouseTriggers(Tile t, byte triggers)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
SB(_m[t].m3, 0, 5, triggers);
|
||||
SB(t.m3(), 0, 5, triggers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,10 +298,10 @@ static inline void SetHouseTriggers(TileIndex t, byte triggers)
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
* @return triggers
|
||||
*/
|
||||
static inline byte GetHouseTriggers(TileIndex t)
|
||||
static inline byte GetHouseTriggers(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return GB(_m[t].m3, 0, 5);
|
||||
return GB(t.m3(), 0, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,10 +310,10 @@ static inline byte GetHouseTriggers(TileIndex t)
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
* @return time remaining
|
||||
*/
|
||||
static inline byte GetHouseProcessingTime(TileIndex t)
|
||||
static inline byte GetHouseProcessingTime(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return GB(_me[t].m6, 2, 6);
|
||||
return GB(t.m6(), 2, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,10 +322,10 @@ static inline byte GetHouseProcessingTime(TileIndex t)
|
||||
* @param time the time to be set
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
*/
|
||||
static inline void SetHouseProcessingTime(TileIndex t, byte time)
|
||||
static inline void SetHouseProcessingTime(Tile t, byte time)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
SB(_me[t].m6, 2, 6, time);
|
||||
SB(t.m6(), 2, 6, time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,10 +333,10 @@ static inline void SetHouseProcessingTime(TileIndex t, byte time)
|
||||
* @param t the house tile
|
||||
* @pre IsTileType(t, MP_HOUSE)
|
||||
*/
|
||||
static inline void DecHouseProcessingTime(TileIndex t)
|
||||
static inline void DecHouseProcessingTime(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
_me[t].m6 -= 1 << 2;
|
||||
t.m6() -= 1 << 2;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,17 +349,17 @@ static inline void DecHouseProcessingTime(TileIndex t)
|
||||
* @param random_bits required for newgrf houses
|
||||
* @pre IsTileType(t, MP_CLEAR)
|
||||
*/
|
||||
static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
|
||||
static inline void MakeHouseTile(Tile t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
|
||||
{
|
||||
assert(IsTileType(t, MP_CLEAR));
|
||||
|
||||
SetTileType(t, MP_HOUSE);
|
||||
_m[t].m1 = random_bits;
|
||||
_m[t].m2 = tid;
|
||||
_m[t].m3 = 0;
|
||||
t.m1() = random_bits;
|
||||
t.m2() = tid;
|
||||
t.m3() = 0;
|
||||
SetHouseType(t, type);
|
||||
SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
|
||||
_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
|
||||
t.m5() = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
|
||||
SetAnimationFrame(t, 0);
|
||||
SetHouseProcessingTime(t, HouseSpec::Get(type)->processing_time);
|
||||
}
|
||||
|
Reference in New Issue
Block a user