Skip to content

Commit cf71641

Browse files
authored
Merge pull request #788 from russellquinn/rrq-approximate-location-warning-fix
Fix for approximate-location warning when loading a saved state, which could crash with a null pointer.
2 parents ec462d9 + 48f5c40 commit cf71641

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ink-engine-runtime/CallStack.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ public Thread(Dictionary<string, object> jThreadObj, Story storyContext) : this(
7171
pointer.container = threadPointerResult.container;
7272
pointer.index = (int)jElementObj ["idx"];
7373

74-
if (threadPointerResult.obj == null)
74+
if (threadPointerResult.obj == null) {
7575
throw new System.Exception ("When loading state, internal story location couldn't be found: " + currentContainerPathStr + ". Has the story changed since this save data was created?");
76-
else if (threadPointerResult.approximate)
77-
storyContext.Warning ("When loading state, exact internal story location couldn't be found: '" + currentContainerPathStr + "', so it was approximated to '"+pointer.container.path.ToString()+"' to recover. Has the story changed since this save data was created?");
76+
} else if (threadPointerResult.approximate) {
77+
if (pointer.container != null) {
78+
storyContext.Warning ("When loading state, exact internal story location couldn't be found: '" + currentContainerPathStr + "', so it was approximated to '" + pointer.container.path.ToString() + "' to recover. Has the story changed since this save data was created?");
79+
} else {
80+
storyContext.Warning ("When loading state, exact internal story location couldn't be found: '" + currentContainerPathStr + "' and it may not be recoverable. Has the story changed since this save data was created?");
81+
}
82+
}
7883
}
7984

8085
bool inExpressionEvaluation = (bool)jElementObj ["exp"];

0 commit comments

Comments
 (0)