Skip to content
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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

oznogon
Copy link
Contributor

@oznogon oznogon commented Feb 22, 2023

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.

@daid
Copy link
Owner

daid commented Feb 23, 2023

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.

@oznogon
Copy link
Contributor Author

oznogon commented Feb 24, 2023

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 oznogon force-pushed the stop-docking-with-carried-ships branch from 52a3fb9 to d254cbf Compare March 19, 2023 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants