Merge branch 'master' into jgrpp

# Conflicts:
#	src/build_vehicle_gui.cpp
#	src/engine.cpp
#	src/engine_func.h
#	src/group_gui.cpp
#	src/lang/english.txt
#	src/newgrf.cpp
#	src/saveload/oldloader_sl.cpp
#	src/timetable_cmd.cpp
#	src/timetable_cmd.h
#	src/timetable_gui.cpp
This commit is contained in:
Jonathan G Rennison
2022-12-28 00:25:16 +00:00
42 changed files with 881 additions and 381 deletions

View File

@@ -341,13 +341,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();
}
/**
@@ -1276,6 +1270,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, mapping_entry, buf);
break;
@@ -1470,6 +1472,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, mapping_entry, buf);
break;
@@ -1642,6 +1652,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, mapping_entry, buf);
break;
@@ -1796,6 +1814,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, mapping_entry, buf);
break;
@@ -7126,9 +7152,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 (uint16 n = num; n > 0; n--) {
_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);
}
}
if (type == 0x04 && ((_cur.grfconfig->ident.grfid & 0x00FFFFFF) == OPENTTD_GRAPHICS_BASE_GRF_ID || _cur.grfconfig->ident.grfid == BSWAP32(0xFF4F4701))) {
@@ -7616,15 +7650,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;
}
}
@@ -8479,23 +8513,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);
}
/**
@@ -10557,6 +10577,11 @@ static void FinaliseEngineArray()
if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
/* 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 */
if (e->type != VEH_TRAIN || e->u.rail.railveh_type != RAILVEH_WAGON) {
LiveryScheme ls = GetEngineLiveryScheme(e->index, INVALID_ENGINE, nullptr);