src/town_map.h
author rubidium
Wed, 17 Dec 2008 23:08:11 +0000
changeset 10434 3659467c844c
parent 10360 049db04f827f
permissions -rw-r--r--
(svn r14687) -Change: log all configure errors to config.log
3319
16c0f06829a5 (svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff changeset
     1
/* $Id$ */
16c0f06829a5 (svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff changeset
     2
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
     3
/** @file town_map.h Accessors for towns */
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
     4
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
     5
#ifndef TOWN_MAP_H
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
     6
#define TOWN_MAP_H
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
     7
3319
16c0f06829a5 (svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff changeset
     8
#include "town.h"
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 7931
diff changeset
     9
#include "tile_map.h"
3319
16c0f06829a5 (svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff changeset
    10
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    11
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    12
 * Get the index of which town this house/street is attached to.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    13
 * @param t the tile
7370
41adc721b1fa (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents: 7318
diff changeset
    14
 * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD)
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    15
 * @return TownID
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    16
 */
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    17
static inline TownID GetTownIndex(TileIndex t)
3319
16c0f06829a5 (svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff changeset
    18
{
7370
41adc721b1fa (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents: 7318
diff changeset
    19
	assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_ROAD)); // XXX incomplete
3319
16c0f06829a5 (svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff changeset
    20
	return _m[t].m2;
16c0f06829a5 (svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff changeset
    21
}
16c0f06829a5 (svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff changeset
    22
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    23
/**
3983
0f815283e04b (svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents: 3432
diff changeset
    24
 * Set the town index for a road or house tile.
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    25
 * @param t the tile
7370
41adc721b1fa (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents: 7318
diff changeset
    26
 * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD)
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    27
 * @param index the index of the town
7370
41adc721b1fa (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents: 7318
diff changeset
    28
 * @pre IsTileType(t, MP_ROAD) || IsTileType(t, MP_HOUSE)
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    29
 */
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    30
static inline void SetTownIndex(TileIndex t, TownID index)
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    31
{
7370
41adc721b1fa (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents: 7318
diff changeset
    32
	assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_ROAD));
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    33
	_m[t].m2 = index;
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    34
}
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
    35
5969
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    36
/**
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    37
 * Gets the town associated with the house or road tile
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    38
 * @param t the tile to get the town of
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    39
 * @return the town
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    40
 */
7318
632cd0497770 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 6422
diff changeset
    41
static inline Town *GetTownByTile(TileIndex t)
5969
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    42
{
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    43
	return GetTown(GetTownIndex(t));
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    44
}
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    45
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    46
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    47
 * Get the type of this house, which is an index into the house spec array
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    48
 * Since m4 is only a byte and we want to support 512 houses, we use the bit 6
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    49
 * of m3 as an additional bit to house type.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    50
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    51
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    52
 * @return house type
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    53
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    54
static inline HouseID GetHouseType(TileIndex t)
5969
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    55
{
57cbd6e884f5 (svn r8651) -Codechange: group the functions related to getting and setting the town index and move one function that is not related to the map array out of town_map.h.
rubidium
parents: 5475
diff changeset
    56
	assert(IsTileType(t, MP_HOUSE));
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    57
	return _m[t].m4 | (GB(_m[t].m3, 6, 1) << 8);
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
    58
}
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
    59
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    60
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    61
 * Set the house type.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    62
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    63
 * @param house_id the new house type
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    64
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    65
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    66
static inline void SetHouseType(TileIndex t, HouseID house_id)
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
    67
{
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    68
	assert(IsTileType(t, MP_HOUSE));
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    69
	_m[t].m4 = GB(house_id, 0, 8);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    70
	SB(_m[t].m3, 6, 1, GB(house_id, 8, 1));
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
    71
}
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
    72
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    73
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    74
 * Check if the lift of this animated house has a destination
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    75
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    76
 * @return has destination
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    77
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    78
static inline bool LiftHasDestination(TileIndex t)
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
    79
{
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7922
diff changeset
    80
	return HasBit(_me[t].m7, 0);
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
    81
}
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
    82
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    83
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    84
 * Set the new destination of the lift for this animated house, and activate
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    85
 * the LiftHasDestination bit.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    86
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    87
 * @param dest new destination
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    88
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    89
static inline void SetLiftDestination(TileIndex t, byte dest)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    90
{
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
    91
	SetBit(_me[t].m7, 0);
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    92
	SB(_me[t].m7, 1, 3, dest);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    93
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    94
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    95
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    96
 * Get the current destination for this lift
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    97
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    98
 * @return destination
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
    99
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   100
static inline byte GetLiftDestination(TileIndex t)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   101
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   102
	return GB(_me[t].m7, 1, 3);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   103
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   104
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   105
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   106
 * Stop the lift of this animated house from moving.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   107
 * Clears the first 4 bits of m7 at once, clearing the LiftHasDestination bit
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   108
 * and the destination.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   109
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   110
 */
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   111
static inline void HaltLift(TileIndex t)
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   112
{
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   113
	SB(_me[t].m7, 0, 4, 0);
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   114
}
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   115
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   116
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   117
 * Get the position of the lift on this animated house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   118
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   119
 * @return position, from 0 to 36
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   120
 */
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   121
static inline byte GetLiftPosition(TileIndex t)
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   122
{
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   123
	return GB(_m[t].m6, 2, 6);
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   124
}
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   125
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   126
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   127
 * Set the position of the lift on this animated house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   128
 * @param t the tile
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6418
diff changeset
   129
 * @param pos position, from 0 to 36
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   130
 */
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   131
static inline void SetLiftPosition(TileIndex t, byte pos)
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   132
{
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   133
	SB(_m[t].m6, 2, 6, pos);
3426
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   134
}
451a6367552d (svn r4254) -Codechange: Add and make use of map accessors for town lifts.
celestar
parents: 3382
diff changeset
   135
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   136
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   137
 * Get the current animation frame for this house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   138
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   139
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   140
 * @return frame number
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   141
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   142
static inline byte GetHouseAnimationFrame(TileIndex t)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   143
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   144
	assert(IsTileType(t, MP_HOUSE));
8681
c1853fb3c47a (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch
parents: 8485
diff changeset
   145
	return GB(_m[t].m6, 2, 6) | (GB(_m[t].m3, 5, 1) << 6);
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   146
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   147
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   148
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   149
 * Set a new animation frame for this house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   150
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   151
 * @param frame the new frame number
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   152
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   153
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   154
static inline void SetHouseAnimationFrame(TileIndex t, byte frame)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   155
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   156
	assert(IsTileType(t, MP_HOUSE));
8681
c1853fb3c47a (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch
parents: 8485
diff changeset
   157
	SB(_m[t].m6, 2, 6, GB(frame, 0, 6));
c1853fb3c47a (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch
parents: 8485
diff changeset
   158
	SB(_m[t].m3, 5, 1, GB(frame, 6, 1));
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   159
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   160
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   161
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   162
 * Get the completion of this house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   163
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   164
 * @return true if it is, false if it is not
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   165
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   166
static inline bool IsHouseCompleted(TileIndex t)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   167
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   168
	assert(IsTileType(t, MP_HOUSE));
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7922
diff changeset
   169
	return HasBit(_m[t].m3, 7);
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   170
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   171
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   172
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   173
 * Mark this house as been completed
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   174
 * @param t the tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   175
 * @param status
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   176
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   177
static inline void SetHouseCompleted(TileIndex t, bool status)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   178
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   179
	assert(IsTileType(t, MP_HOUSE));
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   180
	SB(_m[t].m3, 7, 1, !!status);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   181
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   182
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   183
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   184
 * Make the tile a house.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   185
 * @param t tile index
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   186
 * @param tid Town index
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   187
 * @param counter of construction step
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   188
 * @param stage of construction (used for drawing)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   189
 * @param type of house.  Index into house specs array
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   190
 * @param random_bits required for newgrf houses
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   191
 * @pre IsTileType(t, MP_CLEAR)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   192
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   193
static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
3382
be14efb0dfd7 (svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents: 3377
diff changeset
   194
{
be14efb0dfd7 (svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents: 3377
diff changeset
   195
	assert(IsTileType(t, MP_CLEAR));
be14efb0dfd7 (svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents: 3377
diff changeset
   196
be14efb0dfd7 (svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents: 3377
diff changeset
   197
	SetTileType(t, MP_HOUSE);
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   198
	_m[t].m1 = random_bits;
3382
be14efb0dfd7 (svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents: 3377
diff changeset
   199
	_m[t].m2 = tid;
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   200
	_m[t].m3 = 0;
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   201
	SetHouseType(t, type);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   202
	SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   203
	_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   204
	SetHouseAnimationFrame(t, 0);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   205
	_me[t].m7 = GetHouseSpecs(type)->processing_time;
3382
be14efb0dfd7 (svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents: 3377
diff changeset
   206
}
be14efb0dfd7 (svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents: 3377
diff changeset
   207
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   208
/**
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   209
 * House Construction Scheme.
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   210
 *  Construction counter, for buildings under construction. Incremented on every
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   211
 *  periodic tile processing.
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   212
 *  On wraparound, the stage of building in is increased.
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   213
 *  GetHouseBuildingStage is taking care of the real stages,
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   214
 *  (as the sprite for the next phase of house building)
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   215
 *  (Get|Inc)HouseConstructionTick is simply a tick counter between the
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   216
 *  different stages
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   217
 */
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   218
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   219
/**
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   220
 * Gets the building stage of a house
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   221
 * Since the stage is used for determining what sprite to use,
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   222
 * if the house is complete (and that stage no longuer is available),
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   223
 * fool the system by returning the TOWN_HOUSE_COMPLETE (3),
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   224
 * thus showing a beautiful complete house.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   225
 * @param t the tile of the house to get the building stage of
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   226
 * @pre IsTileType(t, MP_HOUSE)
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   227
 * @return the building stage of the house
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   228
 */
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   229
static inline byte GetHouseBuildingStage(TileIndex t)
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   230
{
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   231
	assert(IsTileType(t, MP_HOUSE));
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   232
	return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(_m[t].m5, 3, 2);
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   233
}
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   234
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   235
/**
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   236
 * Gets the construction stage of a house
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   237
 * @param t the tile of the house to get the construction stage of
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   238
 * @pre IsTileType(t, MP_HOUSE)
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   239
 * @return the construction stage of the house
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   240
 */
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   241
static inline byte GetHouseConstructionTick(TileIndex t)
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   242
{
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   243
	assert(IsTileType(t, MP_HOUSE));
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   244
	return IsHouseCompleted(t) ? 0 : GB(_m[t].m5, 0, 3);
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   245
}
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   246
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   247
/**
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   248
 * Sets the increment stage of a house
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   249
 * It is working with the whole counter + stage 5 bits, making it
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   250
 * easier to work:  the wraparound is automatic.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   251
 * @param t the tile of the house to increment the construction stage of
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   252
 * @pre IsTileType(t, MP_HOUSE)
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   253
 */
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   254
static inline void IncHouseConstructionTick(TileIndex t)
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   255
{
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   256
	assert(IsTileType(t, MP_HOUSE));
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   257
	AB(_m[t].m5, 0, 5, 1);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   258
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   259
	if (GB(_m[t].m5, 3, 2) == TOWN_HOUSE_COMPLETED) {
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   260
		/* House is now completed.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   261
		 * Store the year of construction as well, for newgrf house purpose */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   262
		SetHouseCompleted(t, true);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   263
	}
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   264
}
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   265
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   266
/**
10360
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   267
 * Sets the age of the house to zero.
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   268
 * Needs to be called after the house is completed. During construction stages the map space is used otherwise.
9006
7666e7b47088 (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium
parents: 9005
diff changeset
   269
 * @param t the tile of this house
7666e7b47088 (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium
parents: 9005
diff changeset
   270
 * @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
7666e7b47088 (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium
parents: 9005
diff changeset
   271
 */
10360
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   272
static inline void ResetHouseAge(TileIndex t)
9006
7666e7b47088 (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium
parents: 9005
diff changeset
   273
{
7666e7b47088 (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium
parents: 9005
diff changeset
   274
	assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t));
10360
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   275
	_m[t].m5 = 0;
9006
7666e7b47088 (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium
parents: 9005
diff changeset
   276
}
7666e7b47088 (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium
parents: 9005
diff changeset
   277
7666e7b47088 (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium
parents: 9005
diff changeset
   278
/**
10360
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   279
 * Increments the age of the house.
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   280
 * @param t the tile of this house
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   281
 * @pre IsTileType(t, MP_HOUSE)
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   282
 */
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   283
static inline void IncrementHouseAge(TileIndex t)
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   284
{
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   285
	assert(IsTileType(t, MP_HOUSE));
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   286
	if (IsHouseCompleted(t) && _m[t].m5 < 0xFF) _m[t].m5++;
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   287
}
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   288
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   289
/**
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   290
 * Get the age of the house
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   291
 * @param t the tile of this house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   292
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   293
 * @return year
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   294
 */
10360
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   295
static inline Year GetHouseAge(TileIndex t)
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   296
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   297
	assert(IsTileType(t, MP_HOUSE));
10360
049db04f827f (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch
parents: 10357
diff changeset
   298
	return IsHouseCompleted(t) ? _m[t].m5 : 0;
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   299
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   300
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   301
/**
7861
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   302
 * Set the random bits for this house.
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   303
 * This is required for newgrf house
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   304
 * @param t      the tile of this house
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   305
 * @param random the new random bits
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   306
 * @pre IsTileType(t, MP_HOUSE)
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   307
 */
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   308
static inline void SetHouseRandomBits(TileIndex t, byte random)
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   309
{
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   310
	assert(IsTileType(t, MP_HOUSE));
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   311
	_m[t].m1 = random;
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   312
}
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   313
77e12b5259fe (svn r11411) -Codechange: implement random triggers for houses.
rubidium
parents: 7370
diff changeset
   314
/**
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   315
 * Get the random bits for this house.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   316
 * This is required for newgrf house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   317
 * @param t the tile of this house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   318
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   319
 * @return random bits
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   320
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   321
static inline byte GetHouseRandomBits(TileIndex t)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   322
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   323
	assert(IsTileType(t, MP_HOUSE));
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   324
	return _m[t].m1;
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   325
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   326
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   327
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   328
 * Set the activated triggers bits for this house.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   329
 * This is required for newgrf house
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6332
diff changeset
   330
 * @param t        the tile of this house
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6332
diff changeset
   331
 * @param triggers the activated triggers
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   332
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   333
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   334
static inline void SetHouseTriggers(TileIndex t, byte triggers)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   335
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   336
	assert(IsTileType(t, MP_HOUSE));
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   337
	SB(_m[t].m3, 0, 5, triggers);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   338
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   339
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   340
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   341
 * Get the already activated triggers bits for this house.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   342
 * This is required for newgrf house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   343
 * @param t the tile of this house
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   344
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   345
 * @return triggers
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   346
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   347
static inline byte GetHouseTriggers(TileIndex t)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   348
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   349
	assert(IsTileType(t, MP_HOUSE));
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   350
	return GB(_m[t].m3, 0, 5);
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   351
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   352
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   353
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   354
 * Get the amount of time remaining before the tile loop processes this tile.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   355
 * @param t the house tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   356
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   357
 * @return time remaining
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   358
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   359
static inline byte GetHouseProcessingTime(TileIndex t)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   360
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   361
	assert(IsTileType(t, MP_HOUSE));
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   362
	return _me[t].m7;
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   363
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   364
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   365
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   366
 * Set the amount of time remaining before the tile loop processes this tile.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   367
 * @param t the house tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   368
 * @param time the time to be set
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   369
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   370
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   371
static inline void SetHouseProcessingTime(TileIndex t, byte time)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   372
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   373
	assert(IsTileType(t, MP_HOUSE));
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   374
	_me[t].m7 = time;
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   375
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   376
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   377
/**
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   378
 * Decrease the amount of time remaining before the tile loop processes this tile.
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   379
 * @param t the house tile
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   380
 * @pre IsTileType(t, MP_HOUSE)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   381
 */
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   382
static inline void DecHouseProcessingTime(TileIndex t)
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   383
{
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   384
	assert(IsTileType(t, MP_HOUSE));
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   385
	_me[t].m7--;
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 5969
diff changeset
   386
}
3432
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   387
650dd1972479 (svn r4261) CodeChange : Add and Use Accessor for Houses Construction. And cleaning on town.flags12 too
belugas
parents: 3426
diff changeset
   388
#endif /* TOWN_MAP_H */