feat(quest): QT2/QT4 — the contract catalog, and retail's progress column

The wire carries an id, a stage and two timers. Every word the player reads
lives in portal.dat's ContractTable, which nothing in the tree had ever
opened — the only reference counted its entries in a CLI diagnostic. Chorizite
does decode it (322 contracts installed), which was a real question given it
declares TabooTable without decoding it.

FillProgressString @0x00498DE0 is the one real algorithm in this panel, and it
is now ported whole. Its x87 compares are the usual fcom/sahf pattern, so the
(status & 0x41) tests decode as "<= 0" rather than "< 0" — the difference
between a cooldown that expires and one that never does.

Three readings recorded as tests because each looks like a mistake:
TimeWhenDone is on the wire and is never read; an EMPTY QuestflagRepeatTime is
the entire difference between "Done" and "Available"; and DescriptionProgress
is a printf format taking stage-4, not a literal — rendering it verbatim shows
the player "%d/20 Tuskers".

DeltaTimeToString @0x00565E10 emits every part with a trailing space and then
overwrites the last one. That truncation is invisible in the decompiler output
(the instruction reads as pointer noise), so it was settled by decoding the
bytes: mov byte ptr [esp+eax+0x1b], cl with cl == 0 and eax == strlen writes
the terminator over buffer[len-1]. Guessing either way was a coin flip that
decides whether every repeat timer reads "Done (1h 30s  to Repeat)".

The single-%d substitution is a MEASUREMENT, not a convenience: 89 of the 322
installed contracts author a progress format and every one uses exactly one
specifier. An installed-DAT test asserts that, so a future dat that ships two
fails there rather than silently rendering a raw specifier.

LayoutDump gained --contracts, which is how all of the above was measured.

Campaign QT slices 2 and 4 of 6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-21 14:53:21 +02:00
parent f629ce7f3d
commit ef6b7310c5
6 changed files with 637 additions and 0 deletions

View file

@ -35,6 +35,55 @@ string datDir = SysEnv.GetEnvironmentVariable("ACDREAM_DAT_DIR")
using var dats = new DatCollection(datDir, DatAccessType.Read);
using var adapter = new DatCollectionAdapter(dats);
if (args.Contains("--contracts"))
{
// Campaign QT slice QT2: what does the installed ContractTable actually
// hold, and does the reader decode it at all?
var table = dats.Get<DatReaderWriter.DBObjs.ContractTable>(0x0E00001Du);
if (table is null)
{
Console.WriteLine("ContractTable 0x0E00001D not found");
return 2;
}
Console.WriteLine($"ContractTable 0x{table.Id:X8}: {table.Contracts.Count} contracts");
// Which printf specifiers does the authored DescriptionProgress actually
// use? FillProgressString passes exactly ONE integer, so anything else
// would be reading past the argument in retail too.
var specs = new SortedDictionary<string, int>(StringComparer.Ordinal);
int withProgress = 0;
foreach (var c in table.Contracts.Values)
{
string f = c.DescriptionProgress ?? "";
if (f.Length == 0) continue;
withProgress++;
for (int i = 0; i < f.Length - 1; i++)
{
if (f[i] != '%') continue;
string spec = f.Substring(i, 2);
specs[spec] = specs.TryGetValue(spec, out int n) ? n + 1 : 1;
}
}
Console.WriteLine($" {withProgress} have a DescriptionProgress; specifiers:");
foreach (var (spec, n) in specs)
Console.WriteLine($" {spec} x{n}");
int shown = 0;
foreach (var (key, contract) in table.Contracts.OrderBy(kv => kv.Key))
{
if (shown++ >= 5) break;
Console.WriteLine($" 0x{key:X8} v{contract.Version} \"{contract.ContractName}\"");
Console.WriteLine($" desc: {contract.Description}");
Console.WriteLine($" progress: {contract.DescriptionProgress}");
Console.WriteLine($" npc: {contract.NameNPCStart} -> {contract.NameNPCEnd}");
Console.WriteLine($" flags: started={contract.QuestflagStarted} "
+ $"finished={contract.QuestflagFinished} progress={contract.QuestflagProgress} "
+ $"repeat={contract.QuestflagRepeatTime}");
}
return 0;
}
int findAt = Array.IndexOf(args, "--find");
if (findAt >= 0)
{