diff --git a/d2common/d2fileformats/d2tbl/text_dictionary.go b/d2common/d2fileformats/d2tbl/text_dictionary.go index 863b92e8..a31c67c6 100644 --- a/d2common/d2fileformats/d2tbl/text_dictionary.go +++ b/d2common/d2fileformats/d2tbl/text_dictionary.go @@ -224,7 +224,13 @@ func (td *TextDictionary) Marshal() []byte { sw.PushUint32(0) sw.PushUint32(uint32(dataPos)) - dataPos += len(key) + 1 + + if key[0] == '#' { + // 1 for X, and 1 for separator + dataPos += 2 + } else { + dataPos += len(key) + 1 + } sw.PushUint32(uint32(dataPos)) dataPos += len(value) + 1 @@ -236,6 +242,10 @@ func (td *TextDictionary) Marshal() []byte { for _, key := range keys { value := (*td)[key] + if key[0] == '#' { + key = "x" + } + for _, i := range key { sw.PushBytes(byte(i)) } diff --git a/d2common/d2fileformats/d2tbl/text_dictionary_test.go b/d2common/d2fileformats/d2tbl/text_dictionary_test.go index 20267803..f92824c9 100644 --- a/d2common/d2fileformats/d2tbl/text_dictionary_test.go +++ b/d2common/d2fileformats/d2tbl/text_dictionary_test.go @@ -6,8 +6,11 @@ import ( func exampleData() *TextDictionary { result := &TextDictionary{ - "abc": "def", - "someStr": "Some long string", + "abc": "def", + "someStr": "Some long string", + // #2 is non-named (X: OK) + // so 2 is an index in map + "#2": "OK", "teststring": "TeStxwsas123 long strin122*8:wq", }