diff --git a/src/newgrf.cpp b/src/newgrf.cpp index d547674e68..d026d4e9d4 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -304,7 +304,7 @@ public: } }; -typedef void (*SpecialSpriteHandler)(ByteReader *buf); +typedef void (*SpecialSpriteHandler)(ByteReader &buf); /** The maximum amount of stations a single GRF is allowed to add */ static const uint NUM_STATIONS_PER_GRF = UINT16_MAX - 1; @@ -746,11 +746,11 @@ static void MapSpriteMappingRecolour(PalSpriteID *grf_sprite) * @param[out] max_palette_offset Optionally returns the number of sprites in the spriteset of the palette. (0 if no spritset) * @return Read TileLayoutFlags. */ -static TileLayoutFlags ReadSpriteLayoutSprite(ByteReader *buf, bool read_flags, bool invert_action1_flag, bool use_cur_spritesets, int feature, PalSpriteID *grf_sprite, uint16_t *max_sprite_offset = nullptr, uint16_t *max_palette_offset = nullptr) +static TileLayoutFlags ReadSpriteLayoutSprite(ByteReader &buf, bool read_flags, bool invert_action1_flag, bool use_cur_spritesets, int feature, PalSpriteID *grf_sprite, uint16_t *max_sprite_offset = nullptr, uint16_t *max_palette_offset = nullptr) { - grf_sprite->sprite = buf->ReadWord(); - grf_sprite->pal = buf->ReadWord(); - TileLayoutFlags flags = read_flags ? (TileLayoutFlags)buf->ReadWord() : TLF_NOTHING; + grf_sprite->sprite = buf.ReadWord(); + grf_sprite->pal = buf.ReadWord(); + TileLayoutFlags flags = read_flags ? (TileLayoutFlags)buf.ReadWord() : TLF_NOTHING; MapSpriteMappingRecolour(grf_sprite); @@ -804,7 +804,7 @@ static TileLayoutFlags ReadSpriteLayoutSprite(ByteReader *buf, bool read_flags, * @param dts Sprite layout to insert data into. * @param index Sprite index to process; 0 for ground sprite. */ -static void ReadSpriteLayoutRegisters(ByteReader *buf, TileLayoutFlags flags, bool is_parent, NewGRFSpriteLayout *dts, uint index) +static void ReadSpriteLayoutRegisters(ByteReader &buf, TileLayoutFlags flags, bool is_parent, NewGRFSpriteLayout *dts, uint index) { if (!(flags & TLF_DRAWING_FLAGS)) return; @@ -812,23 +812,23 @@ static void ReadSpriteLayoutRegisters(ByteReader *buf, TileLayoutFlags flags, bo TileLayoutRegisters ®s = const_cast(dts->registers[index]); regs.flags = flags & TLF_DRAWING_FLAGS; - if (flags & TLF_DODRAW) regs.dodraw = buf->ReadByte(); - if (flags & TLF_SPRITE) regs.sprite = buf->ReadByte(); - if (flags & TLF_PALETTE) regs.palette = buf->ReadByte(); + if (flags & TLF_DODRAW) regs.dodraw = buf.ReadByte(); + if (flags & TLF_SPRITE) regs.sprite = buf.ReadByte(); + if (flags & TLF_PALETTE) regs.palette = buf.ReadByte(); if (is_parent) { if (flags & TLF_BB_XY_OFFSET) { - regs.delta.parent[0] = buf->ReadByte(); - regs.delta.parent[1] = buf->ReadByte(); + regs.delta.parent[0] = buf.ReadByte(); + regs.delta.parent[1] = buf.ReadByte(); } - if (flags & TLF_BB_Z_OFFSET) regs.delta.parent[2] = buf->ReadByte(); + if (flags & TLF_BB_Z_OFFSET) regs.delta.parent[2] = buf.ReadByte(); } else { - if (flags & TLF_CHILD_X_OFFSET) regs.delta.child[0] = buf->ReadByte(); - if (flags & TLF_CHILD_Y_OFFSET) regs.delta.child[1] = buf->ReadByte(); + if (flags & TLF_CHILD_X_OFFSET) regs.delta.child[0] = buf.ReadByte(); + if (flags & TLF_CHILD_Y_OFFSET) regs.delta.child[1] = buf.ReadByte(); } if (flags & TLF_SPRITE_VAR10) { - regs.sprite_var10 = buf->ReadByte(); + regs.sprite_var10 = buf.ReadByte(); if (regs.sprite_var10 > TLR_MAX_VAR10) { GrfMsg(1, "ReadSpriteLayoutRegisters: Spritelayout specifies var10 ({}) exceeding the maximal allowed value {}", regs.sprite_var10, TLR_MAX_VAR10); DisableGrf(STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT); @@ -837,7 +837,7 @@ static void ReadSpriteLayoutRegisters(ByteReader *buf, TileLayoutFlags flags, bo } if (flags & TLF_PALETTE_VAR10) { - regs.palette_var10 = buf->ReadByte(); + regs.palette_var10 = buf.ReadByte(); if (regs.palette_var10 > TLR_MAX_VAR10) { GrfMsg(1, "ReadSpriteLayoutRegisters: Spritelayout specifies var10 ({}) exceeding the maximal allowed value {}", regs.palette_var10, TLR_MAX_VAR10); DisableGrf(STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT); @@ -857,7 +857,7 @@ static void ReadSpriteLayoutRegisters(ByteReader *buf, TileLayoutFlags flags, bo * @param dts Layout container to output into * @return True on error (GRF was disabled). */ -static bool ReadSpriteLayout(ByteReader *buf, uint num_building_sprites, bool use_cur_spritesets, uint8_t feature, bool allow_var10, bool no_z_position, NewGRFSpriteLayout *dts) +static bool ReadSpriteLayout(ByteReader &buf, uint num_building_sprites, bool use_cur_spritesets, uint8_t feature, bool allow_var10, bool no_z_position, NewGRFSpriteLayout *dts) { bool has_flags = HasBit(num_building_sprites, 6); ClrBit(num_building_sprites, 6); @@ -893,15 +893,15 @@ static bool ReadSpriteLayout(ByteReader *buf, uint num_building_sprites, bool us return true; } - seq->delta_x = buf->ReadByte(); - seq->delta_y = buf->ReadByte(); + seq->delta_x = buf.ReadByte(); + seq->delta_y = buf.ReadByte(); - if (!no_z_position) seq->delta_z = buf->ReadByte(); + if (!no_z_position) seq->delta_z = buf.ReadByte(); if (seq->IsParentSprite()) { - seq->size_x = buf->ReadByte(); - seq->size_y = buf->ReadByte(); - seq->size_z = buf->ReadByte(); + seq->size_x = buf.ReadByte(); + seq->size_y = buf.ReadByte(); + seq->size_z = buf.ReadByte(); } ReadSpriteLayoutRegisters(buf, flags, seq->IsParentSprite(), dts, i + 1); @@ -995,7 +995,7 @@ enum ChangeInfoResult { CIR_INVALID_ID, ///< Attempt to modify an invalid ID }; -typedef ChangeInfoResult (*VCI_Handler)(uint engine, int numinfo, int prop, ByteReader *buf); +typedef ChangeInfoResult (*VCI_Handler)(uint engine, int numinfo, int prop, ByteReader &buf); /** * Define properties common to all vehicles @@ -1004,32 +1004,32 @@ typedef ChangeInfoResult (*VCI_Handler)(uint engine, int numinfo, int prop, Byte * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteReader *buf) +static ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteReader &buf) { switch (prop) { case 0x00: // Introduction date - ei->base_intro = buf->ReadWord() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; + ei->base_intro = buf.ReadWord() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; break; case 0x02: // Decay speed - ei->decay_speed = buf->ReadByte(); + ei->decay_speed = buf.ReadByte(); break; case 0x03: // Vehicle life - ei->lifelength = buf->ReadByte(); + ei->lifelength = buf.ReadByte(); break; case 0x04: // Model life - ei->base_life = buf->ReadByte(); + ei->base_life = buf.ReadByte(); break; case 0x06: // Climates available - ei->climates = buf->ReadByte(); + ei->climates = buf.ReadByte(); break; case PROP_VEHICLE_LOAD_AMOUNT: // 0x07 Loading speed /* Amount of cargo loaded during a vehicle's "loading tick" */ - ei->load_amount = buf->ReadByte(); + ei->load_amount = buf.ReadByte(); break; default: @@ -1047,7 +1047,7 @@ static ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteRe * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -1060,7 +1060,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop switch (prop) { case 0x05: { // Track type - uint8_t tracktype = buf->ReadByte(); + uint8_t tracktype = buf.ReadByte(); if (tracktype < _cur.grffile->railtype_list.size()) { _gted[e->index].railtypelabel = _cur.grffile->railtype_list[tracktype]; @@ -1081,11 +1081,11 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop case 0x08: // AI passenger service /* Tells the AI that this engine is designed for * passenger services and shouldn't be used for freight. */ - rvi->ai_passenger_only = buf->ReadByte(); + rvi->ai_passenger_only = buf.ReadByte(); break; case PROP_TRAIN_SPEED: { // 0x09 Speed (1 unit is 1 km-ish/h) - uint16_t speed = buf->ReadWord(); + uint16_t speed = buf.ReadWord(); if (speed == 0xFFFF) speed = 0; rvi->max_speed = speed; @@ -1093,7 +1093,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } case PROP_TRAIN_POWER: // 0x0B Power - rvi->power = buf->ReadWord(); + rvi->power = buf.ReadWord(); /* Set engine / wagon state based on power */ if (rvi->power != 0) { @@ -1106,15 +1106,15 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop break; case PROP_TRAIN_RUNNING_COST_FACTOR: // 0x0D Running cost factor - rvi->running_cost = buf->ReadByte(); + rvi->running_cost = buf.ReadByte(); break; case 0x0E: // Running cost base - ConvertTTDBasePrice(buf->ReadDWord(), "RailVehicleChangeInfo", &rvi->running_cost_class); + ConvertTTDBasePrice(buf.ReadDWord(), "RailVehicleChangeInfo", &rvi->running_cost_class); break; case 0x12: { // Sprite ID - uint8_t spriteid = buf->ReadByte(); + uint8_t spriteid = buf.ReadByte(); uint8_t orig_spriteid = spriteid; /* TTD sprite IDs point to a location in a 16bit array, but we use it @@ -1131,7 +1131,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } case 0x13: { // Dual-headed - uint8_t dual = buf->ReadByte(); + uint8_t dual = buf.ReadByte(); if (dual != 0) { rvi->railveh_type = RAILVEH_MULTIHEAD; @@ -1143,12 +1143,12 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } case PROP_TRAIN_CARGO_CAPACITY: // 0x14 Cargo capacity - rvi->capacity = buf->ReadByte(); + rvi->capacity = buf.ReadByte(); break; case 0x15: { // Cargo type _gted[e->index].defaultcargo_grf = _cur.grffile; - uint8_t ctype = buf->ReadByte(); + uint8_t ctype = buf.ReadByte(); if (ctype == 0xFF) { /* 0xFF is specified as 'use first refittable' */ @@ -1168,16 +1168,16 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } case PROP_TRAIN_WEIGHT: // 0x16 Weight - SB(rvi->weight, 0, 8, buf->ReadByte()); + SB(rvi->weight, 0, 8, buf.ReadByte()); break; case PROP_TRAIN_COST_FACTOR: // 0x17 Cost factor - rvi->cost_factor = buf->ReadByte(); + rvi->cost_factor = buf.ReadByte(); break; case 0x18: // AI rank GrfMsg(2, "RailVehicleChangeInfo: Property 0x18 'AI rank' not used by NoAI, ignored."); - buf->ReadByte(); + buf.ReadByte(); break; case 0x19: { // Engine traction type @@ -1188,7 +1188,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop * 0x32 .. 0x37: Monorail * 0x38 .. 0x41: Maglev */ - uint8_t traction = buf->ReadByte(); + uint8_t traction = buf.ReadByte(); EngineClass engclass; if (traction <= 0x07) { @@ -1217,19 +1217,19 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } case 0x1A: // Alter purchase list sort order - AlterVehicleListOrder(e->index, buf->ReadExtendedByte()); + AlterVehicleListOrder(e->index, buf.ReadExtendedByte()); break; case 0x1B: // Powered wagons power bonus - rvi->pow_wag_power = buf->ReadWord(); + rvi->pow_wag_power = buf.ReadWord(); break; case 0x1C: // Refit cost - ei->refit_cost = buf->ReadByte(); + ei->refit_cost = buf.ReadByte(); break; case 0x1D: { // Refit cargo - uint32_t mask = buf->ReadDWord(); + uint32_t mask = buf.ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); _gted[e->index].defaultcargo_grf = _cur.grffile; @@ -1237,23 +1237,23 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } case 0x1E: // Callback - SB(ei->callback_mask, 0, 8, buf->ReadByte()); + SB(ei->callback_mask, 0, 8, buf.ReadByte()); break; case PROP_TRAIN_TRACTIVE_EFFORT: // 0x1F Tractive effort coefficient - rvi->tractive_effort = buf->ReadByte(); + rvi->tractive_effort = buf.ReadByte(); break; case 0x20: // Air drag - rvi->air_drag = buf->ReadByte(); + rvi->air_drag = buf.ReadByte(); break; case PROP_TRAIN_SHORTEN_FACTOR: // 0x21 Shorter vehicle - rvi->shorten_factor = buf->ReadByte(); + rvi->shorten_factor = buf.ReadByte(); break; case 0x22: // Visual effect - rvi->visual_effect = buf->ReadByte(); + rvi->visual_effect = buf.ReadByte(); /* Avoid accidentally setting visual_effect to the default value * Since bit 6 (disable effects) is set anyways, we can safely erase some bits. */ if (rvi->visual_effect == VE_DEFAULT) { @@ -1263,11 +1263,11 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop break; case 0x23: // Powered wagons weight bonus - rvi->pow_wag_weight = buf->ReadByte(); + rvi->pow_wag_weight = buf.ReadByte(); break; case 0x24: { // High byte of vehicle weight - uint8_t weight = buf->ReadByte(); + uint8_t weight = buf.ReadByte(); if (weight > 4) { GrfMsg(2, "RailVehicleChangeInfo: Nonsensical weight of {} tons, ignoring", weight << 8); @@ -1278,65 +1278,65 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } case PROP_TRAIN_USER_DATA: // 0x25 User-defined bit mask to set when checking veh. var. 42 - rvi->user_def_data = buf->ReadByte(); + rvi->user_def_data = buf.ReadByte(); break; case 0x26: // Retire vehicle early - ei->retire_early = buf->ReadByte(); + ei->retire_early = buf.ReadByte(); break; case 0x27: // Miscellaneous flags - ei->misc_flags = buf->ReadByte(); + ei->misc_flags = buf.ReadByte(); _loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); break; case 0x28: // Cargo classes allowed - _gted[e->index].cargo_allowed = buf->ReadWord(); + _gted[e->index].cargo_allowed = buf.ReadWord(); _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != 0); _gted[e->index].defaultcargo_grf = _cur.grffile; break; case 0x29: // Cargo classes disallowed - _gted[e->index].cargo_disallowed = buf->ReadWord(); + _gted[e->index].cargo_disallowed = buf.ReadWord(); _gted[e->index].UpdateRefittability(false); break; case 0x2A: // Long format introduction date (days since year 0) - ei->base_intro = buf->ReadDWord(); + ei->base_intro = buf.ReadDWord(); break; case PROP_TRAIN_CARGO_AGE_PERIOD: // 0x2B Cargo aging period - ei->cargo_age_period = buf->ReadWord(); + ei->cargo_age_period = buf.ReadWord(); break; case 0x2C: // CTT refit include list case 0x2D: { // CTT refit exclude list - uint8_t count = buf->ReadByte(); + uint8_t count = buf.ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x2C && count != 0); if (prop == 0x2C) _gted[e->index].defaultcargo_grf = _cur.grffile; CargoTypes &ctt = prop == 0x2C ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { - CargoID ctype = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + CargoID ctype = GetCargoTranslation(buf.ReadByte(), _cur.grffile); if (IsValidCargoID(ctype)) SetBit(ctt, ctype); } break; } case PROP_TRAIN_CURVE_SPEED_MOD: // 0x2E Curve speed modifier - rvi->curve_speed_mod = buf->ReadWord(); + rvi->curve_speed_mod = buf.ReadWord(); break; case 0x2F: // Engine variant - ei->variant_id = buf->ReadWord(); + ei->variant_id = buf.ReadWord(); break; case 0x30: // Extra miscellaneous flags - ei->extra_flags = static_cast(buf->ReadDWord()); + ei->extra_flags = static_cast(buf.ReadDWord()); break; case 0x31: // Callback additional mask - SB(ei->callback_mask, 8, 8, buf->ReadByte()); + SB(ei->callback_mask, 8, 8, buf.ReadByte()); break; default: @@ -1356,7 +1356,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -1371,23 +1371,23 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop case 0x05: // Road/tram type /* RoadTypeLabel is looked up later after the engine's road/tram * flag is set, however 0 means the value has not been set. */ - _gted[e->index].roadtramtype = buf->ReadByte() + 1; + _gted[e->index].roadtramtype = buf.ReadByte() + 1; break; case 0x08: // Speed (1 unit is 0.5 kmh) - rvi->max_speed = buf->ReadByte(); + rvi->max_speed = buf.ReadByte(); break; case PROP_ROADVEH_RUNNING_COST_FACTOR: // 0x09 Running cost factor - rvi->running_cost = buf->ReadByte(); + rvi->running_cost = buf.ReadByte(); break; case 0x0A: // Running cost base - ConvertTTDBasePrice(buf->ReadDWord(), "RoadVehicleChangeInfo", &rvi->running_cost_class); + ConvertTTDBasePrice(buf.ReadDWord(), "RoadVehicleChangeInfo", &rvi->running_cost_class); break; case 0x0E: { // Sprite ID - uint8_t spriteid = buf->ReadByte(); + uint8_t spriteid = buf.ReadByte(); uint8_t orig_spriteid = spriteid; /* cars have different custom id in the GRF file */ @@ -1405,12 +1405,12 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop } case PROP_ROADVEH_CARGO_CAPACITY: // 0x0F Cargo capacity - rvi->capacity = buf->ReadByte(); + rvi->capacity = buf.ReadByte(); break; case 0x10: { // Cargo type _gted[e->index].defaultcargo_grf = _cur.grffile; - uint8_t ctype = buf->ReadByte(); + uint8_t ctype = buf.ReadByte(); if (ctype == 0xFF) { /* 0xFF is specified as 'use first refittable' */ @@ -1430,27 +1430,27 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop } case PROP_ROADVEH_COST_FACTOR: // 0x11 Cost factor - rvi->cost_factor = buf->ReadByte(); + rvi->cost_factor = buf.ReadByte(); break; case 0x12: // SFX - rvi->sfx = GetNewGRFSoundID(_cur.grffile, buf->ReadByte()); + rvi->sfx = GetNewGRFSoundID(_cur.grffile, buf.ReadByte()); break; case PROP_ROADVEH_POWER: // Power in units of 10 HP. - rvi->power = buf->ReadByte(); + rvi->power = buf.ReadByte(); break; case PROP_ROADVEH_WEIGHT: // Weight in units of 1/4 tons. - rvi->weight = buf->ReadByte(); + rvi->weight = buf.ReadByte(); break; case PROP_ROADVEH_SPEED: // Speed in mph/0.8 - _gted[e->index].rv_max_speed = buf->ReadByte(); + _gted[e->index].rv_max_speed = buf.ReadByte(); break; case 0x16: { // Cargoes available for refitting - uint32_t mask = buf->ReadDWord(); + uint32_t mask = buf.ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); _gted[e->index].defaultcargo_grf = _cur.grffile; @@ -1458,51 +1458,51 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop } case 0x17: // Callback mask - SB(ei->callback_mask, 0, 8, buf->ReadByte()); + SB(ei->callback_mask, 0, 8, buf.ReadByte()); break; case PROP_ROADVEH_TRACTIVE_EFFORT: // Tractive effort coefficient in 1/256. - rvi->tractive_effort = buf->ReadByte(); + rvi->tractive_effort = buf.ReadByte(); break; case 0x19: // Air drag - rvi->air_drag = buf->ReadByte(); + rvi->air_drag = buf.ReadByte(); break; case 0x1A: // Refit cost - ei->refit_cost = buf->ReadByte(); + ei->refit_cost = buf.ReadByte(); break; case 0x1B: // Retire vehicle early - ei->retire_early = buf->ReadByte(); + ei->retire_early = buf.ReadByte(); break; case 0x1C: // Miscellaneous flags - ei->misc_flags = buf->ReadByte(); + ei->misc_flags = buf.ReadByte(); _loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); break; case 0x1D: // Cargo classes allowed - _gted[e->index].cargo_allowed = buf->ReadWord(); + _gted[e->index].cargo_allowed = buf.ReadWord(); _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != 0); _gted[e->index].defaultcargo_grf = _cur.grffile; break; case 0x1E: // Cargo classes disallowed - _gted[e->index].cargo_disallowed = buf->ReadWord(); + _gted[e->index].cargo_disallowed = buf.ReadWord(); _gted[e->index].UpdateRefittability(false); break; case 0x1F: // Long format introduction date (days since year 0) - ei->base_intro = buf->ReadDWord(); + ei->base_intro = buf.ReadDWord(); break; case 0x20: // Alter purchase list sort order - AlterVehicleListOrder(e->index, buf->ReadExtendedByte()); + AlterVehicleListOrder(e->index, buf.ReadExtendedByte()); break; case 0x21: // Visual effect - rvi->visual_effect = buf->ReadByte(); + rvi->visual_effect = buf.ReadByte(); /* Avoid accidentally setting visual_effect to the default value * Since bit 6 (disable effects) is set anyways, we can safely erase some bits. */ if (rvi->visual_effect == VE_DEFAULT) { @@ -1512,37 +1512,37 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop break; case PROP_ROADVEH_CARGO_AGE_PERIOD: // 0x22 Cargo aging period - ei->cargo_age_period = buf->ReadWord(); + ei->cargo_age_period = buf.ReadWord(); break; case PROP_ROADVEH_SHORTEN_FACTOR: // 0x23 Shorter vehicle - rvi->shorten_factor = buf->ReadByte(); + rvi->shorten_factor = buf.ReadByte(); break; case 0x24: // CTT refit include list case 0x25: { // CTT refit exclude list - uint8_t count = buf->ReadByte(); + uint8_t count = buf.ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x24 && count != 0); if (prop == 0x24) _gted[e->index].defaultcargo_grf = _cur.grffile; CargoTypes &ctt = prop == 0x24 ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { - CargoID ctype = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + CargoID ctype = GetCargoTranslation(buf.ReadByte(), _cur.grffile); if (IsValidCargoID(ctype)) SetBit(ctt, ctype); } break; } case 0x26: // Engine variant - ei->variant_id = buf->ReadWord(); + ei->variant_id = buf.ReadWord(); break; case 0x27: // Extra miscellaneous flags - ei->extra_flags = static_cast(buf->ReadDWord()); + ei->extra_flags = static_cast(buf.ReadDWord()); break; case 0x28: // Callback additional mask - SB(ei->callback_mask, 8, 8, buf->ReadByte()); + SB(ei->callback_mask, 8, 8, buf.ReadByte()); break; default: @@ -1562,7 +1562,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -1575,7 +1575,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop switch (prop) { case 0x08: { // Sprite ID - uint8_t spriteid = buf->ReadByte(); + uint8_t spriteid = buf.ReadByte(); uint8_t orig_spriteid = spriteid; /* ships have different custom id in the GRF file */ @@ -1593,20 +1593,20 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop } case 0x09: // Refittable - svi->old_refittable = (buf->ReadByte() != 0); + svi->old_refittable = (buf.ReadByte() != 0); break; case PROP_SHIP_COST_FACTOR: // 0x0A Cost factor - svi->cost_factor = buf->ReadByte(); + svi->cost_factor = buf.ReadByte(); break; case PROP_SHIP_SPEED: // 0x0B Speed (1 unit is 0.5 km-ish/h). Use 0x23 to achieve higher speeds. - svi->max_speed = buf->ReadByte(); + svi->max_speed = buf.ReadByte(); break; case 0x0C: { // Cargo type _gted[e->index].defaultcargo_grf = _cur.grffile; - uint8_t ctype = buf->ReadByte(); + uint8_t ctype = buf.ReadByte(); if (ctype == 0xFF) { /* 0xFF is specified as 'use first refittable' */ @@ -1626,19 +1626,19 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop } case PROP_SHIP_CARGO_CAPACITY: // 0x0D Cargo capacity - svi->capacity = buf->ReadWord(); + svi->capacity = buf.ReadWord(); break; case PROP_SHIP_RUNNING_COST_FACTOR: // 0x0F Running cost factor - svi->running_cost = buf->ReadByte(); + svi->running_cost = buf.ReadByte(); break; case 0x10: // SFX - svi->sfx = GetNewGRFSoundID(_cur.grffile, buf->ReadByte()); + svi->sfx = GetNewGRFSoundID(_cur.grffile, buf.ReadByte()); break; case 0x11: { // Cargoes available for refitting - uint32_t mask = buf->ReadDWord(); + uint32_t mask = buf.ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); _gted[e->index].defaultcargo_grf = _cur.grffile; @@ -1646,51 +1646,51 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop } case 0x12: // Callback mask - SB(ei->callback_mask, 0, 8, buf->ReadByte()); + SB(ei->callback_mask, 0, 8, buf.ReadByte()); break; case 0x13: // Refit cost - ei->refit_cost = buf->ReadByte(); + ei->refit_cost = buf.ReadByte(); break; case 0x14: // Ocean speed fraction - svi->ocean_speed_frac = buf->ReadByte(); + svi->ocean_speed_frac = buf.ReadByte(); break; case 0x15: // Canal speed fraction - svi->canal_speed_frac = buf->ReadByte(); + svi->canal_speed_frac = buf.ReadByte(); break; case 0x16: // Retire vehicle early - ei->retire_early = buf->ReadByte(); + ei->retire_early = buf.ReadByte(); break; case 0x17: // Miscellaneous flags - ei->misc_flags = buf->ReadByte(); + ei->misc_flags = buf.ReadByte(); _loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); break; case 0x18: // Cargo classes allowed - _gted[e->index].cargo_allowed = buf->ReadWord(); + _gted[e->index].cargo_allowed = buf.ReadWord(); _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != 0); _gted[e->index].defaultcargo_grf = _cur.grffile; break; case 0x19: // Cargo classes disallowed - _gted[e->index].cargo_disallowed = buf->ReadWord(); + _gted[e->index].cargo_disallowed = buf.ReadWord(); _gted[e->index].UpdateRefittability(false); break; case 0x1A: // Long format introduction date (days since year 0) - ei->base_intro = buf->ReadDWord(); + ei->base_intro = buf.ReadDWord(); break; case 0x1B: // Alter purchase list sort order - AlterVehicleListOrder(e->index, buf->ReadExtendedByte()); + AlterVehicleListOrder(e->index, buf.ReadExtendedByte()); break; case 0x1C: // Visual effect - svi->visual_effect = buf->ReadByte(); + svi->visual_effect = buf.ReadByte(); /* Avoid accidentally setting visual_effect to the default value * Since bit 6 (disable effects) is set anyways, we can safely erase some bits. */ if (svi->visual_effect == VE_DEFAULT) { @@ -1700,41 +1700,41 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop break; case PROP_SHIP_CARGO_AGE_PERIOD: // 0x1D Cargo aging period - ei->cargo_age_period = buf->ReadWord(); + ei->cargo_age_period = buf.ReadWord(); break; case 0x1E: // CTT refit include list case 0x1F: { // CTT refit exclude list - uint8_t count = buf->ReadByte(); + uint8_t count = buf.ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x1E && count != 0); if (prop == 0x1E) _gted[e->index].defaultcargo_grf = _cur.grffile; CargoTypes &ctt = prop == 0x1E ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { - CargoID ctype = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + CargoID ctype = GetCargoTranslation(buf.ReadByte(), _cur.grffile); if (IsValidCargoID(ctype)) SetBit(ctt, ctype); } break; } case 0x20: // Engine variant - ei->variant_id = buf->ReadWord(); + ei->variant_id = buf.ReadWord(); break; case 0x21: // Extra miscellaneous flags - ei->extra_flags = static_cast(buf->ReadDWord()); + ei->extra_flags = static_cast(buf.ReadDWord()); break; case 0x22: // Callback additional mask - SB(ei->callback_mask, 8, 8, buf->ReadByte()); + SB(ei->callback_mask, 8, 8, buf.ReadByte()); break; case 0x23: // Speed (1 unit is 0.5 km-ish/h) - svi->max_speed = buf->ReadWord(); + svi->max_speed = buf.ReadWord(); break; case 0x24: // Acceleration (1 unit is 0.5 km-ish/h per tick) - svi->acceleration = std::max(1, buf->ReadByte()); + svi->acceleration = std::max(1, buf.ReadByte()); break; default: @@ -1754,7 +1754,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -1767,7 +1767,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int switch (prop) { case 0x08: { // Sprite ID - uint8_t spriteid = buf->ReadByte(); + uint8_t spriteid = buf.ReadByte(); uint8_t orig_spriteid = spriteid; /* aircraft have different custom id in the GRF file */ @@ -1785,7 +1785,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int } case 0x09: // Helicopter - if (buf->ReadByte() == 0) { + if (buf.ReadByte() == 0) { avi->subtype = AIR_HELI; } else { SB(avi->subtype, 0, 1, 1); // AIR_CTOL @@ -1793,39 +1793,39 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int break; case 0x0A: // Large - SB(avi->subtype, 1, 1, (buf->ReadByte() != 0 ? 1 : 0)); // AIR_FAST + SB(avi->subtype, 1, 1, (buf.ReadByte() != 0 ? 1 : 0)); // AIR_FAST break; case PROP_AIRCRAFT_COST_FACTOR: // 0x0B Cost factor - avi->cost_factor = buf->ReadByte(); + avi->cost_factor = buf.ReadByte(); break; case PROP_AIRCRAFT_SPEED: // 0x0C Speed (1 unit is 8 mph, we translate to 1 unit is 1 km-ish/h) - avi->max_speed = (buf->ReadByte() * 128) / 10; + avi->max_speed = (buf.ReadByte() * 128) / 10; break; case 0x0D: // Acceleration - avi->acceleration = buf->ReadByte(); + avi->acceleration = buf.ReadByte(); break; case PROP_AIRCRAFT_RUNNING_COST_FACTOR: // 0x0E Running cost factor - avi->running_cost = buf->ReadByte(); + avi->running_cost = buf.ReadByte(); break; case PROP_AIRCRAFT_PASSENGER_CAPACITY: // 0x0F Passenger capacity - avi->passenger_capacity = buf->ReadWord(); + avi->passenger_capacity = buf.ReadWord(); break; case PROP_AIRCRAFT_MAIL_CAPACITY: // 0x11 Mail capacity - avi->mail_capacity = buf->ReadByte(); + avi->mail_capacity = buf.ReadByte(); break; case 0x12: // SFX - avi->sfx = GetNewGRFSoundID(_cur.grffile, buf->ReadByte()); + avi->sfx = GetNewGRFSoundID(_cur.grffile, buf.ReadByte()); break; case 0x13: { // Cargoes available for refitting - uint32_t mask = buf->ReadDWord(); + uint32_t mask = buf.ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); _gted[e->index].defaultcargo_grf = _cur.grffile; @@ -1833,73 +1833,73 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int } case 0x14: // Callback mask - SB(ei->callback_mask, 0, 8, buf->ReadByte()); + SB(ei->callback_mask, 0, 8, buf.ReadByte()); break; case 0x15: // Refit cost - ei->refit_cost = buf->ReadByte(); + ei->refit_cost = buf.ReadByte(); break; case 0x16: // Retire vehicle early - ei->retire_early = buf->ReadByte(); + ei->retire_early = buf.ReadByte(); break; case 0x17: // Miscellaneous flags - ei->misc_flags = buf->ReadByte(); + ei->misc_flags = buf.ReadByte(); _loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); break; case 0x18: // Cargo classes allowed - _gted[e->index].cargo_allowed = buf->ReadWord(); + _gted[e->index].cargo_allowed = buf.ReadWord(); _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != 0); _gted[e->index].defaultcargo_grf = _cur.grffile; break; case 0x19: // Cargo classes disallowed - _gted[e->index].cargo_disallowed = buf->ReadWord(); + _gted[e->index].cargo_disallowed = buf.ReadWord(); _gted[e->index].UpdateRefittability(false); break; case 0x1A: // Long format introduction date (days since year 0) - ei->base_intro = buf->ReadDWord(); + ei->base_intro = buf.ReadDWord(); break; case 0x1B: // Alter purchase list sort order - AlterVehicleListOrder(e->index, buf->ReadExtendedByte()); + AlterVehicleListOrder(e->index, buf.ReadExtendedByte()); break; case PROP_AIRCRAFT_CARGO_AGE_PERIOD: // 0x1C Cargo aging period - ei->cargo_age_period = buf->ReadWord(); + ei->cargo_age_period = buf.ReadWord(); break; case 0x1D: // CTT refit include list case 0x1E: { // CTT refit exclude list - uint8_t count = buf->ReadByte(); + uint8_t count = buf.ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x1D && count != 0); if (prop == 0x1D) _gted[e->index].defaultcargo_grf = _cur.grffile; CargoTypes &ctt = prop == 0x1D ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { - CargoID ctype = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + CargoID ctype = GetCargoTranslation(buf.ReadByte(), _cur.grffile); if (IsValidCargoID(ctype)) SetBit(ctt, ctype); } break; } case PROP_AIRCRAFT_RANGE: // 0x1F Max aircraft range - avi->max_range = buf->ReadWord(); + avi->max_range = buf.ReadWord(); break; case 0x20: // Engine variant - ei->variant_id = buf->ReadWord(); + ei->variant_id = buf.ReadWord(); break; case 0x21: // Extra miscellaneous flags - ei->extra_flags = static_cast(buf->ReadDWord()); + ei->extra_flags = static_cast(buf.ReadDWord()); break; case 0x22: // Callback additional mask - SB(ei->callback_mask, 8, 8, buf->ReadByte()); + SB(ei->callback_mask, 8, 8, buf.ReadByte()); break; default: @@ -1919,7 +1919,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -1949,13 +1949,13 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte } /* Swap classid because we read it in BE meaning WAYP or DFLT */ - uint32_t classid = buf->ReadDWord(); + uint32_t classid = buf.ReadDWord(); statspec->class_index = StationClass::Allocate(BSWAP32(classid)); break; } case 0x09: { // Define sprite layout - uint16_t tiles = buf->ReadExtendedByte(); + uint16_t tiles = buf.ReadExtendedByte(); statspec->renderdata.clear(); // delete earlier loaded stuff statspec->renderdata.reserve(tiles); @@ -1963,8 +1963,8 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte NewGRFSpriteLayout *dts = &statspec->renderdata.emplace_back(); dts->consistent_max_offset = UINT16_MAX; // Spritesets are unknown, so no limit. - if (buf->HasData(4) && *(uint32_t*)buf->Data() == 0) { - buf->Skip(4); + if (buf.HasData(4) && *(uint32_t*)buf.Data() == 0) { + buf.Skip(4); extern const DrawTileSprites _station_display_datas_rail[8]; dts->Clone(&_station_display_datas_rail[t % 8]); continue; @@ -1981,13 +1981,13 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte DrawTileSeqStruct &dtss = tmp_layout.emplace_back(); MemSetT(&dtss, 0); - dtss.delta_x = buf->ReadByte(); + dtss.delta_x = buf.ReadByte(); if (dtss.IsTerminator()) break; - dtss.delta_y = buf->ReadByte(); - dtss.delta_z = buf->ReadByte(); - dtss.size_x = buf->ReadByte(); - dtss.size_y = buf->ReadByte(); - dtss.size_z = buf->ReadByte(); + dtss.delta_y = buf.ReadByte(); + dtss.delta_z = buf.ReadByte(); + dtss.size_x = buf.ReadByte(); + dtss.size_y = buf.ReadByte(); + dtss.size_z = buf.ReadByte(); ReadSpriteLayoutSprite(buf, false, true, false, GSF_STATIONS, &dtss.image); /* On error, bail out immediately. Temporary GRF data was already freed */ @@ -2005,7 +2005,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte } case 0x0A: { // Copy sprite layout - uint16_t srcid = buf->ReadExtendedByte(); + uint16_t srcid = buf.ReadExtendedByte(); const StationSpec *srcstatspec = srcid >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[srcid].get(); if (srcstatspec == nullptr) { @@ -2024,28 +2024,28 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte } case 0x0B: // Callback mask - statspec->callback_mask = buf->ReadByte(); + statspec->callback_mask = buf.ReadByte(); break; case 0x0C: // Disallowed number of platforms - statspec->disallowed_platforms = buf->ReadByte(); + statspec->disallowed_platforms = buf.ReadByte(); break; case 0x0D: // Disallowed platform lengths - statspec->disallowed_lengths = buf->ReadByte(); + statspec->disallowed_lengths = buf.ReadByte(); break; case 0x0E: // Define custom layout - while (buf->HasData()) { - uint8_t length = buf->ReadByte(); - uint8_t number = buf->ReadByte(); + while (buf.HasData()) { + uint8_t length = buf.ReadByte(); + uint8_t number = buf.ReadByte(); if (length == 0 || number == 0) break; if (statspec->layouts.size() < length) statspec->layouts.resize(length); if (statspec->layouts[length - 1].size() < number) statspec->layouts[length - 1].resize(number); - const uint8_t *layout = buf->ReadBytes(length * number); + const uint8_t *layout = buf.ReadBytes(length * number); statspec->layouts[length - 1][number - 1].assign(layout, layout + length * number); /* Validate tile values are only the permitted 00, 02, 04 and 06. */ @@ -2059,7 +2059,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte break; case 0x0F: { // Copy custom layout - uint16_t srcid = buf->ReadExtendedByte(); + uint16_t srcid = buf.ReadExtendedByte(); const StationSpec *srcstatspec = srcid >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[srcid].get(); if (srcstatspec == nullptr) { @@ -2072,56 +2072,56 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte } case 0x10: // Little/lots cargo threshold - statspec->cargo_threshold = buf->ReadWord(); + statspec->cargo_threshold = buf.ReadWord(); break; case 0x11: // Pylon placement - statspec->pylons = buf->ReadByte(); + statspec->pylons = buf.ReadByte(); break; case 0x12: // Cargo types for random triggers if (_cur.grffile->grf_version >= 7) { - statspec->cargo_triggers = TranslateRefitMask(buf->ReadDWord()); + statspec->cargo_triggers = TranslateRefitMask(buf.ReadDWord()); } else { - statspec->cargo_triggers = (CargoTypes)buf->ReadDWord(); + statspec->cargo_triggers = (CargoTypes)buf.ReadDWord(); } break; case 0x13: // General flags - statspec->flags = buf->ReadByte(); + statspec->flags = buf.ReadByte(); break; case 0x14: // Overhead wire placement - statspec->wires = buf->ReadByte(); + statspec->wires = buf.ReadByte(); break; case 0x15: // Blocked tiles - statspec->blocked = buf->ReadByte(); + statspec->blocked = buf.ReadByte(); break; case 0x16: // Animation info - statspec->animation.frames = buf->ReadByte(); - statspec->animation.status = buf->ReadByte(); + statspec->animation.frames = buf.ReadByte(); + statspec->animation.status = buf.ReadByte(); break; case 0x17: // Animation speed - statspec->animation.speed = buf->ReadByte(); + statspec->animation.speed = buf.ReadByte(); break; case 0x18: // Animation triggers - statspec->animation.triggers = buf->ReadWord(); + statspec->animation.triggers = buf.ReadWord(); break; /* 0x19 road routing (not implemented) */ case 0x1A: { // Advanced sprite layout - uint16_t tiles = buf->ReadExtendedByte(); + uint16_t tiles = buf.ReadExtendedByte(); statspec->renderdata.clear(); // delete earlier loaded stuff statspec->renderdata.reserve(tiles); for (uint t = 0; t < tiles; t++) { NewGRFSpriteLayout *dts = &statspec->renderdata.emplace_back(); - uint num_building_sprites = buf->ReadByte(); + uint num_building_sprites = buf.ReadByte(); /* On error, bail out immediately. Temporary GRF data was already freed */ if (ReadSpriteLayout(buf, num_building_sprites, false, GSF_STATIONS, true, false, dts)) return CIR_DISABLED; } @@ -2135,18 +2135,18 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte } case 0x1B: // Minimum bridge height (not implemented) - buf->ReadWord(); - buf->ReadWord(); - buf->ReadWord(); - buf->ReadWord(); + buf.ReadWord(); + buf.ReadWord(); + buf.ReadWord(); + buf.ReadWord(); break; case 0x1C: // Station Name - AddStringForMapping(buf->ReadWord(), &statspec->name); + AddStringForMapping(buf.ReadWord(), &statspec->name); break; case 0x1D: // Station Class name - AddStringForMapping(buf->ReadWord(), [statspec](StringID str) { StationClass::Get(statspec->class_index)->name = str; }); + AddStringForMapping(buf.ReadWord(), [statspec](StringID str) { StationClass::Get(statspec->class_index)->name = str; }); break; default: @@ -2166,7 +2166,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult CanalChangeInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult CanalChangeInfo(uint id, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -2180,11 +2180,11 @@ static ChangeInfoResult CanalChangeInfo(uint id, int numinfo, int prop, ByteRead switch (prop) { case 0x08: - cp->callback_mask = buf->ReadByte(); + cp->callback_mask = buf.ReadByte(); break; case 0x09: - cp->flags = buf->ReadByte(); + cp->flags = buf.ReadByte(); break; default: @@ -2204,7 +2204,7 @@ static ChangeInfoResult CanalChangeInfo(uint id, int numinfo, int prop, ByteRead * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -2219,32 +2219,32 @@ static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, ByteR switch (prop) { case 0x08: { // Year of availability /* We treat '0' as always available */ - uint8_t year = buf->ReadByte(); + uint8_t year = buf.ReadByte(); bridge->avail_year = (year > 0 ? CalendarTime::ORIGINAL_BASE_YEAR + year : 0); break; } case 0x09: // Minimum length - bridge->min_length = buf->ReadByte(); + bridge->min_length = buf.ReadByte(); break; case 0x0A: // Maximum length - bridge->max_length = buf->ReadByte(); + bridge->max_length = buf.ReadByte(); if (bridge->max_length > 16) bridge->max_length = UINT16_MAX; break; case 0x0B: // Cost factor - bridge->price = buf->ReadByte(); + bridge->price = buf.ReadByte(); break; case 0x0C: // Maximum speed - bridge->speed = buf->ReadWord(); + bridge->speed = buf.ReadWord(); if (bridge->speed == 0) bridge->speed = UINT16_MAX; break; case 0x0D: { // Bridge sprite tables - uint8_t tableid = buf->ReadByte(); - uint8_t numtables = buf->ReadByte(); + uint8_t tableid = buf.ReadByte(); + uint8_t numtables = buf.ReadByte(); if (bridge->sprite_table == nullptr) { /* Allocate memory for sprite table pointers and zero out */ @@ -2254,7 +2254,7 @@ static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, ByteR for (; numtables-- != 0; tableid++) { if (tableid >= 7) { // skip invalid data GrfMsg(1, "BridgeChangeInfo: Table {} >= 7, skipping", tableid); - for (uint8_t sprite = 0; sprite < 32; sprite++) buf->ReadDWord(); + for (uint8_t sprite = 0; sprite < 32; sprite++) buf.ReadDWord(); continue; } @@ -2263,8 +2263,8 @@ static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, ByteR } for (uint8_t sprite = 0; sprite < 32; sprite++) { - SpriteID image = buf->ReadWord(); - PaletteID pal = buf->ReadWord(); + SpriteID image = buf.ReadWord(); + PaletteID pal = buf.ReadWord(); bridge->sprite_table[tableid][sprite].sprite = image; bridge->sprite_table[tableid][sprite].pal = pal; @@ -2276,28 +2276,28 @@ static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, ByteR } case 0x0E: // Flags; bit 0 - disable far pillars - bridge->flags = buf->ReadByte(); + bridge->flags = buf.ReadByte(); break; case 0x0F: // Long format year of availability (year since year 0) - bridge->avail_year = Clamp(TimerGameCalendar::Year(buf->ReadDWord()), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR); + bridge->avail_year = Clamp(TimerGameCalendar::Year(buf.ReadDWord()), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR); break; case 0x10: { // purchase string - StringID newone = GetGRFStringID(_cur.grffile->grfid, buf->ReadWord()); + StringID newone = GetGRFStringID(_cur.grffile->grfid, buf.ReadWord()); if (newone != STR_UNDEFINED) bridge->material = newone; break; } case 0x11: // description of bridge with rails or roads case 0x12: { - StringID newone = GetGRFStringID(_cur.grffile->grfid, buf->ReadWord()); + StringID newone = GetGRFStringID(_cur.grffile->grfid, buf.ReadWord()); if (newone != STR_UNDEFINED) bridge->transport_name[prop - 0x11] = newone; break; } case 0x13: // 16 bits cost multiplier - bridge->price = buf->ReadWord(); + bridge->price = buf.ReadWord(); break; default: @@ -2315,7 +2315,7 @@ static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, ByteR * @param buf Property value. * @return ChangeInfoResult. */ -static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader *buf) +static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -2337,7 +2337,7 @@ static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader *buf) case 0x1C: case 0x1D: case 0x1F: - buf->ReadByte(); + buf.ReadByte(); break; case 0x0A: @@ -2346,25 +2346,25 @@ static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader *buf) case 0x13: case 0x21: case 0x22: - buf->ReadWord(); + buf.ReadWord(); break; case 0x1E: - buf->ReadDWord(); + buf.ReadDWord(); break; case 0x17: - for (uint j = 0; j < 4; j++) buf->ReadByte(); + for (uint j = 0; j < 4; j++) buf.ReadByte(); break; case 0x20: { - uint8_t count = buf->ReadByte(); - for (uint8_t j = 0; j < count; j++) buf->ReadByte(); + uint8_t count = buf.ReadByte(); + for (uint8_t j = 0; j < count; j++) buf.ReadByte(); break; } case 0x23: - buf->Skip(buf->ReadByte() * 2); + buf.Skip(buf.ReadByte() * 2); break; default: @@ -2382,7 +2382,7 @@ static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader *buf) * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -2406,7 +2406,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt switch (prop) { case 0x08: { // Substitute building type, and definition of a new house - uint8_t subs_id = buf->ReadByte(); + uint8_t subs_id = buf.ReadByte(); if (subs_id == 0xFF) { /* Instead of defining a new house, a substitute house id * of 0xFF disables the old house with the current id. */ @@ -2451,31 +2451,31 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt } case 0x09: // Building flags - housespec->building_flags = (BuildingFlags)buf->ReadByte(); + housespec->building_flags = (BuildingFlags)buf.ReadByte(); break; case 0x0A: { // Availability years - uint16_t years = buf->ReadWord(); + uint16_t years = buf.ReadWord(); housespec->min_year = GB(years, 0, 8) > 150 ? CalendarTime::MAX_YEAR : CalendarTime::ORIGINAL_BASE_YEAR + GB(years, 0, 8); housespec->max_year = GB(years, 8, 8) > 150 ? CalendarTime::MAX_YEAR : CalendarTime::ORIGINAL_BASE_YEAR + GB(years, 8, 8); break; } case 0x0B: // Population - housespec->population = buf->ReadByte(); + housespec->population = buf.ReadByte(); break; case 0x0C: // Mail generation multiplier - housespec->mail_generation = buf->ReadByte(); + housespec->mail_generation = buf.ReadByte(); break; case 0x0D: // Passenger acceptance case 0x0E: // Mail acceptance - housespec->cargo_acceptance[prop - 0x0D] = buf->ReadByte(); + housespec->cargo_acceptance[prop - 0x0D] = buf.ReadByte(); break; case 0x0F: { // Goods/candy, food/fizzy drinks acceptance - int8_t goods = buf->ReadByte(); + int8_t goods = buf.ReadByte(); /* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance. * Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */ @@ -2492,27 +2492,27 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt } case 0x10: // Local authority rating decrease on removal - housespec->remove_rating_decrease = buf->ReadWord(); + housespec->remove_rating_decrease = buf.ReadWord(); break; case 0x11: // Removal cost multiplier - housespec->removal_cost = buf->ReadByte(); + housespec->removal_cost = buf.ReadByte(); break; case 0x12: // Building name ID - AddStringForMapping(buf->ReadWord(), &housespec->building_name); + AddStringForMapping(buf.ReadWord(), &housespec->building_name); break; case 0x13: // Building availability mask - housespec->building_availability = (HouseZones)buf->ReadWord(); + housespec->building_availability = (HouseZones)buf.ReadWord(); break; case 0x14: // House callback mask - housespec->callback_mask |= buf->ReadByte(); + housespec->callback_mask |= buf.ReadByte(); break; case 0x15: { // House override byte - uint8_t override = buf->ReadByte(); + uint8_t override = buf.ReadByte(); /* The house being overridden must be an original house. */ if (override >= NEW_HOUSE_OFFSET) { @@ -2525,41 +2525,41 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt } case 0x16: // Periodic refresh multiplier - housespec->processing_time = std::min(buf->ReadByte(), 63u); + housespec->processing_time = std::min(buf.ReadByte(), 63u); break; case 0x17: // Four random colours to use - for (uint j = 0; j < 4; j++) housespec->random_colour[j] = static_cast(GB(buf->ReadByte(), 0, 4)); + for (uint j = 0; j < 4; j++) housespec->random_colour[j] = static_cast(GB(buf.ReadByte(), 0, 4)); break; case 0x18: // Relative probability of appearing - housespec->probability = buf->ReadByte(); + housespec->probability = buf.ReadByte(); break; case 0x19: // Extra flags - housespec->extra_flags = (HouseExtraFlags)buf->ReadByte(); + housespec->extra_flags = (HouseExtraFlags)buf.ReadByte(); break; case 0x1A: // Animation frames - housespec->animation.frames = buf->ReadByte(); + housespec->animation.frames = buf.ReadByte(); housespec->animation.status = GB(housespec->animation.frames, 7, 1); SB(housespec->animation.frames, 7, 1, 0); break; case 0x1B: // Animation speed - housespec->animation.speed = Clamp(buf->ReadByte(), 2, 16); + housespec->animation.speed = Clamp(buf.ReadByte(), 2, 16); break; case 0x1C: // Class of the building type - housespec->class_id = AllocateHouseClassID(buf->ReadByte(), _cur.grffile->grfid); + housespec->class_id = AllocateHouseClassID(buf.ReadByte(), _cur.grffile->grfid); break; case 0x1D: // Callback mask part 2 - housespec->callback_mask |= (buf->ReadByte() << 8); + housespec->callback_mask |= (buf.ReadByte() << 8); break; case 0x1E: { // Accepted cargo types - uint32_t cargotypes = buf->ReadDWord(); + uint32_t cargotypes = buf.ReadDWord(); /* Check if the cargo types should not be changed */ if (cargotypes == 0xFFFFFFFF) break; @@ -2581,29 +2581,29 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt } case 0x1F: // Minimum life span - housespec->minimum_life = buf->ReadByte(); + housespec->minimum_life = buf.ReadByte(); break; case 0x20: { // Cargo acceptance watch list - uint8_t count = buf->ReadByte(); + uint8_t count = buf.ReadByte(); for (uint8_t j = 0; j < count; j++) { - CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + CargoID cargo = GetCargoTranslation(buf.ReadByte(), _cur.grffile); if (IsValidCargoID(cargo)) SetBit(housespec->watched_cargoes, cargo); } break; } case 0x21: // long introduction year - housespec->min_year = buf->ReadWord(); + housespec->min_year = buf.ReadWord(); break; case 0x22: // long maximum year - housespec->max_year = buf->ReadWord(); + housespec->max_year = buf.ReadWord(); if (housespec->max_year == UINT16_MAX) housespec->max_year = CalendarTime::MAX_YEAR; break; case 0x23: { // variable length cargo types accepted - uint count = buf->ReadByte(); + uint count = buf.ReadByte(); if (count > lengthof(housespec->accepts_cargo)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; @@ -2614,8 +2614,8 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt * any risks of array overrun. */ for (uint i = 0; i < lengthof(housespec->accepts_cargo); i++) { if (i < count) { - housespec->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile); - housespec->cargo_acceptance[i] = buf->ReadByte(); + housespec->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + housespec->cargo_acceptance[i] = buf.ReadByte(); } else { housespec->accepts_cargo[i] = INVALID_CARGO; housespec->cargo_acceptance[i] = 0; @@ -2662,7 +2662,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt * @return ChangeInfoResult. */ template -static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader *buf, std::vector &translation_table, const char *name) +static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader &buf, std::vector &translation_table, const char *name) { if (gvid != 0) { GrfMsg(1, "LoadTranslationTable: {} translation table must start at zero", name); @@ -2672,7 +2672,7 @@ static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader translation_table.clear(); translation_table.reserve(numinfo); for (int i = 0; i < numinfo; i++) { - translation_table.push_back(T(BSWAP32(buf->ReadDWord()))); + translation_table.push_back(T(BSWAP32(buf.ReadDWord()))); } return CIR_SUCCESS; @@ -2684,10 +2684,10 @@ static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader * @param reader The source of the DWord. * @return The read DWord as string. */ -static std::string ReadDWordAsString(ByteReader *reader) +static std::string ReadDWordAsString(ByteReader &reader) { std::string output; - for (int i = 0; i < 4; i++) output.push_back(reader->ReadByte()); + for (int i = 0; i < 4; i++) output.push_back(reader.ReadByte()); return StrMakeValid(output); } @@ -2699,7 +2699,7 @@ static std::string ReadDWordAsString(ByteReader *reader) * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, ByteReader &buf) { /* Properties which are handled as a whole */ switch (prop) { @@ -2724,7 +2724,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By for (int i = 0; i < numinfo; i++) { switch (prop) { case 0x08: { // Cost base factor - int factor = buf->ReadByte(); + int factor = buf.ReadByte(); uint price = gvid + i; if (price < PR_END) { @@ -2737,7 +2737,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By case 0x0A: { // Currency display names uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); - StringID newone = GetGRFStringID(_cur.grffile->grfid, buf->ReadWord()); + StringID newone = GetGRFStringID(_cur.grffile->grfid, buf.ReadWord()); if ((newone != STR_UNDEFINED) && (curidx < CURRENCY_END)) { _currency_specs[curidx].name = newone; @@ -2748,7 +2748,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By case 0x0B: { // Currency multipliers uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); - uint32_t rate = buf->ReadDWord(); + uint32_t rate = buf.ReadDWord(); if (curidx < CURRENCY_END) { /* TTDPatch uses a multiple of 1000 for its conversion calculations, @@ -2763,7 +2763,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By case 0x0C: { // Currency options uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); - uint16_t options = buf->ReadWord(); + uint16_t options = buf.ReadWord(); if (curidx < CURRENCY_END) { _currency_specs[curidx].separator.clear(); @@ -2803,7 +2803,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By case 0x0F: { // Euro introduction dates uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); - TimerGameCalendar::Year year_euro = buf->ReadWord(); + TimerGameCalendar::Year year_euro = buf.ReadWord(); if (curidx < CURRENCY_END) { _currency_specs[curidx].to_euro = year_euro; @@ -2816,14 +2816,14 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By case 0x10: // Snow line height table if (numinfo > 1 || IsSnowLineSet()) { GrfMsg(1, "GlobalVarChangeInfo: The snowline can only be set once ({})", numinfo); - } else if (buf->Remaining() < SNOW_LINE_MONTHS * SNOW_LINE_DAYS) { - GrfMsg(1, "GlobalVarChangeInfo: Not enough entries set in the snowline table ({})", buf->Remaining()); + } else if (buf.Remaining() < SNOW_LINE_MONTHS * SNOW_LINE_DAYS) { + GrfMsg(1, "GlobalVarChangeInfo: Not enough entries set in the snowline table ({})", buf.Remaining()); } else { uint8_t table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; for (uint i = 0; i < SNOW_LINE_MONTHS; i++) { for (uint j = 0; j < SNOW_LINE_DAYS; j++) { - table[i][j] = buf->ReadByte(); + table[i][j] = buf.ReadByte(); if (_cur.grffile->grf_version >= 8) { if (table[i][j] != 0xFF) table[i][j] = table[i][j] * (1 + _settings_game.construction.map_height_limit) / 256; } else { @@ -2843,7 +2843,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By case 0x11: // GRF match for engine allocation /* This is loaded during the reservation stage, so just skip it here. */ /* Each entry is 8 bytes. */ - buf->Skip(8); + buf.Skip(8); break; case 0x13: // Gender translation table @@ -2855,17 +2855,17 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By GrfMsg(1, "GlobalVarChangeInfo: Language {} is not known, ignoring", curidx); /* Skip over the data. */ if (prop == 0x15) { - buf->ReadByte(); + buf.ReadByte(); } else { - while (buf->ReadByte() != 0) { - buf->ReadString(); + while (buf.ReadByte() != 0) { + buf.ReadString(); } } break; } if (prop == 0x15) { - uint plural_form = buf->ReadByte(); + uint plural_form = buf.ReadByte(); if (plural_form >= LANGUAGE_MAX_PLURAL) { GrfMsg(1, "GlobalVarChanceInfo: Plural form {} is out of range, ignoring", plural_form); } else { @@ -2874,9 +2874,9 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By break; } - uint8_t newgrf_id = buf->ReadByte(); // The NewGRF (custom) identifier. + uint8_t newgrf_id = buf.ReadByte(); // The NewGRF (custom) identifier. while (newgrf_id != 0) { - std::string_view name = buf->ReadString(); // The name for the OpenTTD identifier. + std::string_view name = buf.ReadString(); // The name for the OpenTTD identifier. /* We'll just ignore the UTF8 identifier character. This is (fairly) * safe as OpenTTD's strings gender/cases are usually in ASCII which @@ -2903,7 +2903,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By _cur.grffile->language_map[curidx].case_map.push_back(map); } } - newgrf_id = buf->ReadByte(); + newgrf_id = buf.ReadByte(); } break; } @@ -2917,7 +2917,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By return ret; } -static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, ByteReader &buf) { /* Properties which are handled as a whole */ switch (prop) { @@ -2943,36 +2943,36 @@ static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, B switch (prop) { case 0x08: // Cost base factor case 0x15: // Plural form translation - buf->ReadByte(); + buf.ReadByte(); break; case 0x0A: // Currency display names case 0x0C: // Currency options case 0x0F: // Euro introduction dates - buf->ReadWord(); + buf.ReadWord(); break; case 0x0B: // Currency multipliers case 0x0D: // Currency prefix symbol case 0x0E: // Currency suffix symbol - buf->ReadDWord(); + buf.ReadDWord(); break; case 0x10: // Snow line height table - buf->Skip(SNOW_LINE_MONTHS * SNOW_LINE_DAYS); + buf.Skip(SNOW_LINE_MONTHS * SNOW_LINE_DAYS); break; case 0x11: { // GRF match for engine allocation - uint32_t s = buf->ReadDWord(); - uint32_t t = buf->ReadDWord(); + uint32_t s = buf.ReadDWord(); + uint32_t t = buf.ReadDWord(); SetNewGRFOverride(s, t); break; } case 0x13: // Gender translation table case 0x14: // Case translation table - while (buf->ReadByte() != 0) { - buf->ReadString(); + while (buf.ReadByte() != 0) { + buf.ReadString(); } break; @@ -2994,7 +2994,7 @@ static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, B * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -3008,7 +3008,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea switch (prop) { case 0x08: // Bit number of cargo - cs->bitnum = buf->ReadByte(); + cs->bitnum = buf.ReadByte(); if (cs->IsValid()) { cs->grffile = _cur.grffile; SetBit(_cargo_mask, cid + i); @@ -3019,11 +3019,11 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea break; case 0x09: // String ID for cargo type name - AddStringForMapping(buf->ReadWord(), &cs->name); + AddStringForMapping(buf.ReadWord(), &cs->name); break; case 0x0A: // String for 1 unit of cargo - AddStringForMapping(buf->ReadWord(), &cs->name_single); + AddStringForMapping(buf.ReadWord(), &cs->name_single); break; case 0x0B: // String for singular quantity of cargo (e.g. 1 tonne of coal) @@ -3031,7 +3031,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea /* String for units of cargo. This is different in OpenTTD * (e.g. tonnes) to TTDPatch (e.g. {COMMA} tonne of coal). * Property 1B is used to set OpenTTD's behaviour. */ - AddStringForMapping(buf->ReadWord(), &cs->units_volume); + AddStringForMapping(buf.ReadWord(), &cs->units_volume); break; case 0x0C: // String for plural quantity of cargo (e.g. 10 tonnes of coal) @@ -3039,56 +3039,56 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea /* Strings for an amount of cargo. This is different in OpenTTD * (e.g. {WEIGHT} of coal) to TTDPatch (e.g. {COMMA} tonnes of coal). * Property 1C is used to set OpenTTD's behaviour. */ - AddStringForMapping(buf->ReadWord(), &cs->quantifier); + AddStringForMapping(buf.ReadWord(), &cs->quantifier); break; case 0x0D: // String for two letter cargo abbreviation - AddStringForMapping(buf->ReadWord(), &cs->abbrev); + AddStringForMapping(buf.ReadWord(), &cs->abbrev); break; case 0x0E: // Sprite ID for cargo icon - cs->sprite = buf->ReadWord(); + cs->sprite = buf.ReadWord(); break; case 0x0F: // Weight of one unit of cargo - cs->weight = buf->ReadByte(); + cs->weight = buf.ReadByte(); break; case 0x10: // Used for payment calculation - cs->transit_periods[0] = buf->ReadByte(); + cs->transit_periods[0] = buf.ReadByte(); break; case 0x11: // Used for payment calculation - cs->transit_periods[1] = buf->ReadByte(); + cs->transit_periods[1] = buf.ReadByte(); break; case 0x12: // Base cargo price - cs->initial_payment = buf->ReadDWord(); + cs->initial_payment = buf.ReadDWord(); break; case 0x13: // Colour for station rating bars - cs->rating_colour = buf->ReadByte(); + cs->rating_colour = buf.ReadByte(); break; case 0x14: // Colour for cargo graph - cs->legend_colour = buf->ReadByte(); + cs->legend_colour = buf.ReadByte(); break; case 0x15: // Freight status - cs->is_freight = (buf->ReadByte() != 0); + cs->is_freight = (buf.ReadByte() != 0); break; case 0x16: // Cargo classes - cs->classes = buf->ReadWord(); + cs->classes = buf.ReadWord(); break; case 0x17: // Cargo label - cs->label = CargoLabel{BSWAP32(buf->ReadDWord())}; + cs->label = CargoLabel{BSWAP32(buf.ReadDWord())}; BuildCargoLabelMap(); break; case 0x18: { // Town growth substitute type - uint8_t substitute_type = buf->ReadByte(); + uint8_t substitute_type = buf.ReadByte(); switch (substitute_type) { case 0x00: cs->town_acceptance_effect = TAE_PASSENGERS; break; @@ -3105,19 +3105,19 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea } case 0x19: // Town growth coefficient - buf->ReadWord(); + buf.ReadWord(); break; case 0x1A: // Bitmask of callbacks to use - cs->callback_mask = buf->ReadByte(); + cs->callback_mask = buf.ReadByte(); break; case 0x1D: // Vehicle capacity muliplier - cs->multiplier = std::max(1u, buf->ReadWord()); + cs->multiplier = std::max(1u, buf.ReadWord()); break; case 0x1E: { // Town production substitute type - uint8_t substitute_type = buf->ReadByte(); + uint8_t substitute_type = buf.ReadByte(); switch (substitute_type) { case 0x00: cs->town_production_effect = TPE_PASSENGERS; break; @@ -3131,7 +3131,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea } case 0x1F: // Town production multiplier - cs->town_production_multiplier = std::max(1U, buf->ReadWord()); + cs->town_production_multiplier = std::max(1U, buf.ReadWord()); break; default: @@ -3152,7 +3152,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -3171,15 +3171,15 @@ static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, B switch (prop) { case 0x08: // Relative volume - sound->volume = Clamp(buf->ReadByte(), 0, SOUND_EFFECT_MAX_VOLUME); + sound->volume = Clamp(buf.ReadByte(), 0, SOUND_EFFECT_MAX_VOLUME); break; case 0x09: // Priority - sound->priority = buf->ReadByte(); + sound->priority = buf.ReadByte(); break; case 0x0A: { // Override old sound - SoundID orig_sound = buf->ReadByte(); + SoundID orig_sound = buf.ReadByte(); if (orig_sound >= ORIGINAL_SAMPLE_COUNT) { GrfMsg(1, "SoundEffectChangeInfo: Original sound {} not defined (max {})", orig_sound, ORIGINAL_SAMPLE_COUNT); @@ -3207,7 +3207,7 @@ static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, B * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader *buf) +static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -3218,18 +3218,18 @@ static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader *buf) case 0x10: case 0x11: case 0x12: - buf->ReadByte(); + buf.ReadByte(); break; case 0x0A: case 0x0B: case 0x0C: case 0x0F: - buf->ReadWord(); + buf.ReadWord(); break; case 0x13: - buf->Skip(buf->ReadByte() * 2); + buf.Skip(buf.ReadByte() * 2); break; default: @@ -3247,7 +3247,7 @@ static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader *buf) * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -3270,7 +3270,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr switch (prop) { case 0x08: { // Substitute industry tile type - uint8_t subs_id = buf->ReadByte(); + uint8_t subs_id = buf.ReadByte(); if (subs_id >= NEW_INDUSTRYTILEOFFSET) { /* The substitute id must be one of the original industry tile. */ GrfMsg(2, "IndustryTilesChangeInfo: Attempt to use new industry tile {} as substitute industry tile for {}. Ignoring.", subs_id, indtid + i); @@ -3299,7 +3299,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr } case 0x09: { // Industry tile override - uint8_t ovrid = buf->ReadByte(); + uint8_t ovrid = buf.ReadByte(); /* The industry being overridden must be an original industry. */ if (ovrid >= NEW_INDUSTRYTILEOFFSET) { @@ -3314,7 +3314,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr case 0x0A: // Tile acceptance case 0x0B: case 0x0C: { - uint16_t acctp = buf->ReadWord(); + uint16_t acctp = buf.ReadWord(); tsp->accepts_cargo[prop - 0x0A] = GetCargoTranslation(GB(acctp, 0, 8), _cur.grffile); tsp->acceptance[prop - 0x0A] = Clamp(GB(acctp, 8, 8), 0, 16); tsp->accepts_cargo_label[prop - 0x0A] = CT_INVALID; @@ -3322,32 +3322,32 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr } case 0x0D: // Land shape flags - tsp->slopes_refused = (Slope)buf->ReadByte(); + tsp->slopes_refused = (Slope)buf.ReadByte(); break; case 0x0E: // Callback mask - tsp->callback_mask = buf->ReadByte(); + tsp->callback_mask = buf.ReadByte(); break; case 0x0F: // Animation information - tsp->animation.frames = buf->ReadByte(); - tsp->animation.status = buf->ReadByte(); + tsp->animation.frames = buf.ReadByte(); + tsp->animation.status = buf.ReadByte(); break; case 0x10: // Animation speed - tsp->animation.speed = buf->ReadByte(); + tsp->animation.speed = buf.ReadByte(); break; case 0x11: // Triggers for callback 25 - tsp->animation.triggers = buf->ReadByte(); + tsp->animation.triggers = buf.ReadByte(); break; case 0x12: // Special flags - tsp->special_flags = (IndustryTileSpecialFlags)buf->ReadByte(); + tsp->special_flags = (IndustryTileSpecialFlags)buf.ReadByte(); break; case 0x13: { // variable length cargo acceptance - uint8_t num_cargoes = buf->ReadByte(); + uint8_t num_cargoes = buf.ReadByte(); if (num_cargoes > std::size(tsp->acceptance)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; @@ -3355,9 +3355,9 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr } for (uint i = 0; i < std::size(tsp->acceptance); i++) { if (i < num_cargoes) { - tsp->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + tsp->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur.grffile); /* Tile acceptance can be negative to counteract the INDTILE_SPECIAL_ACCEPTS_ALL_CARGO flag */ - tsp->acceptance[i] = (int8_t)buf->ReadByte(); + tsp->acceptance[i] = (int8_t)buf.ReadByte(); } else { tsp->accepts_cargo[i] = INVALID_CARGO; tsp->acceptance[i] = 0; @@ -3382,7 +3382,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader *buf) +static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -3398,7 +3398,7 @@ static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader *buf) case 0x19: case 0x21: case 0x22: - buf->ReadByte(); + buf.ReadByte(); break; case 0x0C: @@ -3408,7 +3408,7 @@ static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader *buf) case 0x1B: case 0x1F: case 0x24: - buf->ReadWord(); + buf.ReadWord(); break; case 0x11: // INDUSTRY_ORIGINAL_NUM_INPUTS bytes + 1 @@ -3418,45 +3418,45 @@ static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader *buf) case 0x1E: case 0x20: case 0x23: - buf->ReadDWord(); + buf.ReadDWord(); break; case 0x0A: { - uint8_t num_table = buf->ReadByte(); + uint8_t num_table = buf.ReadByte(); for (uint8_t j = 0; j < num_table; j++) { for (uint k = 0;; k++) { - uint8_t x = buf->ReadByte(); + uint8_t x = buf.ReadByte(); if (x == 0xFE && k == 0) { - buf->ReadByte(); - buf->ReadByte(); + buf.ReadByte(); + buf.ReadByte(); break; } - uint8_t y = buf->ReadByte(); + uint8_t y = buf.ReadByte(); if (x == 0 && y == 0x80) break; - uint8_t gfx = buf->ReadByte(); - if (gfx == 0xFE) buf->ReadWord(); + uint8_t gfx = buf.ReadByte(); + if (gfx == 0xFE) buf.ReadWord(); } } break; } case 0x16: - for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_INPUTS; j++) buf->ReadByte(); + for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_INPUTS; j++) buf.ReadByte(); break; case 0x15: case 0x25: case 0x26: case 0x27: - buf->Skip(buf->ReadByte()); + buf.Skip(buf.ReadByte()); break; case 0x28: { - int num_inputs = buf->ReadByte(); - int num_outputs = buf->ReadByte(); - buf->Skip(num_inputs * num_outputs * 2); + int num_inputs = buf.ReadByte(); + int num_outputs = buf.ReadByte(); + buf.Skip(num_inputs * num_outputs * 2); break; } @@ -3505,7 +3505,7 @@ static bool ValidateIndustryLayout(const IndustryTileLayout &layout) * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -3528,7 +3528,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, switch (prop) { case 0x08: { // Substitute industry type - uint8_t subs_id = buf->ReadByte(); + uint8_t subs_id = buf.ReadByte(); if (subs_id == 0xFF) { /* Instead of defining a new industry, a substitute industry id * of 0xFF disables the old industry with the current id. */ @@ -3559,7 +3559,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } case 0x09: { // Industry type override - uint8_t ovrid = buf->ReadByte(); + uint8_t ovrid = buf.ReadByte(); /* The industry being overridden must be an original industry. */ if (ovrid >= NEW_INDUSTRYOFFSET) { @@ -3572,8 +3572,8 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } case 0x0A: { // Set industry layout(s) - uint8_t new_num_layouts = buf->ReadByte(); - uint32_t definition_size = buf->ReadDWord(); + uint8_t new_num_layouts = buf.ReadByte(); + uint32_t definition_size = buf.ReadDWord(); uint32_t bytes_read = 0; std::vector new_layouts; IndustryTileLayout layout; @@ -3592,13 +3592,13 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, layout.push_back(IndustryTileLayoutTile{}); IndustryTileLayoutTile &it = layout.back(); - it.ti.x = buf->ReadByte(); // Offsets from northermost tile + it.ti.x = buf.ReadByte(); // Offsets from northermost tile ++bytes_read; if (it.ti.x == 0xFE && k == 0) { /* This means we have to borrow the layout from an old industry */ - IndustryType type = buf->ReadByte(); - uint8_t laynbr = buf->ReadByte(); + IndustryType type = buf.ReadByte(); + uint8_t laynbr = buf.ReadByte(); bytes_read += 2; if (type >= lengthof(_origin_industry_specs)) { @@ -3615,7 +3615,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, break; } - it.ti.y = buf->ReadByte(); // Or table definition finalisation + it.ti.y = buf.ReadByte(); // Or table definition finalisation ++bytes_read; if (it.ti.x == 0 && it.ti.y == 0x80) { @@ -3624,12 +3624,12 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, break; } - it.gfx = buf->ReadByte(); + it.gfx = buf.ReadByte(); ++bytes_read; if (it.gfx == 0xFE) { /* Use a new tile from this GRF */ - int local_tile_id = buf->ReadWord(); + int local_tile_id = buf.ReadWord(); bytes_read += 2; /* Read the ID from the _industile_mngr. */ @@ -3672,56 +3672,56 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } case 0x0B: // Industry production flags - indsp->life_type = (IndustryLifeType)buf->ReadByte(); + indsp->life_type = (IndustryLifeType)buf.ReadByte(); break; case 0x0C: // Industry closure message - AddStringForMapping(buf->ReadWord(), &indsp->closure_text); + AddStringForMapping(buf.ReadWord(), &indsp->closure_text); break; case 0x0D: // Production increase message - AddStringForMapping(buf->ReadWord(), &indsp->production_up_text); + AddStringForMapping(buf.ReadWord(), &indsp->production_up_text); break; case 0x0E: // Production decrease message - AddStringForMapping(buf->ReadWord(), &indsp->production_down_text); + AddStringForMapping(buf.ReadWord(), &indsp->production_down_text); break; case 0x0F: // Fund cost multiplier - indsp->cost_multiplier = buf->ReadByte(); + indsp->cost_multiplier = buf.ReadByte(); break; case 0x10: // Production cargo types for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_OUTPUTS; j++) { - indsp->produced_cargo[j] = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + indsp->produced_cargo[j] = GetCargoTranslation(buf.ReadByte(), _cur.grffile); indsp->produced_cargo_label[j] = CT_INVALID; } break; case 0x11: // Acceptance cargo types for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_INPUTS; j++) { - indsp->accepts_cargo[j] = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + indsp->accepts_cargo[j] = GetCargoTranslation(buf.ReadByte(), _cur.grffile); indsp->accepts_cargo_label[j] = CT_INVALID; } - buf->ReadByte(); // Unnused, eat it up + buf.ReadByte(); // Unnused, eat it up break; case 0x12: // Production multipliers case 0x13: - indsp->production_rate[prop - 0x12] = buf->ReadByte(); + indsp->production_rate[prop - 0x12] = buf.ReadByte(); break; case 0x14: // Minimal amount of cargo distributed - indsp->minimal_cargo = buf->ReadByte(); + indsp->minimal_cargo = buf.ReadByte(); break; case 0x15: { // Random sound effects - uint8_t num_sounds = buf->ReadByte(); + uint8_t num_sounds = buf.ReadByte(); std::vector sounds; sounds.reserve(num_sounds); for (uint8_t j = 0; j < num_sounds; ++j) { - sounds.push_back(buf->ReadByte()); + sounds.push_back(buf.ReadByte()); } indsp->random_sounds = std::move(sounds); @@ -3729,59 +3729,59 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } case 0x16: // Conflicting industry types - for (uint8_t j = 0; j < 3; j++) indsp->conflicting[j] = buf->ReadByte(); + for (uint8_t j = 0; j < 3; j++) indsp->conflicting[j] = buf.ReadByte(); break; case 0x17: // Probability in random game - indsp->appear_creation[_settings_game.game_creation.landscape] = buf->ReadByte(); + indsp->appear_creation[_settings_game.game_creation.landscape] = buf.ReadByte(); break; case 0x18: // Probability during gameplay - indsp->appear_ingame[_settings_game.game_creation.landscape] = buf->ReadByte(); + indsp->appear_ingame[_settings_game.game_creation.landscape] = buf.ReadByte(); break; case 0x19: // Map colour - indsp->map_colour = buf->ReadByte(); + indsp->map_colour = buf.ReadByte(); break; case 0x1A: // Special industry flags to define special behavior - indsp->behaviour = (IndustryBehaviour)buf->ReadDWord(); + indsp->behaviour = (IndustryBehaviour)buf.ReadDWord(); break; case 0x1B: // New industry text ID - AddStringForMapping(buf->ReadWord(), &indsp->new_industry_text); + AddStringForMapping(buf.ReadWord(), &indsp->new_industry_text); break; case 0x1C: // Input cargo multipliers for the three input cargo types case 0x1D: case 0x1E: { - uint32_t multiples = buf->ReadDWord(); + uint32_t multiples = buf.ReadDWord(); indsp->input_cargo_multiplier[prop - 0x1C][0] = GB(multiples, 0, 16); indsp->input_cargo_multiplier[prop - 0x1C][1] = GB(multiples, 16, 16); break; } case 0x1F: // Industry name - AddStringForMapping(buf->ReadWord(), &indsp->name); + AddStringForMapping(buf.ReadWord(), &indsp->name); break; case 0x20: // Prospecting success chance - indsp->prospecting_chance = buf->ReadDWord(); + indsp->prospecting_chance = buf.ReadDWord(); break; case 0x21: // Callback mask case 0x22: { // Callback additional mask - uint8_t aflag = buf->ReadByte(); + uint8_t aflag = buf.ReadByte(); SB(indsp->callback_mask, (prop - 0x21) * 8, 8, aflag); break; } case 0x23: // removal cost multiplier - indsp->removal_cost_multiplier = buf->ReadDWord(); + indsp->removal_cost_multiplier = buf.ReadDWord(); break; case 0x24: { // name for nearby station - uint16_t str = buf->ReadWord(); + uint16_t str = buf.ReadWord(); if (str == 0) { indsp->station_name = STR_NULL; } else { @@ -3791,7 +3791,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } case 0x25: { // variable length produced cargoes - uint8_t num_cargoes = buf->ReadByte(); + uint8_t num_cargoes = buf.ReadByte(); if (num_cargoes > std::size(indsp->produced_cargo)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; @@ -3799,7 +3799,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } for (size_t i = 0; i < std::size(indsp->produced_cargo); i++) { if (i < num_cargoes) { - CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + CargoID cargo = GetCargoTranslation(buf.ReadByte(), _cur.grffile); indsp->produced_cargo[i] = cargo; } else { indsp->produced_cargo[i] = INVALID_CARGO; @@ -3810,7 +3810,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } case 0x26: { // variable length accepted cargoes - uint8_t num_cargoes = buf->ReadByte(); + uint8_t num_cargoes = buf.ReadByte(); if (num_cargoes > std::size(indsp->accepts_cargo)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; @@ -3818,7 +3818,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } for (size_t i = 0; i < std::size(indsp->accepts_cargo); i++) { if (i < num_cargoes) { - CargoID cargo = GetCargoTranslation(buf->ReadByte(), _cur.grffile); + CargoID cargo = GetCargoTranslation(buf.ReadByte(), _cur.grffile); indsp->accepts_cargo[i] = cargo; } else { indsp->accepts_cargo[i] = INVALID_CARGO; @@ -3829,7 +3829,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } case 0x27: { // variable length production rates - uint8_t num_cargoes = buf->ReadByte(); + uint8_t num_cargoes = buf.ReadByte(); if (num_cargoes > lengthof(indsp->production_rate)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; @@ -3837,7 +3837,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } for (uint i = 0; i < lengthof(indsp->production_rate); i++) { if (i < num_cargoes) { - indsp->production_rate[i] = buf->ReadByte(); + indsp->production_rate[i] = buf.ReadByte(); } else { indsp->production_rate[i] = 0; } @@ -3846,8 +3846,8 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } case 0x28: { // variable size input/output production multiplier table - uint8_t num_inputs = buf->ReadByte(); - uint8_t num_outputs = buf->ReadByte(); + uint8_t num_inputs = buf.ReadByte(); + uint8_t num_outputs = buf.ReadByte(); if (num_inputs > std::size(indsp->accepts_cargo) || num_outputs > std::size(indsp->produced_cargo)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; @@ -3856,7 +3856,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, for (size_t i = 0; i < std::size(indsp->accepts_cargo); i++) { for (size_t j = 0; j < std::size(indsp->produced_cargo); j++) { uint16_t mult = 0; - if (i < num_inputs && j < num_outputs) mult = buf->ReadWord(); + if (i < num_inputs && j < num_outputs) mult = buf.ReadWord(); indsp->input_cargo_multiplier[i][j] = mult; } } @@ -3880,7 +3880,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -3902,7 +3902,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B switch (prop) { case 0x08: { // Modify original airport - uint8_t subs_id = buf->ReadByte(); + uint8_t subs_id = buf.ReadByte(); if (subs_id == 0xFF) { /* Instead of defining a new airport, an airport id * of 0xFF disables the old airport with the current id. */ @@ -3932,8 +3932,8 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B } case 0x0A: { // Set airport layout - uint8_t num_layouts = buf->ReadByte(); - buf->ReadDWord(); // Total size of definition, unneeded. + uint8_t num_layouts = buf.ReadByte(); + buf.ReadDWord(); // Total size of definition, unneeded. uint8_t size_x = 0; uint8_t size_y = 0; @@ -3942,12 +3942,12 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B for (uint8_t j = 0; j != num_layouts; ++j) { auto &layout = layouts.emplace_back(); - layout.rotation = static_cast(buf->ReadByte() & 6); // Rotation can only be DIR_NORTH, DIR_EAST, DIR_SOUTH or DIR_WEST. + layout.rotation = static_cast(buf.ReadByte() & 6); // Rotation can only be DIR_NORTH, DIR_EAST, DIR_SOUTH or DIR_WEST. for (;;) { auto &tile = layout.tiles.emplace_back(); - tile.ti.x = buf->ReadByte(); - tile.ti.y = buf->ReadByte(); + tile.ti.x = buf.ReadByte(); + tile.ti.y = buf.ReadByte(); if (tile.ti.x == 0 && tile.ti.y == 0x80) { /* Convert terminator to our own. */ tile.ti.x = -0x80; @@ -3956,11 +3956,11 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B break; } - tile.gfx = buf->ReadByte(); + tile.gfx = buf.ReadByte(); if (tile.gfx == 0xFE) { /* Use a new tile from this GRF */ - int local_tile_id = buf->ReadWord(); + int local_tile_id = buf.ReadWord(); /* Read the ID from the _airporttile_mngr. */ uint16_t tempid = _airporttile_mngr.GetID(local_tile_id, _cur.grffile->grfid); @@ -3993,29 +3993,29 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B } case 0x0C: - as->min_year = buf->ReadWord(); - as->max_year = buf->ReadWord(); + as->min_year = buf.ReadWord(); + as->max_year = buf.ReadWord(); if (as->max_year == 0xFFFF) as->max_year = CalendarTime::MAX_YEAR; break; case 0x0D: - as->ttd_airport_type = (TTDPAirportType)buf->ReadByte(); + as->ttd_airport_type = (TTDPAirportType)buf.ReadByte(); break; case 0x0E: - as->catchment = Clamp(buf->ReadByte(), 1, MAX_CATCHMENT); + as->catchment = Clamp(buf.ReadByte(), 1, MAX_CATCHMENT); break; case 0x0F: - as->noise_level = buf->ReadByte(); + as->noise_level = buf.ReadByte(); break; case 0x10: - AddStringForMapping(buf->ReadWord(), &as->name); + AddStringForMapping(buf.ReadWord(), &as->name); break; case 0x11: // Maintenance cost factor - as->maintenance_cost = buf->ReadWord(); + as->maintenance_cost = buf.ReadWord(); break; default: @@ -4033,7 +4033,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader *buf) +static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4046,7 +4046,7 @@ static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader *buf) case 0x16: case 0x17: case 0x18: - buf->ReadByte(); + buf.ReadByte(); break; case 0x09: @@ -4055,13 +4055,13 @@ static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader *buf) case 0x11: case 0x13: case 0x15: - buf->ReadWord(); + buf.ReadWord(); break; case 0x08: case 0x0E: case 0x0F: - buf->ReadDWord(); + buf.ReadDWord(); break; default: @@ -4080,7 +4080,7 @@ static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader *buf) * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4113,26 +4113,26 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea } /* Swap classid because we read it in BE. */ - uint32_t classid = buf->ReadDWord(); + uint32_t classid = buf.ReadDWord(); spec->class_index = ObjectClass::Allocate(BSWAP32(classid)); break; } case 0x09: { // Class name - AddStringForMapping(buf->ReadWord(), [spec](StringID str) { ObjectClass::Get(spec->class_index)->name = str; }); + AddStringForMapping(buf.ReadWord(), [spec](StringID str) { ObjectClass::Get(spec->class_index)->name = str; }); break; } case 0x0A: // Object name - AddStringForMapping(buf->ReadWord(), &spec->name); + AddStringForMapping(buf.ReadWord(), &spec->name); break; case 0x0B: // Climate mask - spec->climate = buf->ReadByte(); + spec->climate = buf.ReadByte(); break; case 0x0C: // Size - spec->size = buf->ReadByte(); + spec->size = buf.ReadByte(); if (GB(spec->size, 0, 4) == 0 || GB(spec->size, 4, 4) == 0) { GrfMsg(0, "ObjectChangeInfo: Invalid object size requested (0x{:X}) for object id {}. Ignoring.", spec->size, id + i); spec->size = OBJECT_SIZE_1X1; @@ -4140,50 +4140,50 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea break; case 0x0D: // Build cost multipler - spec->build_cost_multiplier = buf->ReadByte(); + spec->build_cost_multiplier = buf.ReadByte(); spec->clear_cost_multiplier = spec->build_cost_multiplier; break; case 0x0E: // Introduction date - spec->introduction_date = buf->ReadDWord(); + spec->introduction_date = buf.ReadDWord(); break; case 0x0F: // End of life - spec->end_of_life_date = buf->ReadDWord(); + spec->end_of_life_date = buf.ReadDWord(); break; case 0x10: // Flags - spec->flags = (ObjectFlags)buf->ReadWord(); + spec->flags = (ObjectFlags)buf.ReadWord(); _loaded_newgrf_features.has_2CC |= (spec->flags & OBJECT_FLAG_2CC_COLOUR) != 0; break; case 0x11: // Animation info - spec->animation.frames = buf->ReadByte(); - spec->animation.status = buf->ReadByte(); + spec->animation.frames = buf.ReadByte(); + spec->animation.status = buf.ReadByte(); break; case 0x12: // Animation speed - spec->animation.speed = buf->ReadByte(); + spec->animation.speed = buf.ReadByte(); break; case 0x13: // Animation triggers - spec->animation.triggers = buf->ReadWord(); + spec->animation.triggers = buf.ReadWord(); break; case 0x14: // Removal cost multiplier - spec->clear_cost_multiplier = buf->ReadByte(); + spec->clear_cost_multiplier = buf.ReadByte(); break; case 0x15: // Callback mask - spec->callback_mask = buf->ReadWord(); + spec->callback_mask = buf.ReadWord(); break; case 0x16: // Building height - spec->height = buf->ReadByte(); + spec->height = buf.ReadByte(); break; case 0x17: // Views - spec->views = buf->ReadByte(); + spec->views = buf.ReadByte(); if (spec->views != 1 && spec->views != 2 && spec->views != 4) { GrfMsg(2, "ObjectChangeInfo: Invalid number of views ({}) for object id {}. Ignoring.", spec->views, id + i); spec->views = 1; @@ -4191,7 +4191,7 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea break; case 0x18: // Amount placed on 256^2 map on map creation - spec->generate_amount = buf->ReadByte(); + spec->generate_amount = buf.ReadByte(); break; default: @@ -4211,7 +4211,7 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4231,11 +4231,11 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR switch (prop) { case 0x08: // Label of rail type /* Skipped here as this is loaded during reservation stage. */ - buf->ReadDWord(); + buf.ReadDWord(); break; case 0x09: { // Toolbar caption of railtype (sets name as well for backwards compatibility for grf ver < 8) - uint16_t str = buf->ReadWord(); + uint16_t str = buf.ReadWord(); AddStringForMapping(str, &rti->strings.toolbar_caption); if (_cur.grffile->grf_version < 8) { AddStringForMapping(str, &rti->strings.name); @@ -4244,19 +4244,19 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR } case 0x0A: // Menu text of railtype - AddStringForMapping(buf->ReadWord(), &rti->strings.menu_text); + AddStringForMapping(buf.ReadWord(), &rti->strings.menu_text); break; case 0x0B: // Build window caption - AddStringForMapping(buf->ReadWord(), &rti->strings.build_caption); + AddStringForMapping(buf.ReadWord(), &rti->strings.build_caption); break; case 0x0C: // Autoreplace text - AddStringForMapping(buf->ReadWord(), &rti->strings.replace_text); + AddStringForMapping(buf.ReadWord(), &rti->strings.replace_text); break; case 0x0D: // New locomotive text - AddStringForMapping(buf->ReadWord(), &rti->strings.new_loco); + AddStringForMapping(buf.ReadWord(), &rti->strings.new_loco); break; case 0x0E: // Compatible railtype list @@ -4267,9 +4267,9 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR /* Rail type compatibility bits are added to the existing bits * to allow multiple GRFs to modify compatibility with the * default rail types. */ - int n = buf->ReadByte(); + int n = buf.ReadByte(); for (int j = 0; j != n; j++) { - RailTypeLabel label = buf->ReadDWord(); + RailTypeLabel label = buf.ReadDWord(); RailType resolved_rt = GetRailTypeByLabel(BSWAP32(label), false); if (resolved_rt != INVALID_RAILTYPE) { switch (prop) { @@ -4284,52 +4284,52 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR } case 0x10: // Rail Type flags - rti->flags = (RailTypeFlags)buf->ReadByte(); + rti->flags = (RailTypeFlags)buf.ReadByte(); break; case 0x11: // Curve speed advantage - rti->curve_speed = buf->ReadByte(); + rti->curve_speed = buf.ReadByte(); break; case 0x12: // Station graphic - rti->fallback_railtype = Clamp(buf->ReadByte(), 0, 2); + rti->fallback_railtype = Clamp(buf.ReadByte(), 0, 2); break; case 0x13: // Construction cost factor - rti->cost_multiplier = buf->ReadWord(); + rti->cost_multiplier = buf.ReadWord(); break; case 0x14: // Speed limit - rti->max_speed = buf->ReadWord(); + rti->max_speed = buf.ReadWord(); break; case 0x15: // Acceleration model - rti->acceleration_type = Clamp(buf->ReadByte(), 0, 2); + rti->acceleration_type = Clamp(buf.ReadByte(), 0, 2); break; case 0x16: // Map colour - rti->map_colour = buf->ReadByte(); + rti->map_colour = buf.ReadByte(); break; case 0x17: // Introduction date - rti->introduction_date = buf->ReadDWord(); + rti->introduction_date = buf.ReadDWord(); break; case 0x1A: // Sort order - rti->sorting_order = buf->ReadByte(); + rti->sorting_order = buf.ReadByte(); break; case 0x1B: // Name of railtype (overridden by prop 09 for grf ver < 8) - AddStringForMapping(buf->ReadWord(), &rti->strings.name); + AddStringForMapping(buf.ReadWord(), &rti->strings.name); break; case 0x1C: // Maintenance cost factor - rti->maintenance_multiplier = buf->ReadWord(); + rti->maintenance_multiplier = buf.ReadWord(); break; case 0x1D: // Alternate rail type label list /* Skipped here as this is loaded during reservation stage. */ - for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord(); + for (int j = buf.ReadByte(); j != 0; j--) buf.ReadDWord(); break; default: @@ -4341,7 +4341,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR return ret; } -static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4356,7 +4356,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, Byte switch (prop) { case 0x08: // Label of rail type { - RailTypeLabel rtl = buf->ReadDWord(); + RailTypeLabel rtl = buf.ReadDWord(); rtl = BSWAP32(rtl); RailType rt = GetRailTypeByLabel(rtl, false); @@ -4378,14 +4378,14 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, Byte case 0x14: // Speed limit case 0x1B: // Name of railtype case 0x1C: // Maintenance cost factor - buf->ReadWord(); + buf.ReadWord(); break; case 0x1D: // Alternate rail type label list if (_cur.grffile->railtype_map[id + i] != INVALID_RAILTYPE) { - int n = buf->ReadByte(); + int n = buf.ReadByte(); for (int j = 0; j != n; j++) { - _railtypes[_cur.grffile->railtype_map[id + i]].alternate_labels.push_back(BSWAP32(buf->ReadDWord())); + _railtypes[_cur.grffile->railtype_map[id + i]].alternate_labels.push_back(BSWAP32(buf.ReadDWord())); } break; } @@ -4396,7 +4396,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, Byte case 0x0F: // Powered railtype list case 0x18: // Railtype list required for date introduction case 0x19: // Introduced railtype list - for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord(); + for (int j = buf.ReadByte(); j != 0; j--) buf.ReadDWord(); break; case 0x10: // Rail Type flags @@ -4405,11 +4405,11 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, Byte case 0x15: // Acceleration model case 0x16: // Map colour case 0x1A: // Sort order - buf->ReadByte(); + buf.ReadByte(); break; case 0x17: // Introduction date - buf->ReadDWord(); + buf.ReadDWord(); break; default: @@ -4429,7 +4429,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, Byte * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteReader *buf, RoadTramType rtt) +static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteReader &buf, RoadTramType rtt) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4450,29 +4450,29 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteR switch (prop) { case 0x08: // Label of road type /* Skipped here as this is loaded during reservation stage. */ - buf->ReadDWord(); + buf.ReadDWord(); break; case 0x09: { // Toolbar caption of roadtype (sets name as well for backwards compatibility for grf ver < 8) - uint16_t str = buf->ReadWord(); + uint16_t str = buf.ReadWord(); AddStringForMapping(str, &rti->strings.toolbar_caption); break; } case 0x0A: // Menu text of roadtype - AddStringForMapping(buf->ReadWord(), &rti->strings.menu_text); + AddStringForMapping(buf.ReadWord(), &rti->strings.menu_text); break; case 0x0B: // Build window caption - AddStringForMapping(buf->ReadWord(), &rti->strings.build_caption); + AddStringForMapping(buf.ReadWord(), &rti->strings.build_caption); break; case 0x0C: // Autoreplace text - AddStringForMapping(buf->ReadWord(), &rti->strings.replace_text); + AddStringForMapping(buf.ReadWord(), &rti->strings.replace_text); break; case 0x0D: // New engine text - AddStringForMapping(buf->ReadWord(), &rti->strings.new_engine); + AddStringForMapping(buf.ReadWord(), &rti->strings.new_engine); break; case 0x0F: // Powered roadtype list @@ -4481,9 +4481,9 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteR /* Road type compatibility bits are added to the existing bits * to allow multiple GRFs to modify compatibility with the * default road types. */ - int n = buf->ReadByte(); + int n = buf.ReadByte(); for (int j = 0; j != n; j++) { - RoadTypeLabel label = buf->ReadDWord(); + RoadTypeLabel label = buf.ReadDWord(); RoadType resolved_rt = GetRoadTypeByLabel(BSWAP32(label), false); if (resolved_rt != INVALID_ROADTYPE) { switch (prop) { @@ -4503,40 +4503,40 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteR } case 0x10: // Road Type flags - rti->flags = (RoadTypeFlags)buf->ReadByte(); + rti->flags = (RoadTypeFlags)buf.ReadByte(); break; case 0x13: // Construction cost factor - rti->cost_multiplier = buf->ReadWord(); + rti->cost_multiplier = buf.ReadWord(); break; case 0x14: // Speed limit - rti->max_speed = buf->ReadWord(); + rti->max_speed = buf.ReadWord(); break; case 0x16: // Map colour - rti->map_colour = buf->ReadByte(); + rti->map_colour = buf.ReadByte(); break; case 0x17: // Introduction date - rti->introduction_date = buf->ReadDWord(); + rti->introduction_date = buf.ReadDWord(); break; case 0x1A: // Sort order - rti->sorting_order = buf->ReadByte(); + rti->sorting_order = buf.ReadByte(); break; case 0x1B: // Name of roadtype - AddStringForMapping(buf->ReadWord(), &rti->strings.name); + AddStringForMapping(buf.ReadWord(), &rti->strings.name); break; case 0x1C: // Maintenance cost factor - rti->maintenance_multiplier = buf->ReadWord(); + rti->maintenance_multiplier = buf.ReadWord(); break; case 0x1D: // Alternate road type label list /* Skipped here as this is loaded during reservation stage. */ - for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord(); + for (int j = buf.ReadByte(); j != 0; j--) buf.ReadDWord(); break; default: @@ -4548,18 +4548,18 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteR return ret; } -static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteReader &buf) { return RoadTypeChangeInfo(id, numinfo, prop, buf, RTT_ROAD); } -static ChangeInfoResult TramTypeChangeInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult TramTypeChangeInfo(uint id, int numinfo, int prop, ByteReader &buf) { return RoadTypeChangeInfo(id, numinfo, prop, buf, RTT_TRAM); } -static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf, RoadTramType rtt) +static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, ByteReader &buf, RoadTramType rtt) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4574,7 +4574,7 @@ static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, Byte for (int i = 0; i < numinfo; i++) { switch (prop) { case 0x08: { // Label of road type - RoadTypeLabel rtl = buf->ReadDWord(); + RoadTypeLabel rtl = buf.ReadDWord(); rtl = BSWAP32(rtl); RoadType rt = GetRoadTypeByLabel(rtl, false); @@ -4598,14 +4598,14 @@ static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, Byte case 0x14: // Speed limit case 0x1B: // Name of roadtype case 0x1C: // Maintenance cost factor - buf->ReadWord(); + buf.ReadWord(); break; case 0x1D: // Alternate road type label list if (type_map[id + i] != INVALID_ROADTYPE) { - int n = buf->ReadByte(); + int n = buf.ReadByte(); for (int j = 0; j != n; j++) { - _roadtypes[type_map[id + i]].alternate_labels.push_back(BSWAP32(buf->ReadDWord())); + _roadtypes[type_map[id + i]].alternate_labels.push_back(BSWAP32(buf.ReadDWord())); } break; } @@ -4615,17 +4615,17 @@ static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, Byte case 0x0F: // Powered roadtype list case 0x18: // Roadtype list required for date introduction case 0x19: // Introduced roadtype list - for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord(); + for (int j = buf.ReadByte(); j != 0; j--) buf.ReadDWord(); break; case 0x10: // Road Type flags case 0x16: // Map colour case 0x1A: // Sort order - buf->ReadByte(); + buf.ReadByte(); break; case 0x17: // Introduction date - buf->ReadDWord(); + buf.ReadDWord(); break; default: @@ -4637,17 +4637,17 @@ static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, Byte return ret; } -static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, ByteReader &buf) { return RoadTypeReserveInfo(id, numinfo, prop, buf, RTT_ROAD); } -static ChangeInfoResult TramTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult TramTypeReserveInfo(uint id, int numinfo, int prop, ByteReader &buf) { return RoadTypeReserveInfo(id, numinfo, prop, buf, RTT_TRAM); } -static ChangeInfoResult AirportTilesChangeInfo(uint airtid, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult AirportTilesChangeInfo(uint airtid, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4669,7 +4669,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint airtid, int numinfo, int pro switch (prop) { case 0x08: { // Substitute airport tile type - uint8_t subs_id = buf->ReadByte(); + uint8_t subs_id = buf.ReadByte(); if (subs_id >= NEW_AIRPORTTILE_OFFSET) { /* The substitute id must be one of the original airport tiles. */ GrfMsg(2, "AirportTileChangeInfo: Attempt to use new airport tile {} as substitute airport tile for {}. Ignoring.", subs_id, airtid + i); @@ -4694,7 +4694,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint airtid, int numinfo, int pro } case 0x09: { // Airport tile override - uint8_t override = buf->ReadByte(); + uint8_t override = buf.ReadByte(); /* The airport tile being overridden must be an original airport tile. */ if (override >= NEW_AIRPORTTILE_OFFSET) { @@ -4707,20 +4707,20 @@ static ChangeInfoResult AirportTilesChangeInfo(uint airtid, int numinfo, int pro } case 0x0E: // Callback mask - tsp->callback_mask = buf->ReadByte(); + tsp->callback_mask = buf.ReadByte(); break; case 0x0F: // Animation information - tsp->animation.frames = buf->ReadByte(); - tsp->animation.status = buf->ReadByte(); + tsp->animation.frames = buf.ReadByte(); + tsp->animation.status = buf.ReadByte(); break; case 0x10: // Animation speed - tsp->animation.speed = buf->ReadByte(); + tsp->animation.speed = buf.ReadByte(); break; case 0x11: // Animation triggers - tsp->animation.triggers = buf->ReadByte(); + tsp->animation.triggers = buf.ReadByte(); break; default: @@ -4738,7 +4738,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint airtid, int numinfo, int pro * @param buf The property value. * @return ChangeInfoResult. */ -static ChangeInfoResult IgnoreRoadStopProperty(uint prop, ByteReader *buf) +static ChangeInfoResult IgnoreRoadStopProperty(uint prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4747,7 +4747,7 @@ static ChangeInfoResult IgnoreRoadStopProperty(uint prop, ByteReader *buf) case 0x0C: case 0x0F: case 0x11: - buf->ReadByte(); + buf.ReadByte(); break; case 0x0A: @@ -4755,13 +4755,13 @@ static ChangeInfoResult IgnoreRoadStopProperty(uint prop, ByteReader *buf) case 0x0E: case 0x10: case 0x15: - buf->ReadWord(); + buf.ReadWord(); break; case 0x08: case 0x0D: case 0x12: - buf->ReadDWord(); + buf.ReadDWord(); break; default: @@ -4772,7 +4772,7 @@ static ChangeInfoResult IgnoreRoadStopProperty(uint prop, ByteReader *buf) return ret; } -static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, ByteReader *buf) +static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, ByteReader &buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -4800,55 +4800,55 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, ByteR rs = _cur.grffile->roadstops[id + i].get(); } - uint32_t classid = buf->ReadDWord(); + uint32_t classid = buf.ReadDWord(); rs->class_index = RoadStopClass::Allocate(BSWAP32(classid)); break; } case 0x09: // Road stop type - rs->stop_type = (RoadStopAvailabilityType)buf->ReadByte(); + rs->stop_type = (RoadStopAvailabilityType)buf.ReadByte(); break; case 0x0A: // Road Stop Name - AddStringForMapping(buf->ReadWord(), &rs->name); + AddStringForMapping(buf.ReadWord(), &rs->name); break; case 0x0B: // Road Stop Class name - AddStringForMapping(buf->ReadWord(), [rs](StringID str) { RoadStopClass::Get(rs->class_index)->name = str; }); + AddStringForMapping(buf.ReadWord(), [rs](StringID str) { RoadStopClass::Get(rs->class_index)->name = str; }); break; case 0x0C: // The draw mode - rs->draw_mode = (RoadStopDrawMode)buf->ReadByte(); + rs->draw_mode = (RoadStopDrawMode)buf.ReadByte(); break; case 0x0D: // Cargo types for random triggers - rs->cargo_triggers = TranslateRefitMask(buf->ReadDWord()); + rs->cargo_triggers = TranslateRefitMask(buf.ReadDWord()); break; case 0x0E: // Animation info - rs->animation.frames = buf->ReadByte(); - rs->animation.status = buf->ReadByte(); + rs->animation.frames = buf.ReadByte(); + rs->animation.status = buf.ReadByte(); break; case 0x0F: // Animation speed - rs->animation.speed = buf->ReadByte(); + rs->animation.speed = buf.ReadByte(); break; case 0x10: // Animation triggers - rs->animation.triggers = buf->ReadWord(); + rs->animation.triggers = buf.ReadWord(); break; case 0x11: // Callback mask - rs->callback_mask = buf->ReadByte(); + rs->callback_mask = buf.ReadByte(); break; case 0x12: // General flags - rs->flags = (uint8_t)buf->ReadDWord(); // Future-proofing, size this as 4 bytes, but we only need one byte's worth of flags at present + rs->flags = (uint8_t)buf.ReadDWord(); // Future-proofing, size this as 4 bytes, but we only need one byte's worth of flags at present break; case 0x15: // Cost multipliers - rs->build_cost_multiplier = buf->ReadByte(); - rs->clear_cost_multiplier = buf->ReadByte(); + rs->build_cost_multiplier = buf.ReadByte(); + rs->clear_cost_multiplier = buf.ReadByte(); break; default: @@ -4890,7 +4890,7 @@ static bool HandleChangeInfoResult(const char *caller, ChangeInfoResult cir, uin } /* Action 0x00 */ -static void FeatureChangeInfo(ByteReader *buf) +static void FeatureChangeInfo(ByteReader &buf) { /* <00> ()... * @@ -4928,10 +4928,10 @@ static void FeatureChangeInfo(ByteReader *buf) }; static_assert(GSF_END == lengthof(handler)); - uint8_t feature = buf->ReadByte(); - uint8_t numprops = buf->ReadByte(); - uint numinfo = buf->ReadByte(); - uint engine = buf->ReadExtendedByte(); + uint8_t feature = buf.ReadByte(); + uint8_t numprops = buf.ReadByte(); + uint numinfo = buf.ReadByte(); + uint engine = buf.ReadExtendedByte(); if (feature >= GSF_END) { GrfMsg(1, "FeatureChangeInfo: Unsupported feature 0x{:02X}, skipping", feature); @@ -4949,8 +4949,8 @@ static void FeatureChangeInfo(ByteReader *buf) /* Mark the feature as used by the grf */ SetBit(_cur.grffile->grf_features, feature); - while (numprops-- && buf->HasData()) { - uint8_t prop = buf->ReadByte(); + while (numprops-- && buf.HasData()) { + uint8_t prop = buf.ReadByte(); ChangeInfoResult cir = handler[feature](engine, numinfo, prop, buf); if (HandleChangeInfoResult("FeatureChangeInfo", cir, feature, prop)) return; @@ -4958,26 +4958,26 @@ static void FeatureChangeInfo(ByteReader *buf) } /* Action 0x00 (GLS_SAFETYSCAN) */ -static void SafeChangeInfo(ByteReader *buf) +static void SafeChangeInfo(ByteReader &buf) { - uint8_t feature = buf->ReadByte(); - uint8_t numprops = buf->ReadByte(); - uint numinfo = buf->ReadByte(); - buf->ReadExtendedByte(); // id + uint8_t feature = buf.ReadByte(); + uint8_t numprops = buf.ReadByte(); + uint numinfo = buf.ReadByte(); + buf.ReadExtendedByte(); // id if (feature == GSF_BRIDGES && numprops == 1) { - uint8_t prop = buf->ReadByte(); + uint8_t prop = buf.ReadByte(); /* Bridge property 0x0D is redefinition of sprite layout tables, which * is considered safe. */ if (prop == 0x0D) return; } else if (feature == GSF_GLOBALVAR && numprops == 1) { - uint8_t prop = buf->ReadByte(); + uint8_t prop = buf.ReadByte(); /* Engine ID Mappings are safe, if the source is static */ if (prop == 0x11) { bool is_safe = true; for (uint i = 0; i < numinfo; i++) { - uint32_t s = buf->ReadDWord(); - buf->ReadDWord(); // dest + uint32_t s = buf.ReadDWord(); + buf.ReadDWord(); // dest const GRFConfig *grfconfig = GetGRFConfig(s); if (grfconfig != nullptr && !HasBit(grfconfig->flags, GCF_STATIC)) { is_safe = false; @@ -4995,18 +4995,18 @@ static void SafeChangeInfo(ByteReader *buf) } /* Action 0x00 (GLS_RESERVE) */ -static void ReserveChangeInfo(ByteReader *buf) +static void ReserveChangeInfo(ByteReader &buf) { - uint8_t feature = buf->ReadByte(); + uint8_t feature = buf.ReadByte(); if (feature != GSF_CARGOES && feature != GSF_GLOBALVAR && feature != GSF_RAILTYPES && feature != GSF_ROADTYPES && feature != GSF_TRAMTYPES) return; - uint8_t numprops = buf->ReadByte(); - uint8_t numinfo = buf->ReadByte(); - uint8_t index = buf->ReadExtendedByte(); + uint8_t numprops = buf.ReadByte(); + uint8_t numinfo = buf.ReadByte(); + uint8_t index = buf.ReadExtendedByte(); - while (numprops-- && buf->HasData()) { - uint8_t prop = buf->ReadByte(); + while (numprops-- && buf.HasData()) { + uint8_t prop = buf.ReadByte(); ChangeInfoResult cir = CIR_SUCCESS; switch (feature) { @@ -5037,7 +5037,7 @@ static void ReserveChangeInfo(ByteReader *buf) } /* Action 0x01 */ -static void NewSpriteSet(ByteReader *buf) +static void NewSpriteSet(ByteReader &buf) { /* Basic format: <01> * Extended format: <01> 00 @@ -5053,17 +5053,17 @@ static void NewSpriteSet(ByteReader *buf) * In that case, use num-dirs=4. */ - uint8_t feature = buf->ReadByte(); - uint16_t num_sets = buf->ReadByte(); + uint8_t feature = buf.ReadByte(); + uint16_t num_sets = buf.ReadByte(); uint16_t first_set = 0; - if (num_sets == 0 && buf->HasData(3)) { + if (num_sets == 0 && buf.HasData(3)) { /* Extended Action1 format. * Some GRFs define zero sets of zero sprites, though there is actually no use in that. Ignore them. */ - first_set = buf->ReadExtendedByte(); - num_sets = buf->ReadExtendedByte(); + first_set = buf.ReadExtendedByte(); + num_sets = buf.ReadExtendedByte(); } - uint16_t num_ents = buf->ReadExtendedByte(); + uint16_t num_ents = buf.ReadExtendedByte(); if (feature >= GSF_END) { _cur.skip_sprites = num_sets * num_ents; @@ -5084,18 +5084,18 @@ static void NewSpriteSet(ByteReader *buf) } /* Action 0x01 (SKIP) */ -static void SkipAct1(ByteReader *buf) +static void SkipAct1(ByteReader &buf) { - buf->ReadByte(); - uint16_t num_sets = buf->ReadByte(); + buf.ReadByte(); + uint16_t num_sets = buf.ReadByte(); - if (num_sets == 0 && buf->HasData(3)) { + if (num_sets == 0 && buf.HasData(3)) { /* Extended Action1 format. * Some GRFs define zero sets of zero sprites, though there is actually no use in that. Ignore them. */ - buf->ReadExtendedByte(); // first_set - num_sets = buf->ReadExtendedByte(); + buf.ReadExtendedByte(); // first_set + num_sets = buf.ReadExtendedByte(); } - uint16_t num_ents = buf->ReadExtendedByte(); + uint16_t num_ents = buf.ReadExtendedByte(); _cur.skip_sprites = num_sets * num_ents; @@ -5150,7 +5150,7 @@ static const SpriteGroup *CreateGroupFromGroupID(uint8_t feature, uint8_t setid, } /* Action 0x02 */ -static void NewSpriteGroup(ByteReader *buf) +static void NewSpriteGroup(ByteReader &buf) { /* <02> * @@ -5164,14 +5164,14 @@ static void NewSpriteGroup(ByteReader *buf) * V feature-specific-data (huge mess, don't even look it up --pasky) */ const SpriteGroup *act_group = nullptr; - uint8_t feature = buf->ReadByte(); + uint8_t feature = buf.ReadByte(); if (feature >= GSF_END) { GrfMsg(1, "NewSpriteGroup: Unsupported feature 0x{:02X}, skipping", feature); return; } - uint8_t setid = buf->ReadByte(); - uint8_t type = buf->ReadByte(); + uint8_t setid = buf.ReadByte(); + uint8_t type = buf.ReadByte(); /* Sprite Groups are created here but they are allocated from a pool, so * we do not need to delete anything if there is an exception from the @@ -5208,23 +5208,23 @@ static void NewSpriteGroup(ByteReader *buf) DeterministicSpriteGroupAdjust &adjust = group->adjusts.emplace_back(); /* The first var adjust doesn't have an operation specified, so we set it to add. */ - adjust.operation = group->adjusts.size() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf->ReadByte(); - adjust.variable = buf->ReadByte(); + adjust.operation = group->adjusts.size() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf.ReadByte(); + adjust.variable = buf.ReadByte(); if (adjust.variable == 0x7E) { /* Link subroutine group */ - adjust.subroutine = GetGroupFromGroupID(setid, type, buf->ReadByte()); + adjust.subroutine = GetGroupFromGroupID(setid, type, buf.ReadByte()); } else { - adjust.parameter = IsInsideMM(adjust.variable, 0x60, 0x80) ? buf->ReadByte() : 0; + adjust.parameter = IsInsideMM(adjust.variable, 0x60, 0x80) ? buf.ReadByte() : 0; } - varadjust = buf->ReadByte(); + varadjust = buf.ReadByte(); adjust.shift_num = GB(varadjust, 0, 5); adjust.type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2); - adjust.and_mask = buf->ReadVarSize(varsize); + adjust.and_mask = buf.ReadVarSize(varsize); if (adjust.type != DSGA_TYPE_NONE) { - adjust.add_val = buf->ReadVarSize(varsize); - adjust.divmod_val = buf->ReadVarSize(varsize); + adjust.add_val = buf.ReadVarSize(varsize); + adjust.divmod_val = buf.ReadVarSize(varsize); } else { adjust.add_val = 0; adjust.divmod_val = 0; @@ -5234,14 +5234,14 @@ static void NewSpriteGroup(ByteReader *buf) } while (HasBit(varadjust, 5)); std::vector ranges; - ranges.resize(buf->ReadByte()); + ranges.resize(buf.ReadByte()); for (auto &range : ranges) { - range.group = GetGroupFromGroupID(setid, type, buf->ReadWord()); - range.low = buf->ReadVarSize(varsize); - range.high = buf->ReadVarSize(varsize); + range.group = GetGroupFromGroupID(setid, type, buf.ReadWord()); + range.low = buf.ReadVarSize(varsize); + range.high = buf.ReadVarSize(varsize); } - group->default_group = GetGroupFromGroupID(setid, type, buf->ReadWord()); + group->default_group = GetGroupFromGroupID(setid, type, buf.ReadWord()); group->error_group = ranges.empty() ? group->default_group : ranges[0].group; /* nvar == 0 is a special case -- we turn our value into a callback result */ group->calculated_result = ranges.empty(); @@ -5300,22 +5300,22 @@ static void NewSpriteGroup(ByteReader *buf) if (HasBit(type, 2)) { if (feature <= GSF_AIRCRAFT) group->var_scope = VSG_SCOPE_RELATIVE; - group->count = buf->ReadByte(); + group->count = buf.ReadByte(); } - uint8_t triggers = buf->ReadByte(); + uint8_t triggers = buf.ReadByte(); group->triggers = GB(triggers, 0, 7); group->cmp_mode = HasBit(triggers, 7) ? RSG_CMP_ALL : RSG_CMP_ANY; - group->lowest_randbit = buf->ReadByte(); + group->lowest_randbit = buf.ReadByte(); - uint8_t num_groups = buf->ReadByte(); + uint8_t num_groups = buf.ReadByte(); if (!HasExactlyOneBit(num_groups)) { GrfMsg(1, "NewSpriteGroup: Random Action 2 nrand should be power of 2"); } group->groups.reserve(num_groups); for (uint i = 0; i < num_groups; i++) { - group->groups.push_back(GetGroupFromGroupID(setid, type, buf->ReadWord())); + group->groups.push_back(GetGroupFromGroupID(setid, type, buf.ReadWord())); } break; @@ -5338,7 +5338,7 @@ static void NewSpriteGroup(ByteReader *buf) case GSF_TRAMTYPES: { uint8_t num_loaded = type; - uint8_t num_loading = buf->ReadByte(); + uint8_t num_loading = buf.ReadByte(); if (!_cur.HasValidSpriteSets(feature)) { GrfMsg(0, "NewSpriteGroup: No sprite set to work on! Skipping"); @@ -5355,7 +5355,7 @@ static void NewSpriteGroup(ByteReader *buf) if (num_loaded + num_loading == 1) { /* Avoid creating 'Real' sprite group if only one option. */ - uint16_t spriteid = buf->ReadWord(); + uint16_t spriteid = buf.ReadWord(); act_group = CreateGroupFromGroupID(feature, setid, type, spriteid); GrfMsg(8, "NewSpriteGroup: one result, skipping RealSpriteGroup = subset {}", spriteid); break; @@ -5366,13 +5366,13 @@ static void NewSpriteGroup(ByteReader *buf) loaded.reserve(num_loaded); for (uint i = 0; i < num_loaded; i++) { - loaded.push_back(buf->ReadWord()); + loaded.push_back(buf.ReadWord()); GrfMsg(8, "NewSpriteGroup: + rg->loaded[{}] = subset {}", i, loaded[i]); } loading.reserve(num_loading); for (uint i = 0; i < num_loading; i++) { - loading.push_back(buf->ReadWord()); + loading.push_back(buf.ReadWord()); GrfMsg(8, "NewSpriteGroup: + rg->loading[{}] = subset {}", i, loading[i]); } @@ -5438,32 +5438,32 @@ static void NewSpriteGroup(ByteReader *buf) if (type == 0) { group->num_input = INDUSTRY_ORIGINAL_NUM_INPUTS; for (uint i = 0; i < INDUSTRY_ORIGINAL_NUM_INPUTS; i++) { - group->subtract_input[i] = (int16_t)buf->ReadWord(); // signed + group->subtract_input[i] = (int16_t)buf.ReadWord(); // signed } group->num_output = INDUSTRY_ORIGINAL_NUM_OUTPUTS; for (uint i = 0; i < INDUSTRY_ORIGINAL_NUM_OUTPUTS; i++) { - group->add_output[i] = buf->ReadWord(); // unsigned + group->add_output[i] = buf.ReadWord(); // unsigned } - group->again = buf->ReadByte(); + group->again = buf.ReadByte(); } else if (type == 1) { group->num_input = INDUSTRY_ORIGINAL_NUM_INPUTS; for (uint i = 0; i < INDUSTRY_ORIGINAL_NUM_INPUTS; i++) { - group->subtract_input[i] = buf->ReadByte(); + group->subtract_input[i] = buf.ReadByte(); } group->num_output = INDUSTRY_ORIGINAL_NUM_OUTPUTS; for (uint i = 0; i < INDUSTRY_ORIGINAL_NUM_OUTPUTS; i++) { - group->add_output[i] = buf->ReadByte(); + group->add_output[i] = buf.ReadByte(); } - group->again = buf->ReadByte(); + group->again = buf.ReadByte(); } else if (type == 2) { - group->num_input = buf->ReadByte(); + group->num_input = buf.ReadByte(); if (group->num_input > lengthof(group->subtract_input)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_INDPROD_CALLBACK); error->data = "too many inputs (max 16)"; return; } for (uint i = 0; i < group->num_input; i++) { - uint8_t rawcargo = buf->ReadByte(); + uint8_t rawcargo = buf.ReadByte(); CargoID cargo = GetCargoTranslation(rawcargo, _cur.grffile); if (!IsValidCargoID(cargo)) { /* The mapped cargo is invalid. This is permitted at this point, @@ -5476,16 +5476,16 @@ static void NewSpriteGroup(ByteReader *buf) return; } group->cargo_input[i] = cargo; - group->subtract_input[i] = buf->ReadByte(); + group->subtract_input[i] = buf.ReadByte(); } - group->num_output = buf->ReadByte(); + group->num_output = buf.ReadByte(); if (group->num_output > lengthof(group->add_output)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_INDPROD_CALLBACK); error->data = "too many outputs (max 16)"; return; } for (uint i = 0; i < group->num_output; i++) { - uint8_t rawcargo = buf->ReadByte(); + uint8_t rawcargo = buf.ReadByte(); CargoID cargo = GetCargoTranslation(rawcargo, _cur.grffile); if (!IsValidCargoID(cargo)) { /* Mark this result as invalid to use */ @@ -5496,9 +5496,9 @@ static void NewSpriteGroup(ByteReader *buf) return; } group->cargo_output[i] = cargo; - group->add_output[i] = buf->ReadByte(); + group->add_output[i] = buf.ReadByte(); } - group->again = buf->ReadByte(); + group->again = buf.ReadByte(); } else { NOT_REACHED(); } @@ -5572,7 +5572,7 @@ static bool IsValidGroupID(uint16_t groupid, const char *function) return true; } -static void VehicleMapSpriteGroup(ByteReader *buf, uint8_t feature, uint8_t idcount) +static void VehicleMapSpriteGroup(ByteReader &buf, uint8_t feature, uint8_t idcount) { static std::vector last_engines; // Engine IDs are remembered in case the next action is a wagon override. bool wagover = false; @@ -5596,7 +5596,7 @@ static void VehicleMapSpriteGroup(ByteReader *buf, uint8_t feature, uint8_t idco std::vector engines; engines.reserve(idcount); for (uint i = 0; i < idcount; i++) { - Engine *e = GetNewEngine(_cur.grffile, (VehicleType)feature, buf->ReadExtendedByte()); + Engine *e = GetNewEngine(_cur.grffile, (VehicleType)feature, buf.ReadExtendedByte()); if (e == nullptr) { /* No engine could be allocated?!? Deal with it. Okay, * this might look bad. Also make sure this NewGRF @@ -5609,10 +5609,10 @@ static void VehicleMapSpriteGroup(ByteReader *buf, uint8_t feature, uint8_t idco if (!wagover) last_engines[i] = engines[i]; } - uint8_t cidcount = buf->ReadByte(); + uint8_t cidcount = buf.ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8_t ctype = buf->ReadByte(); - uint16_t groupid = buf->ReadWord(); + uint8_t ctype = buf.ReadByte(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) continue; GrfMsg(8, "VehicleMapSpriteGroup: * [{}] Cargo type 0x{:X}, group id 0x{:02X}", c, ctype, groupid); @@ -5633,7 +5633,7 @@ static void VehicleMapSpriteGroup(ByteReader *buf, uint8_t feature, uint8_t idco } } - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) return; GrfMsg(8, "-- Default group id 0x{:04X}", groupid); @@ -5651,18 +5651,18 @@ static void VehicleMapSpriteGroup(ByteReader *buf, uint8_t feature, uint8_t idco } -static void CanalMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void CanalMapSpriteGroup(ByteReader &buf, uint8_t idcount) { std::vector cfs; cfs.reserve(idcount); for (uint i = 0; i < idcount; i++) { - cfs.push_back(buf->ReadExtendedByte()); + cfs.push_back(buf.ReadExtendedByte()); } - uint8_t cidcount = buf->ReadByte(); - buf->Skip(cidcount * 3); + uint8_t cidcount = buf.ReadByte(); + buf.Skip(cidcount * 3); - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "CanalMapSpriteGroup")) return; for (auto &cf : cfs) { @@ -5677,7 +5677,7 @@ static void CanalMapSpriteGroup(ByteReader *buf, uint8_t idcount) } -static void StationMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void StationMapSpriteGroup(ByteReader &buf, uint8_t idcount) { if (_cur.grffile->stations.empty()) { GrfMsg(1, "StationMapSpriteGroup: No stations defined, skipping"); @@ -5687,13 +5687,13 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8_t idcount) std::vector stations; stations.reserve(idcount); for (uint i = 0; i < idcount; i++) { - stations.push_back(buf->ReadExtendedByte()); + stations.push_back(buf.ReadExtendedByte()); } - uint8_t cidcount = buf->ReadByte(); + uint8_t cidcount = buf.ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8_t ctype = buf->ReadByte(); - uint16_t groupid = buf->ReadWord(); + uint8_t ctype = buf.ReadByte(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) continue; ctype = TranslateCargo(GSF_STATIONS, ctype); @@ -5711,7 +5711,7 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return; for (auto &station : stations) { @@ -5735,7 +5735,7 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8_t idcount) } -static void TownHouseMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void TownHouseMapSpriteGroup(ByteReader &buf, uint8_t idcount) { if (_cur.grffile->housespec.empty()) { GrfMsg(1, "TownHouseMapSpriteGroup: No houses defined, skipping"); @@ -5745,14 +5745,14 @@ static void TownHouseMapSpriteGroup(ByteReader *buf, uint8_t idcount) std::vector houses; houses.reserve(idcount); for (uint i = 0; i < idcount; i++) { - houses.push_back(buf->ReadExtendedByte()); + houses.push_back(buf.ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ - uint8_t cidcount = buf->ReadByte(); - buf->Skip(cidcount * 3); + uint8_t cidcount = buf.ReadByte(); + buf.Skip(cidcount * 3); - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "TownHouseMapSpriteGroup")) return; for (auto &house : houses) { @@ -5767,7 +5767,7 @@ static void TownHouseMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } -static void IndustryMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void IndustryMapSpriteGroup(ByteReader &buf, uint8_t idcount) { if (_cur.grffile->industryspec.empty()) { GrfMsg(1, "IndustryMapSpriteGroup: No industries defined, skipping"); @@ -5777,14 +5777,14 @@ static void IndustryMapSpriteGroup(ByteReader *buf, uint8_t idcount) std::vector industries; industries.reserve(idcount); for (uint i = 0; i < idcount; i++) { - industries.push_back(buf->ReadExtendedByte()); + industries.push_back(buf.ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ - uint8_t cidcount = buf->ReadByte(); - buf->Skip(cidcount * 3); + uint8_t cidcount = buf.ReadByte(); + buf.Skip(cidcount * 3); - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "IndustryMapSpriteGroup")) return; for (auto &industry : industries) { @@ -5799,7 +5799,7 @@ static void IndustryMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } -static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void IndustrytileMapSpriteGroup(ByteReader &buf, uint8_t idcount) { if (_cur.grffile->indtspec.empty()) { GrfMsg(1, "IndustrytileMapSpriteGroup: No industry tiles defined, skipping"); @@ -5809,14 +5809,14 @@ static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8_t idcount) std::vector indtiles; indtiles.reserve(idcount); for (uint i = 0; i < idcount; i++) { - indtiles.push_back(buf->ReadExtendedByte()); + indtiles.push_back(buf.ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ - uint8_t cidcount = buf->ReadByte(); - buf->Skip(cidcount * 3); + uint8_t cidcount = buf.ReadByte(); + buf.Skip(cidcount * 3); - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "IndustrytileMapSpriteGroup")) return; for (auto &indtile : indtiles) { @@ -5831,19 +5831,19 @@ static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } -static void CargoMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void CargoMapSpriteGroup(ByteReader &buf, uint8_t idcount) { std::vector cargoes; cargoes.reserve(idcount); for (uint i = 0; i < idcount; i++) { - cargoes.push_back(buf->ReadExtendedByte()); + cargoes.push_back(buf.ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ - uint8_t cidcount = buf->ReadByte(); - buf->Skip(cidcount * 3); + uint8_t cidcount = buf.ReadByte(); + buf.Skip(cidcount * 3); - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "CargoMapSpriteGroup")) return; for (auto &cid : cargoes) { @@ -5858,7 +5858,7 @@ static void CargoMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } -static void ObjectMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void ObjectMapSpriteGroup(ByteReader &buf, uint8_t idcount) { if (_cur.grffile->objectspec.empty()) { GrfMsg(1, "ObjectMapSpriteGroup: No object tiles defined, skipping"); @@ -5868,13 +5868,13 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8_t idcount) std::vector objects; objects.reserve(idcount); for (uint i = 0; i < idcount; i++) { - objects.push_back(buf->ReadExtendedByte()); + objects.push_back(buf.ReadExtendedByte()); } - uint8_t cidcount = buf->ReadByte(); + uint8_t cidcount = buf.ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8_t ctype = buf->ReadByte(); - uint16_t groupid = buf->ReadWord(); + uint8_t ctype = buf.ReadByte(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "ObjectMapSpriteGroup")) continue; /* The only valid option here is purchase list sprite groups. */ @@ -5895,7 +5895,7 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "ObjectMapSpriteGroup")) return; for (auto &object : objects) { @@ -5917,19 +5917,19 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } -static void RailTypeMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void RailTypeMapSpriteGroup(ByteReader &buf, uint8_t idcount) { std::vector railtypes; railtypes.reserve(idcount); for (uint i = 0; i < idcount; i++) { - uint16_t id = buf->ReadExtendedByte(); + uint16_t id = buf.ReadExtendedByte(); railtypes.push_back(id < RAILTYPE_END ? _cur.grffile->railtype_map[id] : INVALID_RAILTYPE); } - uint8_t cidcount = buf->ReadByte(); + uint8_t cidcount = buf.ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8_t ctype = buf->ReadByte(); - uint16_t groupid = buf->ReadWord(); + uint8_t ctype = buf.ReadByte(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "RailTypeMapSpriteGroup")) continue; if (ctype >= RTSG_END) continue; @@ -5946,24 +5946,24 @@ static void RailTypeMapSpriteGroup(ByteReader *buf, uint8_t idcount) } /* Railtypes do not use the default group. */ - buf->ReadWord(); + buf.ReadWord(); } -static void RoadTypeMapSpriteGroup(ByteReader *buf, uint8_t idcount, RoadTramType rtt) +static void RoadTypeMapSpriteGroup(ByteReader &buf, uint8_t idcount, RoadTramType rtt) { RoadType *type_map = (rtt == RTT_TRAM) ? _cur.grffile->tramtype_map : _cur.grffile->roadtype_map; std::vector roadtypes; roadtypes.reserve(idcount); for (uint i = 0; i < idcount; i++) { - uint16_t id = buf->ReadExtendedByte(); + uint16_t id = buf.ReadExtendedByte(); roadtypes.push_back(id < ROADTYPE_END ? type_map[id] : INVALID_ROADTYPE); } - uint8_t cidcount = buf->ReadByte(); + uint8_t cidcount = buf.ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8_t ctype = buf->ReadByte(); - uint16_t groupid = buf->ReadWord(); + uint8_t ctype = buf.ReadByte(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "RoadTypeMapSpriteGroup")) continue; if (ctype >= ROTSG_END) continue; @@ -5980,10 +5980,10 @@ static void RoadTypeMapSpriteGroup(ByteReader *buf, uint8_t idcount, RoadTramTyp } /* Roadtypes do not use the default group. */ - buf->ReadWord(); + buf.ReadWord(); } -static void AirportMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void AirportMapSpriteGroup(ByteReader &buf, uint8_t idcount) { if (_cur.grffile->airportspec.empty()) { GrfMsg(1, "AirportMapSpriteGroup: No airports defined, skipping"); @@ -5993,14 +5993,14 @@ static void AirportMapSpriteGroup(ByteReader *buf, uint8_t idcount) std::vector airports; airports.reserve(idcount); for (uint i = 0; i < idcount; i++) { - airports.push_back(buf->ReadExtendedByte()); + airports.push_back(buf.ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ - uint8_t cidcount = buf->ReadByte(); - buf->Skip(cidcount * 3); + uint8_t cidcount = buf.ReadByte(); + buf.Skip(cidcount * 3); - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "AirportMapSpriteGroup")) return; for (auto &airport : airports) { @@ -6015,7 +6015,7 @@ static void AirportMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } -static void AirportTileMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void AirportTileMapSpriteGroup(ByteReader &buf, uint8_t idcount) { if (_cur.grffile->airtspec.empty()) { GrfMsg(1, "AirportTileMapSpriteGroup: No airport tiles defined, skipping"); @@ -6025,14 +6025,14 @@ static void AirportTileMapSpriteGroup(ByteReader *buf, uint8_t idcount) std::vector airptiles; airptiles.reserve(idcount); for (uint i = 0; i < idcount; i++) { - airptiles.push_back(buf->ReadExtendedByte()); + airptiles.push_back(buf.ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ - uint8_t cidcount = buf->ReadByte(); - buf->Skip(cidcount * 3); + uint8_t cidcount = buf.ReadByte(); + buf.Skip(cidcount * 3); - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "AirportTileMapSpriteGroup")) return; for (auto &airptile : airptiles) { @@ -6047,7 +6047,7 @@ static void AirportTileMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } -static void RoadStopMapSpriteGroup(ByteReader *buf, uint8_t idcount) +static void RoadStopMapSpriteGroup(ByteReader &buf, uint8_t idcount) { if (_cur.grffile->roadstops.empty()) { GrfMsg(1, "RoadStopMapSpriteGroup: No roadstops defined, skipping"); @@ -6057,13 +6057,13 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8_t idcount) std::vector roadstops; roadstops.reserve(idcount); for (uint i = 0; i < idcount; i++) { - roadstops.push_back(buf->ReadExtendedByte()); + roadstops.push_back(buf.ReadExtendedByte()); } - uint8_t cidcount = buf->ReadByte(); + uint8_t cidcount = buf.ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8_t ctype = buf->ReadByte(); - uint16_t groupid = buf->ReadWord(); + uint8_t ctype = buf.ReadByte(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "RoadStopMapSpriteGroup")) continue; ctype = TranslateCargo(GSF_ROADSTOPS, ctype); @@ -6081,7 +6081,7 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8_t idcount) } } - uint16_t groupid = buf->ReadWord(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "RoadStopMapSpriteGroup")) return; for (auto &roadstop : roadstops) { @@ -6105,7 +6105,7 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8_t idcount) } /* Action 0x03 */ -static void FeatureMapSpriteGroup(ByteReader *buf) +static void FeatureMapSpriteGroup(ByteReader &buf) { /* <03> ... [ ]... * id-list := [] [id-list] @@ -6121,8 +6121,8 @@ static void FeatureMapSpriteGroup(ByteReader *buf) * W cid cargo ID (sprite group ID) for this type of cargo * W def-cid default cargo ID (sprite group ID) */ - uint8_t feature = buf->ReadByte(); - uint8_t idcount = buf->ReadByte(); + uint8_t feature = buf.ReadByte(); + uint8_t idcount = buf.ReadByte(); if (feature >= GSF_END) { GrfMsg(1, "FeatureMapSpriteGroup: Unsupported feature 0x{:02X}, skipping", feature); @@ -6132,8 +6132,8 @@ static void FeatureMapSpriteGroup(ByteReader *buf) /* If idcount is zero, this is a feature callback */ if (idcount == 0) { /* Skip number of cargo ids? */ - buf->ReadByte(); - uint16_t groupid = buf->ReadWord(); + buf.ReadByte(); + uint16_t groupid = buf.ReadWord(); if (!IsValidGroupID(groupid, "FeatureMapSpriteGroup")) return; GrfMsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature 0x{:02X}", feature); @@ -6214,7 +6214,7 @@ static void FeatureMapSpriteGroup(ByteReader *buf) } /* Action 0x04 */ -static void FeatureNewName(ByteReader *buf) +static void FeatureNewName(ByteReader &buf) { /* <04> * @@ -6234,22 +6234,22 @@ static void FeatureNewName(ByteReader *buf) bool new_scheme = _cur.grffile->grf_version >= 7; - uint8_t feature = buf->ReadByte(); + uint8_t feature = buf.ReadByte(); if (feature >= GSF_END && feature != 0x48) { GrfMsg(1, "FeatureNewName: Unsupported feature 0x{:02X}, skipping", feature); return; } - uint8_t lang = buf->ReadByte(); - uint8_t num = buf->ReadByte(); + uint8_t lang = buf.ReadByte(); + uint8_t num = buf.ReadByte(); bool generic = HasBit(lang, 7); uint16_t id; if (generic) { - id = buf->ReadWord(); + id = buf.ReadWord(); } else if (feature <= GSF_AIRCRAFT) { - id = buf->ReadExtendedByte(); + id = buf.ReadExtendedByte(); } else { - id = buf->ReadByte(); + id = buf.ReadByte(); } ClrBit(lang, 7); @@ -6259,8 +6259,8 @@ static void FeatureNewName(ByteReader *buf) GrfMsg(6, "FeatureNewName: About to rename engines {}..{} (feature 0x{:02X}) in language 0x{:02X}", id, endid, feature, lang); - for (; id < endid && buf->HasData(); id++) { - const std::string_view name = buf->ReadString(); + for (; id < endid && buf.HasData(); id++) { + const std::string_view name = buf.ReadString(); GrfMsg(8, "FeatureNewName: 0x{:04X} <- {}", id, name); switch (feature) { @@ -6396,7 +6396,7 @@ std::span GetAction5Types() } /* Action 0x05 */ -static void GraphicsNew(ByteReader *buf) +static void GraphicsNew(ByteReader &buf) { /* <05> * @@ -6404,9 +6404,9 @@ static void GraphicsNew(ByteReader *buf) * E num-sprites How many sprites are in this set? * V other data Graphics type specific data. Currently unused. */ - uint8_t type = buf->ReadByte(); - uint16_t num = buf->ReadExtendedByte(); - uint16_t offset = HasBit(type, 7) ? buf->ReadExtendedByte() : 0; + uint8_t type = buf.ReadByte(); + uint16_t num = buf.ReadExtendedByte(); + uint16_t offset = HasBit(type, 7) ? buf.ReadExtendedByte() : 0; ClrBit(type, 7); // Clear the high bit as that only indicates whether there is an offset. if ((type == 0x0D) && (num == 10) && HasBit(_cur.grfconfig->flags, GCF_SYSTEM)) { @@ -6485,13 +6485,13 @@ static void GraphicsNew(ByteReader *buf) } /* Action 0x05 (SKIP) */ -static void SkipAct5(ByteReader *buf) +static void SkipAct5(ByteReader &buf) { /* Ignore type byte */ - buf->ReadByte(); + buf.ReadByte(); /* Skip the sprites of this action */ - _cur.skip_sprites = buf->ReadExtendedByte(); + _cur.skip_sprites = buf.ReadExtendedByte(); GrfMsg(3, "SkipAct5: Skipping {} sprites", _cur.skip_sprites); } @@ -6683,7 +6683,7 @@ static uint32_t GetParamVal(uint8_t param, uint32_t *cond_val) } /* Action 0x06 */ -static void CfgApply(ByteReader *buf) +static void CfgApply(ByteReader &buf) { /* <06> ... * @@ -6733,12 +6733,12 @@ static void CfgApply(ByteReader *buf) bool add_value; /* Read the parameter to apply. 0xFF indicates no more data to change. */ - param_num = buf->ReadByte(); + param_num = buf.ReadByte(); if (param_num == 0xFF) break; /* Get the size of the parameter to use. If the size covers multiple * double words, sequential parameter values are used. */ - param_size = buf->ReadByte(); + param_size = buf.ReadByte(); /* Bit 7 of param_size indicates we should add to the original value * instead of replacing it. */ @@ -6746,7 +6746,7 @@ static void CfgApply(ByteReader *buf) param_size = GB(param_size, 0, 7); /* Where to apply the data to within the pseudo sprite data. */ - offset = buf->ReadExtendedByte(); + offset = buf.ReadExtendedByte(); /* If the parameter is a GRF parameter (not an internal variable) check * if it (and all further sequential parameters) has been defined. */ @@ -6793,7 +6793,7 @@ static void DisableStaticNewGRFInfluencingNonStaticNewGRFs(GRFConfig *c) /* Action 0x07 * Action 0x09 */ -static void SkipIf(ByteReader *buf) +static void SkipIf(ByteReader &buf) { /* <07/09> * @@ -6806,9 +6806,9 @@ static void SkipIf(ByteReader *buf) uint32_t mask = 0; bool result; - uint8_t param = buf->ReadByte(); - uint8_t paramsize = buf->ReadByte(); - uint8_t condtype = buf->ReadByte(); + uint8_t param = buf.ReadByte(); + uint8_t paramsize = buf.ReadByte(); + uint8_t condtype = buf.ReadByte(); if (condtype < 2) { /* Always 1 for bit tests, the given value should be ignored. */ @@ -6816,10 +6816,10 @@ static void SkipIf(ByteReader *buf) } switch (paramsize) { - case 8: cond_val = buf->ReadDWord(); mask = buf->ReadDWord(); break; - case 4: cond_val = buf->ReadDWord(); mask = 0xFFFFFFFF; break; - case 2: cond_val = buf->ReadWord(); mask = 0x0000FFFF; break; - case 1: cond_val = buf->ReadByte(); mask = 0x000000FF; break; + case 8: cond_val = buf.ReadDWord(); mask = buf.ReadDWord(); break; + case 4: cond_val = buf.ReadDWord(); mask = 0xFFFFFFFF; break; + case 2: cond_val = buf.ReadWord(); mask = 0x0000FFFF; break; + case 1: cond_val = buf.ReadByte(); mask = 0x000000FF; break; default: break; } @@ -6931,7 +6931,7 @@ static void SkipIf(ByteReader *buf) return; } - uint8_t numsprites = buf->ReadByte(); + uint8_t numsprites = buf.ReadByte(); /* numsprites can be a GOTO label if it has been defined in the GRF * file. The jump will always be the first matching label that follows @@ -6974,11 +6974,11 @@ static void SkipIf(ByteReader *buf) /* Action 0x08 (GLS_FILESCAN) */ -static void ScanInfo(ByteReader *buf) +static void ScanInfo(ByteReader &buf) { - uint8_t grf_version = buf->ReadByte(); - uint32_t grfid = buf->ReadDWord(); - std::string_view name = buf->ReadString(); + uint8_t grf_version = buf.ReadByte(); + uint32_t grfid = buf.ReadDWord(); + std::string_view name = buf.ReadString(); _cur.grfconfig->ident.grfid = grfid; @@ -6992,8 +6992,8 @@ static void ScanInfo(ByteReader *buf) AddGRFTextToList(_cur.grfconfig->name, 0x7F, grfid, false, name); - if (buf->HasData()) { - std::string_view info = buf->ReadString(); + if (buf.HasData()) { + std::string_view info = buf.ReadString(); AddGRFTextToList(_cur.grfconfig->info, 0x7F, grfid, true, info); } @@ -7002,7 +7002,7 @@ static void ScanInfo(ByteReader *buf) } /* Action 0x08 */ -static void GRFInfo(ByteReader *buf) +static void GRFInfo(ByteReader &buf) { /* <08> * @@ -7011,9 +7011,9 @@ static void GRFInfo(ByteReader *buf) * S name name of this .grf set * S info string describing the set, and e.g. author and copyright */ - uint8_t version = buf->ReadByte(); - uint32_t grfid = buf->ReadDWord(); - std::string_view name = buf->ReadString(); + uint8_t version = buf.ReadByte(); + uint32_t grfid = buf.ReadDWord(); + std::string_view name = buf.ReadString(); if (_cur.stage < GLS_RESERVE && _cur.grfconfig->status != GCS_UNKNOWN) { DisableGrf(STR_NEWGRF_ERROR_MULTIPLE_ACTION_8); @@ -7048,7 +7048,7 @@ static bool IsGRMReservedSprite(SpriteID first_sprite, uint16_t num_sprites) } /* Action 0x0A */ -static void SpriteReplace(ByteReader *buf) +static void SpriteReplace(ByteReader &buf) { /* <0A> [ ...] * : @@ -7058,11 +7058,11 @@ static void SpriteReplace(ByteReader *buf) * B num-sprites How many sprites are in this set * W first-sprite First sprite number to replace */ - uint8_t num_sets = buf->ReadByte(); + uint8_t num_sets = buf.ReadByte(); for (uint i = 0; i < num_sets; i++) { - uint8_t num_sprites = buf->ReadByte(); - uint16_t first_sprite = buf->ReadWord(); + uint8_t num_sprites = buf.ReadByte(); + uint16_t first_sprite = buf.ReadWord(); GrfMsg(2, "SpriteReplace: [Set {}] Changing {} sprites, beginning with {}", i, num_sprites, first_sprite @@ -7095,22 +7095,22 @@ static void SpriteReplace(ByteReader *buf) } /* Action 0x0A (SKIP) */ -static void SkipActA(ByteReader *buf) +static void SkipActA(ByteReader &buf) { - uint8_t num_sets = buf->ReadByte(); + uint8_t num_sets = buf.ReadByte(); for (uint i = 0; i < num_sets; i++) { /* Skip the sprites this replaces */ - _cur.skip_sprites += buf->ReadByte(); + _cur.skip_sprites += buf.ReadByte(); /* But ignore where they go */ - buf->ReadWord(); + buf.ReadWord(); } GrfMsg(3, "SkipActA: Skipping {} sprites", _cur.skip_sprites); } /* Action 0x0B */ -static void GRFLoadError(ByteReader *buf) +static void GRFLoadError(ByteReader &buf) { /* <0B> [ 00] [] 00 [] * @@ -7144,9 +7144,9 @@ static void GRFLoadError(ByteReader *buf) STR_NEWGRF_ERROR_MSG_FATAL }; - uint8_t severity = buf->ReadByte(); - uint8_t lang = buf->ReadByte(); - uint8_t message_id = buf->ReadByte(); + uint8_t severity = buf.ReadByte(); + uint8_t lang = buf.ReadByte(); + uint8_t message_id = buf.ReadByte(); /* Skip the error if it isn't valid for the current language. */ if (!CheckGrfLangID(lang, _cur.grffile->grf_version)) return; @@ -7176,7 +7176,7 @@ static void GRFLoadError(ByteReader *buf) return; } - if (buf->Remaining() <= 1) { + if (buf.Remaining() <= 1) { GrfMsg(7, "GRFLoadError: No message data supplied."); return; } @@ -7189,8 +7189,8 @@ static void GRFLoadError(ByteReader *buf) if (message_id == 0xFF) { /* This is a custom error message. */ - if (buf->HasData()) { - std::string_view message = buf->ReadString(); + if (buf.HasData()) { + std::string_view message = buf.ReadString(); error->custom_message = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, message, SCC_RAW_STRING_POINTER); } else { @@ -7201,8 +7201,8 @@ static void GRFLoadError(ByteReader *buf) error->message = msgstr[message_id]; } - if (buf->HasData()) { - std::string_view data = buf->ReadString(); + if (buf.HasData()) { + std::string_view data = buf.ReadString(); error->data = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, data); } else { @@ -7211,29 +7211,29 @@ static void GRFLoadError(ByteReader *buf) } /* Only two parameter numbers can be used in the string. */ - for (uint i = 0; i < error->param_value.size() && buf->HasData(); i++) { - uint param_number = buf->ReadByte(); + for (uint i = 0; i < error->param_value.size() && buf.HasData(); i++) { + uint param_number = buf.ReadByte(); error->param_value[i] = _cur.grffile->GetParam(param_number); } } /* Action 0x0C */ -static void GRFComment(ByteReader *buf) +static void GRFComment(ByteReader &buf) { /* <0C> [] * * V ignored Anything following the 0C is ignored */ - if (!buf->HasData()) return; + if (!buf.HasData()) return; - std::string_view text = buf->ReadString(); + std::string_view text = buf.ReadString(); GrfMsg(2, "GRFComment: {}", text); } /* Action 0x0D (GLS_SAFETYSCAN) */ -static void SafeParamSet(ByteReader *buf) +static void SafeParamSet(ByteReader &buf) { - uint8_t target = buf->ReadByte(); + uint8_t target = buf.ReadByte(); /* Writing GRF parameters and some bits of 'misc GRF features' are safe. */ if (target < 0x80 || target == 0x9E) return; @@ -7376,7 +7376,7 @@ static uint32_t PerformGRM(uint32_t *grm, uint16_t num_ids, uint16_t count, uint /** Action 0x0D: Set parameter */ -static void ParamSet(ByteReader *buf) +static void ParamSet(ByteReader &buf) { /* <0D> [] * @@ -7400,13 +7400,13 @@ static void ParamSet(ByteReader *buf) * (source2 like in 05, and source1 as well) */ - uint8_t target = buf->ReadByte(); - uint8_t oper = buf->ReadByte(); - uint32_t src1 = buf->ReadByte(); - uint32_t src2 = buf->ReadByte(); + uint8_t target = buf.ReadByte(); + uint8_t oper = buf.ReadByte(); + uint32_t src1 = buf.ReadByte(); + uint32_t src2 = buf.ReadByte(); uint32_t data = 0; - if (buf->Remaining() >= 4) data = buf->ReadDWord(); + if (buf.Remaining() >= 4) data = buf.ReadDWord(); /* You can add 80 to the operation to make it apply only if the target * is not defined yet. In this respect, a parameter is taken to be @@ -7678,17 +7678,17 @@ static void ParamSet(ByteReader *buf) } /* Action 0x0E (GLS_SAFETYSCAN) */ -static void SafeGRFInhibit(ByteReader *buf) +static void SafeGRFInhibit(ByteReader &buf) { /* <0E> * * B num Number of GRFIDs that follow * D grfids GRFIDs of the files to deactivate */ - uint8_t num = buf->ReadByte(); + uint8_t num = buf.ReadByte(); for (uint i = 0; i < num; i++) { - uint32_t grfid = buf->ReadDWord(); + uint32_t grfid = buf.ReadDWord(); /* GRF is unsafe it if tries to deactivate other GRFs */ if (grfid != _cur.grfconfig->ident.grfid) { @@ -7703,17 +7703,17 @@ static void SafeGRFInhibit(ByteReader *buf) } /* Action 0x0E */ -static void GRFInhibit(ByteReader *buf) +static void GRFInhibit(ByteReader &buf) { /* <0E> * * B num Number of GRFIDs that follow * D grfids GRFIDs of the files to deactivate */ - uint8_t num = buf->ReadByte(); + uint8_t num = buf.ReadByte(); for (uint i = 0; i < num; i++) { - uint32_t grfid = buf->ReadDWord(); + uint32_t grfid = buf.ReadDWord(); GRFConfig *file = GetGRFConfig(grfid); /* Unset activation flag */ @@ -7726,7 +7726,7 @@ static void GRFInhibit(ByteReader *buf) } /** Action 0x0F - Define Town names */ -static void FeatureTownName(ByteReader *buf) +static void FeatureTownName(ByteReader &buf) { /* <0F> * @@ -7739,7 +7739,7 @@ static void FeatureTownName(ByteReader *buf) GRFTownName *townname = AddGRFTownName(grfid); - uint8_t id = buf->ReadByte(); + uint8_t id = buf.ReadByte(); GrfMsg(6, "FeatureTownName: definition 0x{:02X}", id & 0x7F); if (HasBit(id, 7)) { @@ -7747,43 +7747,43 @@ static void FeatureTownName(ByteReader *buf) ClrBit(id, 7); bool new_scheme = _cur.grffile->grf_version >= 7; - uint8_t lang = buf->ReadByte(); + uint8_t lang = buf.ReadByte(); StringID style = STR_UNDEFINED; do { ClrBit(lang, 7); - std::string_view name = buf->ReadString(); + std::string_view name = buf.ReadString(); std::string lang_name = TranslateTTDPatchCodes(grfid, lang, false, name); GrfMsg(6, "FeatureTownName: lang 0x{:X} -> '{}'", lang, lang_name); style = AddGRFString(grfid, id, lang, new_scheme, false, name, STR_UNDEFINED); - lang = buf->ReadByte(); + lang = buf.ReadByte(); } while (lang != 0); townname->styles.emplace_back(style, id); } - uint8_t parts = buf->ReadByte(); + uint8_t parts = buf.ReadByte(); GrfMsg(6, "FeatureTownName: {} parts", parts); townname->partlists[id].reserve(parts); for (uint partnum = 0; partnum < parts; partnum++) { NamePartList &partlist = townname->partlists[id].emplace_back(); - uint8_t texts = buf->ReadByte(); - partlist.bitstart = buf->ReadByte(); - partlist.bitcount = buf->ReadByte(); + uint8_t texts = buf.ReadByte(); + partlist.bitstart = buf.ReadByte(); + partlist.bitcount = buf.ReadByte(); partlist.maxprob = 0; GrfMsg(6, "FeatureTownName: part {} contains {} texts and will use GB(seed, {}, {})", partnum, texts, partlist.bitstart, partlist.bitcount); partlist.parts.reserve(texts); for (uint textnum = 0; textnum < texts; textnum++) { NamePart &part = partlist.parts.emplace_back(); - part.prob = buf->ReadByte(); + part.prob = buf.ReadByte(); if (HasBit(part.prob, 7)) { - uint8_t ref_id = buf->ReadByte(); + uint8_t ref_id = buf.ReadByte(); if (ref_id >= GRFTownName::MAX_LISTS || townname->partlists[ref_id].empty()) { GrfMsg(0, "FeatureTownName: definition 0x{:02X} doesn't exist, deactivating", ref_id); DelGRFTownName(grfid); @@ -7793,7 +7793,7 @@ static void FeatureTownName(ByteReader *buf) part.id = ref_id; GrfMsg(6, "FeatureTownName: part {}, text {}, uses intermediate definition 0x{:02X} (with probability {})", partnum, textnum, ref_id, part.prob & 0x7F); } else { - std::string_view text = buf->ReadString(); + std::string_view text = buf.ReadString(); part.text = TranslateTTDPatchCodes(grfid, 0, false, text); GrfMsg(6, "FeatureTownName: part {}, text {}, '{}' (with probability {})", partnum, textnum, part.text, part.prob); } @@ -7804,14 +7804,14 @@ static void FeatureTownName(ByteReader *buf) } /** Action 0x10 - Define goto label */ -static void DefineGotoLabel(ByteReader *buf) +static void DefineGotoLabel(ByteReader &buf) { /* <10>