From da3fe0ed09ed921d105e86ff63e2277877db81cd Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Fri, 5 Mar 2021 13:12:53 +0100 Subject: [PATCH] string table: fixed bug, when (despite OpenDiablo2#1080) string tables wasn't encoded correctly --- d2common/d2fileformats/d2tbl/text_dictionary.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/d2common/d2fileformats/d2tbl/text_dictionary.go b/d2common/d2fileformats/d2tbl/text_dictionary.go index a31c67c6..32aca47f 100644 --- a/d2common/d2fileformats/d2tbl/text_dictionary.go +++ b/d2common/d2fileformats/d2tbl/text_dictionary.go @@ -2,7 +2,6 @@ package d2tbl import ( "fmt" - "strconv" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils" @@ -190,7 +189,7 @@ func (td *TextDictionary) Marshal() []byte { keys = append(keys, key) } - sw.PushInt32(int32(len(keys))) + sw.PushUint32(uint32(len(keys))) // version (always 0) sw.PushBytes(0) @@ -246,16 +245,12 @@ func (td *TextDictionary) Marshal() []byte { key = "x" } - for _, i := range key { - sw.PushBytes(byte(i)) - } + sw.PushBytes([]byte(key)...) // 0 as separator sw.PushBytes(0) - for _, i := range value { - sw.PushBytes(byte(i)) - } + sw.PushBytes([]byte(value)...) // 0 as separator sw.PushBytes(0)