2006-02-03 12:55:21 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file newgrf_engine.h Functions for NewGRF engines. */
|
2007-03-21 03:06:21 +00:00
|
|
|
|
2006-02-03 12:55:21 +00:00
|
|
|
#ifndef NEWGRF_ENGINE_H
|
|
|
|
#define NEWGRF_ENGINE_H
|
|
|
|
|
2007-12-18 19:52:14 +00:00
|
|
|
#include "direction_type.h"
|
2009-06-24 22:38:47 +00:00
|
|
|
#include "newgrf_callbacks.h"
|
2009-09-22 19:28:57 +00:00
|
|
|
#include "newgrf_properties.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "vehicle_type.h"
|
|
|
|
#include "engine_type.h"
|
|
|
|
#include "gfx_type.h"
|
2006-03-08 06:55:33 +00:00
|
|
|
|
2010-05-13 09:44:44 +00:00
|
|
|
static const uint TRAININFO_DEFAULT_VEHICLE_WIDTH = 29;
|
|
|
|
static const uint ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 28;
|
|
|
|
static const uint VEHICLEINFO_FULL_VEHICLE_WIDTH = 32;
|
2006-02-03 12:55:21 +00:00
|
|
|
|
2008-01-05 15:39:22 +00:00
|
|
|
void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains);
|
|
|
|
const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine);
|
2006-04-30 18:19:37 +00:00
|
|
|
void SetCustomEngineSprites(EngineID engine, byte cargo, const struct SpriteGroup *group);
|
2009-01-10 00:31:47 +00:00
|
|
|
SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction direction);
|
2009-05-22 20:03:26 +00:00
|
|
|
SpriteID GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, bool info_view);
|
2006-06-22 21:15:27 +00:00
|
|
|
#define GetCustomRotorSprite(v, i) GetRotorOverrideSprite(v->engine_type, v, i)
|
|
|
|
#define GetCustomRotorIcon(et) GetRotorOverrideSprite(et, NULL, true)
|
2006-04-23 22:25:33 +00:00
|
|
|
|
2006-05-31 17:31:08 +00:00
|
|
|
/* Forward declaration of GRFFile, to avoid unnecessary inclusion of newgrf.h
|
|
|
|
* elsewhere... */
|
|
|
|
struct GRFFile;
|
|
|
|
|
|
|
|
void SetEngineGRF(EngineID engine, const struct GRFFile *file);
|
|
|
|
const struct GRFFile *GetEngineGRF(EngineID engine);
|
2006-04-23 22:25:33 +00:00
|
|
|
uint32 GetEngineGRFID(EngineID engine);
|
|
|
|
|
2007-07-25 19:06:29 +00:00
|
|
|
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v);
|
|
|
|
uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent);
|
2006-02-03 12:55:21 +00:00
|
|
|
bool UsesWagonOverride(const Vehicle *v);
|
|
|
|
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
|
|
|
|
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
|
|
|
|
|
2007-04-18 18:37:40 +00:00
|
|
|
/* Handler to Evaluate callback 36. If the callback fails (i.e. most of the
|
|
|
|
* time) orig_value is returned */
|
2009-09-22 19:28:57 +00:00
|
|
|
uint GetVehicleProperty(const Vehicle *v, PropertyID property, uint orig_value);
|
|
|
|
uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value);
|
2007-04-18 18:37:40 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
enum VehicleTrigger {
|
2007-11-11 12:29:47 +00:00
|
|
|
VEHICLE_TRIGGER_NEW_CARGO = 0x01,
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Externally triggered only for the first vehicle in chain */
|
2007-11-11 12:29:47 +00:00
|
|
|
VEHICLE_TRIGGER_DEPOT = 0x02,
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Externally triggered only for the first vehicle in chain, only if whole chain is empty */
|
2007-11-11 12:29:47 +00:00
|
|
|
VEHICLE_TRIGGER_EMPTY = 0x04,
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Not triggered externally (called for the whole chain if we got NEW_CARGO) */
|
2007-11-11 12:29:47 +00:00
|
|
|
VEHICLE_TRIGGER_ANY_NEW_CARGO = 0x08,
|
2007-10-28 16:00:51 +00:00
|
|
|
/* Externally triggered for each vehicle in chain */
|
2007-11-11 12:29:47 +00:00
|
|
|
VEHICLE_TRIGGER_CALLBACK_32 = 0x10,
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-02-03 12:55:21 +00:00
|
|
|
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
|
|
|
|
|
2008-04-29 21:31:29 +00:00
|
|
|
void UnloadWagonOverrides(Engine *e);
|
2006-02-03 12:55:21 +00:00
|
|
|
|
2008-04-29 21:31:29 +00:00
|
|
|
uint ListPositionOfEngine(EngineID engine);
|
2008-07-20 21:23:28 +00:00
|
|
|
void AlterVehicleListOrder(EngineID engine, EngineID target);
|
|
|
|
void CommitVehicleListOrderChanges();
|
2006-02-04 21:48:46 +00:00
|
|
|
|
2008-04-30 17:42:08 +00:00
|
|
|
EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id);
|
|
|
|
|
2006-02-03 12:55:21 +00:00
|
|
|
#endif /* NEWGRF_ENGINE_H */
|