Hello,
I have been investigating this issue, and the cause is in haltestelle_t::change_owner().
This function was written when a halt could only have a single owner, so it currently converts every tile in the halt to the public player, regardless of who actually owns it. In a shared halt, this also makes buildings and ways belonging to another co-owner public.
This behaviour is incorrect: only the tiles belonging to the player using the "make public" tool should be converted. The exception is when the action is initiated by the public player itself, in which case the previous behaviour is preserved and all tiles are converted.
I also found a second related issue immediately after the loop. The owner mask was assigned directly with:
owners = 1 << player->get_player_nr()This removes any remaining co-owner from the halt's owner mask. The patch now rebuilds the mask from the actual owners of the tiles, following the same approach already used by add_grund().
Changes included in the patch:- change_owner() now also receives the player initiating the action through the old_owner parameter.
- Buildings and ways are only converted when they belong to old_owner. If the action is initiated by the public player, the conversion remains unconditional in order to preserve the existing behaviour.
- The tool branch that makes an individual way public already used this same check, so this change makes change_owner() consistent with the surrounding code.
- The owner mask is recalculated from the remaining tiles after the conversion.
- The only caller, in tool_make_stop_public_t::work(), now passes the player initiating the action.
I also added a regression test, test_halt_make_public_shared.
The test creates a halt shared by the public player and two companies. One of the companies then uses the tool to make its part of the halt public, and the test verifies that the tile belonging to the other company remains unchanged.
The full test suite passes. The new test fails without the fix and passes with the patch applied.
The patch is attached as a unified diff. It can be applied with patch -p1 or git apply on a recent trunk revision.
I had fixed this already, thank you, less than an hour after the inital submission.
Ideally, the function to make stops public should no longer be needed anymore with the shared stops.