OpenTTD
|
Handling of object tiles. More...
#include "stdafx.h"
#include "landscape.h"
#include "command_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 "date_func.h"
#include "newgrf_debug.h"
#include "vehicle_func.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. More... | |
#define | IncreaseCompanyHQSize IncreaseAnimationStage |
We encode the company HQ size in the animation stage. More... | |
Functions | |
ObjectType | GetObjectType (TileIndex t) |
Gets the ObjectType of the given object tile. More... | |
void | InitializeObjects () |
Initialize/reset the objects. More... | |
void | BuildObject (ObjectType type, TileIndex tile, CompanyID owner, Town *town, uint8 view) |
Actually build the object. More... | |
static void | IncreaseAnimationStage (TileIndex tile) |
Increase the animation stage of a whole structure. More... | |
void | UpdateCompanyHQ (TileIndex tile, uint score) |
Update the CompanyHQ to the state associated with the given score. More... | |
void | UpdateObjectColours (const Company *c) |
Updates the colour of the object whenever a company changes. More... | |
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. More... | |
static CommandCost | ClearTile_Object (TileIndex tile, DoCommandFlag flags) |
CommandCost | CmdBuildObject (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Build an object object. More... | |
static Foundation | GetFoundation_Object (TileIndex tile, Slope tileh) |
static void | DrawTile_Object (TileInfo *ti) |
static int | GetSlopePixelZ_Object (TileIndex tile, uint x, uint y) |
static void | ReallyClearObjectTile (Object *o) |
Perform the actual removal of the object from the map. More... | |
ClearedObjectArea * | FindClearedObject (TileIndex tile) |
Find the entry in _cleared_object_areas which occupies a certain tile. More... | |
static void | AddAcceptedCargo_Object (TileIndex tile, CargoArray &acceptance, uint32 *always_accepted) |
static void | GetTileDesc_Object (TileIndex tile, TileDesc *td) |
static void | TileLoop_Object (TileIndex tile) |
static TrackStatus | GetTileTrackStatus_Object (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
static bool | ClickTile_Object (TileIndex tile) |
static void | AnimateTile_Object (TileIndex tile) |
static bool | HasTransmitter (TileIndex tile, void *user) |
Helper function for CircularTileSearch . More... | |
static bool | TryBuildLightHouse () |
Try to build a lighthouse. More... | |
static bool | TryBuildTransmitter () |
Try to build a transmitter. More... | |
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") |
SmallVector< ClearedObjectArea, 4 > | _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 148 of file object_cmd.cpp.
Referenced by UpdateCompanyHQ().
#define IncreaseCompanyHQSize IncreaseAnimationStage |
We encode the company HQ size in the animation stage.
Definition at line 150 of file object_cmd.cpp.
Referenced by UpdateCompanyHQ().
void BuildObject | ( | ObjectType | type, |
TileIndex | tile, | ||
CompanyID | owner, | ||
Town * | town, | ||
uint8 | 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 85 of file object_cmd.cpp.
References _date, Object::build_date, CalcClosestTownFromTile(), Object::colour, GB(), ObjectSpec::Get(), HasBit(), Object::location, Object::Object(), OWNER_NONE, ObjectSpec::size, Object::town, Object::type, and Object::view.
Referenced by TryBuildTransmitter().
CommandCost CheckBuildableTile | ( | TileIndex | tile, |
uint | invalid_dirs, | ||
int & | allowed_z, | ||
bool | allow_steep, | ||
bool | check_bridge = true |
||
) |
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 729 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(), GetTileSlope(), HasBit(), IsBridgeAbove(), IsSteepSlope(), return_cmd_error, and SLOPE_FLAT.
Referenced by CheckFlatLand(), CheckFlatLandRailStation(), and CheckFlatLandRoadStop().
CommandCost CmdBuildObject | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Build an object object.
tile | tile where the object will be located |
flags | type of operation |
p1 | the object type to build |
p2 | the view for the object |
text | unused |
Definition at line 206 of file object_cmd.cpp.
References CMD_ERROR, EXPENSES_PROPERTY, GB(), ObjectSpec::Get(), NUM_OBJECTS, Object::type, and Object::view.
ClearedObjectArea* FindClearedObject | ( | TileIndex | tile | ) |
Find the entry in _cleared_object_areas which occupies a certain tile.
tile | Tile of interest |
Definition at line 453 of file object_cmd.cpp.
References SmallVector< T, S >::Begin(), and SmallVector< T, S >::End().
ObjectType GetObjectType | ( | TileIndex | t | ) |
Gets the ObjectType of the given object tile.
t | the tile to get the type from. |
Definition at line 63 of file object_cmd.cpp.
Referenced by ObjectSpec::GetByTile(), IsObjectType(), and IsObjectTypeTile().
|
static |
Helper function for CircularTileSearch
.
tile | The tile to check. |
user | Ignored. |
Definition at line 644 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 138 of file object_cmd.cpp.
References GetAnimationFrame(), Object::GetByTile(), Object::location, MarkTileDirtyByTile(), SetAnimationFrame(), and TILE_AREA_LOOP.
void InitializeObjects | ( | ) |
Initialize/reset the objects.
Definition at line 70 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 435 of file object_cmd.cpp.
References Object::DecTypeCount(), DeleteNewGRFInspectWindow(), Object::location, TILE_AREA_LOOP, and Object::type.
|
static |
Try to build a lighthouse.
Definition at line 653 of file object_cmd.cpp.
|
static |
Try to build a transmitter.
Definition at line 695 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 157 of file object_cmd.cpp.
References GetCompanyHQSize, IncreaseCompanyHQSize, and INVALID_TILE.
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 177 of file object_cmd.cpp.
const TileTypeProcs _tile_type_object_procs |