|
@@ -20,48 +20,49 @@
|
|
|
#include "command.h"
|
|
|
#include "gfx.h"
|
|
|
#include "industry.h"
|
|
|
#include "station.h"
|
|
|
#include "vehicle.h"
|
|
|
#include "player.h"
|
|
|
#include "news.h"
|
|
|
#include "saveload.h"
|
|
|
#include "economy.h"
|
|
|
#include "gui.h"
|
|
|
#include "unmovable_map.h"
|
|
|
#include "water_map.h"
|
|
|
#include "variables.h"
|
|
|
#include "bridge.h"
|
|
|
#include "bridge_map.h"
|
|
|
#include "date.h"
|
|
|
#include "table/town_land.h"
|
|
|
#include "genworld.h"
|
|
|
#include "newgrf.h"
|
|
|
#include "newgrf_callbacks.h"
|
|
|
#include "newgrf_house.h"
|
|
|
#include "newgrf_commons.h"
|
|
|
#include "newgrf_townname.h"
|
|
|
#include "misc/autoptr.hpp"
|
|
|
#include "autoslope.h"
|
|
|
|
|
|
/* Initialize the town-pool */
|
|
|
DEFINE_OLD_POOL_GENERIC(Town, Town)
|
|
|
|
|
|
Town::Town(TileIndex tile)
|
|
|
{
|
|
|
if (tile != 0) _total_towns++;
|
|
|
this->xy = tile;
|
|
|
}
|
|
|
|
|
|
Town::~Town()
|
|
|
{
|
|
|
DeleteName(this->townnametype);
|
|
|
|
|
|
if (CleaningPool()) return;
|
|
|
|
|
|
Industry *i;
|
|
|
|
|
|
/* Delete town authority window
|
|
|
* and remove from list of sorted towns */
|
|
|
DeleteWindowById(WC_TOWN_VIEW, this->index);
|
|
|
_town_sort_dirty = true;
|
|
|
_total_towns--;
|
|
|
|
|
@@ -2288,48 +2289,57 @@ void TownsMonthlyLoop()
|
|
|
UpdateTownUnwanted(t);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void InitializeTowns()
|
|
|
{
|
|
|
Subsidy *s;
|
|
|
|
|
|
/* Clean the town pool and create 1 block in it */
|
|
|
_Town_pool.CleanPool();
|
|
|
_Town_pool.AddBlockToPool();
|
|
|
|
|
|
memset(_subsidies, 0, sizeof(_subsidies));
|
|
|
for (s=_subsidies; s != endof(_subsidies); s++)
|
|
|
s->cargo_type = CT_INVALID;
|
|
|
|
|
|
_cur_town_ctr = 0;
|
|
|
_cur_town_iter = 0;
|
|
|
_total_towns = 0;
|
|
|
_town_sort_dirty = true;
|
|
|
}
|
|
|
|
|
|
static CommandCost TerraformTile_Town(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
|
|
|
{
|
|
|
if (AutoslopeEnabled()) {
|
|
|
HouseID house = GetHouseType(tile);
|
|
|
HouseSpec *hs = GetHouseSpecs(house);
|
|
|
|
|
|
/* Here we differ from TTDP by checking TILE_NOT_SLOPED */
|
|
|
if (((hs->building_flags & TILE_NOT_SLOPED) == 0) && !IsSteepSlope(tileh_new) &&
|
|
|
(GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) return _price.terraform;
|
|
|
}
|
|
|
|
|
|
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
}
|
|
|
|
|
|
extern const TileTypeProcs _tile_type_town_procs = {
|
|
|
DrawTile_Town, /* draw_tile_proc */
|
|
|
GetSlopeZ_Town, /* get_slope_z_proc */
|
|
|
ClearTile_Town, /* clear_tile_proc */
|
|
|
GetAcceptedCargo_Town, /* get_accepted_cargo_proc */
|
|
|
GetTileDesc_Town, /* get_tile_desc_proc */
|
|
|
GetTileTrackStatus_Town, /* get_tile_track_status_proc */
|
|
|
ClickTile_Town, /* click_tile_proc */
|
|
|
AnimateTile_Town, /* animate_tile_proc */
|
|
|
TileLoop_Town, /* tile_loop_clear */
|
|
|
ChangeTileOwner_Town, /* change_tile_owner_clear */
|
|
|
NULL, /* get_produced_cargo_proc */
|
|
|
NULL, /* vehicle_enter_tile_proc */
|
|
|
GetFoundation_Town, /* get_foundation_proc */
|
|
|
TerraformTile_Town, /* terraform_tile_proc */
|
|
|
};
|
|
|
|
|
|
|
|
|
/** Save and load of towns. */
|
|
|
static const SaveLoad _town_desc[] = {
|
|
|
SLE_CONDVAR(Town, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
|