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: ee42d9e6f376
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da53560a6680
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Jun 1, 2019

  1. Copy the full SHA
    7c3146d View commit details
  2. Cleanup.

    pleroy committed Jun 1, 2019
    Copy the full SHA
    a04d38f View commit details
  3. Merge pull request #2189 from pleroy/2188

    Remove the last manœuvre when it leads to an integration error
    pleroy authored Jun 1, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    da53560 View commit details
Showing with 14 additions and 10 deletions.
  1. +4 −3 journal/player.cpp
  2. +2 −1 journal/player.hpp
  3. +6 −6 journal/player_test.cpp
  4. +2 −0 ksp_plugin/interface_flight_plan.cpp
7 changes: 4 additions & 3 deletions journal/player.cpp
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ Player::Player(std::filesystem::path const& path)
CHECK(!stream_.fail());
}

bool Player::Play() {
bool Player::Play(int const index) {
std::unique_ptr<serialization::Method> method_in = Read();
if (method_in == nullptr) {
// End of input file.
@@ -39,8 +39,9 @@ bool Player::Play() {
}

#if 0
LOG(ERROR) << "\n" << method_in->ShortDebugString() << "\n"
<< method_out_return->ShortDebugString();
LOG_IF(ERROR, index > 3170000) << "index: " << index << "\n"
<< method_in->ShortDebugString() << "\n"
<< method_out_return->ShortDebugString();
#endif

auto const before = std::chrono::system_clock::now();
3 changes: 2 additions & 1 deletion journal/player.hpp
Original file line number Diff line number Diff line change
@@ -18,7 +18,8 @@ class Player final {
explicit Player(std::filesystem::path const& path);

// Replays the next message in the journal. Returns false at end of journal.
bool Play();
// |index| is the 0-based index of the message in the journal.
bool Play(int index);

// Return the last replayed messages.
serialization::Method const& last_method_in() const;
12 changes: 6 additions & 6 deletions journal/player_test.cpp
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ void BM_PlayForReal(benchmark::State& state) {
Player player(
R"(P:\Public Mockingbird\Principia\Journals\JOURNAL.20180311-192733)");
int count = 0;
while (player.Play()) {
while (player.Play(count)) {
++count;
LOG_IF(ERROR, (count % 100'000) == 0)
<< count << " journal entries replayed";
@@ -74,7 +74,7 @@ TEST_F(PlayerTest, PlayTiny) {

// Replay the journal.
int count = 0;
while (player.Play()) {
while (player.Play(count)) {
++count;
}
EXPECT_EQ(2, count);
@@ -88,10 +88,10 @@ TEST_F(PlayerTest, DISABLED_Debug) {
// An example of how journaling may be used for debugging. You must set
// |path| and fill the |method_in| and |method_out_return| protocol buffers.
std::string path =
R"(C:\Program Files\Kerbal Space Program\1.6.1\glog\Principia\JOURNAL.20190520-205625)"; // NOLINT
R"(C:\Program Files\Kerbal Space Program\1.7.0\glog\Principia\JOURNAL.20190601-174743)"; // NOLINT
Player player(path);
int count = 0;
while (player.Play()) {
while (player.Play(count)) {
++count;
LOG_IF(ERROR, (count % 100'000) == 0) << count
<< " journal entries replayed";
@@ -108,8 +108,8 @@ TEST_F(PlayerTest, DISABLED_Debug) {
auto* extension = method_in.MutableExtension(
serialization::FlightPlanGetManoeuvreFrenetTrihedron::extension);
auto* in = extension->mutable_in();
in->set_plugin(2634828656);
in->set_vessel_guid("88d741d3-600c-4f4b-9567-8109cecab2bd");
in->set_plugin(2312193072);
in->set_vessel_guid("bedd9d23-de56-4fb8-881c-f647e22f848f");
in->set_index(0);
}
serialization::Method method_out_return;
2 changes: 2 additions & 0 deletions ksp_plugin/interface_flight_plan.cpp
Original file line number Diff line number Diff line change
@@ -476,6 +476,8 @@ bool principia__FlightPlanReplaceLast(Plugin const* const plugin,
} else if (status.ok() || flight_plan.number_of_anomalous_manœuvres() == 0) {
return m.Return(true);
} else {
// The last manœuvre is broken. Roll it back.
flight_plan.RemoveLast();
flight_plan.Append(manœuvre.burn());
return m.Return(false);
}