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

Fix #6574: Remove go to hangar orders when rebuilding airport #7100

Conversation

SamuXarick
Copy link
Contributor

@SamuXarick SamuXarick commented Jan 25, 2019

When replacing an airport with another, cancel current orders of type 'go to depot' from aircraft still heading to it if the rebuilt airport doesn't have a hangar (helicopter vs heliport), or if the airplane can't land on the rebuilt airport (airplane vs helistation).

Invalidates 'go to hangar' orders from all aircraft when replacing an airport with hangar with another without hangar (heliport).

When replacing an airport with another, cancel current orders of type 'go to depot' from aircraft still heading to it if the rebuilt airport doesn't have a hangar (helicopter vs heliport), or if the airplane can't land on the rebuilt airport (airplane vs helistation).

Removes 'go to hangar' orders from all aircraft when replacing an airport with hangar with another without hangar (heliport).
@PeterN
Copy link
Member

PeterN commented Jan 25, 2019

You can perhaps remove the vehicle's current order, but orders defined in the order list should not be automatically removed. Maybe they can be marked as invalid like when a destination is removed.

@Eddi-z
Copy link
Contributor

Eddi-z commented Jan 25, 2019

#7051 should solve this?

@SamuXarick
Copy link
Contributor Author

nendington transport 2002-02-23
nendington transport 2002-02-23 1
nendington transport 2002-02-23 2

{
OrderBackup *ob;
FOR_ALL_ORDER_BACKUPS(ob) {
for (Order *order = ob->orders; order != NULL; order = order->next) {
OrderType ot = order->GetType();
if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
if (ot == OT_IMPLICIT || (IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT)) ot = OT_GOTO_STATION;
if (ot == OT_IMPLICIT || (IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT && !hangar)) ot = OT_GOTO_STATION;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the hangar argument needed? Isn't that already implied by ot == OT_GOTO_DEPOT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to clear up (invalidate) the 'to go hangar' orders when replacing an airport with hangar with another without hangar, while still keeping the 'go to same airport' orders. Since I couldn't invalidate only the 'go to hangar' orders, I had to change this part of the code to let me keep the 'go to airport' orders. Otherwise, both 'go to hangar' and 'go to same airport' would be made invalid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hanger argument is in fact needed, if not present order backups with service/goto depot orders are not deleted. A newly built helicopter will then have orders referring to a non-existing hangar.

@stale
Copy link

stale bot commented Feb 26, 2019

This pull request has been automatically marked as stale because it has not had any activity in the last month.
Please feel free to give a status update now, ping for review, or re-open when it's ready.
It will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added stale Stale issues and removed stale Stale issues labels Feb 26, 2019
@michicc michicc merged commit 9b99b95 into OpenTTD:master Feb 26, 2019
@SamuXarick SamuXarick deleted the Remove-go-to-hangar-orders-when-rebuilding-airport branch February 27, 2019 22:51
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

5 participants