mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-24 12:16:14 -04:00
text dictionary: added support for non-name (#??) strings
This commit is contained in:
parent
287fb2bf4d
commit
4104d9d9ae
@ -224,7 +224,13 @@ func (td *TextDictionary) Marshal() []byte {
|
|||||||
sw.PushUint32(0)
|
sw.PushUint32(0)
|
||||||
|
|
||||||
sw.PushUint32(uint32(dataPos))
|
sw.PushUint32(uint32(dataPos))
|
||||||
|
|
||||||
|
if key[0] == '#' {
|
||||||
|
// 1 for X, and 1 for separator
|
||||||
|
dataPos += 2
|
||||||
|
} else {
|
||||||
dataPos += len(key) + 1
|
dataPos += len(key) + 1
|
||||||
|
}
|
||||||
|
|
||||||
sw.PushUint32(uint32(dataPos))
|
sw.PushUint32(uint32(dataPos))
|
||||||
dataPos += len(value) + 1
|
dataPos += len(value) + 1
|
||||||
@ -236,6 +242,10 @@ func (td *TextDictionary) Marshal() []byte {
|
|||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
value := (*td)[key]
|
value := (*td)[key]
|
||||||
|
|
||||||
|
if key[0] == '#' {
|
||||||
|
key = "x"
|
||||||
|
}
|
||||||
|
|
||||||
for _, i := range key {
|
for _, i := range key {
|
||||||
sw.PushBytes(byte(i))
|
sw.PushBytes(byte(i))
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,9 @@ func exampleData() *TextDictionary {
|
|||||||
result := &TextDictionary{
|
result := &TextDictionary{
|
||||||
"abc": "def",
|
"abc": "def",
|
||||||
"someStr": "Some long string",
|
"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",
|
"teststring": "TeStxwsas123 long strin122*8:wq",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user