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

Multiple flight plans #3400

Merged
merged 11 commits into from
Jul 24, 2022
Merged

Multiple flight plans #3400

merged 11 commits into from
Jul 24, 2022

Conversation

eggrobin
Copy link
Member

Towards #3382.

This change extends the existing API of Vessel: in the absence of calls to the new functions SelectFlightPlan and DuplicateFlightPlan, or to the pre-existing CreateFlightPlan on a vessel with a flight plan, semantics are preserved.

A vessel may now have up to 10 flight plans (labeled A through J in English); they are deserialized lazily independently from each other. Additional flight plans are created either by pressing + to add a new blank flight plan, or by duplicating an existing flight plan.

For now, it is not possible to simultaneously display two flight plans; nor can flight plans be named or reordered.

image

ksp_plugin/vessel.cpp Outdated Show resolved Hide resolved
flight_plans_.emplace(it, std::get<serialization::FlightPlan>(original));
} else if (std::holds_alternative<not_null<std::unique_ptr<FlightPlan>>>(
original)) {
std::get<not_null<std::unique_ptr<FlightPlan>>>(original)->WriteToMessage(
Copy link
Member

Choose a reason for hiding this comment

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

This code is somewhat worrisome as it assumes that the serialized form can be freely copied. A comment would be welcome.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a comment; the one we should adjust would probably not be this one anyway.

serialization::FlightPlan> flight_plan_;
std::vector<std::variant<not_null<std::unique_ptr<FlightPlan>>,
serialization::FlightPlan>> flight_plans_;
int selected_flight_plan_ = -1;
Copy link
Member

Choose a reason for hiding this comment

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

Could we make this an optional? It would be safer, just say no to magic values.

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed, this would probably not help readability.

ksp_plugin_adapter/flight_planner.cs Outdated Show resolved Hide resolved
serialization/ksp_plugin.proto Outdated Show resolved Hide resolved
@pleroy pleroy added the LGTM label Jul 24, 2022
@eggrobin eggrobin merged commit 38d1a0c into mockingbirdnest:master Jul 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants