Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In a
PRESENT
event (eg:PRESENT EVIDENCE SWITCH
) we for some reason search both the Evidence and the Profiles tables (maybe that's intentional idk). We index into the Profile table with a P index and into the Evidence table with an E index. The problem is we look into the table we're currently in with both the P and E indices. This is fine for most cases but if you have (for example) 8 evidence items but only 6 profiles you can:Crash!!
This is because we looked into the profile table at index P (where we are currently navigated) and index E (where we used to be navigated to in the Evidence menu). E is larger than the size of the table so we get a nil and all hell breaks loose.
One option would be to defensively check if the resulting value is non-nil in each case but that's like 5 places.
Alternatively (aka the fix I actually did), we could just reset both the P and E values to 1 when you toggle between menus. As far as I can tell this is already the observed behavior the game anyway, so we're not doing anything unexpected.