src/vehicle_type.h
author rubidium
Thu, 18 Dec 2008 12:23:08 +0000
changeset 10436 8d3a9fbe8f19
parent 9913 d9ce89020cc0
permissions -rw-r--r--
(svn r14689) -Change: make configure die on commonly made user mistakes, like not having SDL development files or zlib headers installed; you can still compile a dedicated server or a binary without zlib, but you have to explicitly force it.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8106
diff changeset
     3
/** @file vehicle_type.h Types related to vehicles. */
5991
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5955
diff changeset
     4
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8106
diff changeset
     5
#ifndef VEHICLE_TYPE_H
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8106
diff changeset
     6
#define VEHICLE_TYPE_H
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
     7
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8106
diff changeset
     8
#include "core/enum_type.hpp"
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
     9
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8106
diff changeset
    10
typedef uint16 VehicleID;
6000
181ad2c1ab14 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents: 5991
diff changeset
    11
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    12
enum VehicleType {
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    13
	VEH_TRAIN,
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    14
	VEH_ROAD,
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    15
	VEH_SHIP,
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    16
	VEH_AIRCRAFT,
9008
de19c73e405f (svn r12803) -Cleanup: rename SpecialVehicle to EffectVehicle to have a uniform naming of the thing instead of using both names for the same thing.
rubidium
parents: 8891
diff changeset
    17
	VEH_EFFECT,
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    18
	VEH_DISASTER,
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    19
	VEH_END,
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
    20
	VEH_INVALID = 0xFF,
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    21
};
7086
de7e83fb1602 (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: 7066
diff changeset
    22
DECLARE_POSTFIX_INCREMENT(VehicleType);
6621
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    23
template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID> {};
441559124aea (svn r9841) -Codechange: add a little more type strictness to the vehicle types.
rubidium
parents: 6616
diff changeset
    24
typedef TinyEnumT<VehicleType> VehicleTypeByte;
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1605
diff changeset
    25
7398
b933416cf32b (svn r10770) -Codechange: use the pool item class as super class for the vehicle struct.
rubidium
parents: 7387
diff changeset
    26
struct Vehicle;
7490
bb27d92565d3 (svn r11001) -Codechange: unify the way to determine whether a vehicle is in a depot.
rubidium
parents: 7488
diff changeset
    27
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    28
struct BaseVehicle
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    29
{
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    30
	VehicleTypeByte type;    ///< Type of vehicle
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    31
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    32
	/**
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    33
	 * Is this vehicle a valid vehicle?
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    34
	 * @return true if and only if the vehicle is valid.
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    35
	 */
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    36
	inline bool IsValid() const { return this->type != VEH_INVALID; }
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    37
};
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    38
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    39
static const VehicleID INVALID_VEHICLE = 0xFFFF;
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8108
diff changeset
    40
8551
f0bcd6753287 (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz
parents: 8144
diff changeset
    41
/** Pathfinding option states */
f0bcd6753287 (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz
parents: 8144
diff changeset
    42
enum {
f0bcd6753287 (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz
parents: 8144
diff changeset
    43
	VPF_OPF  = 0, ///< The Original PathFinder
f0bcd6753287 (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz
parents: 8144
diff changeset
    44
	VPF_NTP  = 0, ///< New Train Pathfinder, replacing OPF for trains
f0bcd6753287 (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz
parents: 8144
diff changeset
    45
	VPF_NPF  = 1, ///< New PathFinder
f0bcd6753287 (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz
parents: 8144
diff changeset
    46
	VPF_YAPF = 2, ///< Yet Another PathFinder
f0bcd6753287 (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz
parents: 8144
diff changeset
    47
};
f0bcd6753287 (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz
parents: 8144
diff changeset
    48
8891
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    49
/* Flags to add to p2 for goto depot commands */
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    50
/* Note: bits 8-10 are used for VLW flags */
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    51
enum DepotCommand {
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    52
	DEPOT_SERVICE       = (1 << 0), ///< The vehicle will leave the depot right after arrival (serivce only)
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    53
	DEPOT_MASS_SEND     = (1 << 1), ///< Tells that it's a mass send to depot command (type in VLW flag)
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    54
	DEPOT_DONT_CANCEL   = (1 << 2), ///< Don't cancel current goto depot command if any
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    55
	DEPOT_LOCATE_HANGAR = (1 << 3), ///< Find another airport if the target one lacks a hangar
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    56
	DEPOT_COMMAND_MASK  = 0xF,
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    57
};
1058c3b69b7f (svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium
parents: 8551
diff changeset
    58
9913
d9ce89020cc0 (svn r14063) -Codechange: replace some "magic" constants with enumified constants.
rubidium
parents: 9396
diff changeset
    59
enum {
d9ce89020cc0 (svn r14063) -Codechange: replace some "magic" constants with enumified constants.
rubidium
parents: 9396
diff changeset
    60
	MAX_LENGTH_VEHICLE_NAME_BYTES  =  31, ///< The maximum length of a vehicle name in bytes including '\0'
d9ce89020cc0 (svn r14063) -Codechange: replace some "magic" constants with enumified constants.
rubidium
parents: 9396
diff changeset
    61
	MAX_LENGTH_VEHICLE_NAME_PIXELS = 150, ///< The maximum length of a vehicle name in pixels
d9ce89020cc0 (svn r14063) -Codechange: replace some "magic" constants with enumified constants.
rubidium
parents: 9396
diff changeset
    62
};
d9ce89020cc0 (svn r14063) -Codechange: replace some "magic" constants with enumified constants.
rubidium
parents: 9396
diff changeset
    63
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8106
diff changeset
    64
#endif /* VEHICLE_TYPE_H */