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

Generated on Fri Jun 3 05:18:54 2011 for OpenTTD by  doxygen 1.6.1