OpenTTD Source 20250205-master-gfd85ab1e2c
|
Handling of object tiles. More...
#include "stdafx.h"
#include "landscape.h"
#include "command_func.h"
#include "company_func.h"
#include "viewport_func.h"
#include "company_base.h"
#include "town.h"
#include "bridge_map.h"
#include "genworld.h"
#include "autoslope.h"
#include "clear_func.h"
#include "water.h"
#include "window_func.h"
#include "company_gui.h"
#include "cheat_type.h"
#include "object.h"
#include "cargopacket.h"
#include "core/random_func.hpp"
#include "core/pool_func.hpp"
#include "object_map.h"
#include "object_base.h"
#include "newgrf_config.h"
#include "newgrf_object.h"
#include "timer/timer_game_calendar.h"
#include "newgrf_debug.h"
#include "vehicle_func.h"
#include "station_func.h"
#include "object_cmd.h"
#include "landscape_cmd.h"
#include "pathfinder/water_regions.h"
#include "table/strings.h"
#include "table/object_land.h"
#include "safeguards.h"
Go to the source code of this file.
Macros | |
#define | GetCompanyHQSize GetAnimationFrame |
We encode the company HQ size in the animation stage. | |
#define | IncreaseCompanyHQSize IncreaseAnimationStage |
We encode the company HQ size in the animation stage. | |
Functions | |
ObjectType | GetObjectType (Tile t) |
Gets the ObjectType of the given object tile. | |
void | InitializeObjects () |
Initialize/reset the objects. | |
void | BuildObject (ObjectType type, TileIndex tile, CompanyID owner, Town *town, uint8_t view) |
Actually build the object. | |
static void | IncreaseAnimationStage (TileIndex tile) |
Increase the animation stage of a whole structure. | |
void | UpdateCompanyHQ (TileIndex tile, uint score) |
Update the CompanyHQ to the state associated with the given score. | |
void | UpdateObjectColours (const Company *c) |
Updates the colour of the object whenever a company changes. | |
CommandCost | CheckBuildableTile (TileIndex tile, uint invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge) |
Checks if the given tile is buildable, flat and has a certain height. | |
static CommandCost | ClearTile_Object (TileIndex tile, DoCommandFlag flags) |
CommandCost | CmdBuildObject (DoCommandFlag flags, TileIndex tile, ObjectType type, uint8_t view) |
Build an object object. | |
CommandCost | CmdBuildObjectArea (DoCommandFlag flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8_t view, bool diagonal) |
Construct multiple objects in an area. | |
static Foundation | GetFoundation_Object (TileIndex tile, Slope tileh) |
static void | DrawTile_Object (TileInfo *ti) |
static int | GetSlopePixelZ_Object (TileIndex tile, uint x, uint y, bool) |
static void | ReallyClearObjectTile (Object *o) |
Perform the actual removal of the object from the map. | |
ClearedObjectArea * | FindClearedObject (TileIndex tile) |
Find the entry in _cleared_object_areas which occupies a certain tile. | |
static void | AddAcceptedCargo_Object (TileIndex tile, CargoArray &acceptance, CargoTypes &always_accepted) |
static void | AddProducedCargo_Object (TileIndex tile, CargoArray &produced) |
static void | GetTileDesc_Object (TileIndex tile, TileDesc *td) |
static void | TileLoop_Object (TileIndex tile) |
static TrackStatus | GetTileTrackStatus_Object (TileIndex, TransportType, uint, DiagDirection) |
static bool | ClickTile_Object (TileIndex tile) |
static void | AnimateTile_Object (TileIndex tile) |
static bool | HasTransmitter (TileIndex tile, void *) |
Helper function for CircularTileSearch . | |
static bool | TryBuildLightHouse () |
Try to build a lighthouse. | |
static bool | TryBuildTransmitter () |
Try to build a transmitter. | |
void | GenerateObjects () |
static void | ChangeTileOwner_Object (TileIndex tile, Owner old_owner, Owner new_owner) |
static CommandCost | TerraformTile_Object (TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new) |
Variables | |
ObjectPool | _object_pool ("Object") |
std::vector< ClearedObjectArea > | _cleared_object_areas |
const TileTypeProcs | _tile_type_object_procs |
Handling of object tiles.
Definition in file object_cmd.cpp.
#define GetCompanyHQSize GetAnimationFrame |
We encode the company HQ size in the animation stage.
Definition at line 155 of file object_cmd.cpp.
#define IncreaseCompanyHQSize IncreaseAnimationStage |
We encode the company HQ size in the animation stage.
Definition at line 157 of file object_cmd.cpp.
|
static |
Definition at line 621 of file object_cmd.cpp.
|
static |
Definition at line 650 of file object_cmd.cpp.
|
static |
Definition at line 741 of file object_cmd.cpp.
void BuildObject | ( | ObjectType | type, |
TileIndex | tile, | ||
CompanyID | owner, | ||
Town * | town, | ||
uint8_t | view | ||
) |
Actually build the object.
type | The type of object to build. |
tile | The tile to build the northern tile of the object on. |
owner | The owner of the object. |
town | Town the tile is related with. |
view | The view for the object. |
Definition at line 88 of file object_cmd.cpp.
References Animation, Object::build_date, CalcClosestTownFromTile(), CALLBACK_FAILED, ObjectSpec::callback_mask, CBID_OBJECT_COLOUR, ClearNeighbourNonFloodingStates(), Colour, Object::colour, Livery::colour1, Livery::colour2, TimerGameCalendar::date, DirtyCompanyInfrastructureWindows(), ErrorUnknownCallbackResult(), ObjectSpec::flags, GB(), ObjectSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetObjectCallback(), GetWaterClass(), ObjectSpec::grf_prop, GRFFilePropsBase< Tcnt >::grfid, HasBit(), HasTileWaterGround(), Object::IncTypeCount(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWaterRegion(), IsDockingTile(), IsTileOwner(), IsWaterTile(), Object::location, MakeObject(), MarkTileDirtyByTile(), OAT_BUILT, OWNER_NONE, OWNER_WATER, Random, ObjectSpec::size, EnumBitSet< Tenum, Tstorage >::Test(), Object::town, TriggerObjectAnimation(), Object::type, Uses2CC, Object::view, WATER_CLASS_CANAL, and WATER_CLASS_INVALID.
Referenced by CmdBuildObject(), TownActionBuildStatue(), TryBuildLightHouse(), and TryBuildTransmitter().
Definition at line 875 of file object_cmd.cpp.
|
extern |
Checks if the given tile is buildable, flat and has a certain height.
tile | TileIndex to check. |
invalid_dirs | Prohibited directions for slopes (set of DiagDirection). |
allowed_z | Height allowed for the tile. If allowed_z is negative, it will be set to the height of this tile. |
allow_steep | Whether steep slopes are allowed. |
check_bridge | Check for the existence of a bridge. |
Definition at line 803 of file station_cmd.cpp.
References _settings_game, CommandCost::AddCost(), ConstructionSettings::build_on_slopes, CanBuildDepotByTileh(), GameSettings::construction, DIAGDIR_BEGIN, DIAGDIR_END, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetSlopeMaxZ(), GetTileSlopeZ(), HasBit(), IsBridgeAbove(), IsSteepSlope(), and SLOPE_FLAT.
Referenced by CheckFlatLandAirport(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), and CmdBuildObject().
|
static |
Definition at line 542 of file object_cmd.cpp.
|
static |
Definition at line 733 of file object_cmd.cpp.
CommandCost CmdBuildObject | ( | DoCommandFlag | flags, |
TileIndex | tile, | ||
ObjectType | type, | ||
uint8_t | view | ||
) |
Build an object object.
flags | type of operation |
tile | tile where the object will be located |
type | the object type to build |
view | the view for the object |
Definition at line 210 of file object_cmd.cpp.
References _current_company, _generating_world, CommandCost::AddCost(), AllowUnderBridge, EnumBitSet< Tenum, Tstorage >::Any(), CompanyProperties::build_object_limit, BuildObject(), BuiltOnWater, CALLBACK_FAILED, ObjectSpec::callback_mask, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::CanAllocateItem(), CBID_OBJECT_LAND_SLOPE_CHECK, CheckBuildableTile(), CheckOwnership(), CMD_ERROR, DC_EXEC, DC_NO_MODIFY_TOWN_RATING, DC_NO_WATER, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), ObjectSpec::flags, GB(), ObjectSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetBridgeHeight(), ObjectSpec::GetBuildCost(), GetErrorMessageFromLocationCallbackResult(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), GetObjectCallback(), GetSouthernBridgeEnd(), GetTileMaxZ(), GetTileOwner(), GetTileSlope(), GetTileSlopeZ(), ObjectSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), HasTileWaterGround(), ObjectSpec::height, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, ObjectSpec::IsAvailable(), IsBridgeAbove(), IsObjectType(), IsTileFlat(), IsTileOwner(), IsTileType(), IsValidTile(), IsWaterTile(), CompanyProperties::location_of_HQ, MAX_COMPANIES, MP_OBJECT, NotOnLand, OBJECT_HQ, OBJECT_LIGHTHOUSE, OBJECT_OWNED_LAND, OBJECT_STATUE, OBJECT_TRANSMITTER, OnlyInGame, OnlyInScenedit, OWNER_DEITY, OWNER_NONE, OWNER_WATER, SetWindowDirty(), ObjectSpec::size, SLOPE_FLAT, SlopeCheck, EnumBitSet< Tenum, Tstorage >::Test(), TileX(), TileY(), ToggleBit(), UpdateCompanyHQ(), UpdateCompanyRatingAndValue(), ObjectSpec::views, ObjectSpec::WasEverAvailable(), and WC_COMPANY.
CommandCost CmdBuildObjectArea | ( | DoCommandFlag | flags, |
TileIndex | tile, | ||
TileIndex | start_tile, | ||
ObjectType | type, | ||
uint8_t | view, | ||
bool | diagonal | ||
) |
Construct multiple objects in an area.
flags | of operation to conduct |
tile | end tile of area dragging |
start_tile | start tile of area dragging |
type | the object type to build |
view | the view for the object |
diagonal | Whether to use the Orthogonal (0) or Diagonal (1) iterator. |
Definition at line 391 of file object_cmd.cpp.
References _current_company, CommandCost::AddCost(), CompanyProperties::build_object_limit, CMD_ERROR, TileIterator::Create(), DC_EXEC, EXPENSES_CONSTRUCTION, CommandCost::Failed(), GB(), ObjectSpec::Get(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), INVALID_TILE, OBJECT_SIZE_1X1, Map::Size(), ObjectSpec::size, and ObjectSpec::views.
|
static |
Definition at line 438 of file object_cmd.cpp.
ClearedObjectArea * FindClearedObject | ( | TileIndex | tile | ) |
Find the entry in _cleared_object_areas which occupies a certain tile.
tile | Tile of interest |
Definition at line 531 of file object_cmd.cpp.
Referenced by CmdBuildTunnel(), CmdLandscapeClear(), and CmdTerraformLand().
void GenerateObjects | ( | ) |
Definition at line 816 of file object_cmd.cpp.
|
static |
Definition at line 504 of file object_cmd.cpp.
ObjectType GetObjectType | ( | Tile | t | ) |
Gets the ObjectType of the given object tile.
t | the tile to get the type from. |
Definition at line 66 of file object_cmd.cpp.
References Object::GetByTile(), IsTileType(), MP_OBJECT, and Object::type.
Referenced by ObjectSpec::GetByTile(), IsObjectType(), and IsObjectTypeTile().
|
static |
Definition at line 493 of file object_cmd.cpp.
Definition at line 661 of file object_cmd.cpp.
|
static |
Definition at line 728 of file object_cmd.cpp.
|
static |
Helper function for CircularTileSearch
.
tile | The tile to check. |
Definition at line 751 of file object_cmd.cpp.
References IsObjectTypeTile(), and OBJECT_TRANSMITTER.
Referenced by TryBuildTransmitter().
|
static |
Increase the animation stage of a whole structure.
tile | The tile of the structure. |
Definition at line 145 of file object_cmd.cpp.
References GetAnimationFrame(), Object::GetByTile(), Object::location, MarkTileDirtyByTile(), and SetAnimationFrame().
void InitializeObjects | ( | ) |
Initialize/reset the objects.
Definition at line 73 of file object_cmd.cpp.
References Object::ResetTypeCounts().
|
static |
Perform the actual removal of the object from the map.
o | The object to really clear. |
Definition at line 513 of file object_cmd.cpp.
References Object::DecTypeCount(), DeleteNewGRFInspectWindow(), GetTileOwner(), Object::location, and Object::type.
|
static |
Definition at line 911 of file object_cmd.cpp.
|
static |
Definition at line 673 of file object_cmd.cpp.
|
static |
Try to build a lighthouse.
Definition at line 760 of file object_cmd.cpp.
References AXIS_X, BuildObject(), DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DiagDirToAxis(), GB(), IsBridgeAbove(), IsTileFlat(), IsTileType(), IsValidTile(), Map::MaxX(), Map::MaxY(), MP_CLEAR, MP_WATER, OBJECT_LIGHTHOUSE, Random, Map::Size(), TileOffsByDiagDir(), and TileXY().
|
static |
Try to build a transmitter.
Definition at line 802 of file object_cmd.cpp.
References BuildObject(), CircularTileSearch(), HasTransmitter(), IsBridgeAbove(), IsTileFlat(), IsTileType(), MP_CLEAR, OBJECT_TRANSMITTER, and RandomTile.
void UpdateCompanyHQ | ( | TileIndex | tile, |
uint | score | ||
) |
Update the CompanyHQ to the state associated with the given score.
tile | The (northern) tile of the company HQ, or INVALID_TILE. |
score | The current (performance) score of the company. |
Definition at line 164 of file object_cmd.cpp.
References GetCompanyHQSize, IncreaseCompanyHQSize, and INVALID_TILE.
Referenced by CmdBuildObject(), and UpdateCompanyRatingAndValue().
void UpdateObjectColours | ( | const Company * | c | ) |
Updates the colour of the object whenever a company changes.
c | The company the company colour changed of. |
Definition at line 183 of file object_cmd.cpp.
References ObjectSpec::callback_mask, Colour, Livery::colour1, Livery::colour2, ObjectSpec::flags, ObjectSpec::GetByTile(), GetTileOwner(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Iterate(), EnumBitSet< Tenum, Tstorage >::Test(), and Uses2CC.
Referenced by CmdSetCompanyColour().
std::vector<ClearedObjectArea> _cleared_object_areas |
Definition at line 524 of file object_cmd.cpp.
|
extern |
Definition at line 58 of file landscape.cpp.