diff --git a/d2common/d2fileformats/d2tbl/text_dictionary.go b/d2common/d2fileformats/d2tbl/text_dictionary.go index 3d53b478..257be33e 100644 --- a/d2common/d2fileformats/d2tbl/text_dictionary.go +++ b/d2common/d2fileformats/d2tbl/text_dictionary.go @@ -227,7 +227,7 @@ func (td *TextDictionary) Marshal() []byte { sw.PushUint32(uint32(dataPos)) dataPos += len(value) + 1 - sw.PushUint16(uint16(len(value) + 0)) + sw.PushUint16(uint16(len(value) + 1)) } // data stream: put all data in appropiate order diff --git a/d2common/d2fileformats/d2tbl/text_dictionary_test.go b/d2common/d2fileformats/d2tbl/text_dictionary_test.go index 5f04bcf4..df5012cf 100644 --- a/d2common/d2fileformats/d2tbl/text_dictionary_test.go +++ b/d2common/d2fileformats/d2tbl/text_dictionary_test.go @@ -19,13 +19,20 @@ func exampleData() *TextDictionary { func TestTBL_Marshal(t *testing.T) { tbl := exampleData() data := tbl.Marshal() + newTbl, err := LoadTextDictionary(data) if err != nil { t.Error(err) } - _, ok := newTbl["lolstring"] - if !ok { - t.Fatal("no string found") + for key, value := range *tbl { + newValue, ok := newTbl[key] + fmt.Println(newValue, value) + if !ok { + t.Fatal("string wasn't encoded to table") + } + if newValue != value { + t.Fatal("unexpected value set") + } } }