summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_house.cpp18
-rw-r--r--src/saveload/town_sl.cpp2
-rw-r--r--src/town.h10
-rw-r--r--src/town_cmd.cpp22
4 files changed, 26 insertions, 26 deletions
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 214734af1..8dddbfae6 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -369,7 +369,7 @@ static void DrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *grou
const HouseSpec *hs = GetHouseSpecs(house_id);
SpriteID palette = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOUR_START;
if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) {
- uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile);
+ uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile);
if (callback != CALLBACK_FAILED) {
/* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */
palette = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback;
@@ -421,7 +421,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
- NewHouseResolver(&object, house_id, ti->tile, GetTownByTile(ti->tile));
+ NewHouseResolver(&object, house_id, ti->tile, Town::GetByTile(ti->tile));
group = SpriteGroup::Resolve(hs->spritegroup, &object);
if (group == NULL || group->type != SGT_TILELAYOUT) {
@@ -443,7 +443,7 @@ void AnimateNewHouseTile(TileIndex tile)
bool frame_set_by_callback = false;
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) {
- uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED) animation_speed = Clamp(callback_res & 0xFF, 2, 16);
}
@@ -458,7 +458,7 @@ void AnimateNewHouseTile(TileIndex tile)
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) {
uint32 param = (hs->extra_flags & CALLBACK_1A_RANDOM_BITS) ? Random() : 0;
- uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED) {
frame_set_by_callback = true;
@@ -525,7 +525,7 @@ bool CanDeleteHouse(TileIndex tile)
}
if (HasBit(hs->callback_mask, CBM_HOUSE_DENY_DESTRUCTION)) {
- uint16 callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
return (callback_res == CALLBACK_FAILED || callback_res == 0);
} else {
return !(hs->extra_flags & BUILDING_IS_PROTECTED);
@@ -538,7 +538,7 @@ static void AnimationControl(TileIndex tile, uint16 random_bits)
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random();
- uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grffile, tile, callback_res);
}
@@ -575,9 +575,9 @@ bool NewHouseTileLoop(TileIndex tile)
/* Check callback 21, which determines if a house should be destroyed. */
if (HasBit(hs->callback_mask, CBM_HOUSE_DESTRUCTION)) {
- uint16 callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED && GB(callback_res, 0, 8) > 0) {
- ClearTownHouse(GetTownByTile(tile), tile);
+ ClearTownHouse(Town::GetByTile(tile), tile);
return false;
}
}
@@ -598,7 +598,7 @@ static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_rando
if (hs->spritegroup == NULL) return;
- NewHouseResolver(&object, hid, tile, GetTownByTile(tile));
+ NewHouseResolver(&object, hid, tile, Town::GetByTile(tile));
object.callback = CBID_RANDOM_TRIGGER;
object.trigger = trigger;
diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp
index 2667997f0..98264382a 100644
--- a/src/saveload/town_sl.cpp
+++ b/src/saveload/town_sl.cpp
@@ -42,7 +42,7 @@ void UpdateHousesAndTowns()
SetHouseType(t, house_id);
}
- town = GetTownByTile(t);
+ town = Town::GetByTile(t);
IncreaseBuildingCount(town, house_id);
if (IsHouseCompleted(t)) town->population += GetHouseSpecs(house_id)->population;
diff --git a/src/town.h b/src/town.h
index a55d45e3d..f4cdf3e37 100644
--- a/src/town.h
+++ b/src/town.h
@@ -135,12 +135,12 @@ struct Town : TownPool::PoolItem<&_town_pool> {
return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
}
-};
-static inline Town *GetTownByTile(TileIndex tile)
-{
- return Town::Get(GetTownIndex(tile));
-}
+ static FORCEINLINE Town *GetByTile(TileIndex tile)
+ {
+ return Town::Get(GetTownIndex(tile));
+ }
+};
uint32 GetWorldPopulation();
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index a14c1330d..aa125ecf6 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -80,7 +80,7 @@ Town::~Town()
for (TileIndex tile = 0; tile < MapSize(); ++tile) {
switch (GetTileType(tile)) {
case MP_HOUSE:
- if (GetTownByTile(tile) == this) DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ if (Town::GetByTile(tile) == this) DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
break;
case MP_ROAD:
@@ -380,14 +380,14 @@ static void MakeSingleHouseBigger(TileIndex tile)
/* Check and/or */
if (HasBit(hs->callback_mask, CBM_HOUSE_CONSTRUCTION_STATE_CHANGE)) {
- uint16 callback_res = GetHouseCallback(CBID_HOUSE_CONSTRUCTION_STATE_CHANGE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_CONSTRUCTION_STATE_CHANGE, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grffile, tile, callback_res);
}
if (IsHouseCompleted(tile)) {
/* Now that construction is complete, we can add the population of the
* building to the town. */
- ChangePopulation(GetTownByTile(tile), hs->population);
+ ChangePopulation(Town::GetByTile(tile), hs->population);
ResetHouseAge(tile);
}
MarkTileDirtyByTile(tile);
@@ -435,7 +435,7 @@ static void TileLoop_Town(TileIndex tile)
AddAnimatedTile(tile);
}
- Town *t = GetTownByTile(tile);
+ Town *t = Town::GetByTile(tile);
uint32 r = Random();
if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
@@ -516,7 +516,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
int rating = hs->remove_rating_decrease;
_cleared_town_rating += rating;
- Town *t = _cleared_town = GetTownByTile(tile);
+ Town *t = _cleared_town = Town::GetByTile(tile);
if (Company::IsValidID(_current_company)) {
if (rating > t->ratings[_current_company] && !(flags & DC_NO_TEST_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
@@ -537,7 +537,7 @@ static void GetProducedCargo_Town(TileIndex tile, CargoID *b)
{
HouseID house_id = GetHouseType(tile);
const HouseSpec *hs = GetHouseSpecs(house_id);
- Town *t = GetTownByTile(tile);
+ Town *t = Town::GetByTile(tile);
if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
for (uint i = 0; i < 256; i++) {
@@ -572,7 +572,7 @@ static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
/* Check for custom accepted cargo types */
if (HasBit(hs->callback_mask, CBM_HOUSE_ACCEPT_CARGO)) {
- uint16 callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
if (callback != CALLBACK_FAILED) {
/* Replace accepted cargo types with translated values from callback */
accepts[0] = GetCargoTranslation(GB(callback, 0, 5), hs->grffile);
@@ -583,7 +583,7 @@ static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
/* Check for custom cargo acceptance */
if (HasBit(hs->callback_mask, CBM_HOUSE_CARGO_ACCEPTANCE)) {
- uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
if (callback != CALLBACK_FAILED) {
if (accepts[0] != CT_INVALID) ac[accepts[0]] += GB(callback, 0, 4);
if (accepts[1] != CT_INVALID) ac[accepts[1]] += GB(callback, 4, 4);
@@ -611,7 +611,7 @@ static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
td->str = hs->building_name;
- uint16 callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, GetTownByTile(tile), tile);
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, Town::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED) {
StringID new_name = GetGRFStringID(hs->grffile->grfid, 0xD000 + callback_res);
if (new_name != STR_NULL && new_name != STR_UNDEFINED) {
@@ -1214,7 +1214,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
if (IsTileType(tile, MP_ROAD) && !IsRoadDepot(tile) && HasTileRoadType(tile, ROADTYPE_ROAD)) {
/* Don't allow building over roads of other cities */
- if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN) && GetTownByTile(tile) != t) {
+ if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN) && Town::GetByTile(tile) != t) {
_grow_town_result = GROWTH_SUCCEED;
} else if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_NONE) && _game_mode == GM_EDITOR) {
/* If we are in the SE, and this road-piece has no town owner yet, it just found an
@@ -2715,7 +2715,7 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold)
/* FALL THROUGH */
case MP_HOUSE:
- return GetTownByTile(tile);
+ return Town::GetByTile(tile);
default:
return CalcClosestTownFromTile(tile, threshold);