~adj/comment-test-tracker#128: 
New BIQ -> New Map -> Add City -> Freeze Map Tab

Do what the title describes, and the map tab will freeze. This is because the city's default owner is -1, which is no one, and causes a null pointer exception.

Status
REPORTED
Submitter
bitbucket:QuintillusCFC
Assigned to
No-one
Submitted
6 years ago
Updated
4 years ago
Labels
No labels applied.

~adj 4 years ago

This is due to the combo box defaulting to -1. Once fixing that with case-handling, the combo box choice still doesn't stick for some reason. Verified that it does stick for existing scenarios. I think there's something funky going on with tile-ownership.

~adj 4 years ago

OK, figured out at least part of what's going on. In the calculateTileOwner method, it takes a tile, and grabs the tile's index with:

int i = curTile.index;

And then it uses i to figure out the width/height, like:

int x = calculateTilePosition(i).width;

And it uses those to figure out nearby cities:

ListnearbyCities = findNearestCities(x, y);

But with a new map, the indexes are not set on the tiles. Thus they are 0, the x/y are calculated as 0, and the nearby cities are 0 (unless you paint it in the upper-left, perhaps).

A question that jumps to mind is, why aren't we using xPos/yPos on the TILE object? And I'm not really sure. xPos/yPos was added in January 2011, whereas the code in question was added five months later, so it wasn't that they didn't exist when the method was written. And the local variables for i, x, and y are only used here, and in a couple debugging/warning statements, not in any other core logic.

Conclusion is this method can be refactored to use the xPos/yPos values, and that the index should be populated.

~adj 4 years ago

Also note that this issue only occurs when you create the map - saving the map and re-loading will work as expected. Thus it's not as high-priority, and is less likely to be encountered, than if it happened indefinitely after a map was created. Still going to fix it though, now that I know what's going on.

~adj 4 years ago

Refactored as noted in the 2nd comment; now working.

Register here or Log in to comment, or comment via email.