Fix invalid avatar when we have old memorial #71328
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
Bugfixes "Fix invalid avatar when we have old memorials"
Purpose of change
Fix Strange: player is already assigned to mission 1 through 10
#67277
Describe the solution
Add a check to this function.
Load game if there's an old memorial that don't have event_type::game_avatar_new, or event_type::game_start,
will cause "strange: player is already assigned to mission 1", actually, this is because, the player ID hasn't been set by game,
and the value is -1, and when we trigger event_type::game_avatar_new, game will assign misson to player, but at this time the target player id of the mission is also -1, so we got this bug.
the u ID is the player ID in current world, so if we load an existed save, this should not happen,
and when we load memorial, the same function will be invoke, so it may happen at this situation.
if the player ID don't set yet, it's -1, this situation only occurs when we have an old memorial without event_type::game_avatar_new or event_type::start_game,
and if the player ID set, then this function need to be done for old savefiles.
Describe alternatives you've considered
Maybe, we can optimize event function.
Testing
try file from the issue not trigger the case.
Additional context
This is how the bug works.
Tell me if the code's anything wrong.