unmovable_cmd.cpp File Reference

Handling of unmovable tiles. More...

#include "stdafx.h"
#include "openttd.h"
#include "landscape.h"
#include "command_func.h"
#include "viewport_func.h"
#include "company_base.h"
#include "town.h"
#include "sprite.h"
#include "bridge_map.h"
#include "unmovable_map.h"
#include "genworld.h"
#include "autoslope.h"
#include "transparency.h"
#include "functions.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "company_gui.h"
#include "economy_func.h"
#include "cheat_type.h"
#include "landscape_type.h"
#include "unmovable.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "table/unmovable_land.h"

Go to the source code of this file.

Functions

static const UnmovableSpec * GetUnmovableSpec (UnmovableType type)
 Accessor for array _original_unmovable.
static CommandCost DestroyCompanyHQ (CompanyID cid, DoCommandFlag flags)
 Destroy a HQ.
void UpdateCompanyHQ (Company *c, uint score)
CommandCost CheckFlatLandBelow (TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear=true)
 Tries to clear the given area.
CommandCost CmdBuildCompanyHQ (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Build or relocate the HQ.
CommandCost CmdPurchaseLandArea (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Purchase a land area.
CommandCost CmdSellLandArea (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Sell a land area.
static Foundation GetFoundation_Unmovable (TileIndex tile, Slope tileh)
static void DrawTile_Unmovable (TileInfo *ti)
static uint GetSlopeZ_Unmovable (TileIndex tile, uint x, uint y)
static CommandCost ClearTile_Unmovable (TileIndex tile, DoCommandFlag flags)
static void GetAcceptedCargo_Unmovable (TileIndex tile, AcceptedCargo ac)
static void GetTileDesc_Unmovable (TileIndex tile, TileDesc *td)
static void AnimateTile_Unmovable (TileIndex tile)
static void TileLoop_Unmovable (TileIndex tile)
static TrackStatus GetTileTrackStatus_Unmovable (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
static bool ClickTile_Unmovable (TileIndex tile)
static bool IsRadioTowerNearby (TileIndex tile)
void GenerateUnmovables ()
static void ChangeTileOwner_Unmovable (TileIndex tile, Owner old_owner, Owner new_owner)
static CommandCost TerraformTile_Unmovable (TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)

Variables

const TileTypeProcs _tile_type_unmovable_procs


Detailed Description

Handling of unmovable tiles.

Definition in file unmovable_cmd.cpp.


Function Documentation

CommandCost CheckFlatLandBelow ( TileIndex  tile,
uint  w,
uint  h,
DoCommandFlag  flags,
uint  invalid_dirs,
StationID station,
bool  check_clear = true 
)

Tries to clear the given area.

Parameters:
tile TileIndex to start check
w width of search area
h height of search area
flags operation to perform
invalid_dirs prohibited directions (set of DiagDirections)
station StationID to be queried and returned if available
check_clear if clearing tile should be performed (in wich case, cost will be added)
Returns:
the cost in case of success, or an error code if it failed.

Definition at line 711 of file station_cmd.cpp.

References _settings_game, CommandCost::AddCost(), BEGIN_TILE_LOOP, ConstructionSettings::build_on_slopes, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), GameSettings::construction, DC_AUTO, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DoCommand(), END_TILE_LOOP, GetStationIndex(), GetTileSlope(), HasBit(), IsBridgeAbove(), IsSteepSlope(), IsTileType(), MayHaveBridgeAbove(), return_cmd_error, SLOPE_FLAT, SLOPE_NE, SLOPE_NW, SLOPE_SE, SLOPE_SW, and TILE_HEIGHT.

Referenced by CmdBuildAirport(), CmdBuildCompanyHQ(), CmdBuildRailroadStation(), and CmdBuildRoadStop().

CommandCost CmdBuildCompanyHQ ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

Build or relocate the HQ.

This depends if the HQ is already built or not

Parameters:
tile tile where the HQ will be built or relocated to
flags type of operation
p1 unused
p2 unused

Definition at line 100 of file unmovable_cmd.cpp.

References CommandCost::AddCost(), CheckFlatLandBelow(), CmdFailed(), DC_EXEC, DestroyCompanyHQ(), INVALID_TILE, InvalidateWindow(), MakeCompanyHQ(), and UpdateCompanyRatingAndValue().

CommandCost CmdPurchaseLandArea ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

Purchase a land area.

Actually you only purchase one tile, so the name is a bit confusing ;p

Parameters:
tile the tile the company is purchasing
flags for this command type
p1 unused
p2 unused
Returns:
error of cost of operation

Definition at line 134 of file unmovable_cmd.cpp.

References CommandCost::AddCost(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DoCommand(), GetUnmovableSpec(), IsOwnedLandTile(), IsTileOwner(), MakeOwnedLand(), MarkTileDirtyByTile(), return_cmd_error, and UNMOVABLE_OWNED_LAND.

CommandCost CmdSellLandArea ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

Sell a land area.

Actually you only sell one tile, so the name is a bit confusing ;p

Parameters:
tile the tile the company is selling
flags for this command type
p1 unused
p2 unused
Returns:
error or cost of operation

Definition at line 161 of file unmovable_cmd.cpp.

References CMD_ERROR, DC_EXEC, GetUnmovableSpec(), IsOwnedLandTile(), OWNER_WATER, and UNMOVABLE_OWNED_LAND.

static CommandCost DestroyCompanyHQ ( CompanyID  cid,
DoCommandFlag  flags 
) [static]

Destroy a HQ.

During normal gameplay you can only implicitely destroy a HQ when you are rebuilding it. Otherwise, only water can destroy it.

Parameters:
cid Company requesting the destruction of his HQ
flags docommand flags of calling function
Returns:
cost of the operation

Definition at line 52 of file unmovable_cmd.cpp.

References DC_EXEC, INVALID_TILE, InvalidateWindow(), and TileDiffXY().

Referenced by CmdBuildCompanyHQ().

static const UnmovableSpec* GetUnmovableSpec ( UnmovableType  type  )  [inline, static]

Accessor for array _original_unmovable.

This will ensure at once : proper access and not allowing modifications of it.

Parameters:
type of unmovable (which is the index in _original_unmovable)
Precondition:
type < UNMOVABLE_MAX
Returns:
a pointer to the corresponding unmovable spec

Definition at line 39 of file unmovable_cmd.cpp.

Referenced by CmdPurchaseLandArea(), and CmdSellLandArea().


Variable Documentation

const TileTypeProcs _tile_type_unmovable_procs

Initial value:

 {
  DrawTile_Unmovable,             
  GetSlopeZ_Unmovable,            
  ClearTile_Unmovable,            
  GetAcceptedCargo_Unmovable,     
  GetTileDesc_Unmovable,          
  GetTileTrackStatus_Unmovable,   
  ClickTile_Unmovable,            
  AnimateTile_Unmovable,          
  TileLoop_Unmovable,             
  ChangeTileOwner_Unmovable,      
  NULL,                           
  NULL,                           
  GetFoundation_Unmovable,        
  TerraformTile_Unmovable,        
}


Generated on Mon Feb 16 23:12:27 2009 for openttd by  doxygen 1.5.6