Discussion:
[Freecol-developers] possible bug in Settlement::exciseSettlement() ?
Enrico Weigelt, metux IT consult
2016-12-27 11:58:48 UTC
Permalink
Hi folks,

just had a look at Settlement::exciseSettlement(), which removes a
settlement from the map, so eg. removing tile ownerships, etc

But it doesn't seem to clear the tile reference (this.tile).

Is that really correct ?

By the way: how are tiles identified in client-server communication?
Coordinates ? Some other key ?


--mtx
Michael T. Pope
2016-12-27 22:37:01 UTC
Permalink
On Tue, 27 Dec 2016 12:58:48 +0100
Post by Enrico Weigelt, metux IT consult
just had a look at Settlement::exciseSettlement(), which removes a
settlement from the map, so eg. removing tile ownerships, etc
But it doesn't seem to clear the tile reference (this.tile).
Is that really correct ?
Yes, or at least harmless. The routine does what it says --- "removes
the settlement from the map". It does not remove all reference to the map
from the settlement, that is something else. Almost certainly, any
settlement this routine is called on is in the process of being removed
from the game, so a few dangling backward references to the tile et al are
not going to matter. Furthermore, on occasion when I have tried to
agressively clean up dangling references it has caused problems
(especially with the owner-player field).
Post by Enrico Weigelt, metux IT consult
By the way: how are tiles identified in client-server communication?
Coordinates ? Some other key ?
id. See FreeColObject, and note the use of Game.freeColGameObjects. id is
fundamental.

Cheers,
Mike Pope
Enrico Weigelt, metux IT consult
2016-12-28 17:24:25 UTC
Permalink
On 27.12.2016 23:37, Michael T. Pope wrote:

Hi,
Post by Michael T. Pope
Yes, or at least harmless. The routine does what it says --- "removes
the settlement from the map". It does not remove all reference to the map
from the settlement, that is something else.
Okay. OTOH, we could use that as an indication for whether a settlement
is on the map - at least for testing. In the opposite direction (adding
to the map) we could add a sanity check (maybe assert).
Post by Michael T. Pope
Furthermore, on occasion when I have tried to
agressively clean up dangling references it has caused problems
(especially with the owner-player field).
Could you explain it more in detail ?
What went wrong here ?
Post by Michael T. Pope
Post by Enrico Weigelt, metux IT consult
By the way: how are tiles identified in client-server communication?
Coordinates ? Some other key ?
id. See FreeColObject, and note the use of Game.freeColGameObjects. id is
fundamental.
Ah, guessed so. I put another topic on my todo list: check whether
there's room for optimization (eg. avoid id in favour of coordinates
where possible, flatten the array, etc)


--mtx

Loading...