EmptyEpsilon icon indicating copy to clipboard operation
EmptyEpsilon copied to clipboard

[#1903] Don't try to dock with ships already docked with yourself

Open oznogon opened this issue 2 years ago • 2 comments

Building on #1906, also don't try to dock with a ship that's already docked with our ship.

For example, given Benedict callsign "Spock" initiated and successfully externally docked to another Benedict callsign "Kirk", "Spock" still appears to "Kirk" as a valid docking target. If "Kirk" attempts to dock with "Spock", "Kirk" enters an endless loop of trying to rotate to dock with "Spock", which moves as "Kirk" rotates.

This could benefit from a potentially recursive check of dockable ships that are docked to ships that are docked to the player; it's still possible to enter an endless docking cycle in those more edge cases of 3+ ships chained together.

This PR also cancels docking if the docking target is moved >1U away from the docking ship.

oznogon avatar Feb 22 '23 06:02 oznogon

I wonder if we should prevent docking if there are any ships docked externally on yourself. I think that should solve most issues, as it will prevent creating odd chains of ships docked to each other.

daid avatar Feb 23 '23 10:02 daid

I wonder if we should prevent docking if there are any ships docked externally on yourself. I think that should solve most issues, as it will prevent creating odd chains of ships docked to each other.

IIRC there are checks if a ship is docked with another ship, either via getDockedWith() or getDockingState(), but not if a ship has other ships docked to it; there's nothing like a ships_docked_with_us value to query or getExternallyDockedShips() check because AFAICT that's not tracked.

So we could prevent other ships from docking to a ship already docked with another ship, but right now I don't think we can prevent a ship that's already carrying another externally docked ship from docking with another ship. So chains would still be possible.

ie. Ship C docks with ship B -> ship B docks with ship A -> ship A doesn't know ship C is indirectly docked with it and could still try to dock with ship C

Similar to #1904/#1905, if ships stored data on which other ships are docked to them, we could control that behavior both ways. Otherwise we could try to do getDockedWith() checks recursively if the ship that getDockedWith() returns would also return its own getDockedWith() value.

oznogon avatar Feb 24 '23 23:02 oznogon