summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-03-28 18:00:38 +0000
committerrubidium <rubidium@openttd.org>2008-03-28 18:00:38 +0000
commit93d59fe4480116a100aa000f38cea9534fab9184 (patch)
treeb9cba7a8f28964bd54d5599b4a146ab3d27b8f80
parentd97c16ee8bf2a1dcffc7edfd82586fc2784f6e9b (diff)
downloadopenttd-93d59fe4480116a100aa000f38cea9534fab9184.tar.xz
(svn r12476) -Codechange: split type engine related types from engine.h (and openttd.h) to engine_type.h.
-rw-r--r--projects/openttd_vs80.vcproj4
-rw-r--r--projects/openttd_vs90.vcproj4
-rw-r--r--source.list1
-rw-r--r--src/ai/trolly/trolly.h1
-rw-r--r--src/articulated_vehicles.h1
-rw-r--r--src/engine.h168
-rw-r--r--src/engine_type.h177
-rw-r--r--src/openttd.h4
-rw-r--r--src/vehicle_base.h1
-rw-r--r--src/vehicle_func.h1
-rw-r--r--src/vehicle_gui.h1
11 files changed, 192 insertions, 171 deletions
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index b80b046af..f28f0d69e 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -936,6 +936,10 @@
>
</File>
<File
+ RelativePath=".\..\src\engine_type.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\core\enum_type.hpp"
>
</File>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index b639ab3c2..1032affd2 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -933,6 +933,10 @@
>
</File>
<File
+ RelativePath=".\..\src\engine_type.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\core\enum_type.hpp"
>
</File>
diff --git a/source.list b/source.list
index 987ce13c2..2a0412e50 100644
--- a/source.list
+++ b/source.list
@@ -142,6 +142,7 @@ economy_func.h
economy_type.h
core/endian_func.hpp
engine.h
+engine_type.h
core/enum_type.hpp
fileio.h
fios.h
diff --git a/src/ai/trolly/trolly.h b/src/ai/trolly/trolly.h
index 43966f423..352a62761 100644
--- a/src/ai/trolly/trolly.h
+++ b/src/ai/trolly/trolly.h
@@ -7,6 +7,7 @@
#include "../../player_type.h"
#include "../../vehicle_type.h"
#include "../../date_type.h"
+#include "../../engine_type.h"
/*
* These defines can be altered to change the behavoir of the AI
diff --git a/src/articulated_vehicles.h b/src/articulated_vehicles.h
index 6db647df1..74f4b3f8e 100644
--- a/src/articulated_vehicles.h
+++ b/src/articulated_vehicles.h
@@ -6,6 +6,7 @@
#define ARTICULATED_VEHICLES_H
#include "vehicle_type.h"
+#include "engine_type.h"
uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type);
diff --git a/src/engine.h b/src/engine.h
index 4a24dd5c6..7b5cac1d5 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -5,157 +5,7 @@
#ifndef ENGINE_H
#define ENGINE_H
-#include "rail_type.h"
-#include "cargo_type.h"
-#include "vehicle_type.h"
-#include "gfx_type.h"
-#include "date_type.h"
-#include "sound_type.h"
-#include "player_type.h"
-#include "strings_type.h"
-
-enum RailVehicleTypes {
- RAILVEH_SINGLEHEAD, ///< indicates a "standalone" locomotive
- RAILVEH_MULTIHEAD, ///< indicates a combination of two locomotives
- RAILVEH_WAGON, ///< simple wagon, not motorized
-};
-
-enum EngineClass {
- EC_STEAM,
- EC_DIESEL,
- EC_ELECTRIC,
- EC_MONORAIL,
- EC_MAGLEV,
-};
-
-struct RailVehicleInfo {
- byte image_index;
- RailVehicleTypes railveh_type;
- byte base_cost;
- RailTypeByte railtype;
- uint16 max_speed;
- uint16 power;
- uint16 weight;
- byte running_cost;
- byte running_cost_class;
- EngineClass engclass; ///< Class of engine for this vehicle
- byte capacity;
- CargoID cargo_type;
- byte ai_rank;
- byte ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only
- uint16 pow_wag_power;
- byte pow_wag_weight;
- byte visual_effect; // NOTE: this is not 100% implemented yet, at the moment it is only used as a 'fallback' value
- // for when the 'powered wagon' callback fails. But it should really also determine what
- // kind of visual effect to generate for a vehicle (default, steam, diesel, electric).
- // Same goes for the callback result, which atm is only used to check if a wagon is powered.
- byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor
- byte tractive_effort; ///< Tractive effort coefficient
- byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
-};
-
-struct ShipVehicleInfo {
- byte image_index;
- byte base_cost;
- uint16 max_speed;
- CargoID cargo_type;
- uint16 capacity;
- byte running_cost;
- SoundFxByte sfx;
- bool refittable;
-};
-
-/* AircraftVehicleInfo subtypes, bitmask type.
- * If bit 0 is 0 then it is a helicopter, otherwise it is a plane
- * in which case bit 1 tells us whether it's a big(fast) plane or not */
-enum {
- AIR_HELI = 0,
- AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes
- AIR_FAST = 2
-};
-
-struct AircraftVehicleInfo {
- byte image_index;
- byte base_cost;
- byte running_cost;
- byte subtype;
- SoundFxByte sfx;
- byte acceleration;
- uint16 max_speed;
- byte mail_capacity;
- uint16 passenger_capacity;
-};
-
-struct RoadVehicleInfo {
- byte image_index;
- byte base_cost;
- byte running_cost;
- byte running_cost_class;
- SoundFxByte sfx;
- byte max_speed;
- byte capacity;
- CargoID cargo_type;
-};
-
-/** Information about a vehicle
- * @see table/engines.h
- */
-struct EngineInfo {
- Date base_intro;
- Year lifelength;
- Year base_life;
- byte unk2; ///< flag for carriage(bit 7) and decay speed(bits0..6)
- byte load_amount;
- byte climates;
- uint32 refit_mask;
- byte refit_cost;
- byte misc_flags;
- byte callbackmask;
- int8 retire_early; ///< Number of years early to retire vehicle
- StringID string_id; ///< Default name of engine
-};
-
-struct Engine {
- char *name; ///< Custom name of engine
- Date intro_date;
- Date age;
- uint16 reliability;
- uint16 reliability_spd_dec;
- uint16 reliability_start, reliability_max, reliability_final;
- uint16 duration_phase_1, duration_phase_2, duration_phase_3;
- byte lifelength;
- byte flags;
- uint8 preview_player_rank;
- byte preview_wait;
- byte player_avail;
- VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
-};
-
-/**
- * EngineInfo.misc_flags is a bitmask, with the following values
- */
-enum {
- EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves
- EF_ROAD_TRAM = 0, ///< Road vehicle is a tram/light rail vehicle
- EF_USES_2CC = 1, ///< Vehicle uses two company colours
- EF_RAIL_IS_MU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU)
-};
-
-/**
- * Engine.flags is a bitmask, with the following values.
- */
-enum {
- ENGINE_AVAILABLE = 1, ///< This vehicle is available to everyone.
- ENGINE_EXCLUSIVE_PREVIEW = 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a player.
- ENGINE_OFFER_WINDOW_OPEN = 4, ///< The exclusive offer window is currently open for a player.
-};
-
-enum {
- NUM_VEHICLE_TYPES = 6
-};
-
-static const EngineID INVALID_ENGINE = 0xFFFF;
-
+#include "engine_type.h"
void SetupEngines();
void StartupEngines();
@@ -172,20 +22,6 @@ void DeleteCustomEngineNames();
bool IsEngineBuildable(EngineID engine, VehicleType type, PlayerID player);
CargoID GetEngineCargoType(EngineID engine);
-enum {
- NUM_NORMAL_RAIL_ENGINES = 54,
- NUM_MONORAIL_ENGINES = 30,
- NUM_MAGLEV_ENGINES = 32,
- NUM_TRAIN_ENGINES = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES,
- NUM_ROAD_ENGINES = 88,
- NUM_SHIP_ENGINES = 11,
- NUM_AIRCRAFT_ENGINES = 41,
- TOTAL_NUM_ENGINES = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES + NUM_AIRCRAFT_ENGINES,
- AIRCRAFT_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES,
- SHIP_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES,
- ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES,
-};
-
static inline EngineID GetFirstEngineOfType(VehicleType type)
{
const EngineID start[] = {0, ROAD_ENGINES_INDEX, SHIP_ENGINES_INDEX, AIRCRAFT_ENGINES_INDEX};
@@ -263,8 +99,6 @@ static inline const RoadVehicleInfo* RoadVehInfo(EngineID e)
return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
}
-typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C code (see helpers.cpp)
-
/* Engine list manipulators - current implementation is only C wrapper of CBlobT<EngineID> class (helpers.cpp) */
void EngList_Create(EngineList *el); ///< Creates engine list
void EngList_Destroy(EngineList *el); ///< Deallocate and destroy engine list
diff --git a/src/engine_type.h b/src/engine_type.h
new file mode 100644
index 000000000..6079cdc6a
--- /dev/null
+++ b/src/engine_type.h
@@ -0,0 +1,177 @@
+/* $Id$ */
+
+/** @file engine_type.h Types related to engines. */
+
+#ifndef ENGINE_TYPE_H
+#define ENGINE_TYPE_H
+
+#include "rail_type.h"
+#include "cargo_type.h"
+#include "vehicle_type.h"
+#include "gfx_type.h"
+#include "date_type.h"
+#include "sound_type.h"
+#include "player_type.h"
+#include "strings_type.h"
+
+typedef uint16 EngineID;
+typedef uint16 EngineRenewID;
+typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C code (see helpers.cpp)
+
+enum RailVehicleTypes {
+ RAILVEH_SINGLEHEAD, ///< indicates a "standalone" locomotive
+ RAILVEH_MULTIHEAD, ///< indicates a combination of two locomotives
+ RAILVEH_WAGON, ///< simple wagon, not motorized
+};
+
+enum EngineClass {
+ EC_STEAM,
+ EC_DIESEL,
+ EC_ELECTRIC,
+ EC_MONORAIL,
+ EC_MAGLEV,
+};
+
+struct RailVehicleInfo {
+ byte image_index;
+ RailVehicleTypes railveh_type;
+ byte base_cost;
+ RailTypeByte railtype;
+ uint16 max_speed;
+ uint16 power;
+ uint16 weight;
+ byte running_cost;
+ byte running_cost_class;
+ EngineClass engclass; ///< Class of engine for this vehicle
+ byte capacity;
+ CargoID cargo_type;
+ byte ai_rank;
+ byte ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only
+ uint16 pow_wag_power;
+ byte pow_wag_weight;
+ byte visual_effect; // NOTE: this is not 100% implemented yet, at the moment it is only used as a 'fallback' value
+ // for when the 'powered wagon' callback fails. But it should really also determine what
+ // kind of visual effect to generate for a vehicle (default, steam, diesel, electric).
+ // Same goes for the callback result, which atm is only used to check if a wagon is powered.
+ byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor
+ byte tractive_effort; ///< Tractive effort coefficient
+ byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
+};
+
+struct ShipVehicleInfo {
+ byte image_index;
+ byte base_cost;
+ uint16 max_speed;
+ CargoID cargo_type;
+ uint16 capacity;
+ byte running_cost;
+ SoundFxByte sfx;
+ bool refittable;
+};
+
+/* AircraftVehicleInfo subtypes, bitmask type.
+ * If bit 0 is 0 then it is a helicopter, otherwise it is a plane
+ * in which case bit 1 tells us whether it's a big(fast) plane or not */
+enum {
+ AIR_HELI = 0,
+ AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes
+ AIR_FAST = 2
+};
+
+struct AircraftVehicleInfo {
+ byte image_index;
+ byte base_cost;
+ byte running_cost;
+ byte subtype;
+ SoundFxByte sfx;
+ byte acceleration;
+ uint16 max_speed;
+ byte mail_capacity;
+ uint16 passenger_capacity;
+};
+
+struct RoadVehicleInfo {
+ byte image_index;
+ byte base_cost;
+ byte running_cost;
+ byte running_cost_class;
+ SoundFxByte sfx;
+ byte max_speed;
+ byte capacity;
+ CargoID cargo_type;
+};
+
+/** Information about a vehicle
+ * @see table/engines.h
+ */
+struct EngineInfo {
+ Date base_intro;
+ Year lifelength;
+ Year base_life;
+ byte unk2; ///< flag for carriage(bit 7) and decay speed(bits0..6)
+ byte load_amount;
+ byte climates;
+ uint32 refit_mask;
+ byte refit_cost;
+ byte misc_flags;
+ byte callbackmask;
+ int8 retire_early; ///< Number of years early to retire vehicle
+ StringID string_id; ///< Default name of engine
+};
+
+struct Engine {
+ char *name; ///< Custom name of engine
+ Date intro_date;
+ Date age;
+ uint16 reliability;
+ uint16 reliability_spd_dec;
+ uint16 reliability_start, reliability_max, reliability_final;
+ uint16 duration_phase_1, duration_phase_2, duration_phase_3;
+ byte lifelength;
+ byte flags;
+ uint8 preview_player_rank;
+ byte preview_wait;
+ byte player_avail;
+ VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
+};
+
+/**
+ * EngineInfo.misc_flags is a bitmask, with the following values
+ */
+enum {
+ EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves
+ EF_ROAD_TRAM = 0, ///< Road vehicle is a tram/light rail vehicle
+ EF_USES_2CC = 1, ///< Vehicle uses two company colours
+ EF_RAIL_IS_MU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU)
+};
+
+/**
+ * Engine.flags is a bitmask, with the following values.
+ */
+enum {
+ ENGINE_AVAILABLE = 1, ///< This vehicle is available to everyone.
+ ENGINE_EXCLUSIVE_PREVIEW = 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a player.
+ ENGINE_OFFER_WINDOW_OPEN = 4, ///< The exclusive offer window is currently open for a player.
+};
+
+enum {
+ NUM_VEHICLE_TYPES = 6
+};
+
+static const EngineID INVALID_ENGINE = 0xFFFF;
+
+enum {
+ NUM_NORMAL_RAIL_ENGINES = 54,
+ NUM_MONORAIL_ENGINES = 30,
+ NUM_MAGLEV_ENGINES = 32,
+ NUM_TRAIN_ENGINES = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES,
+ NUM_ROAD_ENGINES = 88,
+ NUM_SHIP_ENGINES = 11,
+ NUM_AIRCRAFT_ENGINES = 41,
+ TOTAL_NUM_ENGINES = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES + NUM_AIRCRAFT_ENGINES,
+ AIRCRAFT_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES,
+ SHIP_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES,
+ ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES,
+};
+
+#endif /* ENGINE_TYPE_H */
diff --git a/src/openttd.h b/src/openttd.h
index 633f10939..445d95b05 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -10,12 +10,8 @@
// Forward declarations of structs.
typedef byte LandscapeID;
-typedef uint16 EngineID;
typedef uint16 UnitID;
-/* IDs used in Pools */
-typedef uint16 EngineRenewID;
-
enum GameModes {
GM_MENU,
GM_NORMAL,
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 75982b0a7..80de9f4a4 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -21,6 +21,7 @@
#include "cargopacket.h"
#include "texteff.hpp"
#include "group_type.h"
+#include "engine_type.h"
/** Road vehicle states */
enum RoadVehicleStates {
diff --git a/src/vehicle_func.h b/src/vehicle_func.h
index affd3948a..28355dc11 100644
--- a/src/vehicle_func.h
+++ b/src/vehicle_func.h
@@ -12,6 +12,7 @@
#include "cargo_type.h"
#include "command_type.h"
#include "vehicle_type.h"
+#include "engine_type.h"
#define is_custom_sprite(x) (x >= 0xFD)
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index 9c28d1b41..d9e4ff173 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -9,6 +9,7 @@
#include "vehicle_type.h"
#include "order_type.h"
#include "station_type.h"
+#include "engine_type.h"
void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order);