Skip to content

Commit f68d7dc

Browse files
committed
fix parsing error with empty string, correct "set" order
1 parent 687ad1b commit f68d7dc

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

rF2RippleMapDescriptorEditor.ahk

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ MatchComboIndex(text, data_array)
270270

271271
RippleDescriptorJsonParser(filename)
272272
{
273+
EMPTY_DESC := "RF@CTOR2" ; placeholer for replacing empty string
273274
temp_dict := Map()
274275
level := 0
275276
sub_key1 := ""
@@ -281,8 +282,12 @@ RippleDescriptorJsonParser(filename)
281282
; Read raindrop_desc.json file
282283
Loop read, filename
283284
{
285+
raw_line := RegExReplace(
286+
StrReplace(A_LoopReadLine, "`"`"", "`"" EMPTY_DESC "`""),
287+
"`" *`"$", "`"" EMPTY_DESC "`""
288+
)
284289
; Delimiter by quotation mark, line break
285-
Loop Parse, A_LoopReadLine, "`r`n`""
290+
Loop Parse, raw_line, "`r`n`""
286291
{
287292
; Remove leading & trailing space/tab/comma/colon
288293
value_strip := Trim(A_LoopField, A_Tab A_Space ":,")
@@ -319,17 +324,18 @@ RippleDescriptorJsonParser(filename)
319324
if (check_next_value)
320325
{
321326
check_next_value := false
327+
temp_value := StrReplace(value_strip, EMPTY_DESC, "")
322328
if (level = 1)
323329
{
324-
temp_dict[sub_key1] := value_strip
330+
temp_dict[sub_key1] := temp_value
325331
}
326332
else if (level = 2)
327333
{
328-
temp_dict[sub_key1][sub_key2] := value_strip
334+
temp_dict[sub_key1][sub_key2] := temp_value
329335
}
330336
else if (level = 3)
331337
{
332-
temp_dict[sub_key1][sub_key2][sub_key3] := value_strip
338+
temp_dict[sub_key1][sub_key2][sub_key3] := temp_value
333339
}
334340
continue
335341
}
@@ -353,7 +359,15 @@ RippleDescriptorJsonParser(filename)
353359
;--------------
354360
if (level = 1)
355361
{
356-
sub_key1 := value_strip
362+
; Add 3 leading zero to "Set_*" number for retain sets order
363+
if RegExMatch(value_strip, "Set_")
364+
{
365+
sub_key1 := Format("Set_{:03d}", StrReplace(value_strip, "Set_", ""))
366+
}
367+
else
368+
{
369+
sub_key1 := value_strip
370+
}
357371
check_next_value := true
358372
continue
359373
}

0 commit comments

Comments
 (0)