mirror of
https://github.com/readmet3xt-lab/foxhound.git
synced 2026-12-06 08:38:36 +00:00
Install a title profile without a damaged pipeline list
Loading a profile refused it whole when its pipeline list was missing or did not hash, for example after a damaged download. The list only lets a first start prepare the game's pipelines ahead, so the profile's textures, output size and frame-rate patches were lost for an optional file. An optional table whose file is missing or does not hash is now left out at install with a warning, and the profile is installed. Required tables still refuse it. A table file that does not hash now says it is damaged or from another download, and to unpack the profile's archive again. The launcher names a missing pipeline list on its own, with what it costs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -832,7 +832,10 @@ fn table_file(dirs: &[PathBuf], file: &str, hash: &[u8; 32]) -> Result<(PathBuf,
|
||||
}
|
||||
}
|
||||
Err(match (differs, dirs.first()) {
|
||||
(Some(path), _) => format!("{} does not hash as the profile says", path.display()),
|
||||
(Some(path), _) => format!(
|
||||
"{} does not hash as the profile says: it is damaged or from another download (unpack the profile's archive again)",
|
||||
path.display()
|
||||
),
|
||||
(None, Some(dir)) => format!("the file {file} is not beside the profile ({}): keep the profile and {file} together", dir.display()),
|
||||
(None, None) => format!("the file {file} is not there"),
|
||||
})
|
||||
@ -1141,20 +1144,33 @@ pub fn status(exe_dir: Option<&Path>, executable: &[u8; 32]) -> Status {
|
||||
}
|
||||
}
|
||||
|
||||
/// Tables a profile is used without. The pipeline list only lets a first
|
||||
/// start prepare the game's pipelines ahead: without it (missing, or a
|
||||
/// damaged download) they are made while playing, as before it existed.
|
||||
pub const OPTIONAL_TABLES: &[&str] = &["pipelines"];
|
||||
|
||||
/// Installs the profile at `chosen` (a profile file) for `executable`: it is
|
||||
/// read and checked first (a malformed profile, or a table file not beside
|
||||
/// it, is refused and nothing is copied; one for another copy of the
|
||||
/// executable only with `VICTORY_PROFILE_ANY_EXE` on), then it and its table
|
||||
/// files are copied into `into` ([`installed_place`]) under the names the
|
||||
/// profile gives, whatever names they had. The folder it went to.
|
||||
/// profile gives, whatever names they had. An [optional table](OPTIONAL_TABLES)
|
||||
/// whose file is missing or does not hash is left out with a warning. The
|
||||
/// folder it went to.
|
||||
pub fn install_file(chosen: &Path, executable: &[u8; 32], into: &Path) -> Result<PathBuf, Refused> {
|
||||
let text = read_text(chosen).map_err(|e| Refused::Unreadable(format!("{}: {e}", chosen.display())))?;
|
||||
let from = chosen.parent().unwrap_or(Path::new("."));
|
||||
let profile = Profile::parse_with(&text, from, executable, any_exe())?;
|
||||
let mut tables = Vec::new();
|
||||
for name in profile.table_names() {
|
||||
let bytes = profile.table(name)?;
|
||||
tables.push((profile.tables[name].0.clone(), bytes));
|
||||
match profile.table(name) {
|
||||
Ok(bytes) => tables.push((profile.tables[name].0.clone(), bytes)),
|
||||
Err(why) if OPTIONAL_TABLES.contains(&name) => {
|
||||
tracing::warn!("{why}; the profile is installed without it");
|
||||
println!("title profile table left out: {why}");
|
||||
}
|
||||
Err(why) => return Err(why),
|
||||
}
|
||||
}
|
||||
std::fs::create_dir_all(into).map_err(|e| Refused::Unreadable(format!("{}: {e}", into.display())))?;
|
||||
for (file, bytes) in tables {
|
||||
@ -1398,6 +1414,38 @@ blake3 = "{}"
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_profile_installs_without_an_optional_table() {
|
||||
let (dir, _, hash, text) = setup();
|
||||
let list = b"made-up pipeline list";
|
||||
let text = format!(
|
||||
"{text}[[table]]\nname = \"pipelines\"\nfile = \"pipelines.bin\"\nblake3 = \"{}\"\n",
|
||||
hex_of(blake3::hash(list).as_bytes())
|
||||
);
|
||||
let chosen = dir.path().join(FILE);
|
||||
std::fs::write(&chosen, &text).unwrap();
|
||||
let into = tempfile::tempdir().unwrap();
|
||||
// Missing: installed without it.
|
||||
let target = into.path().join("missing");
|
||||
assert_eq!(install_file(&chosen, &hash, &target).unwrap(), target);
|
||||
assert!(target.join(FILE).exists() && target.join("blocks.bin").exists() && !target.join("pipelines.bin").exists());
|
||||
// Damaged (a short download): installed without it, the error says so.
|
||||
std::fs::write(dir.path().join("pipelines.bin"), &list[..5]).unwrap();
|
||||
let p = Profile::parse(&text, dir.path(), &hash).unwrap();
|
||||
assert!(p.table("pipelines").unwrap_err().to_string().contains("damaged"));
|
||||
let target = into.path().join("damaged");
|
||||
assert_eq!(install_file(&chosen, &hash, &target).unwrap(), target);
|
||||
assert!(target.join("blocks.bin").exists() && !target.join("pipelines.bin").exists());
|
||||
// Sound: copied.
|
||||
std::fs::write(dir.path().join("pipelines.bin"), list).unwrap();
|
||||
let target = into.path().join("sound");
|
||||
install_file(&chosen, &hash, &target).unwrap();
|
||||
assert_eq!(std::fs::read(target.join("pipelines.bin")).unwrap(), list);
|
||||
// A required table missing still refuses the profile.
|
||||
std::fs::remove_file(dir.path().join("blocks.bin")).unwrap();
|
||||
assert!(install_file(&chosen, &hash, &into.path().join("no-blocks")).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_profile_for_another_copy_keeps_its_roles_and_tables_but_not_its_groups() {
|
||||
let (dir, _, _, text) = setup();
|
||||
|
||||
@ -2930,7 +2930,14 @@ namespace Foxhound
|
||||
// What is wrong first; where it came from last (a long folder is cut, all of it in the tooltip).
|
||||
List<string> notes = new List<string>();
|
||||
if (p.ExeDiffers) notes.Add("Made for another copy of the game's .exe: its 1440p, DLSS/FSR and frame-rate patches are off; its shader fixes are used.");
|
||||
if (p.Tables.StartsWith("missing:")) notes.Add("Its table file " + p.Tables.Substring(8) + " is missing: put it beside the profile.");
|
||||
if (p.Tables.StartsWith("missing:"))
|
||||
{
|
||||
List<string> missing = new List<string>(p.Tables.Substring(8).Split(','));
|
||||
// The pipeline list is optional: without it the first start prepares less ahead.
|
||||
if (missing.Remove("pipelines"))
|
||||
notes.Add("No pipeline list (pipelines.bin missing or damaged): the first start prepares fewer pipelines ahead, so it stutters more at first. Unpack the profile's archive again and press \"Load title profile...\".");
|
||||
if (missing.Count > 0) notes.Add("Its table file " + string.Join(",", missing) + " is missing: put it beside the profile.");
|
||||
}
|
||||
if (p.Bcpack == "missing") notes.Add("No bcpack-tables.bin: BCPack textures show flat grey. Put it beside the profile.");
|
||||
if (p.Output && !p.Canvas && store.Get("resolution", "1440") == "1440")
|
||||
notes.Add("An older profile: at 1440p it draws the HUD and menus larger than the console does. The profile handed out with this version keeps their size.");
|
||||
|
||||
Reference in New Issue
Block a user