src/vehicle_func.h
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 9273 ca5e00698c01
child 10098 00ebbccc6181
permissions -rw-r--r--
update tags
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
     3
/** @vehicle.h Functions related to vehicles. */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1020
diff changeset
     4
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
     5
#ifndef VEHICLE_FUNC_H
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
     6
#define VEHICLE_FUNC_H
7631
e810ef25497e (svn r10409) -Codechange: replace (Aircraft|RoadVeh|Ship|Train)_Tick with a Tick method in the Vehicle class.
rubidium
parents: 7630
diff changeset
     7
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
     8
#include "tile_type.h"
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
     9
#include "strings_type.h"
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    10
#include "gfx_type.h"
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    11
#include "direction_type.h"
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    12
#include "cargo_type.h"
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    13
#include "command_type.h"
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    14
#include "vehicle_type.h"
9273
ca5e00698c01 (svn r12476) -Codechange: split type engine related types from engine.h (and openttd.h) to engine_type.h.
rubidium
parents: 9269
diff changeset
    15
#include "engine_type.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
1765
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
    17
#define is_custom_sprite(x) (x >= 0xFD)
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
    18
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
f8d29d5462c9 (svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents: 1763
diff changeset
    19
#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
typedef void *VehicleFromPosProc(Vehicle *v, void *data);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
578
86e352980acd (svn r998) now vehicles are serviced both when entering and when leaving depots to prevent that vehicles might need service when leaving after a long stay (ln--)
bjarni
parents: 577
diff changeset
    23
void VehicleServiceInDepot(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
void VehiclePositionChanged(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
Vehicle *GetLastVehicleInChain(Vehicle *v);
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7631
diff changeset
    26
uint CountVehiclesInChain(const Vehicle *v);
4574
497540b4a75f (svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents: 4544
diff changeset
    27
bool IsEngineCountable(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
void DeleteVehicleChain(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
7367
a0499d5cb8e5 (svn r10111) -Codechange: Add new vehicle hash table for collision detection and finding vehicles on a tile. The hash area scanned is far smaller than the old hash table, which is now used for viewport updates only. This should give a significant performance improvement for games with many vehicles. (Based on work by 'B. N. SmatZ!' and 'madman2003')
peter1138
parents: 7353
diff changeset
    30
void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
    31
void CallVehicleTicks();
1605
c4630be67467 (svn r2109) -Fix: use FindVehicleOnTileZ(tile, 0) over FindVehicleBetween(tile, tile, 0)
truelight
parents: 1601
diff changeset
    32
Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
7510
acb7cfe27b60 (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
truelight
parents: 7506
diff changeset
    33
uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
    35
void InitializeTrains();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
    36
byte VehicleRandomBits();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6524
diff changeset
    37
void ResetVehiclePosHash();
8298
b8f2b501e23a (svn r11352) -Codechange: cache callback 2D result (vehicle color mapping) instead calling it every time the vehicle is drawn
glx
parents: 8044
diff changeset
    38
void ResetVehicleColorMap();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
2704
dc9ae68dfd74 (svn r3248) - Codechange: Change interface of CanRefitTo() to supply the engine type directly instead of getting it from a vehicle. This allows the function to be used before vehicles are involved.
peter1138
parents: 2676
diff changeset
    40
bool CanRefitTo(EngineID engine_type, CargoID cid_to);
3973
7624a250577b (svn r5146) - NewGRF: Support selection of aircraft default cargo type by checking its refit mask. If aircraft can be refitted to passengers, no change happens, else the first refittable type is chosen. Also use refit capacity to determine the default capacity.
peter1138
parents: 3948
diff changeset
    41
CargoID FindFirstRefittableCargo(EngineID engine_type);
7439
0c0e2945c890 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 7367
diff changeset
    42
CommandCost GetRefitCost(EngineID engine_type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
void ViewportAddVehicles(DrawPixelInfo *dpi);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
6117
b50b5ebc1c98 (svn r8448) -Codechange/Fix (r2993): Also update the helicopter's rotor when loading the game. This can solve crashes when a game is loaded with missing GRF's
Darkvater
parents: 6105
diff changeset
    46
SpriteID GetRotorImage(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
    48
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
3881
b2a66893f250 (svn r4937) Reduce the use of _error_message a bit
tron
parents: 3870
diff changeset
    50
StringID VehicleInTheWayErrMsg(const Vehicle* v);
6191
12d69f54e920 (svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents: 6139
diff changeset
    51
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_crashed = false);
8568
a82225425c24 (svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz
parents: 8377
diff changeset
    52
Vehicle *GetVehicleTunnelBridge(TileIndex tile, TileIndex endtile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
void DecreaseVehicleValue(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
void CheckVehicleBreakdown(Vehicle *v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
void AgeVehicle(Vehicle *v);
2574
382fd3f37604 (svn r3111) -Fix: [autoreplace] [ 1341783 ] Assertion failure in vehicle.c line 378
bjarni
parents: 2564
diff changeset
    57
void VehicleEnteredDepotThisTick(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
8813
6d054db96ede (svn r11882) -Codechange: introduce MarkSingleVehicleDirty() and simplify the code at some places
smatz
parents: 8734
diff changeset
    59
void BeginVehicleMove(const Vehicle *v);
6d054db96ede (svn r11882) -Codechange: introduce MarkSingleVehicleDirty() and simplify the code at some places
smatz
parents: 8734
diff changeset
    60
void EndVehicleMove(const Vehicle *v);
6d054db96ede (svn r11882) -Codechange: introduce MarkSingleVehicleDirty() and simplify the code at some places
smatz
parents: 8734
diff changeset
    61
void MarkSingleVehicleDirty(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
    63
UnitID GetFreeUnitNumber(VehicleType type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
1905
f43d9e821deb (svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents: 1804
diff changeset
    65
void TrainConsistChanged(Vehicle *v);
3355
a653b8e47f27 (svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents: 3347
diff changeset
    66
void TrainPowerChanged(Vehicle *v);
7449
5cedaf2c861c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 7439
diff changeset
    67
Money GetTrainRunningCost(const Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
593
e303a764de50 (svn r1015) MFM r789
tron
parents: 578
diff changeset
    69
bool VehicleNeedsService(const Vehicle *v);
e303a764de50 (svn r1015) MFM r789
tron
parents: 578
diff changeset
    70
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
    71
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
    72
void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
7439
0c0e2945c890 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 7367
diff changeset
    73
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
4725
f7284b86833f (svn r6637) -Codechange: merged all (vehicle type)EnterDepot into VehicleEnterDepot()
bjarni
parents: 4681
diff changeset
    74
void VehicleEnterDepot(Vehicle *v);
4506
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
    75
7439
0c0e2945c890 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 7367
diff changeset
    76
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
7582
9f23c01ae23d (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 7562
diff changeset
    77
bool CanBuildVehicleInfrastructure(VehicleType type);
6590
9bbf8fdc5e91 (svn r9073) -Codechange: moved autoreplace to a file of it's own (now autoreplace has a cmd and a gui file)
bjarni
parents: 6585
diff changeset
    78
7974
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7973
diff changeset
    79
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7973
diff changeset
    80
4506
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
    81
/* Flags to add to p2 for goto depot commands */
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
    82
/* Note: bits 8-10 are used for VLW flags */
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
    83
enum {
6988
76eba6a9cc6f (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6986
diff changeset
    84
	DEPOT_SERVICE       = (1 << 0), // The vehicle will leave the depot right after arrival (serivce only)
4506
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
    85
	DEPOT_MASS_SEND     = (1 << 1), // Tells that it's a mass send to depot command (type in VLW flag)
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
    86
	DEPOT_DONT_CANCEL   = (1 << 2), // Don't cancel current goto depot command if any
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
    87
	DEPOT_LOCATE_HANGAR = (1 << 3), // Find another airport if the target one lacks a hangar
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4497
diff changeset
    88
};
4463
3a70624c40eb (svn r6246) -Feature: added the many times requested "send all vehicle to depot" button
bjarni
parents: 4451
diff changeset
    89
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    90
struct GetNewVehiclePosResult {
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7631
diff changeset
    91
	int x, y;
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
    92
	TileIndex old_tile;
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1944
diff changeset
    93
	TileIndex new_tile;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    94
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
/* returns true if staying in the same tile */
6479
b228a94a1832 (svn r8897) -Fix
tron
parents: 6478
diff changeset
    97
GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v);
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7631
diff changeset
    98
Direction GetDirectionTowards(const Vehicle *v, int x, int y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   100
static inline bool IsPlayerBuildableVehicleType(VehicleType type)
5997
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   101
{
6026
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   102
	switch (type) {
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   103
		case VEH_TRAIN:
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   104
		case VEH_ROAD:
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   105
		case VEH_SHIP:
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   106
		case VEH_AIRCRAFT:
5997
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   107
			return true;
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   108
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   109
		default: return false;
5997
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   110
	}
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   111
}
11e028b7f507 (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared
bjarni
parents: 5934
diff changeset
   112
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   113
static inline bool IsPlayerBuildableVehicleType(const BaseVehicle *v)
6026
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   114
{
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   115
	return IsPlayerBuildableVehicleType(v->type);
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   116
}
96b4b02774e5 (svn r8327) -Codechange: though overloading, IsPlayerBuildableVehicleType() now works with the type given as a byte as well as a vehicle pointer
bjarni
parents: 5999
diff changeset
   117
7012
f20d04170833 (svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents: 6988
diff changeset
   118
const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v);
f20d04170833 (svn r9702) -Codechange: Add livery support to newgrf vehicle var 43
peter1138
parents: 6988
diff changeset
   119
3105
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   120
/**
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   121
 * Get the colour map for an engine. This used for unbuilt engines in the user interface.
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   122
 * @param engine_type ID of engine
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   123
 * @param player ID of player
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   124
 * @return A ready-to-use palette modifier
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   125
 */
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5902
diff changeset
   126
SpriteID GetEnginePalette(EngineID engine_type, PlayerID player);
3040
c3473d1fb81f (svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents: 3022
diff changeset
   127
3105
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   128
/**
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   129
 * Get the colour map for a vehicle.
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   130
 * @param v Vehicle to get colour map for
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   131
 * @return A ready-to-use palette modifier
4a6514d7a8ba (svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents: 3040
diff changeset
   132
 */
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5902
diff changeset
   133
SpriteID GetVehiclePalette(const Vehicle *v);
3040
c3473d1fb81f (svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents: 3022
diff changeset
   134
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   135
extern const uint32 _veh_build_proc_table[];
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   136
extern const uint32 _veh_sell_proc_table[];
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   137
extern const uint32 _veh_refit_proc_table[];
4494
15b8ae6bd860 (svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents: 4463
diff changeset
   138
extern const uint32 _send_to_depot_proc_table[];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   139
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   140
/* Functions to find the right command for certain vehicle type */
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   141
static inline uint32 GetCmdBuildVeh(VehicleType type)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   142
{
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   143
	return _veh_build_proc_table[type];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   144
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   145
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   146
static inline uint32 GetCmdBuildVeh(const BaseVehicle *v)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   147
{
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   148
	return GetCmdBuildVeh(v->type);
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   149
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   150
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   151
static inline uint32 GetCmdSellVeh(VehicleType type)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   152
{
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   153
	return _veh_sell_proc_table[type];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   154
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   155
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   156
static inline uint32 GetCmdSellVeh(const BaseVehicle *v)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   157
{
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   158
	return GetCmdSellVeh(v->type);
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   159
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   160
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   161
static inline uint32 GetCmdRefitVeh(VehicleType type)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   162
{
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   163
	return _veh_refit_proc_table[type];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   164
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   165
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   166
static inline uint32 GetCmdRefitVeh(const BaseVehicle *v)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   167
{
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   168
	return GetCmdRefitVeh(v->type);
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   169
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   170
7137
94dd139831be (svn r9872) -Codechange: more type strictness for vehicle types
rubidium
parents: 7117
diff changeset
   171
static inline uint32 GetCmdSendToDepot(VehicleType type)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   172
{
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   173
	return _send_to_depot_proc_table[type];
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   174
}
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   175
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   176
static inline uint32 GetCmdSendToDepot(const BaseVehicle *v)
6043
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   177
{
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   178
	return GetCmdSendToDepot(v->type);
99c8fb13658b (svn r8349) -Codechange: replaced CMD_REFIT_VEH() and similar defines with real static inline functions
bjarni
parents: 6040
diff changeset
   179
}
4451
66603f0f732e (svn r6229) -Feature: Shared order lists now got a "goto depot" button
bjarni
parents: 4434
diff changeset
   180
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8619
diff changeset
   181
bool EnsureNoVehicleOnGround(TileIndex tile);
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   182
void StopAllVehicles();
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8619
diff changeset
   183
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   184
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   185
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   186
Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type);
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
   187
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   188
extern VehicleID _vehicle_id_ctr_day;
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   189
extern Vehicle *_place_clicked_vehicle;
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   190
extern VehicleID _new_vehicle_id;
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
   191
extern uint16 _returned_refit_capacity;
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8604
diff changeset
   192
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
#endif /* VEHICLE_H */