summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-03-30 15:06:49 +0000
committercelestar <celestar@openttd.org>2006-03-30 15:06:49 +0000
commit94ca804e4f63106a7a2019660e3d0b214d737e20 (patch)
treeb4f87a4c2b8239a0a7969758fba389914e01904a
parente2e633665e5b2602b1899f31caea440d4a2de297 (diff)
downloadopenttd-94ca804e4f63106a7a2019660e3d0b214d737e20.tar.xz
(svn r4179) -Codechange: Add and make use of an accessor that obtains the building type
-rw-r--r--town_cmd.c18
-rw-r--r--town_map.h5
2 files changed, 14 insertions, 9 deletions
diff --git a/town_cmd.c b/town_cmd.c
index 4cba570db..8c31c54f2 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -99,7 +99,7 @@ static void DrawTile_Town(TileInfo *ti)
/* Retrieve pointer to the draw town tile struct */
{
/* this "randomizes" on the (up to) 4 variants of a building */
- byte gfx = _m[ti->tile].m4;
+ byte gfx = GetHouseType(ti->tile);
byte stage = GB(_m[ti->tile].m3, 6, 2);
uint variant;
variant = ti->x >> 4;
@@ -166,7 +166,7 @@ static void AnimateTile_Town(TileIndex tile)
// Not exactly sure when this happens, but probably when a house changes.
// Before this was just a return...so it'd leak animated tiles..
// That bug seems to have been here since day 1??
- if (!(_housetype_extra_flags[_m[tile].m4] & 0x20)) {
+ if (!(_housetype_extra_flags[GetHouseType(tile)] & 0x20)) {
DeleteAnimatedTile(tile);
return;
}
@@ -267,14 +267,14 @@ static void MakeSingleHouseBigger(TileIndex tile)
_m[tile].m3 = _m[tile].m3 + 0x40;
if ((_m[tile].m3 & 0xC0) == 0xC0) {
- ChangePopulation(GetTownByTile(tile), _housetype_population[_m[tile].m4]);
+ ChangePopulation(GetTownByTile(tile), _housetype_population[GetHouseType(tile)]);
}
MarkTileDirtyByTile(tile);
}
static void MakeTownHouseBigger(TileIndex tile)
{
- uint flags = _house_more_flags[_m[tile].m4];
+ uint flags = _house_more_flags[GetHouseType(tile)];
if (flags & 8) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 0));
if (flags & 4) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 1));
if (flags & 2) MakeSingleHouseBigger(TILE_ADDXY(tile, 1, 0));
@@ -292,7 +292,7 @@ static void TileLoop_Town(TileIndex tile)
return;
}
- house = _m[tile].m4;
+ house = GetHouseType(tile);
if (_housetype_extra_flags[house] & 0x20 &&
!(_m[tile].m5 & 0x80) &&
CHANCE16(1, 2) &&
@@ -353,7 +353,7 @@ static int32 ClearTile_Town(TileIndex tile, byte flags)
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
if (flags&DC_AUTO && !(flags&DC_AI_BUILDING)) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
- house = _m[tile].m4;
+ house = GetHouseType(tile);
cost = _price.remove_house * _housetype_remove_cost[house] >> 8;
rating = _housetype_remove_ratingmod[house];
@@ -377,7 +377,7 @@ static int32 ClearTile_Town(TileIndex tile, byte flags)
static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
{
- byte type = _m[tile].m4;
+ byte type = GetHouseType(tile);
ac[CT_PASSENGERS] = _housetype_cargo_passengers[type];
ac[CT_MAIL] = _housetype_cargo_mail[type];
@@ -387,7 +387,7 @@ static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
{
- td->str = _town_tile_names[_m[tile].m4];
+ td->str = _town_tile_names[GetHouseType(tile)];
if ((_m[tile].m3 & 0xC0) != 0xC0) {
SetDParamX(td->dparam, 0, td->str);
td->str = STR_2058_UNDER_CONSTRUCTION;
@@ -1378,7 +1378,7 @@ static void DoClearTownHouseHelper(TileIndex tile)
static void ClearTownHouse(Town *t, TileIndex tile)
{
- uint house = _m[tile].m4;
+ uint house = GetHouseType(tile);
uint eflags;
assert(IsTileType(tile, MP_HOUSE));
diff --git a/town_map.h b/town_map.h
index 98b97007d..48d3ad94b 100644
--- a/town_map.h
+++ b/town_map.h
@@ -2,6 +2,11 @@
#include "town.h"
+static inline int GetHouseType(TileIndex t)
+{
+ assert(IsTileType(t, MP_HOUSE));
+ return _m[t].m4;
+}
static inline uint GetTownIndex(TileIndex t)
{