12#include "../newgrf_object.h"
17#include "../safeguards.h"
81 GrfMsg(1,
"ObjectChangeInfo: Too many objects loaded ({}), max ({}). Ignoring.", last,
NUM_OBJECTS_PER_GRF);
86 if (_cur.
grffile->objectspec.size() < last) _cur.
grffile->objectspec.resize(last);
88 for (uint
id = first;
id < last; ++id) {
89 auto &spec = _cur.
grffile->objectspec[id];
91 if (prop != 0x08 && spec ==
nullptr) {
94 if (cir > ret) ret = cir;
101 if (spec ==
nullptr) {
102 spec = std::make_unique<ObjectSpec>();
128 if (
GB(spec->size, 0, 4) == 0 ||
GB(spec->size, 4, 4) == 0) {
129 GrfMsg(0,
"ObjectChangeInfo: Invalid object size requested (0x{:X}) for object id {}. Ignoring.", spec->size,
id);
135 spec->build_cost_multiplier = buf.
ReadByte();
136 spec->clear_cost_multiplier = spec->build_cost_multiplier;
140 spec->introduction_date = TimerGameCalendar::Date(buf.
ReadDWord());
144 spec->end_of_life_date = TimerGameCalendar::Date(buf.
ReadDWord());
153 spec->animation.frames = buf.
ReadByte();
154 spec->animation.status = buf.
ReadByte();
158 spec->animation.speed = buf.
ReadByte();
162 spec->animation.triggers = buf.
ReadWord();
166 spec->clear_cost_multiplier = buf.
ReadByte();
179 if (spec->views != 1 && spec->views != 2 && spec->views != 4) {
180 GrfMsg(2,
"ObjectChangeInfo: Invalid number of views ({}) for object id {}. Ignoring.", spec->views,
id);
186 spec->generate_amount = buf.
ReadByte();
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Class to read from a NewGRF file.
uint32_t ReadDWord()
Read a single DWord (32 bits).
uint16_t ReadWord()
Read a single Word (16 bits).
uint8_t ReadByte()
Read a single byte (8 bits).
StringID name
Name of this class.
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
static Tindex Allocate(uint32_t global_id)
Allocate a class with a given global class ID.
GRFLoadedFeatures _loaded_newgrf_features
Indicates which are the newgrf features currently loaded ingame.
std::vector< BadgeID > ReadBadgeList(ByteReader &buf, GrfSpecFeature feature)
Read a list of badges.
void SkipBadgeList(ByteReader &buf)
Skip a list of badges.
static ChangeInfoResult ObjectChangeInfo(uint first, uint last, int prop, ByteReader &buf)
Define properties for objects.
static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader &buf)
Ignore properties for objects.
NewGRF buffer reader definition.
NewGRF internal processing state.
ChangeInfoResult
Possible return values for the GrfChangeInfoHandler functions.
@ CIR_INVALID_ID
Attempt to modify an invalid ID.
@ CIR_UNKNOWN
Variable is unknown.
@ CIR_UNHANDLED
Variable was parsed but unread.
@ CIR_SUCCESS
Variable was parsed and read.
static const uint8_t OBJECT_SIZE_1X1
The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X,...
@ Uses2CC
Object wants 2CC colour mapping.
void AddStringForMapping(GRFStringID source, std::function< void(StringID)> &&func)
Record a static StringID for getting translated later.
NewGRF string mapping definition.
static const ObjectType NUM_OBJECTS_PER_GRF
Number of supported objects per NewGRF.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
bool has_2CC
Set if any vehicle is loaded which uses 2cc (two company colours).
GRFFile * grffile
Currently processed GRF file.