fix(erf): align restype numbers with upstream neverwinter.nim
ci / ci (pull_request) Successful in 3m34s
ci / ci (pull_request) Successful in 3m34s
Five entries in the restype table disagreed with upstream
neverwinter.nim's restype.nim, so HAKs written from those source
extensions were labelled with a type the game reads as something else:
gff 0x07F7 (2039, upstream bte) -> 0x07F5 (2037)
ltr 0x0813 (2067, upstream bak) -> 0x07F4 (2036)
jpg 0x081C (2076, upstream tml) -> 0x0821 (2081)
dfa -> dft (0x07FD/2045 was already right,
only the name was a typo)
mdb 0x0816 (2070, upstream xbc) -> removed
Upstream registers no restype for mdb, so there is no correct number to
give it; keeping it squatting on xbc silently mislabels the resource.
It is dropped from AssetExtensions too, which turns .mdb into a loud
"unsupported extension" build error instead of a corrupt HAK entry. No
asset in the current corpus uses any of these paths.
Root cause of the miss: the init() consistency guard only panicked when
a number was missing from the reverse map. Its `if canonicalExt == ext
{ continue }` branch did nothing when the two maps disagreed, so a
mismatch was never caught. The guard now panics on disagreement and
also checks the reverse direction.
Adds a conformance test pinning the shared numbers against upstream,
including the four numbers upstream reserves for other extensions, and
a test that the two maps are mutual inverses.
Refs ShadowsOverWestgate/sow-tools#64
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+19
-12
@@ -67,6 +67,10 @@ type resourceEntry struct {
|
||||
Size uint32
|
||||
}
|
||||
|
||||
// extensionTypes and typeExtensions must stay exact inverses of each other;
|
||||
// init() panics if they drift apart. Numbers below 0x0BB8 follow upstream
|
||||
// neverwinter.nim (neverwinter/restype.nim). The 0x0BB8 and up entries are
|
||||
// local additions for source formats upstream does not register.
|
||||
var extensionTypes = map[string]uint16{
|
||||
"res": 0x0000,
|
||||
"bmp": 0x0001,
|
||||
@@ -96,12 +100,13 @@ var extensionTypes = map[string]uint16{
|
||||
"utt": 0x07F0,
|
||||
"dds": 0x07F1,
|
||||
"uts": 0x07F3,
|
||||
"ltr": 0x07F4,
|
||||
"gff": 0x07F5,
|
||||
"fac": 0x07F6,
|
||||
"gff": 0x07F7,
|
||||
"ute": 0x07F8,
|
||||
"utd": 0x07FA,
|
||||
"utp": 0x07FC,
|
||||
"dfa": 0x07FD,
|
||||
"dft": 0x07FD,
|
||||
"gic": 0x07FE,
|
||||
"gui": 0x07FF,
|
||||
"utm": 0x0803,
|
||||
@@ -117,14 +122,12 @@ var extensionTypes = map[string]uint16{
|
||||
"ndb": 0x0810,
|
||||
"ptm": 0x0811,
|
||||
"ptt": 0x0812,
|
||||
"ltr": 0x0813,
|
||||
"shd": 0x0815,
|
||||
"mdb": 0x0816,
|
||||
"mtr": 0x0818,
|
||||
"jpg": 0x081C,
|
||||
"lod": 0x081E,
|
||||
"gif": 0x081F,
|
||||
"png": 0x0820,
|
||||
"jpg": 0x0821,
|
||||
"lyt": 0x0BB8,
|
||||
"vis": 0x0BB9,
|
||||
"mdx": 0x0BC0,
|
||||
@@ -162,12 +165,13 @@ var typeExtensions = map[uint16]string{
|
||||
0x07F0: "utt",
|
||||
0x07F1: "dds",
|
||||
0x07F3: "uts",
|
||||
0x07F4: "ltr",
|
||||
0x07F5: "gff",
|
||||
0x07F6: "fac",
|
||||
0x07F7: "gff",
|
||||
0x07F8: "ute",
|
||||
0x07FA: "utd",
|
||||
0x07FC: "utp",
|
||||
0x07FD: "dfa",
|
||||
0x07FD: "dft",
|
||||
0x07FE: "gic",
|
||||
0x07FF: "gui",
|
||||
0x0803: "utm",
|
||||
@@ -183,14 +187,12 @@ var typeExtensions = map[uint16]string{
|
||||
0x0810: "ndb",
|
||||
0x0811: "ptm",
|
||||
0x0812: "ptt",
|
||||
0x0813: "ltr",
|
||||
0x0815: "shd",
|
||||
0x0816: "mdb",
|
||||
0x0818: "mtr",
|
||||
0x081C: "jpg",
|
||||
0x081E: "lod",
|
||||
0x081F: "gif",
|
||||
0x0820: "png",
|
||||
0x0821: "jpg",
|
||||
0x0BB8: "lyt",
|
||||
0x0BB9: "vis",
|
||||
0x0BC0: "mdx",
|
||||
@@ -205,8 +207,13 @@ func init() {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("missing canonical extension for resource type 0x%04X", resourceType))
|
||||
}
|
||||
if canonicalExt == ext {
|
||||
continue
|
||||
if canonicalExt != ext {
|
||||
panic(fmt.Sprintf("resource type 0x%04X is %q in extensionTypes but %q in typeExtensions", resourceType, ext, canonicalExt))
|
||||
}
|
||||
}
|
||||
for resourceType, ext := range typeExtensions {
|
||||
if registered, ok := extensionTypes[ext]; !ok || registered != resourceType {
|
||||
panic(fmt.Sprintf("extension %q is 0x%04X in typeExtensions but 0x%04X in extensionTypes (registered=%v)", ext, resourceType, registered, ok))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user