2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2007-12-19 23:26:02 +00:00
|
|
|
/** @file vehicle_type.h Types related to vehicles. */
|
|
|
|
|
|
|
|
#ifndef VEHICLE_TYPE_H
|
|
|
|
#define VEHICLE_TYPE_H
|
|
|
|
|
|
|
|
#include "core/enum_type.hpp"
|
|
|
|
|
2011-05-01 19:14:12 +00:00
|
|
|
/** The type all our vehicle IDs have. */
|
2010-08-19 20:58:30 +00:00
|
|
|
typedef uint32 VehicleID;
|
2007-12-19 23:26:02 +00:00
|
|
|
|
2018-09-29 11:26:44 +00:00
|
|
|
static const int GROUND_ACCELERATION = 9800; ///< Acceleration due to gravity, 9.8 m/s^2
|
|
|
|
|
2019-04-21 21:25:54 +00:00
|
|
|
/** Available vehicle types. It needs to be 8bits, because we save and load it as such */
|
|
|
|
enum VehicleType : byte {
|
2011-10-03 17:22:56 +00:00
|
|
|
VEH_BEGIN,
|
|
|
|
|
|
|
|
VEH_TRAIN = VEH_BEGIN, ///< %Train vehicle type.
|
|
|
|
VEH_ROAD, ///< Road vehicle type.
|
|
|
|
VEH_SHIP, ///< %Ship vehicle type.
|
|
|
|
VEH_AIRCRAFT, ///< %Aircraft vehicle type.
|
|
|
|
|
|
|
|
VEH_COMPANY_END, ///< Last company-ownable type.
|
|
|
|
|
|
|
|
VEH_EFFECT = VEH_COMPANY_END, ///< Effect vehicle type (smoke, explosions, sparks, bubbles)
|
|
|
|
VEH_DISASTER, ///< Disaster vehicle type.
|
|
|
|
|
2007-12-19 23:26:02 +00:00
|
|
|
VEH_END,
|
2011-10-03 17:22:56 +00:00
|
|
|
VEH_INVALID = 0xFF, ///< Non-existing type of vehicle.
|
2007-12-19 23:26:02 +00:00
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_POSTFIX_INCREMENT(VehicleType)
|
2011-05-01 19:14:12 +00:00
|
|
|
/** Helper information for extract tool. */
|
2010-04-17 13:31:41 +00:00
|
|
|
template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID, 3> {};
|
2007-12-19 23:26:02 +00:00
|
|
|
|
|
|
|
struct Vehicle;
|
2009-05-22 22:22:46 +00:00
|
|
|
struct Train;
|
|
|
|
struct RoadVehicle;
|
|
|
|
struct Ship;
|
|
|
|
struct Aircraft;
|
2009-06-06 16:54:22 +00:00
|
|
|
struct EffectVehicle;
|
|
|
|
struct DisasterVehicle;
|
2007-12-19 23:26:02 +00:00
|
|
|
|
2010-11-05 16:34:22 +00:00
|
|
|
/** Base vehicle class. */
|
2007-12-27 13:35:39 +00:00
|
|
|
struct BaseVehicle
|
|
|
|
{
|
2019-04-21 21:25:54 +00:00
|
|
|
VehicleType type; ///< Type of vehicle
|
2007-12-27 13:35:39 +00:00
|
|
|
};
|
|
|
|
|
2010-08-19 20:58:30 +00:00
|
|
|
static const VehicleID INVALID_VEHICLE = 0xFFFFF; ///< Constant representing a non-existing vehicle.
|
2007-12-27 13:35:39 +00:00
|
|
|
|
2008-02-13 14:21:36 +00:00
|
|
|
/** Pathfinding option states */
|
2010-05-13 09:44:44 +00:00
|
|
|
enum VehiclePathFinders {
|
2019-02-18 23:55:45 +00:00
|
|
|
// Original PathFinder (OPF) used to be 0
|
2008-02-13 14:21:36 +00:00
|
|
|
VPF_NPF = 1, ///< New PathFinder
|
|
|
|
VPF_YAPF = 2, ///< Yet Another PathFinder
|
|
|
|
};
|
|
|
|
|
2010-09-08 21:02:12 +00:00
|
|
|
/** Flags to add to p1 for goto depot commands. */
|
2008-04-11 08:40:10 +00:00
|
|
|
enum DepotCommand {
|
2018-06-21 22:28:19 +00:00
|
|
|
DEPOT_SELL = (1U << 25), ///< Go to depot and sell order
|
2018-03-29 18:37:16 +00:00
|
|
|
DEPOT_CANCEL = (1U << 26), ///< Cancel depot/service order
|
2016-11-28 20:17:53 +00:00
|
|
|
DEPOT_SPECIFIC = (1U << 27), ///< Send vehicle to specific depot
|
2018-03-29 18:37:16 +00:00
|
|
|
DEPOT_SERVICE = (1U << 28), ///< The vehicle will leave the depot right after arrival (service only)
|
2010-09-08 21:02:12 +00:00
|
|
|
DEPOT_MASS_SEND = (1U << 29), ///< Tells that it's a mass send to depot command (type in VLW flag)
|
|
|
|
DEPOT_DONT_CANCEL = (1U << 30), ///< Don't cancel current goto depot command if any
|
|
|
|
DEPOT_LOCATE_HANGAR = (1U << 31), ///< Find another airport if the target one lacks a hangar
|
2018-06-21 22:28:19 +00:00
|
|
|
DEPOT_COMMAND_MASK = 0x7FU << 25,
|
2008-04-11 08:40:10 +00:00
|
|
|
};
|
|
|
|
|
2017-01-30 19:11:11 +00:00
|
|
|
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 128; ///< The maximum length of a vehicle name in characters including '\0'
|
2008-08-13 06:05:01 +00:00
|
|
|
|
2011-03-05 21:52:45 +00:00
|
|
|
/** The length of a vehicle in tile units. */
|
|
|
|
static const uint VEHICLE_LENGTH = 8;
|
|
|
|
|
2015-08-02 22:00:39 +00:00
|
|
|
/**
|
|
|
|
* The different types of breakdowns
|
|
|
|
*
|
|
|
|
* Aircraft have totally different breakdowns, so we use aliases to make things clearer
|
|
|
|
*/
|
2015-08-02 21:58:41 +00:00
|
|
|
enum BreakdownType {
|
|
|
|
BREAKDOWN_CRITICAL = 0, ///< Old style breakdown (black smoke)
|
|
|
|
BREAKDOWN_EM_STOP = 1, ///< Emergency stop
|
|
|
|
BREAKDOWN_LOW_SPEED = 2, ///< Lower max speed
|
|
|
|
BREAKDOWN_LOW_POWER = 3, ///< Power reduction
|
2017-06-06 19:20:33 +00:00
|
|
|
BREAKDOWN_RV_CRASH = 4, ///< Train hit road vehicle
|
2015-08-02 22:00:39 +00:00
|
|
|
|
2015-08-02 21:58:41 +00:00
|
|
|
BREAKDOWN_AIRCRAFT_SPEED = BREAKDOWN_CRITICAL, ///< Lower speed until the next airport
|
|
|
|
BREAKDOWN_AIRCRAFT_DEPOT = BREAKDOWN_EM_STOP, ///< We have to visit a depot at the next airport
|
|
|
|
BREAKDOWN_AIRCRAFT_EM_LANDING = BREAKDOWN_LOW_SPEED, ///< Emergency landing at the closest airport (with hangar!) we can find
|
|
|
|
};
|
|
|
|
|
2010-01-30 16:27:35 +00:00
|
|
|
/** Vehicle acceleration models. */
|
|
|
|
enum AccelerationModel {
|
|
|
|
AM_ORIGINAL,
|
|
|
|
AM_REALISTIC,
|
2009-01-23 20:53:43 +00:00
|
|
|
};
|
|
|
|
|
2011-11-01 16:51:47 +00:00
|
|
|
/** Visualisation contexts of vehicles and engines. */
|
|
|
|
enum EngineImageType {
|
|
|
|
EIT_ON_MAP = 0x00, ///< Vehicle drawn in viewport.
|
|
|
|
EIT_IN_DEPOT = 0x10, ///< Vehicle drawn in depot.
|
|
|
|
EIT_IN_DETAILS = 0x11, ///< Vehicle drawn in vehicle details, refit window, ...
|
|
|
|
EIT_IN_LIST = 0x12, ///< Vehicle drawn in vehicle list, group list, ...
|
|
|
|
EIT_PURCHASE = 0x20, ///< Vehicle drawn in purchase list, autoreplace gui, ...
|
|
|
|
EIT_PREVIEW = 0x21, ///< Vehicle drawn in preview window, news, ...
|
|
|
|
};
|
|
|
|
|
2007-12-19 23:26:02 +00:00
|
|
|
#endif /* VEHICLE_TYPE_H */
|