Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to convert story state to JSON #29

Closed
j0rdanit0 opened this issue Nov 4, 2022 · 2 comments
Closed

Unable to convert story state to JSON #29

j0rdanit0 opened this issue Nov 4, 2022 · 2 comments

Comments

@j0rdanit0
Copy link
Contributor

blade-ink version: 1.1.1

What is wrong

I get the following stacktrace when trying to convert my story state to JSON:

java.lang.ArrayIndexOutOfBoundsException: Index 26 out of bounds for length 26
	at com.bladecoder.ink.runtime.Json.writeRuntimeObject(Json.java:174) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.Json.writeListRuntimeObjs(Json.java:48) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.Flow$2.write(Flow.java:50) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.SimpleJson$Writer.writePropertyString(SimpleJson.java:388) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.SimpleJson$Writer.writeProperty(SimpleJson.java:306) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.Flow.writeJson(Flow.java:47) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.StoryState$2.write(StoryState.java:1240) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.SimpleJson$Writer.writePropertyString(SimpleJson.java:388) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.SimpleJson$Writer.writeProperty(SimpleJson.java:306) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.StoryState.writeJson(StoryState.java:1237) ~[blade-ink-1.1.1.jar:na]
	at com.bladecoder.ink.runtime.StoryState.toJson(StoryState.java:924) ~[blade-ink-1.1.1.jar:na]

Possibly useful information

The stacktrace points to a place in the code where an array (controlCommandNames) is being accessed at index 26, but there are only 26 entries in it (max index would be 25). The index is coming from ControlCommand.CommandType.ordinal(), which is an enum that indeed has 27 values, so the last value would have an ordinal of 26.

My best guess is that this is related to supporting the latest version of Ink, and the controlCommandNames array was supposed to be updated to add a new entry and it was missed?

@bladecoder
Copy link
Owner

bladecoder commented Nov 5, 2022

Hi, @j0rdanit0, thanks for your bug report!

I uploaded v1.1.2 that should fix this error. But I couldn't test it. Could you verify that the bug is fixed? Also if you could upload an .ink file that fails to verify by myself would be nice too.

@j0rdanit0
Copy link
Contributor Author

Thanks for the quick turnaround, yes it seems to be fixed now. Here's my .ink file (uploaded as .txt because GitHub won't accept it as .ink):
three_little_pigs.ink.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants