1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-25 04:36:12 -04:00

hotfix: string table: fixed bug, when sometimes encoded end decoded table wasn't the same

This commit is contained in:
M. Sz 2021-02-28 12:24:19 +01:00
parent fa4276156c
commit de1c0ebe5d

View File

@ -185,7 +185,12 @@ func (td *TextDictionary) Marshal() []byte {
sw.PushUint16(0)
sw.PushInt32(int32(len(*td)))
keys := make([]string, 0)
for key := range *td {
keys = append(keys, key)
}
sw.PushInt32(int32(len(keys)))
// version (always 0)
sw.PushBytes(0)
@ -205,7 +210,8 @@ func (td *TextDictionary) Marshal() []byte {
// dataPos is a position, when we're placing data stream
dataPos := len(sw.GetBytes()) + 17*len(*td)
for key, value := range *td {
for _, key := range keys {
value := (*td)[key]
// non-zero if record is used (for us, every record is used ;-)
sw.PushBytes(1)
@ -227,7 +233,8 @@ func (td *TextDictionary) Marshal() []byte {
}
// data stream: put all data in appropriate order
for key, value := range *td {
for _, key := range keys {
value := (*td)[key]
for _, i := range key {
sw.PushBytes(byte(i))
}