- A player tries to load their JSON save. It refuses to load, throwing the error
runtime error: Unknown value:
every time it tries to load another file. It doesn't show on the forums, but there are 31 spaces after it.- The save files are clean and not corrupted in any way. I know this because it refuses to load "dummy files" that contain a completely static json table that never changes, and loading that file works normally.
The code is this. It crashes on the "json_decode" line.
var/file_contents = file2text(full_path)
loaded_data = json_decode(file_contents)
Like this isn't consistent. json_decode and file loading works 100% of the time except when this occurs, and when it occurs, the proc just completely stops working and throws that error. I can't even make new files with it when it occurs.
This has never happened before in stable, but I cannot confirm if it's a byond beta bug yet. I need to test my server again tomorrow or something on stable to see if it happens there. Someone has experienced this before, but the solution they used is the solution that I'm actually using now, and it's causing the error. http://www.byond.com/forum/post/2048264
Another thing that just may be coincidence: It is showing 31 spaces after the error. The unicode decimal for a space is 32.
EDIT: Here is also what I am using for file checking. This is called on new when created, so loaded_data on new is always the default data for a player.
var/full_path = "[get_folder(owner.ckey)][get_file()]"
if(!fexists(full_path))
text2file(json_encode(loaded_data),full_path)
var/file_contents = file2text(full_path)
loaded_data = json_decode(file_contents)
Outputting the file contents in the event of a failure should be useful, since it may show if the contents as loaded are corrupt.