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

Check for null owner in AddUnits #7269

Merged

Conversation

trevan
Copy link
Contributor

@trevan trevan commented Jul 28, 2020

Fixes #7226

I don't know the null owner occurred. But there exists code that already checks for the null owner case so this adds similar code to the AddUnits class.

Functional Changes

[] New map or map update
[] New Feature
[] Feature update or enhancement
[] Feature Removal
[] Code Cleanup or refactor
[] Configuration Change
[x] Problem fix
[] Other:

Testing

I don't know how to duplicate the null owner case so I just ensured that things continued to work as expected.

Screens Shots

Additional Notes to Reviewer

Release Note

FIX|Fix null error in AddUnits#buildUnitOwnerMap when loading a saved game

@trevan
Copy link
Contributor Author

trevan commented Jul 28, 2020

I wasn't sure how to give a user friendly release note since I'm not sure when this happens.. And the user just sees a "Error: null" error which can happen in lots of situations so I can't say that I fixed that error.

@RoiEXLab RoiEXLab merged commit c190602 into triplea-game:master Jul 29, 2020
@DanVanAtta
Copy link
Member

Did you play test this @trevan to see what happens? You can hack up the code to always return null for owners and then just see how the game plays out.

I think the problem comes up from serialization, objects are not instantiated via their constructors and so who knows what can happen...

If we go with this workaround, would such units cause problems in the save game - is the save game just corrupt or is this a valid work-around?

@trevan
Copy link
Contributor Author

trevan commented Jul 29, 2020

Did you play test this @trevan to see what happens? You can hack up the code to always return null for owners and then just see how the game plays out.

I think the problem comes up from serialization, objects are not instantiated via their constructors and so who knows what can happen...

If we go with this workaround, would such units cause problems in the save game - is the save game just corrupt or is this a valid work-around?

I tested it but I don't know how to get a null owner. Returning null for getOwner actually breaks a lot of things. I can't play most of my saves. I noticed, though, that in Unit#setOwner, it will use the NULL_PLAYERID if the owner is null. So I'm going to set that as the owner instead of null.

@DanVanAtta
Copy link
Member

I think/suspect the null_playerid indicates neutrals. You might get some interesting behavior 😁

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

Successfully merging this pull request may close these issues.

2.1.20365: AddUnits#lambda$buildUnitOwnerMap$0:45 - NullPointerException
3 participants