Page 1 of 1

[1.0.0] Crash on loading Blueprint String missing a JSON key-value pair ("index":0)

Posted: Thu Aug 20, 2020 10:28 am
by Zarylo
In an effort to preserve my own time and sanity during multiplayer games I wrote a Haskell library for reading exported BP-Strings, decoding, decompressing, modifying, re-compressing and re-encoding them for finally importing them back into the game again.

While doing so, I created a new blueprint book layer and inserted a already existing root-level blueprint book into it (on JSON level) though I neglected to add the "index" key-value pair to the existing, now elevated blueprint book.
Don't judge me I work with JSON for the first time :mrgreen:

Code: Select all

{"blueprint_book":
	{"blueprints":
		[{"blueprint_book":
			{"blueprints":
				[{"blueprint_book":
					{"blueprints":
						[]
						,"item":"blueprint-book"
						,"label":"TEST2"
						,"description":"Test level 2"
						,"active_index":0
						,"version":281474976710656
					}
					,"index":0
				}]
				,"item":"blueprint-book"
				,"label":"TEST"
				,"description":"test level 1"
				,"active_index":0
				,"version":281474976710656
			}
			
		}]
		,"label":"Array"
		,"item":"blueprint-book"
		,"active_index":0
		,"version":281474976710656
	}
}

(root-level "blueprint_book" wrappers do not have an "index" key-value pair, while required for non root ones; according to the BP-String format . Thank you by the way for exposing the inner workings of the Strings. I appreciate it greatly.)

after compressing, encoding and appending that frontal 0 version byte; I imported the String and crashed the game, receiving a Read at address violation
factorio-current.log
Log file created on crash.
(26.5 KiB) Downloaded 145 times

Code: Select all

55942.246 Error CrashHandler.cpp:486: Access Violation: Read at address 000000000017FFF0
Most likely, Factorio tried to access the index value that was never created,

inserting

Code: Select all

,"index":0
on row 22 and retrying resulted in a successful import, no crashing.

I'm not sure how Wube wants to handle this kind of thing, it isn't their string output that created the error. However blerping a "JSON Format Error" Message rather than crashing the game might be considered a worthwhile improvement.

I don't think it matters but the used libraries are the aptly named base64 and zlib packages.

Re: [1.0.0] Crash on loading Blueprint String missing a JSON key-value pair ("index":0)

Posted: Thu Aug 20, 2020 3:09 pm
by Rseding91
Thanks for the report. It's now fixed for a future release.

Re: [1.0.0] Crash on loading Blueprint String missing a JSON key-value pair ("index":0)

Posted: Thu Aug 20, 2020 4:48 pm
by Zarylo
Cheers!