src/newgrf_engine.h
author peter1138
Wed, 30 Apr 2008 17:42:08 +0000
changeset 10390 8978442f5705
parent 10382 d1d4452acbfc
child 10429 1b99254f9607
permissions -rw-r--r--
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2129
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2129
diff changeset
     2
6674
64f4781b4653 (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6574
diff changeset
     3
/** @file newgrf_engine.h */
64f4781b4653 (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6574
diff changeset
     4
2962
dbd168a4703a (svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents: 2848
diff changeset
     5
#ifndef NEWGRF_ENGINE_H
dbd168a4703a (svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents: 2848
diff changeset
     6
#define NEWGRF_ENGINE_H
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
4656
acffecd6f484 (svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents: 4344
diff changeset
     8
#include "newgrf.h"
8596
27646407e0bc (svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies.
rubidium
parents: 8352
diff changeset
     9
#include "direction_type.h"
3866
113de2b20059 (svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents: 3845
diff changeset
    10
#include "newgrf_cargo.h"
3157
40de8616c04c (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 2982
diff changeset
    11
3785
1becd6b333fe (svn r4781) - NewGRF: give _traininfo_vehicle_pitch a proper declaration
peter1138
parents: 3726
diff changeset
    12
extern int _traininfo_vehicle_pitch;
3845
c3cd4b825c2f (svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents: 3785
diff changeset
    13
extern int _traininfo_vehicle_width;
3785
1becd6b333fe (svn r4781) - NewGRF: give _traininfo_vehicle_pitch a proper declaration
peter1138
parents: 3726
diff changeset
    14
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
8694
8b6828a78860 (svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents: 8596
diff changeset
    16
void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains);
8b6828a78860 (svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents: 8596
diff changeset
    17
const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine);
3693
af2ee9b328e6 (svn r4629) - NewGRF: constify more code that deals with sprite groups, now that ref counting is gone.
peter1138
parents: 3684
diff changeset
    18
void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group);
3684
c5dfac322f16 (svn r4609) - NewGRF: give GetCustomEngineSprite the correct return type
peter1138
parents: 3648
diff changeset
    19
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle* v, Direction direction);
4056
30ceffc75059 (svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents: 3924
diff changeset
    20
SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle* v, bool info_view);
30ceffc75059 (svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents: 3924
diff changeset
    21
#define GetCustomRotorSprite(v, i) GetRotorOverrideSprite(v->engine_type, v, i)
30ceffc75059 (svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents: 3924
diff changeset
    22
#define GetCustomRotorIcon(et) GetRotorOverrideSprite(et, NULL, true)
3648
1574c89384cb (svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents: 3604
diff changeset
    23
3924
de86db4fbd1e (svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents: 3866
diff changeset
    24
/* Forward declaration of GRFFile, to avoid unnecessary inclusion of newgrf.h
de86db4fbd1e (svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents: 3866
diff changeset
    25
 * elsewhere... */
de86db4fbd1e (svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents: 3866
diff changeset
    26
struct GRFFile;
de86db4fbd1e (svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents: 3866
diff changeset
    27
de86db4fbd1e (svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents: 3866
diff changeset
    28
void SetEngineGRF(EngineID engine, const struct GRFFile *file);
de86db4fbd1e (svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
peter1138
parents: 3866
diff changeset
    29
const struct GRFFile *GetEngineGRF(EngineID engine);
3648
1574c89384cb (svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents: 3604
diff changeset
    30
uint32 GetEngineGRFID(EngineID engine);
1574c89384cb (svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
peter1138
parents: 3604
diff changeset
    31
7823
cad4dec2b899 (svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium
parents: 7099
diff changeset
    32
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v);
cad4dec2b899 (svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium
parents: 7099
diff changeset
    33
uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent);
1908
bc48a30aba72 (svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents: 1895
diff changeset
    34
bool UsesWagonOverride(const Vehicle *v);
414
e18cc252e2ea (svn r611) -newgrf: Change GetCustomEngineSprite() calling convention (invisible to users of GetCustomVehicle*() wrappers). Needed for deterministic spritegroups support (pasky).
darkvater
parents: 405
diff changeset
    35
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
e18cc252e2ea (svn r611) -newgrf: Change GetCustomEngineSprite() calling convention (invisible to users of GetCustomVehicle*() wrappers). Needed for deterministic spritegroups support (pasky).
darkvater
parents: 405
diff changeset
    36
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
6986
168d3add1f13 (svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents: 6674
diff changeset
    38
/* Handler to Evaluate callback 36. If the callback fails (i.e. most of the
168d3add1f13 (svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents: 6674
diff changeset
    39
 * time) orig_value is returned */
168d3add1f13 (svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents: 6674
diff changeset
    40
uint GetVehicleProperty(const Vehicle *v, uint8 property, uint orig_value);
7013
fb8489ae2770 (svn r9703) -Codechange: support callback 36 in vehicle purchase lists
peter1138
parents: 6986
diff changeset
    41
uint GetEngineProperty(EngineID engine, uint8 property, uint orig_value);
6986
168d3add1f13 (svn r9671) -Codechange: Implement NewGRF callback 36, which allows changing of various properties which were previously static. Vehicle max speed and train power/te/running costs are adjustable.
peter1138
parents: 6674
diff changeset
    42
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    43
enum VehicleTrigger {
8352
6d228e6f39e4 (svn r11406) -Fix: wrong triggers would be activated on callback 32 for vehicles.
rubidium
parents: 8299
diff changeset
    44
	VEHICLE_TRIGGER_NEW_CARGO     = 0x01,
6674
64f4781b4653 (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6574
diff changeset
    45
	/* Externally triggered only for the first vehicle in chain */
8352
6d228e6f39e4 (svn r11406) -Fix: wrong triggers would be activated on callback 32 for vehicles.
rubidium
parents: 8299
diff changeset
    46
	VEHICLE_TRIGGER_DEPOT         = 0x02,
6674
64f4781b4653 (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6574
diff changeset
    47
	/* Externally triggered only for the first vehicle in chain, only if whole chain is empty */
8352
6d228e6f39e4 (svn r11406) -Fix: wrong triggers would be activated on callback 32 for vehicles.
rubidium
parents: 8299
diff changeset
    48
	VEHICLE_TRIGGER_EMPTY         = 0x04,
6674
64f4781b4653 (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6574
diff changeset
    49
	/* Not triggered externally (called for the whole chain if we got NEW_CARGO) */
8352
6d228e6f39e4 (svn r11406) -Fix: wrong triggers would be activated on callback 32 for vehicles.
rubidium
parents: 8299
diff changeset
    50
	VEHICLE_TRIGGER_ANY_NEW_CARGO = 0x08,
8299
d5c112dc0726 (svn r11353) -Codechange: add support for newgrf callback 32
glx
parents: 7823
diff changeset
    51
	/* Externally triggered for each vehicle in chain */
8352
6d228e6f39e4 (svn r11406) -Fix: wrong triggers would be activated on callback 32 for vehicles.
rubidium
parents: 8299
diff changeset
    52
	VEHICLE_TRIGGER_CALLBACK_32   = 0x10,
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    53
};
1477
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1475
diff changeset
    54
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
445
0e3fa3da3899 (svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents: 414
diff changeset
    55
10382
d1d4452acbfc (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents: 10331
diff changeset
    56
void UnloadWagonOverrides(Engine *e);
2491
dfe9542f783e (svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents: 2477
diff changeset
    57
10382
d1d4452acbfc (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents: 10331
diff changeset
    58
uint ListPositionOfEngine(EngineID engine);
2971
9b62397dbd56 (svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents: 2962
diff changeset
    59
void AlterRailVehListOrder(EngineID engine, EngineID target);
10382
d1d4452acbfc (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents: 10331
diff changeset
    60
void CommitRailVehListOrderChanges();
2971
9b62397dbd56 (svn r3546) - NewGRF feature: Implement rail vehicle 'property' 0x1A: allows shuffling order of rail vehicle purchase list (and replace vehicle list)
peter1138
parents: 2962
diff changeset
    61
10390
8978442f5705 (svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents: 10382
diff changeset
    62
EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id);
8978442f5705 (svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents: 10382
diff changeset
    63
2962
dbd168a4703a (svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents: 2848
diff changeset
    64
#endif /* NEWGRF_ENGINE_H */