From f1339dcf88b7741067143144d4e2ad4e3999980f Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 1 Aug 2025 11:33:22 -0500 Subject: [PATCH] loading scen headers, skip parts of legacy load that may error --- src/fileio/fileio_scen.cpp | 9 +++++---- src/scenario/scenario.cpp | 5 ++++- src/scenario/scenario.hpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/fileio/fileio_scen.cpp b/src/fileio/fileio_scen.cpp index f0a41d0f..6edb5e9b 100644 --- a/src/fileio/fileio_scen.cpp +++ b/src/fileio/fileio_scen.cpp @@ -293,8 +293,11 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, eLoadScenario return false; } port_item_list(&item_data); - scenario.import_legacy(temp_scenario); - scenario.import_legacy(item_data); + scenario.import_legacy(temp_scenario, load_type == eLoadScenario::ONLY_HEADER); + if(load_type == eLoadScenario::FULL){ + scenario.ter_types[23].fly_over = false; + scenario.import_legacy(item_data); + } // TODO: Consider skipping the fread and assignment when len is 0 scenario.special_items.resize(50); @@ -322,8 +325,6 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, eLoadScenario fclose(file_id); - scenario.ter_types[23].fly_over = false; - scenario.scen_file = file_to_load; if(load_type == eLoadScenario::ONLY_HEADER) return true; load_spec_graphics_v1(scenario.scen_file); diff --git a/src/scenario/scenario.cpp b/src/scenario/scenario.cpp index 0337292a..5f0df057 100644 --- a/src/scenario/scenario.cpp +++ b/src/scenario/scenario.cpp @@ -231,7 +231,7 @@ cScenario::cItemStorage::cItemStorage() : ter_type(-1), property(0) { item_odds[i] = 0; } -void cScenario::import_legacy(legacy::scenario_data_type& old){ +void cScenario::import_legacy(legacy::scenario_data_type& old, bool header_only){ is_legacy = true; // TODO eventually the absence of feature flags here will replace is_legacy altogether feature_flags = {}; @@ -267,6 +267,9 @@ void cScenario::import_legacy(legacy::scenario_data_type& old){ rating = eContentRating(old.rating); // TODO: Is this used anywhere? uses_custom_graphics = old.uses_custom_graphics; + + if(header_only) return; + boats.resize(30); horses.resize(30); for(short i = 0; i < 30; i++) { diff --git a/src/scenario/scenario.hpp b/src/scenario/scenario.hpp index d52585b2..62180c87 100644 --- a/src/scenario/scenario.hpp +++ b/src/scenario/scenario.hpp @@ -151,7 +151,7 @@ public: towns.back()->init_start(); } - void import_legacy(legacy::scenario_data_type& old); + void import_legacy(legacy::scenario_data_type& old, bool header_only = false); void import_legacy(legacy::scen_item_data_type& old); void writeTo(cTagFile& file) const; void readFrom(const cTagFile& file);