Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3c06940bfeb9
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e21d0924d659
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 8, 2021

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    037b513 View commit details

Commits on Nov 9, 2021

  1. A comment.

    pleroy committed Nov 9, 2021
    Copy the full SHA
    cf7b57a View commit details
  2. Merge pull request #3199 from pleroy/Dbg

    Fix a bug in Part compatibility deserialization and add a test
    pleroy authored Nov 9, 2021
    Copy the full SHA
    e21d092 View commit details
Showing with 35 additions and 2 deletions.
  1. +9 −2 ksp_plugin/part.cpp
  2. +24 −0 ksp_plugin_test/plugin_compatibility_test.cpp
  3. +2 −0 physics/discrete_traject0ry.hpp
11 changes: 9 additions & 2 deletions ksp_plugin/part.cpp
Original file line number Diff line number Diff line change
@@ -337,10 +337,17 @@ not_null<std::unique_ptr<Part>> Part::ReadFromMessage(
}
}
} else if (is_pre_ζήνων) {
DiscreteTrajectorySegmentIterator<Barycentric> history;
DiscreteTrajectorySegmentIterator<Barycentric> psychohistory;
auto prehistory = DiscreteTraject0ry<Barycentric>::ReadFromMessage(
message.prehistory(),
/*tracked=*/{&part->history_, &part->psychohistory_});
part->trajectory_ = prehistory.DetachSegments(part->history_);
/*tracked=*/{&history, &psychohistory});
// We want to get rid of the prehistory segment, so the easiest is to detach
// the history and psychohistory. We must take care of the segment
// iterators as they get invalidated in this case.
part->trajectory_ = prehistory.DetachSegments(history);
part->history_ = part->trajectory_.segments().begin();
part->psychohistory_ = std::next(part->history_);
} else {
part->trajectory_ = DiscreteTraject0ry<Barycentric>::ReadFromMessage(
message.prehistory(),
24 changes: 24 additions & 0 deletions ksp_plugin_test/plugin_compatibility_test.cpp
Original file line number Diff line number Diff line change
@@ -42,7 +42,9 @@ using ksp_plugin::Barycentric;
using ksp_plugin::Plugin;
using physics::DiscreteTraject0ry;
using quantities::Speed;
using quantities::si::Degree;
using quantities::si::Kilo;
using quantities::si::Second;
using testing_utilities::operator""_⑴;
using testing_utilities::IsNear;
using testing_utilities::ReadFromBinaryFile;
@@ -386,6 +388,28 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
WriteAndReadBack(std::move(plugin));
}

TEST_F(PluginCompatibilityTest, DISABLED_Egg) {
StringLogSink log_warning(google::WARNING);
not_null<std::unique_ptr<Plugin const>> plugin = ReadPluginFromFile(
R"(P:\Public Mockingbird\Principia\Saves\3136\3136b.proto.b64)",
/*compressor=*/"gipfeli",
/*decoder=*/"base64");
EXPECT_THAT(log_warning.string(),
AllOf(HasSubstr(u8"pre-Ζήνων"), Not(HasSubstr("pre-Haar"))));

auto& mutable_plugin = const_cast<Plugin&>(*plugin);

// This would fail if segment iterators were invalidated during part
// deserialization.
mutable_plugin.AdvanceTime(
mutable_plugin.GameEpoch() + 133218.91123694609 * Second,
295.52698460805016 * Degree);
mutable_plugin.CatchUpVessel("1e07aaa2-d1f8-4f6d-8b32-495b46109d98");

// Make sure that we can upgrade, save, and reload.
WriteAndReadBack(std::move(plugin));
}

// Use for debugging saves given by users.
TEST_F(PluginCompatibilityTest, DISABLED_SECULAR_Debug) {
CheckSaveCompatibility(
2 changes: 2 additions & 0 deletions physics/discrete_traject0ry.hpp
Original file line number Diff line number Diff line change
@@ -87,6 +87,8 @@ class DiscreteTraject0ry : public Trajectory<Frame> {

SegmentIterator NewSegment();

// All the point and segment iterators in the attached/detached segments are
// invalidated.
DiscreteTraject0ry DetachSegments(SegmentIterator begin);
SegmentIterator AttachSegments(DiscreteTraject0ry&& trajectory);
void DeleteSegments(SegmentIterator& begin);