12#include "../genworld.h"
13#include "../network/network.h"
14#include "../newgrf_engine.h"
15#include "../newgrf_cargo.h"
18#include "../settings_type.h"
22#include "../safeguards.h"
116uint32_t GetParamVal(uint8_t param, uint32_t *cond_val)
135 if (cond_val ==
nullptr) {
139 uint32_t index = *cond_val / 0x20;
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.
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.grffile->labels) {
308 if (label.label != numsprites)
continue;
311 if (choice ==
nullptr) choice = &label;
313 if (label.nfo_line > _cur.
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);
326 GrfMsg(2,
"SkipIf: Skipping {} sprites, test was true", numsprites);
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
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).
void SeekTo(size_t pos, int mode)
Seek in the current file.
bool _generating_world
Whether we are generating the map or not.
bool _networking
are we in networking mode?
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.
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)
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
GameSettings _settings_game
Game settings of a running game or the scenario editor.
bool build_on_slopes
allow building on slopes
uint16_t max_bridge_length
maximum length of bridges
uint8_t train_signal_side
show signals on left / driving / right side
bool inflation
disable inflation
bool allow_town_roads
towns are allowed to build roads (always allowed when generating world / in SE)
bool station_noise_level
build new airports when the town noise level is still within accepted limits
Information about GRF, used in the game and (part of it) in savegames.
GRFStatus status
NOSAVE: GRFStatus, enum.
GRFConfigFlags flags
NOSAVE: GCF_Flags, bitset.
uint32_t GetParam(uint number) const
Get GRF Parameter with range checking.
EconomySettings economy
settings to change the economy
ConstructionSettings construction
construction of things in-game
StationSettings station
settings related to station management
VehicleSettings vehicle
options for vehicles
OrderSettings order
settings related to orders
SpriteFile * file
File of currently processed GRF file.
GRFFile * grffile
Currently processed GRF file.
uint32_t nfo_line
Currently processed pseudo sprite number in the GRF.
GRFConfig * grfconfig
Config of the currently processed GRF file.
GrfLoadingStage stage
Current loading stage.
int skip_sprites
Number of pseudo sprites to skip before processing the next one. (-1 to skip to end of file)
bool improved_load
improved loading algorithm
bool gradual_loading
load vehicles gradually
bool never_expire_airports
never expire airports
bool wagon_speed_limits
enable wagon speed limits
bool dynamic_engines
enable dynamic allocation of engine data
uint8_t freight_trains
value to multiply the weight of cargo by
bool never_expire_vehicles
never expire vehicles
bool disable_elrails
when true, the elrails are disabled