Update last_world_pos
considerations
#2838
Merged
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.
Summary
SUMMARY: Bugfixes "Update
last_world_pos
considerations"Purpose of change
Several issues noted with current version, namely
First issue has been solved on DDA but I was unable to git blame the commit, though I was able to find the solution code. If someone is willing to step forward with the commit I will add them as co-author.
Second issue was solved on DDA as well, but produced more issues and in my opinion was inefficient.
last_world_pos
a class variable and incrementing/decrementing it on world create/deleteIn general, I believe that derived indexes should only be regenerated instead of modified, as this prevents any risk of segfaults and keeps the code easy to follow.
In a similar vein, I don't believe that such indexes should be saved as class variables, as you will need to remember to update them every single time you code for dependent value changes instead of letting it be regenerated.
Describe the solution
Added code to update
last_world_name
andlast_character_name
on saving the game.Added
get_world_index()
function using existingstd::find
code. Nowlast_world_pos
is updated every redraw. The effect of this on performance should be negligible on any half decent phone/computer.Describe alternatives you've considered
Testing
Additional context