Fixed an issue where ext (release_code) wasn't detected and replaced correctly when using user specified bootstrap.xml path. (#398)

## Link to GitHub Issue, if one exists
#0

## Description of change
The original launcher::detect_bootstrap_release_code() wasn't detecting
user specified bootstrap.xml path, and was causing issues for
patch_manager and other ext check spots prior to ea3 init (as ea3 does
proper path check itself).
I've added the user path check and proper xml parsing from
detect_gameversion().

## Testing
Tested with prop/bootstrap.xml presents.
Tested with prop/bootstrap.xml not presents and -b
/path/to/bootstrap.xml
This commit is contained in:
AllanCat
2025-10-11 12:35:34 +08:00
committed by GitHub
parent c6b10402f4
commit 02711cdee1
3 changed files with 26 additions and 15 deletions
+2 -1
View File
@@ -263,7 +263,8 @@ int main_implementation(int argc, char *argv[]) {
// detect model used to load option overrides // detect model used to load option overrides
auto options_version = launcher::detect_gameversion( auto options_version = launcher::detect_gameversion(
LAUNCHER_OPTIONS->at(launcher::Options::PathToEa3Config).value LAUNCHER_OPTIONS->at(launcher::Options::PathToEa3Config).value,
LAUNCHER_OPTIONS->at(launcher::Options::PathToBootstrap).value
); );
if (!options_version.model.empty() && options_version.model.size() < 4) { if (!options_version.model.empty() && options_version.model.size() < 4) {
if (options_version.dest.size() == 1) { if (options_version.dest.size() == 1) {
+20 -10
View File
@@ -2608,8 +2608,19 @@ std::vector<Option> launcher::merge_options(
return merged; return merged;
} }
std::string launcher::detect_bootstrap_release_code() { std::string launcher::detect_bootstrap_release_code(const std::string& bootstrap_user) {
std::string bootstrap_path = "prop/bootstrap.xml"; std::string bootstrap_path;
if (!bootstrap_user.empty()) {
bootstrap_path = bootstrap_user;
} else if (fileutils::file_exists("prop/bootstrap.xml")) {
bootstrap_path = "prop/bootstrap.xml";
}
if (bootstrap_path.empty()) {
log_warning("options", "unable to detect bootstrap.xml file");
return "";
}
// load XML // load XML
tinyxml2::XMLDocument bootstrap; tinyxml2::XMLDocument bootstrap;
@@ -2632,7 +2643,7 @@ std::string launcher::detect_bootstrap_release_code() {
return ""; return "";
} }
static launcher::GameVersion detect_gameversion_ident() { static launcher::GameVersion detect_gameversion_ident(const std::string& bootstrap_user) {
// detect ea3-ident path // detect ea3-ident path
std::string ident_path; std::string ident_path;
@@ -2678,7 +2689,7 @@ static launcher::GameVersion detect_gameversion_ident() {
auto node_ext = node_soft->FirstChildElement("ext"); auto node_ext = node_soft->FirstChildElement("ext");
if (node_ext) { if (node_ext) {
version.ext = node_ext->GetText(); version.ext = node_ext->GetText();
auto bootstrap_ext = launcher::detect_bootstrap_release_code(); auto bootstrap_ext = launcher::detect_bootstrap_release_code(bootstrap_user);
if (version.ext.size() != 10 && bootstrap_ext.size() == 10) { if (version.ext.size() != 10 && bootstrap_ext.size() == 10) {
version.ext = bootstrap_ext; version.ext = bootstrap_ext;
} else if (bootstrap_ext.size() == 10) { } else if (bootstrap_ext.size() == 10) {
@@ -2714,8 +2725,7 @@ static launcher::GameVersion detect_gameversion_ident() {
return launcher::GameVersion(); return launcher::GameVersion();
} }
launcher::GameVersion launcher::detect_gameversion(const std::string &ea3_user) { launcher::GameVersion launcher::detect_gameversion(const std::string &ea3_user, const std::string& bootstrap_user) {
// detect ea3-config path // detect ea3-config path
std::string ea3_path; std::string ea3_path;
if (!ea3_user.empty()) { if (!ea3_user.empty()) {
@@ -2729,7 +2739,7 @@ launcher::GameVersion launcher::detect_gameversion(const std::string &ea3_user)
} }
if (ea3_path.empty()) { if (ea3_path.empty()) {
log_warning("options", "unable to detect EA3 configuration file"); log_warning("options", "unable to detect EA3 configuration file");
return detect_gameversion_ident(); return detect_gameversion_ident(bootstrap_user);
} }
// load XML // load XML
@@ -2769,7 +2779,7 @@ launcher::GameVersion launcher::detect_gameversion(const std::string &ea3_user)
if (ea3_config.Parse(xml_str.c_str()) != tinyxml2::XML_SUCCESS) { if (ea3_config.Parse(xml_str.c_str()) != tinyxml2::XML_SUCCESS) {
// if we still failed, give up // if we still failed, give up
log_warning("options", "unable to parse fixed xml"); log_warning("options", "unable to parse fixed xml");
return detect_gameversion_ident(); return detect_gameversion_ident(bootstrap_user);
} }
} }
@@ -2800,7 +2810,7 @@ launcher::GameVersion launcher::detect_gameversion(const std::string &ea3_user)
auto node_ext = node_soft->FirstChildElement("ext"); auto node_ext = node_soft->FirstChildElement("ext");
if (node_ext) { if (node_ext) {
version.ext = node_ext->GetText(); version.ext = node_ext->GetText();
auto bootstrap_ext = launcher::detect_bootstrap_release_code(); auto bootstrap_ext = launcher::detect_bootstrap_release_code(bootstrap_user);
if (version.ext.size() != 10 && bootstrap_ext.size() == 10) { if (version.ext.size() != 10 && bootstrap_ext.size() == 10) {
version.ext = bootstrap_ext; version.ext = bootstrap_ext;
} else if (bootstrap_ext.size() == 10) { } else if (bootstrap_ext.size() == 10) {
@@ -2833,5 +2843,5 @@ launcher::GameVersion launcher::detect_gameversion(const std::string &ea3_user)
// error // error
log_warning("options", "unable to find /ea3/soft/model in {}", ea3_path); log_warning("options", "unable to find /ea3/soft/model in {}", ea3_path);
return detect_gameversion_ident(); return detect_gameversion_ident(bootstrap_user);
} }
+2 -2
View File
@@ -279,6 +279,6 @@ namespace launcher {
std::string ext; std::string ext;
}; };
std::string detect_bootstrap_release_code(); std::string detect_bootstrap_release_code(const std::string& bootstrap_user);
GameVersion detect_gameversion(const std::string& ea3_user); GameVersion detect_gameversion(const std::string& ea3_user, const std::string& bootstrap_user);
} }