Translations update
[openttd/fttd.git] / src / newgrf_engine.h
blob6bb6327b757f08ad3fa8db8b33d16622d34650ca
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file newgrf_engine.h Functions for NewGRF engines. */
12 #ifndef NEWGRF_ENGINE_H
13 #define NEWGRF_ENGINE_H
15 #include "direction_type.h"
16 #include "newgrf_callbacks.h"
17 #include "newgrf_properties.h"
18 #include "vehicle_type.h"
19 #include "engine_type.h"
20 #include "gfx_type.h"
21 #include "newgrf_spritegroup.h"
23 /** Resolver for a vehicle scope. */
24 struct VehicleScopeResolver : public ScopeResolver {
25 ResolverObject &ro; ///< Surrounding resolver object.
27 const struct Vehicle *v; ///< The vehicle being resolved.
28 EngineID self_type; ///< Type of the vehicle.
29 bool info_view; ///< Indicates if the item is being drawn in an info window.
31 VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool info_view);
33 void SetVehicle(const Vehicle *v) { this->v = v; }
35 /* virtual */ uint32 GetRandomBits() const;
36 /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
37 /* virtual */ uint32 GetTriggers() const;
38 /* virtual */ void SetTriggers(int triggers) const;
41 /** Resolver for a vehicle (chain) */
42 struct VehicleResolverObject : public ResolverObject {
43 VehicleScopeResolver self_scope; ///< Scope resolver for the indicated vehicle.
44 VehicleScopeResolver parent_scope; ///< Scope resolver for its parent vehicle.
46 VehicleScopeResolver relative_scope; ///< Scope resolver for an other vehicle in the chain.
47 byte cached_relative_count; ///< Relative position of the other vehicle.
49 VehicleResolverObject (EngineID engine_type, const Vehicle *v, bool info_view = false,
50 CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
52 /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0);
54 /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
57 static const uint TRAININFO_DEFAULT_VEHICLE_WIDTH = 29;
58 static const uint ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 32;
59 static const uint VEHICLEINFO_FULL_VEHICLE_WIDTH = 32;
61 struct VehicleSpriteSeq;
63 void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains);
64 const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine);
65 void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group);
67 void GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction, EngineImageType image_type, VehicleSpriteSeq *result);
68 #define GetCustomVehicleSprite(v, direction, image_type, result) GetCustomEngineSprite(v->engine_type, v, direction, image_type, result)
69 #define GetCustomVehicleIcon(et, direction, image_type, result) GetCustomEngineSprite(et, NULL, direction, image_type, result)
71 void GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, bool info_view, EngineImageType image_type, VehicleSpriteSeq *result);
72 #define GetCustomRotorSprite(v, i, image_type, result) GetRotorOverrideSprite(v->engine_type, v, i, image_type, result)
73 #define GetCustomRotorIcon(et, image_type, result) GetRotorOverrideSprite(et, NULL, true, image_type, result)
75 /* Forward declaration of GRFFile, to avoid unnecessary inclusion of newgrf.h
76 * elsewhere... */
77 struct GRFFile;
79 void SetEngineGRF(EngineID engine, const struct GRFFile *file);
81 uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v);
82 uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent);
83 bool UsesWagonOverride(const Vehicle *v);
85 /* Handler to Evaluate callback 36. If the callback fails (i.e. most of the
86 * time) orig_value is returned */
87 uint GetVehicleProperty(const Vehicle *v, PropertyID property, uint orig_value);
88 uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value, const Vehicle *v = NULL);
90 enum VehicleTrigger {
91 VEHICLE_TRIGGER_NEW_CARGO = 0x01,
92 /* Externally triggered only for the first vehicle in chain */
93 VEHICLE_TRIGGER_DEPOT = 0x02,
94 /* Externally triggered only for the first vehicle in chain, only if whole chain is empty */
95 VEHICLE_TRIGGER_EMPTY = 0x04,
96 /* Not triggered externally (called for the whole chain if we got NEW_CARGO) */
97 VEHICLE_TRIGGER_ANY_NEW_CARGO = 0x08,
98 /* Externally triggered for each vehicle in chain */
99 VEHICLE_TRIGGER_CALLBACK_32 = 0x10,
101 void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
103 void UnloadWagonOverrides(Engine *e);
105 void AlterVehicleListOrder(EngineID engine, uint target);
106 void CommitVehicleListOrderChanges();
108 EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id);
110 #endif /* NEWGRF_ENGINE_H */