summaryrefslogtreecommitdiff
path: root/town_cmd.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-04-03 11:46:28 +0000
committercelestar <celestar@openttd.org>2006-04-03 11:46:28 +0000
commit7eedaf9a0ec70a53e6f5e74979c3304113587981 (patch)
tree6856d89c08220ff39d4884c62f240b6e46e27f07 /town_cmd.c
parent646badb7d7b597355722fadcea2c575e9705b0c0 (diff)
downloadopenttd-7eedaf9a0ec70a53e6f5e74979c3304113587981.tar.xz
(svn r4254) -Codechange: Add and make use of map accessors for town lifts.
Diffstat (limited to 'town_cmd.c')
-rw-r--r--town_cmd.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/town_cmd.c b/town_cmd.c
index 45b7c94d3..1e1a77c4f 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -81,7 +81,7 @@ typedef struct DrawTownTileStruct {
static void TownDrawHouseLift(const TileInfo *ti)
{
- AddChildSpriteScreen(SPR_LIFT, 14, 60 - GB(_m[ti->tile].m1, 0, 7));
+ AddChildSpriteScreen(SPR_LIFT, 14, 60 - GetLiftPosition(ti->tile));
}
typedef void TownDrawTileProc(const TileInfo *ti);
@@ -157,8 +157,7 @@ static uint GetSlopeTileh_Town(TileIndex tile, uint tileh)
static void AnimateTile_Town(TileIndex tile)
{
- int old;
- int a,b;
+ int pos, dest;
if (_tick_counter & 3) return;
@@ -171,32 +170,26 @@ static void AnimateTile_Town(TileIndex tile)
return;
}
- if (!((old = _m[tile].m1) & 0x80)) {
+ if (!IsLiftMoving(tile)) {
int i;
- _m[tile].m1 |= 0x80;
-
/** Building has 6 floors, number 0 .. 6, where 1 is illegal.
* This is due to the fact that the first floor is, in the graphics,
* the height of 2 'normal' floors.
* Furthermore, there are 6 lift positions from floor N (incl) to floor N + 1 (excl) */
do {
i = (Random() & 7) - 1;
- } while (i < 0 || i == 1 || i * 6 == old);
+ } while (i < 0 || i == 1 || i * 6 == GetLiftPosition(tile));
- SB(_m[tile].m5, 0, 6, i);
+ SetLiftDestination(tile, i);
}
- a = GB(_m[tile].m1, 0, 7);
- b = GB(_m[tile].m5, 0, 6) * 6;
- a += (a < b) ? 1 : -1;
- SB(_m[tile].m1, 0, 7, a);
+ pos = GetLiftPosition(tile);
+ dest = GetLiftDestination(tile) * 6;
+ pos += (pos < dest) ? 1 : -1;
+ SetLiftPosition(tile, pos);
- if (a == b) {
- _m[tile].m1 &= 0x7F;
- _m[tile].m5 &= 0x40;
- DeleteAnimatedTile(tile);
- }
+ if (pos == dest) HaltLift(tile);
MarkTileDirtyByTile(tile);
}
@@ -259,7 +252,7 @@ static void MakeSingleHouseBigger(TileIndex tile)
{
assert(IsTileType(tile, MP_HOUSE));
- if (_m[tile].m5 & 0x80) return;
+ if (LiftHasDestination(tile)) return;
AB(_m[tile].m5, 0, 3, 1);
if (GB(_m[tile].m5, 0, 3) != 0) return;
@@ -293,12 +286,7 @@ static void TileLoop_Town(TileIndex tile)
}
house = GetHouseType(tile);
- if (_housetype_extra_flags[house] & 0x20 &&
- !(_m[tile].m5 & 0x80) &&
- CHANCE16(1, 2) &&
- AddAnimatedTile(tile)) {
- _m[tile].m5 = (_m[tile].m5 & 0x40) | 0x80;
- }
+ if ((_housetype_extra_flags[house] & 0x20) && !LiftHasDestination(tile) && CHANCE16(1, 2) && AddAnimatedTile(tile)) BeginLiftMovement(tile);
t = GetTownByTile(tile);