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/>.
|
|
|
|
*/
|
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* @file newgrf_commons.h This file simplyfies and embeds a common mechanism of
|
2007-05-15 21:36:58 +00:00
|
|
|
* loading/saving and mapping of grf entities.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NEWGRF_COMMONS_H
|
|
|
|
#define NEWGRF_COMMONS_H
|
|
|
|
|
2011-05-14 17:25:45 +00:00
|
|
|
#include "sprite.h"
|
|
|
|
#include "core/alloc_type.hpp"
|
2011-07-11 16:32:19 +00:00
|
|
|
#include "command_type.h"
|
2011-07-11 16:32:35 +00:00
|
|
|
#include "direction_type.h"
|
2011-08-27 08:42:24 +00:00
|
|
|
#include "company_type.h"
|
2023-07-03 22:34:52 +00:00
|
|
|
#include <vector>
|
2008-11-22 16:04:11 +00:00
|
|
|
|
2011-05-14 17:25:45 +00:00
|
|
|
/** Context for tile accesses */
|
2024-01-07 16:41:53 +00:00
|
|
|
enum TileContext : uint8_t {
|
2010-08-09 10:59:30 +00:00
|
|
|
TCX_NORMAL, ///< Nothing special.
|
|
|
|
TCX_UPPER_HALFTILE, ///< Querying information about the upper part of a tile with halftile foundation.
|
|
|
|
TCX_ON_BRIDGE, ///< Querying information about stuff on the bridge (via some bridgehead).
|
2010-08-09 07:10:42 +00:00
|
|
|
};
|
|
|
|
|
2011-05-29 16:56:22 +00:00
|
|
|
/**
|
|
|
|
* Flags to enable register usage in sprite layouts.
|
|
|
|
*/
|
2024-01-23 19:19:31 +00:00
|
|
|
enum TileLayoutFlags : uint16_t {
|
2011-05-29 16:56:22 +00:00
|
|
|
TLF_NOTHING = 0x00,
|
|
|
|
|
|
|
|
TLF_DODRAW = 0x01, ///< Only draw sprite if value of register TileLayoutRegisters::dodraw is non-zero.
|
|
|
|
TLF_SPRITE = 0x02, ///< Add signed offset to sprite from register TileLayoutRegisters::sprite.
|
|
|
|
TLF_PALETTE = 0x04, ///< Add signed offset to palette from register TileLayoutRegisters::palette.
|
|
|
|
TLF_CUSTOM_PALETTE = 0x08, ///< Palette is from Action 1 (moved to SPRITE_MODIFIER_CUSTOM_SPRITE in palette during loading).
|
|
|
|
|
|
|
|
TLF_BB_XY_OFFSET = 0x10, ///< Add signed offset to bounding box X and Y positions from register TileLayoutRegisters::delta.parent[0..1].
|
|
|
|
TLF_BB_Z_OFFSET = 0x20, ///< Add signed offset to bounding box Z positions from register TileLayoutRegisters::delta.parent[2].
|
|
|
|
|
|
|
|
TLF_CHILD_X_OFFSET = 0x10, ///< Add signed offset to child sprite X positions from register TileLayoutRegisters::delta.child[0].
|
|
|
|
TLF_CHILD_Y_OFFSET = 0x20, ///< Add signed offset to child sprite Y positions from register TileLayoutRegisters::delta.child[1].
|
|
|
|
|
|
|
|
TLF_SPRITE_VAR10 = 0x40, ///< Resolve sprite with a specific value in variable 10.
|
|
|
|
TLF_PALETTE_VAR10 = 0x80, ///< Resolve palette with a specific value in variable 10.
|
|
|
|
|
2016-04-02 16:02:22 +00:00
|
|
|
TLF_KNOWN_FLAGS = 0xFF, ///< Known flags. Any unknown set flag will disable the GRF.
|
2011-05-29 16:56:22 +00:00
|
|
|
|
|
|
|
/** Flags which are still required after loading the GRF. */
|
2024-01-23 19:19:31 +00:00
|
|
|
TLF_DRAWING_FLAGS = (uint16_t)~TLF_CUSTOM_PALETTE,
|
2011-05-29 16:56:22 +00:00
|
|
|
|
|
|
|
/** Flags which do not work for the (first) ground sprite. */
|
|
|
|
TLF_NON_GROUND_FLAGS = TLF_BB_XY_OFFSET | TLF_BB_Z_OFFSET | TLF_CHILD_X_OFFSET | TLF_CHILD_Y_OFFSET,
|
|
|
|
|
|
|
|
/** Flags which refer to using multiple action-1-2-3 chains. */
|
|
|
|
TLF_VAR10_FLAGS = TLF_SPRITE_VAR10 | TLF_PALETTE_VAR10,
|
|
|
|
|
|
|
|
/** Flags which require resolving the action-1-2-3 chain for the sprite, even if it is no action-1 sprite. */
|
|
|
|
TLF_SPRITE_REG_FLAGS = TLF_DODRAW | TLF_SPRITE | TLF_BB_XY_OFFSET | TLF_BB_Z_OFFSET | TLF_CHILD_X_OFFSET | TLF_CHILD_Y_OFFSET,
|
|
|
|
|
|
|
|
/** Flags which require resolving the action-1-2-3 chain for the palette, even if it is no action-1 palette. */
|
|
|
|
TLF_PALETTE_REG_FLAGS = TLF_PALETTE,
|
|
|
|
};
|
|
|
|
DECLARE_ENUM_AS_BIT_SET(TileLayoutFlags)
|
|
|
|
|
2011-09-11 15:09:13 +00:00
|
|
|
/**
|
|
|
|
* Determines which sprite to use from a spriteset for a specific construction stage.
|
|
|
|
* @param construction_stage Construction stage 0 - 3.
|
|
|
|
* @param num_sprites Number of available sprites to select stage from.
|
|
|
|
* @return Sprite to use
|
|
|
|
*/
|
2024-01-06 11:19:27 +00:00
|
|
|
inline uint GetConstructionStageOffset(uint construction_stage, uint num_sprites)
|
2011-09-11 15:09:13 +00:00
|
|
|
{
|
|
|
|
assert(num_sprites > 0);
|
|
|
|
if (num_sprites > 4) num_sprites = 4;
|
|
|
|
switch (construction_stage) {
|
|
|
|
case 0: return 0;
|
|
|
|
case 1: return num_sprites > 2 ? 1 : 0;
|
|
|
|
case 2: return num_sprites > 2 ? num_sprites - 2 : 0;
|
|
|
|
case 3: return num_sprites - 1;
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-29 16:56:22 +00:00
|
|
|
/**
|
|
|
|
* Additional modifiers for items in sprite layouts.
|
|
|
|
*/
|
|
|
|
struct TileLayoutRegisters {
|
2024-01-07 16:41:53 +00:00
|
|
|
TileLayoutFlags flags; ///< Flags defining which members are valid and to be used.
|
2024-01-23 19:19:31 +00:00
|
|
|
uint16_t max_sprite_offset; ///< Maximum offset to add to the sprite. (limited by size of the spriteset)
|
|
|
|
uint16_t max_palette_offset; ///< Maximum offset to add to the palette. (limited by size of the spriteset)
|
2024-01-07 16:41:53 +00:00
|
|
|
uint8_t dodraw; ///< Register deciding whether the sprite shall be drawn at all. Non-zero means drawing.
|
|
|
|
uint8_t sprite; ///< Register specifying a signed offset for the sprite.
|
|
|
|
uint8_t palette; ///< Register specifying a signed offset for the palette.
|
2011-05-29 16:56:22 +00:00
|
|
|
union {
|
2024-01-07 16:41:53 +00:00
|
|
|
uint8_t parent[3]; ///< Registers for signed offsets for the bounding box position of parent sprites.
|
|
|
|
uint8_t child[2]; ///< Registers for signed offsets for the position of child sprites.
|
2011-05-29 16:56:22 +00:00
|
|
|
} delta;
|
2024-01-07 16:41:53 +00:00
|
|
|
uint8_t sprite_var10; ///< Value for variable 10 when resolving the sprite.
|
|
|
|
uint8_t palette_var10; ///< Value for variable 10 when resolving the palette.
|
2011-05-29 16:56:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const uint TLR_MAX_VAR10 = 7; ///< Maximum value for var 10.
|
|
|
|
|
2011-05-14 17:25:45 +00:00
|
|
|
/**
|
|
|
|
* NewGRF supplied spritelayout.
|
|
|
|
* In contrast to #DrawTileSprites this struct is for allocated
|
|
|
|
* layouts on the heap. It allocates data and frees them on destruction.
|
|
|
|
*/
|
|
|
|
struct NewGRFSpriteLayout : ZeroedMemoryAllocator, DrawTileSprites {
|
2011-05-29 16:56:22 +00:00
|
|
|
const TileLayoutRegisters *registers;
|
|
|
|
|
2011-09-11 15:10:09 +00:00
|
|
|
/**
|
|
|
|
* Number of sprites in all referenced spritesets.
|
|
|
|
* If these numbers are inconsistent, then this is 0 and the real values are in \c registers.
|
|
|
|
*/
|
|
|
|
uint consistent_max_offset;
|
|
|
|
|
2011-05-14 17:25:45 +00:00
|
|
|
void Allocate(uint num_sprites);
|
2011-05-29 16:56:22 +00:00
|
|
|
void AllocateRegisters();
|
2011-05-14 17:25:45 +00:00
|
|
|
void Clone(const DrawTileSeqStruct *source);
|
2011-05-29 16:56:22 +00:00
|
|
|
void Clone(const NewGRFSpriteLayout *source);
|
2011-05-14 17:25:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clone a spritelayout.
|
|
|
|
* @param source The spritelayout to copy.
|
|
|
|
*/
|
|
|
|
void Clone(const DrawTileSprites *source)
|
|
|
|
{
|
2019-04-10 21:07:06 +00:00
|
|
|
assert(source != nullptr && this != source);
|
2011-05-14 17:25:45 +00:00
|
|
|
this->ground = source->ground;
|
|
|
|
this->Clone(source->seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~NewGRFSpriteLayout()
|
|
|
|
{
|
2011-11-12 13:00:29 +00:00
|
|
|
free(this->seq);
|
|
|
|
free(this->registers);
|
2011-05-29 16:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests whether this spritelayout needs preprocessing by
|
|
|
|
* #PrepareLayout() and #ProcessRegisters(), or whether it can be
|
|
|
|
* used directly.
|
|
|
|
* @return true if preprocessing is needed
|
|
|
|
*/
|
|
|
|
bool NeedsPreprocessing() const
|
|
|
|
{
|
2019-04-10 21:07:06 +00:00
|
|
|
return this->registers != nullptr;
|
2011-05-29 16:56:22 +00:00
|
|
|
}
|
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint32_t PrepareLayout(uint32_t orig_offset, uint32_t newgrf_ground_offset, uint32_t newgrf_offset, uint constr_stage, bool separate_ground) const;
|
|
|
|
void ProcessRegisters(uint8_t resolved_var10, uint32_t resolved_sprite, bool separate_ground) const;
|
2011-05-29 16:56:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the result spritelayout after preprocessing.
|
|
|
|
* @pre #PrepareLayout() and #ProcessRegisters() need calling first.
|
|
|
|
* @return result spritelayout
|
|
|
|
*/
|
|
|
|
const DrawTileSeqStruct *GetLayout(PalSpriteID *ground) const
|
|
|
|
{
|
2019-02-17 11:20:52 +00:00
|
|
|
DrawTileSeqStruct *front = result_seq.data();
|
2011-05-29 16:56:22 +00:00
|
|
|
*ground = front->image;
|
|
|
|
return front + 1;
|
2011-05-14 17:25:45 +00:00
|
|
|
}
|
2011-05-29 16:56:22 +00:00
|
|
|
|
|
|
|
private:
|
2019-03-03 17:30:09 +00:00
|
|
|
static std::vector<DrawTileSeqStruct> result_seq; ///< Temporary storage when preprocessing spritelayouts.
|
2011-05-14 17:25:45 +00:00
|
|
|
};
|
|
|
|
|
2007-05-15 21:36:58 +00:00
|
|
|
/**
|
|
|
|
* Maps an entity id stored on the map to a GRF file.
|
|
|
|
* Entities are objects used ingame (houses, industries, industry tiles) for
|
|
|
|
* which we need to correlate the ids from the grf files with the ones in the
|
|
|
|
* the savegames themselves.
|
|
|
|
* An array of EntityIDMapping structs is saved with the savegame so
|
|
|
|
* that those GRFs can be loaded in a different order, or removed safely. The
|
|
|
|
* index in the array is the entity's ID stored on the map.
|
|
|
|
*
|
|
|
|
* The substitute ID is the ID of an original entity that should be used instead
|
|
|
|
* if the GRF containing the new entity is not available.
|
|
|
|
*/
|
|
|
|
struct EntityIDMapping {
|
2024-01-07 16:41:53 +00:00
|
|
|
uint32_t grfid; ///< The GRF ID of the file the entity belongs to
|
|
|
|
uint16_t entity_id; ///< The entity ID within the GRF file
|
|
|
|
uint16_t substitute_id; ///< The (original) entity ID to use if this GRF is not available
|
2007-05-15 21:36:58 +00:00
|
|
|
};
|
|
|
|
|
2007-07-25 17:18:13 +00:00
|
|
|
class OverrideManagerBase {
|
2007-05-15 21:36:58 +00:00
|
|
|
protected:
|
2024-01-07 16:41:53 +00:00
|
|
|
std::vector<uint16_t> entity_overrides;
|
|
|
|
std::vector<uint32_t> grfid_overrides;
|
2007-05-15 21:36:58 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint16_t max_offset; ///< what is the length of the original entity's array of specs
|
|
|
|
uint16_t max_entities; ///< what is the amount of entities, old and new summed
|
2007-05-15 21:36:58 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint16_t invalid_id; ///< ID used to detected invalid entities
|
|
|
|
virtual bool CheckValidNewID(uint16_t testid) { return true; }
|
2007-05-15 21:36:58 +00:00
|
|
|
|
|
|
|
public:
|
2023-01-22 17:20:23 +00:00
|
|
|
std::vector<EntityIDMapping> mappings; ///< mapping of ids from grf files. Public out of convenience
|
2007-05-15 21:36:58 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
OverrideManagerBase(uint16_t offset, uint16_t maximum, uint16_t invalid);
|
2023-05-14 21:31:03 +00:00
|
|
|
virtual ~OverrideManagerBase() = default;
|
2007-05-15 21:36:58 +00:00
|
|
|
|
|
|
|
void ResetOverride();
|
|
|
|
void ResetMapping();
|
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
void Add(uint16_t local_id, uint32_t grfid, uint entity_type);
|
|
|
|
virtual uint16_t AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id);
|
2007-05-15 21:36:58 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint32_t GetGRFID(uint16_t entity_id) const;
|
|
|
|
uint16_t GetSubstituteID(uint16_t entity_id) const;
|
|
|
|
virtual uint16_t GetID(uint16_t grf_local_id, uint32_t grfid) const;
|
2007-05-15 21:36:58 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
inline uint16_t GetMaxMapping() const { return this->max_entities; }
|
|
|
|
inline uint16_t GetMaxOffset() const { return this->max_offset; }
|
2007-05-15 21:36:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct HouseSpec;
|
2007-07-25 17:18:13 +00:00
|
|
|
class HouseOverrideManager : public OverrideManagerBase {
|
2007-05-15 21:36:58 +00:00
|
|
|
public:
|
2024-01-07 16:41:53 +00:00
|
|
|
HouseOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) :
|
2007-07-25 17:18:13 +00:00
|
|
|
OverrideManagerBase(offset, maximum, invalid) {}
|
2019-03-24 16:23:46 +00:00
|
|
|
|
2007-05-15 21:36:58 +00:00
|
|
|
void SetEntitySpec(const HouseSpec *hs);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-06-09 02:05:51 +00:00
|
|
|
struct IndustrySpec;
|
2007-07-25 17:18:13 +00:00
|
|
|
class IndustryOverrideManager : public OverrideManagerBase {
|
|
|
|
public:
|
2024-01-07 16:41:53 +00:00
|
|
|
IndustryOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) :
|
2007-07-25 17:18:13 +00:00
|
|
|
OverrideManagerBase(offset, maximum, invalid) {}
|
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint16_t AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id) override;
|
|
|
|
uint16_t GetID(uint16_t grf_local_id, uint32_t grfid) const override;
|
2019-03-24 16:23:46 +00:00
|
|
|
|
2007-10-04 00:59:52 +00:00
|
|
|
void SetEntitySpec(IndustrySpec *inds);
|
2007-06-09 02:05:51 +00:00
|
|
|
};
|
|
|
|
|
2007-06-21 17:09:10 +00:00
|
|
|
|
|
|
|
struct IndustryTileSpec;
|
2007-07-25 17:18:13 +00:00
|
|
|
class IndustryTileOverrideManager : public OverrideManagerBase {
|
2007-09-26 02:15:00 +00:00
|
|
|
protected:
|
2023-04-13 06:23:18 +00:00
|
|
|
bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; }
|
2007-07-25 17:18:13 +00:00
|
|
|
public:
|
2024-01-07 16:41:53 +00:00
|
|
|
IndustryTileOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) :
|
2007-07-25 17:18:13 +00:00
|
|
|
OverrideManagerBase(offset, maximum, invalid) {}
|
|
|
|
|
|
|
|
void SetEntitySpec(const IndustryTileSpec *indts);
|
2007-06-21 17:09:10 +00:00
|
|
|
};
|
|
|
|
|
2010-03-18 23:12:38 +00:00
|
|
|
struct AirportSpec;
|
|
|
|
class AirportOverrideManager : public OverrideManagerBase {
|
|
|
|
public:
|
2024-01-07 16:41:53 +00:00
|
|
|
AirportOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) :
|
2010-03-18 23:12:38 +00:00
|
|
|
OverrideManagerBase(offset, maximum, invalid) {}
|
|
|
|
|
|
|
|
void SetEntitySpec(AirportSpec *inds);
|
|
|
|
};
|
|
|
|
|
2010-02-22 14:15:48 +00:00
|
|
|
struct AirportTileSpec;
|
|
|
|
class AirportTileOverrideManager : public OverrideManagerBase {
|
|
|
|
protected:
|
2023-04-13 06:23:18 +00:00
|
|
|
bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; }
|
2010-02-22 14:15:48 +00:00
|
|
|
public:
|
2024-01-07 16:41:53 +00:00
|
|
|
AirportTileOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) :
|
2010-02-22 14:15:48 +00:00
|
|
|
OverrideManagerBase(offset, maximum, invalid) {}
|
|
|
|
|
|
|
|
void SetEntitySpec(const AirportTileSpec *ats);
|
|
|
|
};
|
|
|
|
|
2010-08-28 17:30:55 +00:00
|
|
|
struct ObjectSpec;
|
|
|
|
class ObjectOverrideManager : public OverrideManagerBase {
|
|
|
|
protected:
|
2023-04-13 06:23:18 +00:00
|
|
|
bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; }
|
2010-08-28 17:30:55 +00:00
|
|
|
public:
|
2024-01-07 16:41:53 +00:00
|
|
|
ObjectOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) :
|
2010-08-28 17:30:55 +00:00
|
|
|
OverrideManagerBase(offset, maximum, invalid) {}
|
|
|
|
|
|
|
|
void SetEntitySpec(ObjectSpec *spec);
|
|
|
|
};
|
|
|
|
|
2007-05-15 21:36:58 +00:00
|
|
|
extern HouseOverrideManager _house_mngr;
|
2007-06-09 02:05:51 +00:00
|
|
|
extern IndustryOverrideManager _industry_mngr;
|
2007-06-21 17:09:10 +00:00
|
|
|
extern IndustryTileOverrideManager _industile_mngr;
|
2010-03-18 23:12:38 +00:00
|
|
|
extern AirportOverrideManager _airport_mngr;
|
2010-02-22 14:15:48 +00:00
|
|
|
extern AirportTileOverrideManager _airporttile_mngr;
|
2010-08-28 17:30:55 +00:00
|
|
|
extern ObjectOverrideManager _object_mngr;
|
2007-05-15 21:36:58 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint32_t GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL);
|
2011-07-11 16:32:35 +00:00
|
|
|
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets = true, Axis axis = INVALID_AXIS);
|
2024-01-07 16:41:53 +00:00
|
|
|
uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8, uint32_t mask);
|
|
|
|
uint32_t GetCompanyInfo(CompanyID owner, const struct Livery *l = nullptr);
|
|
|
|
CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, const GRFFile *grffile, StringID default_error);
|
2007-06-05 01:49:08 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res);
|
|
|
|
bool ConvertBooleanCallback(const struct GRFFile *grffile, uint16_t cbid, uint16_t cb_res);
|
|
|
|
bool Convert8bitBooleanCallback(const struct GRFFile *grffile, uint16_t cbid, uint16_t cb_res);
|
2011-11-08 17:24:15 +00:00
|
|
|
|
2010-08-10 15:49:35 +00:00
|
|
|
/**
|
|
|
|
* Data related to the handling of grf files.
|
|
|
|
* @tparam Tcnt Number of spritegroups
|
|
|
|
*/
|
|
|
|
template <size_t Tcnt>
|
2010-08-07 20:51:07 +00:00
|
|
|
struct GRFFilePropsBase {
|
2021-06-16 19:12:08 +00:00
|
|
|
GRFFilePropsBase() : local_id(0), grffile(nullptr)
|
2010-08-11 07:42:47 +00:00
|
|
|
{
|
|
|
|
/* The lack of some compilers to provide default constructors complying to the specs
|
|
|
|
* requires us to zero the stuff ourself. */
|
|
|
|
memset(spritegroup, 0, sizeof(spritegroup));
|
|
|
|
}
|
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint16_t local_id; ///< id defined by the grf file for this entity
|
2010-08-10 15:49:35 +00:00
|
|
|
const struct GRFFile *grffile; ///< grf file that introduced this entity
|
|
|
|
const struct SpriteGroup *spritegroup[Tcnt]; ///< pointer to the different sprites of the entity
|
2010-08-07 20:51:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Data related to the handling of grf files. */
|
2010-08-10 15:49:35 +00:00
|
|
|
struct GRFFileProps : GRFFilePropsBase<1> {
|
2010-08-07 20:51:07 +00:00
|
|
|
/** Set all default data constructor for the props. */
|
2024-01-07 16:41:53 +00:00
|
|
|
GRFFileProps(uint16_t subst_id = 0) :
|
2010-08-10 15:49:35 +00:00
|
|
|
GRFFilePropsBase<1>(), subst_id(subst_id), override(subst_id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint16_t subst_id;
|
|
|
|
uint16_t override; ///< id of the entity been replaced by
|
2010-02-22 14:15:48 +00:00
|
|
|
};
|
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
enum SpriteGroupCallbacksUsed : uint8_t {
|
2021-05-18 18:07:44 +00:00
|
|
|
SGCU_NONE = 0,
|
2022-06-06 17:34:30 +00:00
|
|
|
SGCU_ALL = 0xF,
|
2021-05-18 18:07:44 +00:00
|
|
|
SGCU_VEHICLE_32DAY_CALLBACK = 1 << 0,
|
|
|
|
SGCU_VEHICLE_REFIT_COST = 1 << 1,
|
2021-05-18 21:06:56 +00:00
|
|
|
SGCU_RANDOM_TRIGGER = 1 << 2,
|
2022-05-24 20:50:38 +00:00
|
|
|
SGCU_CB36_SPEED_RAILTYPE = 1 << 3,
|
2022-06-06 17:34:30 +00:00
|
|
|
SGCU_REFIT_CB_ALL_CARGOES = 1 << 4,
|
2021-05-18 18:07:44 +00:00
|
|
|
};
|
|
|
|
DECLARE_ENUM_AS_BIT_SET(SpriteGroupCallbacksUsed)
|
|
|
|
|
2024-02-27 19:18:50 +00:00
|
|
|
enum CustomSignalSpriteContextMode : uint8_t {
|
2022-06-15 18:03:13 +00:00
|
|
|
CSSC_GUI = 0,
|
|
|
|
CSSC_TRACK,
|
|
|
|
CSSC_TUNNEL_BRIDGE_ENTRANCE,
|
|
|
|
CSSC_TUNNEL_BRIDGE_EXIT,
|
|
|
|
CSSC_BRIDGE_MIDDLE,
|
|
|
|
};
|
|
|
|
|
2024-02-27 19:18:50 +00:00
|
|
|
enum CustomSignalSpriteContextFlags : uint8_t {
|
|
|
|
CSSCF_NONE = 0,
|
|
|
|
CSSCF_TUNNEL = 1 << 1,
|
|
|
|
CSSCF_SECOND_SIGNAL = 1 << 2,
|
|
|
|
};
|
|
|
|
DECLARE_ENUM_AS_BIT_SET(CustomSignalSpriteContextFlags)
|
|
|
|
|
|
|
|
struct CustomSignalSpriteContext {
|
|
|
|
CustomSignalSpriteContextMode ctx_mode;
|
|
|
|
CustomSignalSpriteContextFlags ctx_flags = CSSCF_NONE;
|
|
|
|
};
|
|
|
|
|
2007-05-15 21:36:58 +00:00
|
|
|
#endif /* NEWGRF_COMMONS_H */
|