(svn r16666) -Codechange: replace GetHouseSpecs() by HouseSpec::Get(), hide _house_specs[]
This commit is contained in:
@@ -48,8 +48,6 @@
|
||||
#include "table/strings.h"
|
||||
#include "table/town_land.h"
|
||||
|
||||
HouseSpec _house_specs[HOUSE_MAX];
|
||||
|
||||
Town *_cleared_town;
|
||||
int _cleared_town_rating;
|
||||
|
||||
@@ -171,11 +169,11 @@ static void DrawTile_Town(TileInfo *ti)
|
||||
/* Houses don't necessarily need new graphics. If they don't have a
|
||||
* spritegroup associated with them, then the sprite for the substitute
|
||||
* house id is drawn instead. */
|
||||
if (GetHouseSpecs(house_id)->spritegroup != NULL) {
|
||||
if (HouseSpec::Get(house_id)->spritegroup != NULL) {
|
||||
DrawNewHouseTile(ti, house_id);
|
||||
return;
|
||||
} else {
|
||||
house_id = GetHouseSpecs(house_id)->substitute_id;
|
||||
house_id = HouseSpec::Get(house_id)->substitute_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +240,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 (!(GetHouseSpecs(GetHouseType(tile))->building_flags & BUILDING_IS_ANIMATED)) {
|
||||
if (!(HouseSpec::Get(GetHouseType(tile))->building_flags & BUILDING_IS_ANIMATED)) {
|
||||
DeleteAnimatedTile(tile);
|
||||
return;
|
||||
}
|
||||
@@ -376,7 +374,7 @@ static void MakeSingleHouseBigger(TileIndex tile)
|
||||
IncHouseConstructionTick(tile);
|
||||
if (GetHouseConstructionTick(tile) != 0) return;
|
||||
|
||||
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
|
||||
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
|
||||
|
||||
/* Check and/or */
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_CONSTRUCTION_STATE_CHANGE)) {
|
||||
@@ -398,7 +396,7 @@ static void MakeSingleHouseBigger(TileIndex tile)
|
||||
*/
|
||||
static void MakeTownHouseBigger(TileIndex tile)
|
||||
{
|
||||
uint flags = GetHouseSpecs(GetHouseType(tile))->building_flags;
|
||||
uint flags = HouseSpec::Get(GetHouseType(tile))->building_flags;
|
||||
if (flags & BUILDING_HAS_1_TILE) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 0));
|
||||
if (flags & BUILDING_2_TILES_Y) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 1));
|
||||
if (flags & BUILDING_2_TILES_X) MakeSingleHouseBigger(TILE_ADDXY(tile, 1, 0));
|
||||
@@ -425,7 +423,7 @@ static void TileLoop_Town(TileIndex tile)
|
||||
return;
|
||||
}
|
||||
|
||||
const HouseSpec *hs = GetHouseSpecs(house_id);
|
||||
const HouseSpec *hs = HouseSpec::Get(house_id);
|
||||
|
||||
/* If the lift has a destination, it is already an animated tile. */
|
||||
if ((hs->building_flags & BUILDING_IS_ANIMATED) &&
|
||||
@@ -509,7 +507,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
||||
if (flags & DC_AUTO) return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
if (!CanDeleteHouse(tile)) return CMD_ERROR;
|
||||
|
||||
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
|
||||
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
|
||||
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
cost.AddCost(hs->GetRemovalCost());
|
||||
@@ -536,7 +534,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
||||
static void GetProducedCargo_Town(TileIndex tile, CargoID *b)
|
||||
{
|
||||
HouseID house_id = GetHouseType(tile);
|
||||
const HouseSpec *hs = GetHouseSpecs(house_id);
|
||||
const HouseSpec *hs = HouseSpec::Get(house_id);
|
||||
Town *t = Town::GetByTile(tile);
|
||||
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
|
||||
@@ -562,7 +560,7 @@ static void GetProducedCargo_Town(TileIndex tile, CargoID *b)
|
||||
|
||||
static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
|
||||
{
|
||||
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
|
||||
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
|
||||
CargoID accepts[3];
|
||||
|
||||
/* Set the initial accepted cargo types */
|
||||
@@ -606,7 +604,7 @@ static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
|
||||
static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
|
||||
{
|
||||
const HouseID house = GetHouseType(tile);
|
||||
const HouseSpec *hs = GetHouseSpecs(house);
|
||||
const HouseSpec *hs = HouseSpec::Get(house);
|
||||
bool house_completed = IsHouseCompleted(tile);
|
||||
|
||||
td->str = hs->building_name;
|
||||
@@ -1803,7 +1801,7 @@ static inline void ClearMakeHouseTile(TileIndex tile, Town *t, byte counter, byt
|
||||
|
||||
IncreaseBuildingCount(t, type);
|
||||
MakeHouseTile(tile, t->index, counter, stage, type, random_bits);
|
||||
if (GetHouseSpecs(type)->building_flags & BUILDING_IS_ANIMATED) AddAnimatedTile(tile);
|
||||
if (HouseSpec::Get(type)->building_flags & BUILDING_IS_ANIMATED) AddAnimatedTile(tile);
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
@@ -1821,7 +1819,7 @@ static inline void ClearMakeHouseTile(TileIndex tile, Town *t, byte counter, byt
|
||||
*/
|
||||
static void MakeTownHouse(TileIndex t, Town *town, byte counter, byte stage, HouseID type, byte random_bits)
|
||||
{
|
||||
BuildingFlags size = GetHouseSpecs(type)->building_flags;
|
||||
BuildingFlags size = HouseSpec::Get(type)->building_flags;
|
||||
|
||||
ClearMakeHouseTile(t, town, counter, stage, type, random_bits);
|
||||
if (size & BUILDING_2_TILES_Y) ClearMakeHouseTile(t + TileDiffXY(0, 1), town, counter, stage, ++type, random_bits);
|
||||
@@ -2051,7 +2049,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
||||
|
||||
/* Generate a list of all possible houses that can be built. */
|
||||
for (uint i = 0; i < HOUSE_MAX; i++) {
|
||||
const HouseSpec *hs = GetHouseSpecs(i);
|
||||
const HouseSpec *hs = HouseSpec::Get(i);
|
||||
|
||||
/* Verify that the candidate house spec matches the current tile status */
|
||||
if ((~hs->building_availability & bitmask) != 0 || !hs->enabled) continue;
|
||||
@@ -2090,12 +2088,12 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
||||
houses[i] = houses[num];
|
||||
probs[i] = probs[num];
|
||||
|
||||
const HouseSpec *hs = GetHouseSpecs(house);
|
||||
const HouseSpec *hs = HouseSpec::Get(house);
|
||||
|
||||
if (_loaded_newgrf_features.has_newhouses) {
|
||||
if (hs->override != 0) {
|
||||
house = hs->override;
|
||||
hs = GetHouseSpecs(house);
|
||||
hs = HouseSpec::Get(house);
|
||||
}
|
||||
|
||||
if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world && _game_mode != GM_EDITOR) continue;
|
||||
@@ -2187,16 +2185,16 @@ static void DoClearTownHouseHelper(TileIndex tile, Town *t, HouseID house)
|
||||
TileIndexDiff GetHouseNorthPart(HouseID &house)
|
||||
{
|
||||
if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
|
||||
if (GetHouseSpecs(house - 1)->building_flags & TILE_SIZE_2x1) {
|
||||
if (HouseSpec::Get(house - 1)->building_flags & TILE_SIZE_2x1) {
|
||||
house--;
|
||||
return TileDiffXY(-1, 0);
|
||||
} else if (GetHouseSpecs(house - 1)->building_flags & BUILDING_2_TILES_Y) {
|
||||
} else if (HouseSpec::Get(house - 1)->building_flags & BUILDING_2_TILES_Y) {
|
||||
house--;
|
||||
return TileDiffXY(0, -1);
|
||||
} else if (GetHouseSpecs(house - 2)->building_flags & BUILDING_HAS_4_TILES) {
|
||||
} else if (HouseSpec::Get(house - 2)->building_flags & BUILDING_HAS_4_TILES) {
|
||||
house -= 2;
|
||||
return TileDiffXY(-1, 0);
|
||||
} else if (GetHouseSpecs(house - 3)->building_flags & BUILDING_HAS_4_TILES) {
|
||||
} else if (HouseSpec::Get(house - 3)->building_flags & BUILDING_HAS_4_TILES) {
|
||||
house -= 3;
|
||||
return TileDiffXY(-1, -1);
|
||||
}
|
||||
@@ -2213,7 +2211,7 @@ void ClearTownHouse(Town *t, TileIndex tile)
|
||||
/* need to align the tile to point to the upper left corner of the house */
|
||||
tile += GetHouseNorthPart(house); // modifies house to the ID of the north tile
|
||||
|
||||
const HouseSpec *hs = GetHouseSpecs(house);
|
||||
const HouseSpec *hs = HouseSpec::Get(house);
|
||||
|
||||
/* Remove population from the town if the house is finished. */
|
||||
if (IsHouseCompleted(tile)) {
|
||||
@@ -2859,7 +2857,7 @@ static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlag flags, uint
|
||||
if (AutoslopeEnabled()) {
|
||||
HouseID house = GetHouseType(tile);
|
||||
GetHouseNorthPart(house); // modifies house to the ID of the north tile
|
||||
const HouseSpec *hs = GetHouseSpecs(house);
|
||||
const HouseSpec *hs = HouseSpec::Get(house);
|
||||
|
||||
/* Here we differ from TTDP by checking TILE_NOT_SLOPED */
|
||||
if (((hs->building_flags & TILE_NOT_SLOPED) == 0) && !IsSteepSlope(tileh_new) &&
|
||||
@@ -2887,6 +2885,9 @@ extern const TileTypeProcs _tile_type_town_procs = {
|
||||
TerraformTile_Town, // terraform_tile_proc
|
||||
};
|
||||
|
||||
|
||||
HouseSpec _house_specs[HOUSE_MAX];
|
||||
|
||||
void ResetHouses()
|
||||
{
|
||||
memset(&_house_specs, 0, sizeof(_house_specs));
|
||||
|
Reference in New Issue
Block a user