2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2006-04-03 14:56:07 +00:00
|
|
|
/** @file town_map.h Accessors for towns */
|
|
|
|
|
2006-04-03 11:46:28 +00:00
|
|
|
#ifndef TOWN_MAP_H
|
|
|
|
#define TOWN_MAP_H
|
|
|
|
|
2009-09-10 14:27:43 +00:00
|
|
|
#include "road_map.h"
|
2009-06-26 13:44:14 +00:00
|
|
|
#include "house.h"
|
2006-03-24 12:00:24 +00:00
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Get the index of which town this house/street is attached to.
|
|
|
|
* @param t the tile
|
2009-09-10 14:27:43 +00:00
|
|
|
* @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
|
2007-03-19 11:27:30 +00:00
|
|
|
* @return TownID
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline TownID GetTownIndex(TileIndex t)
|
2006-03-24 12:00:24 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)), t);
|
2006-03-24 12:00:24 +00:00
|
|
|
return _m[t].m2;
|
|
|
|
}
|
|
|
|
|
2006-04-03 14:56:07 +00:00
|
|
|
/**
|
2006-06-08 18:31:54 +00:00
|
|
|
* Set the town index for a road or house tile.
|
2007-03-19 11:27:30 +00:00
|
|
|
* @param t the tile
|
2006-04-03 14:56:07 +00:00
|
|
|
* @param index the index of the town
|
2009-09-10 14:27:43 +00:00
|
|
|
* @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
|
2006-04-03 14:56:07 +00:00
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void SetTownIndex(TileIndex t, TownID index)
|
2006-04-03 14:56:07 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)), t);
|
2006-04-03 14:56:07 +00:00
|
|
|
_m[t].m2 = index;
|
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Get the type of this house, which is an index into the house spec array
|
2009-12-20 14:53:32 +00:00
|
|
|
* without doing any NewGRF related translations.
|
2007-03-19 11:27:30 +00:00
|
|
|
* @param t the tile
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
* @return house type
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline HouseID GetCleanHouseType(TileIndex t)
|
2007-03-19 11:27:30 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2021-04-10 11:46:09 +00:00
|
|
|
return _m[t].m4 | (GB(_m[t].m3, 5, 2) << 8);
|
2007-03-19 11:27:30 +00:00
|
|
|
}
|
2007-02-09 16:21:03 +00:00
|
|
|
|
2009-12-20 14:53:32 +00:00
|
|
|
/**
|
|
|
|
* Get the type of this house, which is an index into the house spec array
|
|
|
|
* @param t the tile
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
* @return house type
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline HouseID GetHouseType(TileIndex t)
|
2009-12-20 14:53:32 +00:00
|
|
|
{
|
|
|
|
return GetTranslatedHouseID(GetCleanHouseType(t));
|
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Set the house type.
|
|
|
|
* @param t the tile
|
|
|
|
* @param house_id the new house type
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void SetHouseType(TileIndex t, HouseID house_id)
|
2007-02-09 16:21:03 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-03-19 11:27:30 +00:00
|
|
|
_m[t].m4 = GB(house_id, 0, 8);
|
2021-04-10 11:46:09 +00:00
|
|
|
SB(_m[t].m3, 5, 2, GB(house_id, 8, 2));
|
2007-02-09 16:21:03 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Check if the lift of this animated house has a destination
|
|
|
|
* @param t the tile
|
|
|
|
* @return has destination
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline bool LiftHasDestination(TileIndex t)
|
2006-04-03 11:46:28 +00:00
|
|
|
{
|
2007-11-19 21:02:30 +00:00
|
|
|
return HasBit(_me[t].m7, 0);
|
2006-04-03 11:46:28 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Set the new destination of the lift for this animated house, and activate
|
|
|
|
* the LiftHasDestination bit.
|
|
|
|
* @param t the tile
|
|
|
|
* @param dest new destination
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void SetLiftDestination(TileIndex t, byte dest)
|
2006-04-03 11:46:28 +00:00
|
|
|
{
|
2007-11-20 13:35:54 +00:00
|
|
|
SetBit(_me[t].m7, 0);
|
2007-03-19 11:27:30 +00:00
|
|
|
SB(_me[t].m7, 1, 3, dest);
|
2006-04-03 11:46:28 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Get the current destination for this lift
|
|
|
|
* @param t the tile
|
|
|
|
* @return destination
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline byte GetLiftDestination(TileIndex t)
|
2006-04-03 11:46:28 +00:00
|
|
|
{
|
2007-03-19 11:27:30 +00:00
|
|
|
return GB(_me[t].m7, 1, 3);
|
2006-04-03 11:46:28 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Stop the lift of this animated house from moving.
|
|
|
|
* Clears the first 4 bits of m7 at once, clearing the LiftHasDestination bit
|
|
|
|
* and the destination.
|
|
|
|
* @param t the tile
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void HaltLift(TileIndex t)
|
2006-04-03 11:46:28 +00:00
|
|
|
{
|
2007-03-19 11:27:30 +00:00
|
|
|
SB(_me[t].m7, 0, 4, 0);
|
2006-04-03 11:46:28 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Get the position of the lift on this animated house
|
|
|
|
* @param t the tile
|
|
|
|
* @return position, from 0 to 36
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline byte GetLiftPosition(TileIndex t)
|
2006-04-03 11:46:28 +00:00
|
|
|
{
|
2014-09-21 11:23:33 +00:00
|
|
|
return GB(_me[t].m6, 2, 6);
|
2006-04-03 11:46:28 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Set the position of the lift on this animated house
|
|
|
|
* @param t the tile
|
2007-04-04 03:21:14 +00:00
|
|
|
* @param pos position, from 0 to 36
|
2007-03-19 11:27:30 +00:00
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void SetLiftPosition(TileIndex t, byte pos)
|
2006-04-03 11:46:28 +00:00
|
|
|
{
|
2014-09-21 11:23:33 +00:00
|
|
|
SB(_me[t].m6, 2, 6, pos);
|
2007-03-19 11:27:30 +00:00
|
|
|
}
|
2006-04-03 11:46:28 +00:00
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Get the completion of this house
|
|
|
|
* @param t the tile
|
|
|
|
* @return true if it is, false if it is not
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline bool IsHouseCompleted(TileIndex t)
|
2006-04-03 11:46:28 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-11-19 21:02:30 +00:00
|
|
|
return HasBit(_m[t].m3, 7);
|
2006-04-03 11:46:28 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Mark this house as been completed
|
|
|
|
* @param t the tile
|
|
|
|
* @param status
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void SetHouseCompleted(TileIndex t, bool status)
|
2007-03-19 11:27:30 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-03-19 11:27:30 +00:00
|
|
|
SB(_m[t].m3, 7, 1, !!status);
|
|
|
|
}
|
|
|
|
|
2006-04-03 14:56:07 +00:00
|
|
|
/**
|
|
|
|
* House Construction Scheme.
|
|
|
|
* Construction counter, for buildings under construction. Incremented on every
|
|
|
|
* periodic tile processing.
|
|
|
|
* On wraparound, the stage of building in is increased.
|
2007-03-19 11:27:30 +00:00
|
|
|
* GetHouseBuildingStage is taking care of the real stages,
|
2006-04-03 14:56:07 +00:00
|
|
|
* (as the sprite for the next phase of house building)
|
2007-03-19 11:27:30 +00:00
|
|
|
* (Get|Inc)HouseConstructionTick is simply a tick counter between the
|
2006-04-03 14:56:07 +00:00
|
|
|
* different stages
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the building stage of a house
|
2007-03-19 11:27:30 +00:00
|
|
|
* Since the stage is used for determining what sprite to use,
|
2013-01-08 22:46:42 +00:00
|
|
|
* if the house is complete (and that stage no longer is available),
|
2007-03-19 11:27:30 +00:00
|
|
|
* fool the system by returning the TOWN_HOUSE_COMPLETE (3),
|
|
|
|
* thus showing a beautiful complete house.
|
|
|
|
* @param t the tile of the house to get the building stage of
|
2006-04-03 14:56:07 +00:00
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
* @return the building stage of the house
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline byte GetHouseBuildingStage(TileIndex t)
|
2006-04-03 14:56:07 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-03-19 11:27:30 +00:00
|
|
|
return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(_m[t].m5, 3, 2);
|
2006-04-03 14:56:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-03-19 11:27:30 +00:00
|
|
|
* Gets the construction stage of a house
|
|
|
|
* @param t the tile of the house to get the construction stage of
|
2006-04-03 14:56:07 +00:00
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
2007-03-19 11:27:30 +00:00
|
|
|
* @return the construction stage of the house
|
2006-04-03 14:56:07 +00:00
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline byte GetHouseConstructionTick(TileIndex t)
|
2006-04-03 14:56:07 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-03-19 11:27:30 +00:00
|
|
|
return IsHouseCompleted(t) ? 0 : GB(_m[t].m5, 0, 3);
|
2006-04-03 14:56:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-03-19 11:27:30 +00:00
|
|
|
* Sets the increment stage of a house
|
|
|
|
* It is working with the whole counter + stage 5 bits, making it
|
|
|
|
* easier to work: the wraparound is automatic.
|
|
|
|
* @param t the tile of the house to increment the construction stage of
|
2006-04-03 14:56:07 +00:00
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void IncHouseConstructionTick(TileIndex t)
|
2006-04-03 14:56:07 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-03-19 11:27:30 +00:00
|
|
|
AB(_m[t].m5, 0, 5, 1);
|
|
|
|
|
|
|
|
if (GB(_m[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);
|
|
|
|
}
|
2006-04-03 14:56:07 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 08:43:31 +00:00
|
|
|
/**
|
2008-11-23 14:17:41 +00:00
|
|
|
* Sets the age of the house to zero.
|
|
|
|
* Needs to be called after the house is completed. During construction stages the map space is used otherwise.
|
2008-04-20 08:43:31 +00:00
|
|
|
* @param t the tile of this house
|
|
|
|
* @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void ResetHouseAge(TileIndex t)
|
2008-04-20 08:43:31 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t), t);
|
2008-11-23 14:17:41 +00:00
|
|
|
_m[t].m5 = 0;
|
2008-04-20 08:43:31 +00:00
|
|
|
}
|
|
|
|
|
2006-04-03 14:56:07 +00:00
|
|
|
/**
|
2008-11-23 14:17:41 +00:00
|
|
|
* Increments the age of the house.
|
|
|
|
* @param t the tile of this house
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void IncrementHouseAge(TileIndex t)
|
2008-11-23 14:17:41 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2008-11-23 14:17:41 +00:00
|
|
|
if (IsHouseCompleted(t) && _m[t].m5 < 0xFF) _m[t].m5++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the age of the house
|
2007-03-19 11:27:30 +00:00
|
|
|
* @param t the tile of this house
|
2006-04-03 14:56:07 +00:00
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
2007-03-19 11:27:30 +00:00
|
|
|
* @return year
|
2006-04-03 14:56:07 +00:00
|
|
|
*/
|
2024-02-13 21:34:09 +00:00
|
|
|
inline CalTime::Year GetHouseAge(TileIndex t)
|
2006-04-03 14:56:07 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2008-11-23 14:17:41 +00:00
|
|
|
return IsHouseCompleted(t) ? _m[t].m5 : 0;
|
2006-04-03 14:56:07 +00:00
|
|
|
}
|
|
|
|
|
2007-11-11 17:58:05 +00:00
|
|
|
/**
|
|
|
|
* Set the random bits for this house.
|
|
|
|
* This is required for newgrf house
|
|
|
|
* @param t the tile of this house
|
|
|
|
* @param random the new random bits
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void SetHouseRandomBits(TileIndex t, byte random)
|
2007-11-11 17:58:05 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-11-11 17:58:05 +00:00
|
|
|
_m[t].m1 = random;
|
|
|
|
}
|
|
|
|
|
2006-04-03 14:56:07 +00:00
|
|
|
/**
|
2007-03-19 11:27:30 +00:00
|
|
|
* Get the random bits for this house.
|
|
|
|
* This is required for newgrf house
|
|
|
|
* @param t the tile of this house
|
2006-04-03 14:56:07 +00:00
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
2007-03-19 11:27:30 +00:00
|
|
|
* @return random bits
|
2006-04-03 14:56:07 +00:00
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline byte GetHouseRandomBits(TileIndex t)
|
2006-04-03 14:56:07 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-03-19 11:27:30 +00:00
|
|
|
return _m[t].m1;
|
2006-04-03 14:56:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-03-19 11:27:30 +00:00
|
|
|
* Set the activated triggers bits for this house.
|
|
|
|
* This is required for newgrf house
|
2007-04-03 21:51:40 +00:00
|
|
|
* @param t the tile of this house
|
|
|
|
* @param triggers the activated triggers
|
2006-04-03 14:56:07 +00:00
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void SetHouseTriggers(TileIndex t, byte triggers)
|
2007-03-19 11:27:30 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-03-19 11:27:30 +00:00
|
|
|
SB(_m[t].m3, 0, 5, triggers);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the already activated triggers bits for this house.
|
|
|
|
* This is required for newgrf house
|
|
|
|
* @param t the tile of this house
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
* @return triggers
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline byte GetHouseTriggers(TileIndex t)
|
2007-03-19 11:27:30 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2007-03-19 11:27:30 +00:00
|
|
|
return GB(_m[t].m3, 0, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the amount of time remaining before the tile loop processes this tile.
|
|
|
|
* @param t the house tile
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
* @return time remaining
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline byte GetHouseProcessingTime(TileIndex t)
|
2006-04-03 14:56:07 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2014-09-21 11:23:33 +00:00
|
|
|
return GB(_me[t].m6, 2, 6);
|
2006-04-03 14:56:07 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
/**
|
|
|
|
* Set the amount of time remaining before the tile loop processes this tile.
|
|
|
|
* @param t the house tile
|
|
|
|
* @param time the time to be set
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void SetHouseProcessingTime(TileIndex t, byte time)
|
2007-03-19 11:27:30 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2014-09-21 11:23:33 +00:00
|
|
|
SB(_me[t].m6, 2, 6, time);
|
2007-03-19 11:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decrease the amount of time remaining before the tile loop processes this tile.
|
|
|
|
* @param t the house tile
|
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void DecHouseProcessingTime(TileIndex t)
|
2007-03-19 11:27:30 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_HOUSE), t);
|
2014-09-21 11:23:33 +00:00
|
|
|
_me[t].m6 -= 1 << 2;
|
2010-08-26 14:36:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make the tile a house.
|
|
|
|
* @param t tile index
|
|
|
|
* @param tid Town index
|
|
|
|
* @param counter of construction step
|
|
|
|
* @param stage of construction (used for drawing)
|
|
|
|
* @param type of house. Index into house specs array
|
|
|
|
* @param random_bits required for newgrf houses
|
|
|
|
* @pre IsTileType(t, MP_CLEAR)
|
|
|
|
*/
|
2024-01-07 15:00:16 +00:00
|
|
|
inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
|
2010-08-26 14:36:00 +00:00
|
|
|
{
|
2022-10-22 11:34:54 +00:00
|
|
|
dbg_assert_tile(IsTileType(t, MP_CLEAR), t);
|
2010-08-26 14:36:00 +00:00
|
|
|
|
|
|
|
SetTileType(t, MP_HOUSE);
|
|
|
|
_m[t].m1 = random_bits;
|
|
|
|
_m[t].m2 = tid;
|
|
|
|
_m[t].m3 = 0;
|
|
|
|
SetHouseType(t, type);
|
|
|
|
SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
|
|
|
|
_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
|
2010-08-26 14:45:45 +00:00
|
|
|
SetAnimationFrame(t, 0);
|
2010-08-26 14:36:00 +00:00
|
|
|
SetHouseProcessingTime(t, HouseSpec::Get(type)->processing_time);
|
2007-03-19 11:27:30 +00:00
|
|
|
}
|
2006-04-03 14:56:07 +00:00
|
|
|
|
|
|
|
#endif /* TOWN_MAP_H */
|