planner: fix calculations of variations

In 8704a8b6f9 the code in
cloneDiveplan() was replaced by a simple assignement statement.

Alas, the original code was more complex: it copied only up
to a certain point (it stopped at automatically generated
steps).

The new behavior made the calculations of variations fail.

Therefore, readd a function that copies a dive plan, but
"forgets" the automatically added stops.

Fixes #4368

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-11-14 23:24:24 +01:00
parent beb352d47c
commit 69d1be999a
3 changed files with 16 additions and 2 deletions

View file

@ -74,6 +74,17 @@ diveplan::~diveplan()
{
}
diveplan diveplan::copy_planned_segments() const
{
diveplan res = *this;
// Remove non manually added entries
auto it = std::find_if(res.dp.begin(), res.dp.end(),
[] (const divedatapoint &dp) { return dp.time && !dp.entered; });
res.dp.erase(it, res.dp.end());
return res;
}
bool diveplan::is_empty() const
{
return std::none_of(dp.begin(), dp.end(), [](const divedatapoint &dp) { return dp.time != 0; });