newgrf_engine.h

Go to the documentation of this file.
00001 /* $Id$ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef NEWGRF_ENGINE_H
00013 #define NEWGRF_ENGINE_H
00014 
00015 #include "direction_type.h"
00016 #include "newgrf_callbacks.h"
00017 #include "newgrf_properties.h"
00018 
00019 enum {
00020   TRAININFO_DEFAULT_VEHICLE_WIDTH = 29,
00021   ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 28,
00022   VEHICLEINFO_FULL_VEHICLE_WIDTH = 32,
00023 };
00024 
00025 void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains);
00026 const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine);
00027 void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group);
00028 SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction);
00029 SpriteID GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, bool info_view);
00030 #define GetCustomRotorSprite(v, i) GetRotorOverrideSprite(v->engine_type, v, i)
00031 #define GetCustomRotorIcon(et) GetRotorOverrideSprite(et, NULL, true)
00032 
00033 /* Forward declaration of GRFFile, to avoid unnecessary inclusion of newgrf.h
00034  * elsewhere... */
00035 struct GRFFile;
00036 
00037 void SetEngineGRF(EngineID engine, const struct GRFFile *file);
00038 const struct GRFFile *GetEngineGRF(EngineID engine);
00039 uint32 GetEngineGRFID(EngineID engine);
00040 
00041 uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v);
00042 uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent);
00043 bool UsesWagonOverride(const Vehicle *v);
00044 #define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
00045 #define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
00046 
00047 /* Handler to Evaluate callback 36. If the callback fails (i.e. most of the
00048  * time) orig_value is returned */
00049 uint GetVehicleProperty(const Vehicle *v, PropertyID property, uint orig_value);
00050 uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value);
00051 
00052 enum VehicleTrigger {
00053   VEHICLE_TRIGGER_NEW_CARGO     = 0x01,
00054   /* Externally triggered only for the first vehicle in chain */
00055   VEHICLE_TRIGGER_DEPOT         = 0x02,
00056   /* Externally triggered only for the first vehicle in chain, only if whole chain is empty */
00057   VEHICLE_TRIGGER_EMPTY         = 0x04,
00058   /* Not triggered externally (called for the whole chain if we got NEW_CARGO) */
00059   VEHICLE_TRIGGER_ANY_NEW_CARGO = 0x08,
00060   /* Externally triggered for each vehicle in chain */
00061   VEHICLE_TRIGGER_CALLBACK_32   = 0x10,
00062 };
00063 void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
00064 
00065 void UnloadWagonOverrides(Engine *e);
00066 
00067 uint ListPositionOfEngine(EngineID engine);
00068 void AlterVehicleListOrder(EngineID engine, EngineID target);
00069 void CommitVehicleListOrderChanges();
00070 
00071 EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id);
00072 
00073 #endif /* NEWGRF_ENGINE_H */

Generated on Wed Dec 30 20:40:04 2009 for OpenTTD by  doxygen 1.5.6