|
OpenTTD Source
1.10.0-RC1
|
Handling of road vehicles. More...
#include "stdafx.h"#include "roadveh.h"#include "command_func.h"#include "news_func.h"#include "pathfinder/npf/npf_func.h"#include "station_base.h"#include "company_func.h"#include "articulated_vehicles.h"#include "newgrf_sound.h"#include "pathfinder/yapf/yapf.h"#include "strings_func.h"#include "tunnelbridge_map.h"#include "date_func.h"#include "vehicle_func.h"#include "sound_func.h"#include "ai/ai.hpp"#include "game/game.hpp"#include "depot_map.h"#include "effectvehicle_func.h"#include "roadstop_base.h"#include "spritecache.h"#include "core/random_func.hpp"#include "company_base.h"#include "core/backup_type.hpp"#include "newgrf.h"#include "zoom_func.h"#include "framerate_type.h"#include "table/strings.h"#include "safeguards.h"#include "table/roadveh_movement.h"Go to the source code of this file.
Data Structures | |
| struct | RoadVehFindData |
| struct | OvertakeData |
| struct | RoadDriveEntry |
Macros | |
| #define | return_track(x) { best_track = (Trackdir)x; goto found_best_track; } |
Functions | |
| assert_compile (lengthof(_roadveh_images)==lengthof(_roadveh_full_adder)) | |
| template<> | |
| bool | IsValidImageIndex< VEH_ROAD > (uint8 image_index) |
| static void | GetRoadVehIcon (EngineID engine, EngineImageType image_type, VehicleSpriteSeq *result) |
| void | DrawRoadVehEngine (int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type) |
| Draw a road vehicle engine. More... | |
| void | GetRoadVehSpriteSize (EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type) |
| Get the size of the sprite of a road vehicle sprite heading west (used for lists). More... | |
| static uint | GetRoadVehLength (const RoadVehicle *v) |
| Get length of a road vehicle. More... | |
| void | RoadVehUpdateCache (RoadVehicle *v, bool same_length) |
| Update the cache of a road vehicle. More... | |
| CommandCost | CmdBuildRoadVehicle (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **ret) |
| Build a road vehicle. More... | |
| static FindDepotData | FindClosestRoadDepot (const RoadVehicle *v, int max_distance) |
| CommandCost | CmdTurnRoadVeh (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
| Turn a roadvehicle around. More... | |
| static void | DeleteLastRoadVeh (RoadVehicle *v) |
| Delete last vehicle of a chain road vehicles. More... | |
| static void | RoadVehSetRandomDirection (RoadVehicle *v) |
| static bool | RoadVehIsCrashed (RoadVehicle *v) |
| Road vehicle chain has crashed. More... | |
| static Vehicle * | EnumCheckRoadVehCrashTrain (Vehicle *v, void *data) |
| Check routine whether a road and a train vehicle have collided. More... | |
| static void | RoadVehCrash (RoadVehicle *v) |
| static bool | RoadVehCheckTrainCrash (RoadVehicle *v) |
| static void | StartRoadVehSound (const RoadVehicle *v) |
| static Vehicle * | EnumCheckRoadVehClose (Vehicle *v, void *data) |
| static RoadVehicle * | RoadVehFindCloseTo (RoadVehicle *v, int x, int y, Direction dir, bool update_blocked_ctr=true) |
| static void | RoadVehArrivesAt (const RoadVehicle *v, Station *st) |
| A road vehicle arrives at a station. More... | |
| static Direction | RoadVehGetNewDirection (const RoadVehicle *v, int x, int y) |
| static Direction | RoadVehGetSlidingDirection (const RoadVehicle *v, int x, int y) |
| static Vehicle * | EnumFindVehBlockingOvertake (Vehicle *v, void *data) |
| static bool | CheckRoadBlockedForOvertaking (OvertakeData *od) |
| Check if overtaking is possible on a piece of track. More... | |
| static void | RoadVehCheckOvertake (RoadVehicle *v, RoadVehicle *u) |
| static void | RoadZPosAffectSpeed (RoadVehicle *v, int old_z) |
| static int | PickRandomBit (uint bits) |
| static Trackdir | RoadFindPathToDest (RoadVehicle *v, TileIndex tile, DiagDirection enterdir) |
| Returns direction to for a road vehicle to take or INVALID_TRACKDIR if the direction is currently blocked. More... | |
| static bool | RoadVehLeaveDepot (RoadVehicle *v, bool first) |
| static Trackdir | FollowPreviousRoadVehicle (const RoadVehicle *v, const RoadVehicle *prev, TileIndex tile, DiagDirection entry_dir, bool already_reversed) |
| static bool | CanBuildTramTrackOnTile (CompanyID c, TileIndex t, RoadType rt, RoadBits r) |
| Can a tram track build without destruction on the given tile? More... | |
| bool | IndividualRoadVehicleController (RoadVehicle *v, const RoadVehicle *prev) |
| static bool | RoadVehController (RoadVehicle *v) |
| static void | CheckIfRoadVehNeedsService (RoadVehicle *v) |
Variables | |
| static const uint16 | _roadveh_images [] |
| static const uint16 | _roadveh_full_adder [] |
| static const Trackdir | _road_reverse_table [DIAGDIR_END] |
Handling of road vehicles.
Definition in file roadveh_cmd.cpp.
Can a tram track build without destruction on the given tile?
| c | the company that would be building the tram tracks |
| t | the tile to build on. |
| rt | the tram type to build. |
| r | the road bits needed. |
Definition at line 1129 of file roadveh_cmd.cpp.
References _current_company.
|
static |
Check if overtaking is possible on a piece of track.
| od | Information about the tile and the involved vehicles |
Definition at line 785 of file roadveh_cmd.cpp.
References RoadVehicle::compatible_roadtypes, GetTileTrackStatus(), HasTileAnyRoadType(), and TRANSPORT_ROAD.
| CommandCost CmdBuildRoadVehicle | ( | TileIndex | tile, |
| DoCommandFlag | flags, | ||
| const Engine * | e, | ||
| uint16 | data, | ||
| Vehicle ** | ret | ||
| ) |
Build a road vehicle.
| tile | tile of the depot where road vehicle is built. | |
| flags | type of operation. | |
| e | the engine to build. | |
| data | unused. | |
| [out] | ret | the vehicle that has been built. |
Definition at line 259 of file roadveh_cmd.cpp.
References _current_company, DC_EXEC, DiagDirToDir(), Vehicle::direction, GetRoadDepotDirection(), GetRoadTypeInfo(), HasTileAnyRoadType(), Vehicle::owner, RoadTypeInfo::powered_roadtypes, return_cmd_error, RoadVehicleInfo::roadtype, RoadVehicle::RoadVehicle(), and Vehicle::tile.
| CommandCost CmdTurnRoadVeh | ( | TileIndex | tile, |
| DoCommandFlag | flags, | ||
| uint32 | p1, | ||
| uint32 | p2, | ||
| const char * | text | ||
| ) |
Turn a roadvehicle around.
| tile | unused |
| flags | operation to perform |
| p1 | vehicle ID to turn |
| p2 | unused |
| text | unused |
Definition at line 369 of file roadveh_cmd.cpp.
References Vehicle::breakdown_ctr, CheckOwnership(), CMD_ERROR, Vehicle::current_order, CommandCost::Failed(), SpecializedVehicle< RoadVehicle, Type >::GetIfValid(), RoadVehicle::IsInDepot(), RoadVehicle::IsPrimaryVehicle(), Order::IsType(), RoadVehicle::overtaking, Vehicle::owner, RVSB_WORMHOLE, RoadVehicle::state, Vehicle::vehstatus, VS_CRASHED, and VS_STOPPED.
|
static |
Delete last vehicle of a chain road vehicles.
| v | First roadvehicle. |
Definition at line 467 of file roadveh_cmd.cpp.
References Vehicle::first, SpecializedVehicle< T, Type >::First(), IsInsideMM(), Vehicle::last_station_visited, SpecializedVehicle< T, Type >::Next(), RVSB_IN_ROAD_STOP, Vehicle::SetNext(), and RoadVehicle::state.
| void DrawRoadVehEngine | ( | int | left, |
| int | right, | ||
| int | preferred_x, | ||
| int | y, | ||
| EngineID | engine, | ||
| PaletteID | pal, | ||
| EngineImageType | image_type | ||
| ) |
Draw a road vehicle engine.
| left | Left edge to draw within. |
| right | Right edge to draw within. |
| preferred_x | Preferred position of the engine. |
| y | Vertical position of the engine. |
| engine | Engine to draw |
| pal | Palette to use. |
Definition at line 145 of file roadveh_cmd.cpp.
Check routine whether a road and a train vehicle have collided.
| v | Train vehicle to test. |
| data | Road vehicle to test. |
nullptr. Definition at line 522 of file roadveh_cmd.cpp.
References abs(), BaseVehicle::type, VEH_TRAIN, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.
|
static |
Get length of a road vehicle.
| v | Road vehicle to query length. |
Definition at line 187 of file roadveh_cmd.cpp.
References CALLBACK_FAILED, Vehicle::GetEngine(), Engine::GetGRF(), and VEHICLE_LENGTH.
| void GetRoadVehSpriteSize | ( | EngineID | engine, |
| uint & | width, | ||
| uint & | height, | ||
| int & | xoffs, | ||
| int & | yoffs, | ||
| EngineImageType | image_type | ||
| ) |
Get the size of the sprite of a road vehicle sprite heading west (used for lists).
| engine | The engine to get the sprite from. | |
| [out] | width | The width of the sprite. |
| [out] | height | The height of the sprite. |
| [out] | xoffs | Number of pixels to shift the sprite to the right. |
| [out] | yoffs | Number of pixels to shift the sprite downwards. |
| image_type | Context the sprite is used in. |
Definition at line 168 of file roadveh_cmd.cpp.
|
static |
Returns direction to for a road vehicle to take or INVALID_TRACKDIR if the direction is currently blocked.
| v | the Vehicle to do the pathfinding for |
| tile | the where to start the pathfinding |
| enterdir | the direction the vehicle enters the tile from |
Definition at line 881 of file roadveh_cmd.cpp.
References GetTileTrackStatus(), and TRANSPORT_ROAD.
|
static |
A road vehicle arrives at a station.
If it is the first time, create a news item.
| v | Road vehicle that arrived. |
| st | Station where the road vehicle arrived. |
Definition at line 687 of file roadveh_cmd.cpp.
References AddVehicleNewsItem(), HVOT_BUS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, RoadVehicle::IsBus(), and SetDParam().
|
static |
Road vehicle chain has crashed.
| v | First roadvehicle. |
Definition at line 500 of file roadveh_cmd.cpp.
References RoadVehicle::crashed_ctr, CreateEffectVehicleRel(), EV_EXPLOSION_LARGE, and Vehicle::tick_counter.
| void RoadVehUpdateCache | ( | RoadVehicle * | v, |
| bool | same_length | ||
| ) |
Update the cache of a road vehicle.
| v | Road vehicle needing an update of its cache. |
| same_length | should length of vehicles stay the same? |
Definition at line 215 of file roadveh_cmd.cpp.
|
static |
Definition at line 71 of file roadveh_cmd.cpp.
|
static |
Definition at line 53 of file roadveh_cmd.cpp.
|
static |
Definition at line 42 of file roadveh_cmd.cpp.