-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix map sharing #2055
Fix map sharing #2055
Conversation
Is this really a bug? I would expect that newer information doesn’t get overwritten with older information. |
"Seen" tiles are the tiles currently visible by a player (as opposed to tiles that are merely "known") |
Looks like the PR is failing the clang-format checker. |
Uh I see, the usual case not caught by |
Sharing maps between players was fundamentally broken. The server records the last turn in which a player saw a tile. This information is only updated when the player stops seeing a tile, and not when it just keeps seeing it because the tile is within its vision range. The following map sharing bugs existed: * Tiles seen by the giving player were not sent if the receiving player had last viewed them after the giving player; * Cities were only updated when destroyed. Renamed or growing cities were not updated. This commit fixes both bugs. The core logic in really_give_tile_info_from_player_to_player was completely overhauled to make it easier to follow and more correct. In addition, player_tile.site was turned to a unique_ptr to facilitate bookkeeping.
62812ee
to
dbaff85
Compare
clang-format fixed |
Then I don’t understand this even more. If the seen tiles are currently visible to the player, they are viewed now. How can then the other player have them last viewed at a later time? |
The two players are usually not sharing vision, as this is related to the treaty clauses to share one's map |
Sorry, I missed the question in the second part. As an optimisation (I suppose), the "last viewed" info is not updated at every turn change. It gets updated only when vision is lost. |
I must say that finally I’m utterly confused. I don’t know whether I’d like to help here further. This stuff seems so convoluted that I don’t really have further ambition to try to understand it. Sadly, I’m by no means convinced that the fix in this PR is actually suitable. |
Looking again at what “last viewed” means, it starts to make sense to me why the first point mentioned in the PR description could be a bug. Still, parts of the map where the receiving player has currently vision should not be sent. Is this taken into account by the updated code? |
Yes, this is the first check: // No need to transfer if pdest can see the tile
if (map_is_known_and_seen(ptile, pdest, V_MAIN)) {
return;
} I'd be interested if you have ideas for a simpler implementation |
At least not spontaneously. :slightly_smiling_face: |
@jwrober can you review then? |
Yep. Prolly tomorrow. Will need to setup a test. |
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me. Nice patch!
Sharing maps between players was fundamentally broken. The server records the last turn in which a player saw a tile. This information is only updated when the player stops seeing a tile, and not when it just keeps seeing it because the tile is within its vision range.
The following map sharing bugs existed:
This commit fixes both bugs. The core logic in
really_give_tile_info_from_player_to_player
was completely overhauled to make it easier to follow and more correct. In addition,player_tile.site
was turned to aunique_ptr
to facilitate bookkeeping.Closes #2045
Testing: Before the patch:
After the patch, the other player should always get the information at the time of signing the treaty.
Not suggesting to backport since the bugs had been there for a very long time.