38 default: NOT_REACHED();
48 | ((
_settings_game.construction.max_bridge_length > 16 ? 1U : 0U) << 0x0F)
52 | ((
_settings_game.vehicle.never_expire_vehicles ? 1U : 0U) << 0x16)
78 | ((
_settings_game.construction.build_on_slopes ? 1U : 0U) << 0x0D)
86 | ((
_settings_game.construction.build_on_slopes ? 1U : 0U) << 0x15)
131uint32_t GetParamVal(uint8_t param, uint32_t *cond_val)
150 if (cond_val ==
nullptr) {
154 uint32_t index = *cond_val / 0x20;
167 if (param < 0x80)
return _cur_gps.grffile->GetParam(param);
170 GrfMsg(1,
"Unsupported in-game variable 0x{:02X}", param);
186 uint32_t cond_val = 0;
201 case 4: cond_val = buf.
ReadDWord(); mask = 0xFFFFFFFF;
break;
202 case 2: cond_val = buf.
ReadWord(); mask = 0x0000FFFF;
break;
203 case 1: cond_val = buf.
ReadByte(); mask = 0x000000FF;
break;
207 if (param < 0x80 && std::size(_cur_gps.grffile->param) <= param) {
208 GrfMsg(7,
"SkipIf: Param {} undefined, skipping test", param);
212 GrfMsg(7,
"SkipIf: Test condtype {}, param 0x{:02X}, condval 0x{:08X}", condtype, param, cond_val);
217 if (condtype >= 0x0B) {
248 default: GrfMsg(1,
"SkipIf: Unsupported condition type {:02X}. Ignoring", condtype);
return;
250 }
else if (param == 0x88) {
260 if (condtype != 10 && c ==
nullptr) {
261 GrfMsg(7,
"SkipIf: GRFID 0x{:08X} unknown, skipping test",
std::byteswap(cond_val));
288 default: GrfMsg(1,
"SkipIf: Unsupported GRF condition type {:02X}. Ignoring", condtype);
return;
292 uint32_t param_val = GetParamVal(param, &cond_val);
294 case 0x00: result = !!(param_val & (1 << cond_val));
296 case 0x01: result = !(param_val & (1 << cond_val));
298 case 0x02: result = (param_val & mask) == cond_val;
300 case 0x03: result = (param_val & mask) != cond_val;
302 case 0x04: result = (param_val & mask) < cond_val;
304 case 0x05: result = (param_val & mask) > cond_val;
306 default: GrfMsg(1,
"SkipIf: Unsupported condition type {:02X}. Ignoring", condtype);
return;
311 GrfMsg(2,
"SkipIf: Not skipping sprites, test was false");
315 uint8_t numsprites = buf.
ReadByte();
322 for (
const auto &label : _cur_gps.grffile->labels) {
323 if (label.label != numsprites)
continue;
326 if (choice ==
nullptr) choice = &label;
328 if (label.nfo_line > _cur_gps.nfo_line) {
334 if (choice !=
nullptr) {
335 GrfMsg(2,
"SkipIf: Jumping to label 0x{:X} at line {}, test was true", choice->label, choice->nfo_line);
336 _cur_gps.file->SeekTo(choice->pos, SEEK_SET);
337 _cur_gps.nfo_line = choice->nfo_line;
341 GrfMsg(2,
"SkipIf: Skipping {} sprites, test was true", numsprites);
342 _cur_gps.skip_sprites = numsprites;
343 if (_cur_gps.skip_sprites == 0) {
347 _cur_gps.skip_sprites = -1;
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.
@ Reserve
Third step of NewGRF loading; reserve features and GRMs.
@ Init
Second step of NewGRF loading; load all actions into memory.
@ Activation
Forth step of NewGRF loading; activate the features.
void InitializePatchFlags()
Initialize the TTDPatch flags.
static bool IsSignalSideOnTrafficSide()
Checks whether the train signals are on the same side as the road vehicles are driving.
static std::array< uint32_t, 8 > _ttdpatch_flags
32 * 8 = 256 flags.
NewGRF buffer reader definition.
Cargo support for NewGRFs.
GRFConfig * GetGRFConfig(GrfID grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
@ NotFound
GRF file was not found in the local cache.
@ Initialised
GRF file has been initialised.
@ Disabled
GRF file is disabled.
@ 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.
@ RoadVehicleDrivingSide
Signals at the driving side of road vehicles.
@ Right
Signals at the right side.
@ Left
Signals at the left side.
@ Right
Drive on the right side.
@ Left
Drive on the left side.
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.
static void FileScan(ByteReader &buf)
Implementation of the GrfLoadingStage::FileScan stage of this action.
static void SafetyScan(ByteReader &buf)
Implementation of the GrfLoadingStage::SafetyScan stage of this action.
static void Reserve(ByteReader &buf)
Implementation of the GrfLoadingStage::Reserve stage of this action.
static void Activation(ByteReader &buf)
Implementation of the GrfLoadingStage::Activation stage of this action.
static void Init(ByteReader &buf)
Implementation of the GrfLoadingStage::Init stage of this action.
static void LabelScan(ByteReader &buf)
Implementation of the GrfLoadingStage::LabelScan stage of this action.