summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2004-12-28 17:18:46 +0000
committerbjarni <bjarni@openttd.org>2004-12-28 17:18:46 +0000
commitc4d073a4dedb9c8eca7b25a226703833b04c0266 (patch)
treecf66d4d813a26e378cfc675dff16f4bed5680147
parent5b8c604f47d4f8a121d9d87ea586e54ecf23ec41 (diff)
downloadopenttd-c4d073a4dedb9c8eca7b25a226703833b04c0266.tar.xz
(svn r1290) Added type to typedef struct Engine and filled in the same data as in type in vehicle
it was kind of lame that you should use AircraftVehInfo(), ShipVehInfo() etc. if you wanted to know what type the engine is
-rw-r--r--engine.c23
-rw-r--r--engine.h1
2 files changed, 22 insertions, 2 deletions
diff --git a/engine.c b/engine.c
index 951d5f77c..7286e0c80 100644
--- a/engine.c
+++ b/engine.c
@@ -119,12 +119,12 @@ void StartupEngines()
{
Engine *e;
const EngineInfo *ei;
- uint32 r;
+ uint32 r, counter = 0;
SetupEngineNames();
- for(e=_engines, ei=_engine_info; e != endof(_engines); e++,ei++) {
+ for(e=_engines, ei=_engine_info; e != endof(_engines); e++, ei++, counter++) {
e->age = 0;
e->railtype = ei->railtype_climates >> 4;
e->flags = 0;
@@ -164,6 +164,25 @@ void StartupEngines()
e->flags |= ENGINE_AVAILABLE;
e->player_avail = 0;
}
+
+ /* This sets up type for the engine
+ It is needed if you want to ask the engine what type it is
+ It should hopefully be the same as when you ask a vehicle what it is
+ but using this, you can ask what type an engine number is
+ even if it is not a vehicle (yet)*/
+ e->type = VEH_Train;
+ if (counter >= ROAD_ENGINES_INDEX) {
+ e->type = VEH_Road;
+ if (counter >= SHIP_ENGINES_INDEX) {
+ e->type = VEH_Ship;
+ if (counter >= AIRCRAFT_ENGINES_INDEX) {
+ e->type = VEH_Aircraft;
+ if (counter >= TOTAL_NUM_ENGINES) {
+ e->type = VEH_Special;
+ }
+ }
+ }
+ }
}
AdjustAvailAircraft();
diff --git a/engine.h b/engine.h
index 56b7d9572..7ed1fe6c5 100644
--- a/engine.h
+++ b/engine.h
@@ -70,6 +70,7 @@ typedef struct Engine {
byte preview_wait;
byte railtype;
byte player_avail;
+ byte type; // type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h
} Engine;