Update to 13.0-RC1

This commit is contained in:
Pavel Stupnikov
2023-01-03 15:58:14 +04:00
parent be23283677
commit 59c991fa52
326 changed files with 12923 additions and 8705 deletions

View File

@@ -328,7 +328,6 @@ struct GRFTempEngineData {
uint8 roadtramtype;
const GRFFile *defaultcargo_grf; ///< GRF defining the cargo translation table to use if the default cargo is the 'first refittable'.
Refittability refittability; ///< Did the newgrf set any refittability property? If not, default refittability will be applied.
bool prop27_set; ///< Did the NewGRF set property 27 (misc flags)?
uint8 rv_max_speed; ///< Temporary storage of RV prop 15, maximum speed in mph/0.8
CargoTypes ctt_include_mask; ///< Cargo types always included in the refit mask.
CargoTypes ctt_exclude_mask; ///< Cargo types always excluded from the refit mask.
@@ -430,13 +429,7 @@ static GRFFile *GetFileByFilename(const char *filename)
/** Reset all NewGRFData that was used only while processing data */
static void ClearTemporaryNewGRFData(GRFFile *gf)
{
/* Clear the GOTO labels used for GRF processing */
for (GRFLabel *l = gf->label; l != nullptr;) {
GRFLabel *l2 = l->next;
free(l);
l = l2;
}
gf->label = nullptr;
gf->labels.clear();
}
/**
@@ -1295,7 +1288,6 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
case 0x27: // Miscellaneous flags
ei->misc_flags = buf->ReadByte();
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC);
_gted[e->index].prop27_set = true;
break;
case 0x28: // Cargo classes allowed
@@ -1336,6 +1328,14 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
rvi->curve_speed_mod = buf->ReadWord();
break;
case 0x2F: // Engine variant
ei->variant_id = GetNewEngineID(_cur.grffile, VEH_TRAIN, buf->ReadWord());
break;
case 0x30: // Extra miscellaneous flags
ei->extra_flags = static_cast<ExtraEngineFlags>(buf->ReadDWord());
break;
default:
ret = CommonVehicleChangeInfo(ei, prop, buf);
break;
@@ -1530,6 +1530,14 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
break;
}
case 0x26: // Engine variant
ei->variant_id = GetNewEngineID(_cur.grffile, VEH_ROAD, buf->ReadWord());
break;
case 0x27: // Extra miscellaneous flags
ei->extra_flags = static_cast<ExtraEngineFlags>(buf->ReadDWord());
break;
default:
ret = CommonVehicleChangeInfo(ei, prop, buf);
break;
@@ -1702,6 +1710,14 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
break;
}
case 0x20: // Engine variant
ei->variant_id = GetNewEngineID(_cur.grffile, VEH_SHIP, buf->ReadWord());
break;
case 0x21: // Extra miscellaneous flags
ei->extra_flags = static_cast<ExtraEngineFlags>(buf->ReadDWord());
break;
default:
ret = CommonVehicleChangeInfo(ei, prop, buf);
break;
@@ -1856,6 +1872,14 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int
avi->max_range = buf->ReadWord();
break;
case 0x20: // Engine variant
ei->variant_id = GetNewEngineID(_cur.grffile, VEH_AIRCRAFT, buf->ReadWord());
break;
case 0x21: // Extra miscellaneous flags
ei->extra_flags = static_cast<ExtraEngineFlags>(buf->ReadDWord());
break;
default:
ret = CommonVehicleChangeInfo(ei, prop, buf);
break;
@@ -6250,9 +6274,17 @@ static void GraphicsNew(ByteReader *buf)
if (offset <= depot_no_track_offset && offset + num > depot_no_track_offset) _loaded_newgrf_features.tram = TRAMWAY_REPLACE_DEPOT_NO_TRACK;
}
/* If the baseset or grf only provides sprites for flat tiles (pre #10282), duplicate those for use on slopes. */
bool dup_oneway_sprites = ((type == 0x09) && (offset + num <= SPR_ONEWAY_SLOPE_N_OFFSET));
for (; num > 0; num--) {
_cur.nfo_line++;
LoadNextSprite(replace == 0 ? _cur.spriteid++ : replace++, *_cur.file, _cur.nfo_line);
int load_index = (replace == 0 ? _cur.spriteid++ : replace++);
LoadNextSprite(load_index, *_cur.file, _cur.nfo_line);
if (dup_oneway_sprites) {
DupSprite(load_index, load_index + SPR_ONEWAY_SLOPE_N_OFFSET);
DupSprite(load_index, load_index + SPR_ONEWAY_SLOPE_S_OFFSET);
}
}
_cur.skip_sprites = skip_num;
@@ -6715,15 +6747,15 @@ static void SkipIf(ByteReader *buf)
* file. The jump will always be the first matching label that follows
* the current nfo_line. If no matching label is found, the first matching
* label in the file is used. */
GRFLabel *choice = nullptr;
for (GRFLabel *label = _cur.grffile->label; label != nullptr; label = label->next) {
if (label->label != numsprites) continue;
const GRFLabel *choice = nullptr;
for (const auto &label : _cur.grffile->labels) {
if (label.label != numsprites) continue;
/* Remember a goto before the current line */
if (choice == nullptr) choice = label;
if (choice == nullptr) choice = &label;
/* If we find a label here, this is definitely good */
if (label->nfo_line > _cur.nfo_line) {
choice = label;
if (label.nfo_line > _cur.nfo_line) {
choice = &label;
break;
}
}
@@ -7571,23 +7603,9 @@ static void DefineGotoLabel(ByteReader *buf)
byte nfo_label = buf->ReadByte();
GRFLabel *label = MallocT<GRFLabel>(1);
label->label = nfo_label;
label->nfo_line = _cur.nfo_line;
label->pos = _cur.file->GetPos();
label->next = nullptr;
_cur.grffile->labels.emplace_back(nfo_label, _cur.nfo_line, _cur.file->GetPos());
/* Set up a linked list of goto targets which we will search in an Action 0x7/0x9 */
if (_cur.grffile->label == nullptr) {
_cur.grffile->label = label;
} else {
/* Attach the label to the end of the list */
GRFLabel *l;
for (l = _cur.grffile->label; l->next != nullptr; l = l->next) {}
l->next = label;
}
grfmsg(2, "DefineGotoLabel: GOTO target with label 0x%02X", label->label);
grfmsg(2, "DefineGotoLabel: GOTO target with label 0x%02X", nfo_label);
}
/**
@@ -8365,89 +8383,89 @@ static void GRFUnsafe(ByteReader *buf)
/** Initialize the TTDPatch flags */
static void InitializeGRFSpecial()
{
_ttdpatch_flags[0] = ((_settings_game.station.never_expire_airports ? 1 : 0) << 0x0C) // keepsmallairport
| (1 << 0x0D) // newairports
| (1 << 0x0E) // largestations
| ((_settings_game.construction.max_bridge_length > 16 ? 1 : 0) << 0x0F) // longbridges
| (0 << 0x10) // loadtime
| (1 << 0x12) // presignals
| (1 << 0x13) // extpresignals
| ((_settings_game.vehicle.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist
| (1 << 0x1B) // multihead
| (1 << 0x1D) // lowmemory
| (1 << 0x1E); // generalfixes
_ttdpatch_flags[0] = ((_settings_game.station.never_expire_airports ? 1U : 0U) << 0x0C) // keepsmallairport
| (1U << 0x0D) // newairports
| (1U << 0x0E) // largestations
| ((_settings_game.construction.max_bridge_length > 16 ? 1U : 0U) << 0x0F) // longbridges
| (0U << 0x10) // loadtime
| (1U << 0x12) // presignals
| (1U << 0x13) // extpresignals
| ((_settings_game.vehicle.never_expire_vehicles ? 1U : 0U) << 0x16) // enginespersist
| (1U << 0x1B) // multihead
| (1U << 0x1D) // lowmemory
| (1U << 0x1E); // generalfixes
_ttdpatch_flags[1] = ((_settings_game.economy.station_noise_level ? 1 : 0) << 0x07) // moreairports - based on units of noise
| (1 << 0x08) // mammothtrains
| (1 << 0x09) // trainrefit
| (0 << 0x0B) // subsidiaries
| ((_settings_game.order.gradual_loading ? 1 : 0) << 0x0C) // gradualloading
| (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD
| (1 << 0x13) // unifiedmaglevmode - set bit 1 mode
| (1 << 0x14) // bridgespeedlimits
| (1 << 0x16) // eternalgame
| (1 << 0x17) // newtrains
| (1 << 0x18) // newrvs
| (1 << 0x19) // newships
| (1 << 0x1A) // newplanes
| ((_settings_game.construction.train_signal_side == 1 ? 1 : 0) << 0x1B) // signalsontrafficside
| ((_settings_game.vehicle.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway
_ttdpatch_flags[1] = ((_settings_game.economy.station_noise_level ? 1U : 0U) << 0x07) // moreairports - based on units of noise
| (1U << 0x08) // mammothtrains
| (1U << 0x09) // trainrefit
| (0U << 0x0B) // subsidiaries
| ((_settings_game.order.gradual_loading ? 1U : 0U) << 0x0C) // gradualloading
| (1U << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD
| (1U << 0x13) // unifiedmaglevmode - set bit 1 mode
| (1U << 0x14) // bridgespeedlimits
| (1U << 0x16) // eternalgame
| (1U << 0x17) // newtrains
| (1U << 0x18) // newrvs
| (1U << 0x19) // newships
| (1U << 0x1A) // newplanes
| ((_settings_game.construction.train_signal_side == 1 ? 1U : 0U) << 0x1B) // signalsontrafficside
| ((_settings_game.vehicle.disable_elrails ? 0U : 1U) << 0x1C); // electrifiedrailway
_ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote
| (1 << 0x03) // semaphores
| (1 << 0x0A) // newobjects
| (0 << 0x0B) // enhancedgui
| (0 << 0x0C) // newagerating
| ((_settings_game.construction.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes
| (1 << 0x0E) // fullloadany
| (1 << 0x0F) // planespeed
| (0 << 0x10) // moreindustriesperclimate - obsolete
| (0 << 0x11) // moretoylandfeatures
| (1 << 0x12) // newstations
| (1 << 0x13) // tracktypecostdiff
| (1 << 0x14) // manualconvert
| ((_settings_game.construction.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts
| (1 << 0x16) // canals
| (1 << 0x17) // newstartyear
| ((_settings_game.vehicle.freight_trains > 1 ? 1 : 0) << 0x18) // freighttrains
| (1 << 0x19) // newhouses
| (1 << 0x1A) // newbridges
| (1 << 0x1B) // newtownnames
| (1 << 0x1C) // moreanimation
| ((_settings_game.vehicle.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits
| (1 << 0x1E) // newshistory
| (0 << 0x1F); // custombridgeheads
_ttdpatch_flags[2] = (1U << 0x01) // loadallgraphics - obsolote
| (1U << 0x03) // semaphores
| (1U << 0x0A) // newobjects
| (0U << 0x0B) // enhancedgui
| (0U << 0x0C) // newagerating
| ((_settings_game.construction.build_on_slopes ? 1U : 0U) << 0x0D) // buildonslopes
| (1U << 0x0E) // fullloadany
| (1U << 0x0F) // planespeed
| (0U << 0x10) // moreindustriesperclimate - obsolete
| (0U << 0x11) // moretoylandfeatures
| (1U << 0x12) // newstations
| (1U << 0x13) // tracktypecostdiff
| (1U << 0x14) // manualconvert
| ((_settings_game.construction.build_on_slopes ? 1U : 0U) << 0x15) // buildoncoasts
| (1U << 0x16) // canals
| (1U << 0x17) // newstartyear
| ((_settings_game.vehicle.freight_trains > 1 ? 1U : 0U) << 0x18) // freighttrains
| (1U << 0x19) // newhouses
| (1U << 0x1A) // newbridges
| (1U << 0x1B) // newtownnames
| (1U << 0x1C) // moreanimation
| ((_settings_game.vehicle.wagon_speed_limits ? 1U : 0U) << 0x1D) // wagonspeedlimits
| (1U << 0x1E) // newshistory
| (0U << 0x1F); // custombridgeheads
_ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution
| (1 << 0x01) // windowsnap
| ((_settings_game.economy.allow_town_roads || _generating_world ? 0 : 1) << 0x02) // townbuildnoroad
| (1 << 0x03) // pathbasedsignalling
| (0 << 0x04) // aichoosechance
| (1 << 0x05) // resolutionwidth
| (1 << 0x06) // resolutionheight
| (1 << 0x07) // newindustries
| ((_settings_game.order.improved_load ? 1 : 0) << 0x08) // fifoloading
| (0 << 0x09) // townroadbranchprob
| (0 << 0x0A) // tempsnowline
| (1 << 0x0B) // newcargo
| (1 << 0x0C) // enhancemultiplayer
| (1 << 0x0D) // onewayroads
| (1 << 0x0E) // irregularstations
| (1 << 0x0F) // statistics
| (1 << 0x10) // newsounds
| (1 << 0x11) // autoreplace
| (1 << 0x12) // autoslope
| (0 << 0x13) // followvehicle
| (1 << 0x14) // trams
| (0 << 0x15) // enhancetunnels
| (1 << 0x16) // shortrvs
| (1 << 0x17) // articulatedrvs
| ((_settings_game.vehicle.dynamic_engines ? 1 : 0) << 0x18) // dynamic engines
| (1 << 0x1E) // variablerunningcosts
| (1 << 0x1F); // any switch is on
_ttdpatch_flags[3] = (0U << 0x00) // newcargodistribution
| (1U << 0x01) // windowsnap
| ((_settings_game.economy.allow_town_roads || _generating_world ? 0U : 1U) << 0x02) // townbuildnoroad
| (1U << 0x03) // pathbasedsignalling
| (0U << 0x04) // aichoosechance
| (1U << 0x05) // resolutionwidth
| (1U << 0x06) // resolutionheight
| (1U << 0x07) // newindustries
| ((_settings_game.order.improved_load ? 1U : 0U) << 0x08) // fifoloading
| (0U << 0x09) // townroadbranchprob
| (0U << 0x0A) // tempsnowline
| (1U << 0x0B) // newcargo
| (1U << 0x0C) // enhancemultiplayer
| (1U << 0x0D) // onewayroads
| (1U << 0x0E) // irregularstations
| (1U << 0x0F) // statistics
| (1U << 0x10) // newsounds
| (1U << 0x11) // autoreplace
| (1U << 0x12) // autoslope
| (0U << 0x13) // followvehicle
| (1U << 0x14) // trams
| (0U << 0x15) // enhancetunnels
| (1U << 0x16) // shortrvs
| (1U << 0x17) // articulatedrvs
| ((_settings_game.vehicle.dynamic_engines ? 1U : 0U) << 0x18) // dynamic engines
| (1U << 0x1E) // variablerunningcosts
| (1U << 0x1F); // any switch is on
_ttdpatch_flags[4] = (1 << 0x00) // larger persistent storage
| ((_settings_game.economy.inflation ? 1 : 0) << 0x01); // inflation is on
_ttdpatch_flags[4] = (1U << 0x00) // larger persistent storage
| ((_settings_game.economy.inflation ? 1U : 0U) << 0x01); // inflation is on
}
/** Reset and clear all NewGRF stations */
@@ -8985,11 +9003,9 @@ static void FinaliseEngineArray()
if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
/* When the train does not set property 27 (misc flags), but it
* is overridden by a NewGRF graphically we want to disable the
* flipping possibility. */
if (e->type == VEH_TRAIN && !_gted[e->index].prop27_set && e->GetGRF() != nullptr && is_custom_sprite(e->u.rail.image_index)) {
ClrBit(e->info.misc_flags, EF_RAIL_FLIPS);
/* Set appropriate flags on variant engine */
if (e->info.variant_id != INVALID_ENGINE) {
Engine::Get(e->info.variant_id)->display_flags |= EngineDisplayFlags::HasVariants | EngineDisplayFlags::IsFolded;
}
/* Skip wagons, there livery is defined via the engine */