# newgrf_engine.h

Go to the documentation of this file.

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