33 | ((
_settings_game.construction.max_bridge_length > 16 ? 1U : 0U) << 0x0F)
37 | ((
_settings_game.vehicle.never_expire_vehicles ? 1U : 0U) << 0x16)
55 | ((
_settings_game.construction.train_signal_side == 1 ? 1U : 0U) << 0x1B)
63 | ((
_settings_game.construction.build_on_slopes ? 1U : 0U) << 0x0D)
71 | ((
_settings_game.construction.build_on_slopes ? 1U : 0U) << 0x15)
116uint32_t GetParamVal(uint8_t param, uint32_t *cond_val)
128 if (_cur_gps.stage > GLS_INIT)
SetBit(res, 0);
129 if (_cur_gps.stage == GLS_RESERVE)
SetBit(res, 8);
130 if (_cur_gps.stage == GLS_ACTIVATION)
SetBit(res, 9);
135 if (cond_val ==
nullptr) {
139 uint32_t index = *cond_val / 0x20;
152 if (param < 0x80)
return _cur_gps.grffile->GetParam(param);
155 GrfMsg(1,
"Unsupported in-game variable 0x{:02X}", param);
171 uint32_t cond_val = 0;
186 case 4: cond_val = buf.
ReadDWord(); mask = 0xFFFFFFFF;
break;
187 case 2: cond_val = buf.
ReadWord(); mask = 0x0000FFFF;
break;
188 case 1: cond_val = buf.
ReadByte(); mask = 0x000000FF;
break;
192 if (param < 0x80 && std::size(_cur_gps.grffile->param) <= param) {
193 GrfMsg(7,
"SkipIf: Param {} undefined, skipping test", param);
197 GrfMsg(7,
"SkipIf: Test condtype {}, param 0x{:02X}, condval 0x{:08X}", condtype, param, cond_val);
202 if (condtype >= 0x0B) {
233 default: GrfMsg(1,
"SkipIf: Unsupported condition type {:02X}. Ignoring", condtype);
return;
235 }
else if (param == 0x88) {
245 if (condtype != 10 && c ==
nullptr) {
246 GrfMsg(7,
"SkipIf: GRFID 0x{:08X} unknown, skipping test",
std::byteswap(cond_val));
273 default: GrfMsg(1,
"SkipIf: Unsupported GRF condition type {:02X}. Ignoring", condtype);
return;
277 uint32_t param_val = GetParamVal(param, &cond_val);
279 case 0x00: result = !!(param_val & (1 << cond_val));
281 case 0x01: result = !(param_val & (1 << cond_val));
283 case 0x02: result = (param_val & mask) == cond_val;
285 case 0x03: result = (param_val & mask) != cond_val;
287 case 0x04: result = (param_val & mask) < cond_val;
289 case 0x05: result = (param_val & mask) > cond_val;
291 default: GrfMsg(1,
"SkipIf: Unsupported condition type {:02X}. Ignoring", condtype);
return;
296 GrfMsg(2,
"SkipIf: Not skipping sprites, test was false");
300 uint8_t numsprites = buf.
ReadByte();
307 for (
const auto &label : _cur_gps.grffile->labels) {
308 if (label.label != numsprites)
continue;
311 if (choice ==
nullptr) choice = &label;
313 if (label.nfo_line > _cur_gps.nfo_line) {
319 if (choice !=
nullptr) {
320 GrfMsg(2,
"SkipIf: Jumping to label 0x{:X} at line {}, test was true", choice->label, choice->nfo_line);
321 _cur_gps.file->SeekTo(choice->pos, SEEK_SET);
322 _cur_gps.nfo_line = choice->nfo_line;
326 GrfMsg(2,
"SkipIf: Skipping {} sprites, test was true", numsprites);
327 _cur_gps.skip_sprites = numsprites;
328 if (_cur_gps.skip_sprites == 0) {
332 _cur_gps.skip_sprites = -1;
341template <>
void GrfActionHandler<0x07>::FileScan(
ByteReader &) { }
342template <>
void GrfActionHandler<0x07>::SafetyScan(
ByteReader &) { }
343template <>
void GrfActionHandler<0x07>::LabelScan(
ByteReader &) { }
344template <>
void GrfActionHandler<0x07>::Init(
ByteReader &) { }
345template <>
void GrfActionHandler<0x07>::Reserve(
ByteReader &buf) { SkipIf(buf); }
346template <>
void GrfActionHandler<0x07>::Activation(
ByteReader &buf) { SkipIf(buf); }
348template <>
void GrfActionHandler<0x09>::FileScan(
ByteReader &) { }
349template <>
void GrfActionHandler<0x09>::SafetyScan(
ByteReader &) { }
350template <>
void GrfActionHandler<0x09>::LabelScan(
ByteReader &) { }
351template <>
void GrfActionHandler<0x09>::Init(
ByteReader &buf) { SkipIf(buf); }
352template <>
void GrfActionHandler<0x09>::Reserve(
ByteReader &buf) { SkipIf(buf); }
353template <>
void GrfActionHandler<0x09>::Activation(
ByteReader &buf) { SkipIf(buf); }
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr enable_if_t< is_integral_v< T >, T > byteswap(T x) noexcept
Custom implementation of std::byteswap; remove once we build with C++23.
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
StrongType::Typedef< uint32_t, struct CargoLabelTag, StrongType::Compare > CargoLabel
Globally unique label of a cargo type.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
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).
Functions related to debugging.
bool _generating_world
Whether we are generating the map or not.
Functions related to world/map generation.
bool _networking
are we in networking mode?
Basic functions/variables used all over the place.
void DisableStaticNewGRFInfluencingNonStaticNewGRFs(GRFConfig &c)
Disable a static NewGRF when it is influencing another (non-static) NewGRF as this could cause desync...
GRFError * DisableGrf(StringID message, GRFConfig *config)
Disable a GRF.
bool GetGlobalVariable(uint8_t param, uint32_t *value, const GRFFile *grffile)
Reads a variable common to VarAction2 and Action7/9/D.
void InitializePatchFlags()
Initialize the TTDPatch flags.
static std::array< uint32_t, 8 > _ttdpatch_flags
32 * 8 = 256 flags.
NewGRF buffer reader definition.
Cargo support for NewGRFs.
GRFConfig * GetGRFConfig(uint32_t grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
@ GCS_INITIALISED
GRF file has been initialised.
@ GCS_DISABLED
GRF file is disabled.
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
@ GCS_ACTIVATED
GRF file has been activated.
@ Static
GRF file is used statically (can be used in any MP game).
Functions for NewGRF engines.
NewGRF internal processing state.
RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels)
Get the rail type for a given label.
@ INVALID_RAILTYPE
Flag for invalid railtype.
RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels)
Get the road type for a given label.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Types related to global configuration settings.
Definition of base types and functions in a cross-platform compatible way.
Information about GRF, used in the game and (part of it) in savegames.
GRFStatus status
NOSAVE: GRFStatus, enum.
GRFConfigFlags flags
NOSAVE: GCF_Flags, bitset.