Looks at a tree and returns a MountProbe if it’s this game, or null if it isn’t.
A probe names the mount with a MountId of game, platform and build, like quake/pc/1.06, and a ProbeStatus: Known, or UnknownVariant for the game at a build the adapter doesn’t have a version for, NeedsKey for one it can’t read without a key, and Damaged. Add Evidence, short lines saying what the probe saw, which the boot prints, and any Externals the game reads from outside its own folder, which the host resolves before it calls Open.
Probes run on every location the engine reads, so read as little as you can: a couple of headers or a version file, not the whole install. Return null rather than throwing, since the host doesn’t catch exceptions from a probe. When several games match the same tree, Known probes rank first, then higher Confidence.
Quake’s original edition tells its build from where PAK0.PAK and PAK1.PAK keep their directories:
public MountProbe? Probe(IFileSource tree)
{
if (tree.Exists(QuakeRereleaseGame.Kpf) || Header(tree, Pak0) is not { } first)
return null;
var evidence = new List<string> { $"{Pak0}'s directory is at {first.Offset} for {first.Length} bytes" };
var second = Header(tree, Pak1);
if (second is not null)
evidence.Add($"{Pak1}'s directory is at {second.Value.Offset} for {second.Value.Length} bytes");
if (second is null || !Labels.TryGetValue((first, second.Value), out var label))
{
evidence.Add(second is null
? $"there's no {Pak1}, as a shareware copy has none, so the build is unknown"
: "that pair isn't one the adapter has a version for, so the build is unknown");
return new MountProbe(new MountId(Game, Pc.Id, "unknown"), ProbeStatus.UnknownVariant, tree)
{ Evidence = evidence, Externals = SteamClaims.Externals };
}
evidence.Add($"that pair is the registered {label}");
return new MountProbe(new MountId(Game, Pc.Id, label), ProbeStatus.Known, tree)
{ Evidence = evidence, Externals = SteamClaims.Externals };
}