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

Commits on Mar 23, 2020

  1. Switch to 1.9.1.

    pleroy committed Mar 23, 2020
    Copy the full SHA
    4fccaec View commit details

Commits on Mar 24, 2020

  1. Copy the full SHA
    37b0c4d View commit details

Commits on Mar 26, 2020

  1. Fix the fingerprints.

    pleroy committed Mar 26, 2020
    Copy the full SHA
    b756f3e View commit details
  2. Typo.

    pleroy committed Mar 26, 2020
    Copy the full SHA
    13b6349 View commit details
  3. Merge pull request #2505 from pleroy/1.9.1

    Add support for KSP 1.9.1
    pleroy authored Mar 26, 2020
    Copy the full SHA
    163fb00 View commit details
18 changes: 9 additions & 9 deletions astronomy/kerbol_gravity_model.proto.txt
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ gravity_model {
reference_instant : "JD2451545.000000000"
min_radius : "209100 m"
mean_radius : "210000 m"
max_radius : "214540 m"
max_radius : "214940 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "25 deg"
@@ -38,7 +38,7 @@ gravity_model {
reference_instant : "JD2451545.000000000"
min_radius : "40200 m"
mean_radius : "44000 m"
max_radius : "47800 m"
max_radius : "50400 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "25 deg"
@@ -50,7 +50,7 @@ gravity_model {
reference_instant : "JD2451545.000000000"
min_radius : "41000 m"
mean_radius : "65000 m"
max_radius : "89000 m"
max_radius : "89600 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "230 deg"
@@ -74,7 +74,7 @@ gravity_model {
reference_instant : "JD2451545.000000000"
min_radius : "296900 m"
mean_radius : "300000 m"
max_radius : "306100 m"
max_radius : "308100 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "0 deg"
@@ -86,7 +86,7 @@ gravity_model {
reference_instant : "JD2451545.000000000"
min_radius : "497100 m"
mean_radius : "500000 m"
max_radius : "507100 m"
max_radius : "507900 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "90 deg"
@@ -98,7 +98,7 @@ gravity_model {
reference_instant : "JD2451545.000000000"
min_radius : "135900 m"
mean_radius : "138000 m"
max_radius : "144100 m"
max_radius : "145100 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "25 deg"
@@ -122,7 +122,7 @@ gravity_model {
reference_instant : "JD2451545.000000000"
min_radius : "117900 m"
mean_radius : "130000 m"
max_radius : "142100 m"
max_radius : "143700 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "0 deg"
@@ -145,7 +145,7 @@ gravity_model {
gravitational_parameter : "1765800026.31247 m^3/s^2"
reference_instant : "JD2451545.000000000"
mean_radius : "60000 m"
max_radius : "65000 m"
max_radius : "66000 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "230 deg"
@@ -181,7 +181,7 @@ gravity_model {
reference_instant : "JD2451545.000000000"
min_radius : "5000 m"
mean_radius : "13000 m"
max_radius : "21000 m"
max_radius : "21150 m"
axis_right_ascension : "-90 deg"
axis_declination : "90 deg"
reference_angle : "5 deg"
4 changes: 2 additions & 2 deletions astronomy/ksp_fingerprint_test.cpp
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ TEST_F(KSPFingerprintTest, Stock) {
uint64_t const fingerprint = Fingerprint2011(SerializeAsBytes(message).get());
LOG(INFO) << "Stock KSP fingerprint is 0x" << std::hex << std::uppercase
<< fingerprint;
EXPECT_THAT(fingerprint, Eq(KSPStockSystemFingerprint));
EXPECT_THAT(fingerprint, Eq(KSPStockSystemFingerprints[KSP191]));
}

TEST_F(KSPFingerprintTest, Corrected) {
@@ -59,7 +59,7 @@ TEST_F(KSPFingerprintTest, Corrected) {
uint64_t const fingerprint = Fingerprint2011(SerializeAsBytes(message).get());
LOG(INFO) << "Corrected KSP fingerprint is 0x" << std::hex << std::uppercase
<< fingerprint;
EXPECT_THAT(fingerprint, Eq(KSPStabilizedSystemFingerprint));
EXPECT_THAT(fingerprint, Eq(KSPStabilizedSystemFingerprints[KSP191]));
}

} // namespace astronomy
12 changes: 10 additions & 2 deletions astronomy/solar_system_fingerprints.hpp
Original file line number Diff line number Diff line change
@@ -5,8 +5,16 @@
namespace principia {
namespace astronomy {

constexpr std::uint64_t KSPStockSystemFingerprint = 0xC366DDFC05246F42;
constexpr std::uint64_t KSPStabilizedSystemFingerprint = 0xC6E30693245BE096;
// Indices in the arrays below.
constexpr std::int64_t KSP122 = 0;
constexpr std::int64_t KSP191 = 1;

constexpr std::uint64_t KSPStockSystemFingerprints[] = {
0xC366DDFC05246F42,
0x63A5CF9AAB1676AE};
constexpr std::uint64_t KSPStabilizedSystemFingerprints[] = {
0xC6E30693245BE096,
0x9DCFF6CCCD13551F};

} // namespace astronomy
} // namespace principia
54 changes: 33 additions & 21 deletions ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -58,8 +58,10 @@ namespace principia {
namespace ksp_plugin {
namespace internal_plugin {

using astronomy::KSPStabilizedSystemFingerprint;
using astronomy::KSPStockSystemFingerprint;
using astronomy::KSP122;
using astronomy::KSP191;
using astronomy::KSPStabilizedSystemFingerprints;
using astronomy::KSPStockSystemFingerprints;
using astronomy::ParseTT;
using astronomy::StabilizeKSP;
using base::check_not_null;
@@ -199,25 +201,35 @@ void Plugin::EndInitialization() {
LOG(INFO) << "System fingerprint is " << std::hex << std::uppercase
<< system_fingerprint;

if (system_fingerprint == KSPStockSystemFingerprint) {
LOG(WARNING) << "This appears to be the dreaded KSP stock system!";
StabilizeKSP(solar_system);
auto const hierarchical_system = solar_system.MakeHierarchicalSystem();
serialization::HierarchicalSystem message;
hierarchical_system->WriteToMessage(&message);
uint64_t const system_fingerprint =
Fingerprint2011(SerializeAsBytes(message).get());
LOG(INFO) << "System fingerprint after stabilization is " << std::hex
<< std::uppercase << system_fingerprint;
CHECK_EQ(KSPStabilizedSystemFingerprint, system_fingerprint)
<< "Attempt at stabilizing the KSP system failed!\n"
<< gravity_model_.DebugString() << "\n"
<< initial_state_.DebugString();
LOG(INFO) << "This is the stabilized KSP system, all hail retrobop!";
} else if (system_fingerprint == KSPStabilizedSystemFingerprint) {
LOG(INFO) << "This is the stabilized KSP system, and we didn't have to "
<< "stabilize it ourselves. All hail retrobop anyway!";
} else {
bool is_well_known = false;
for (auto const ksp_version : {KSP122, KSP191}) {
if (system_fingerprint == KSPStockSystemFingerprints[ksp_version]) {
LOG(WARNING) << "This appears to be the dreaded KSP stock system!";
StabilizeKSP(solar_system);
auto const hierarchical_system = solar_system.MakeHierarchicalSystem();
serialization::HierarchicalSystem message;
hierarchical_system->WriteToMessage(&message);
uint64_t const system_fingerprint =
Fingerprint2011(SerializeAsBytes(message).get());
LOG(INFO) << "System fingerprint after stabilization is " << std::hex
<< std::uppercase << system_fingerprint;
CHECK_EQ(KSPStabilizedSystemFingerprints[ksp_version],
system_fingerprint)
<< "Attempt at stabilizing the KSP system failed!\n"
<< gravity_model_.DebugString() << "\n"
<< initial_state_.DebugString();
LOG(INFO) << "This is the stabilized KSP system, all hail retrobop!";
is_well_known = true;
break;
} else if (system_fingerprint ==
KSPStabilizedSystemFingerprints[ksp_version]) {
LOG(INFO) << "This is the stabilized KSP system, and we didn't have to "
<< "stabilize it ourselves. All hail retrobop anyway!";
is_well_known = true;
break;
}
}
if (!is_well_known) {
LOG(WARNING) << "This is an unknown system, we don't know anything about "
<< "its stability:\n"
<< gravity_model_.DebugString() << "\n"
2 changes: 1 addition & 1 deletion ksp_plugin_adapter/gl_lines.cs
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ private static UnityEngine.Material line_material {
get {
if (line_material_ == null) {
line_material_ = new UnityEngine.Material(
#if KSP_VERSION_1_8_1
#if KSP_VERSION_1_9_1
UnityEngine.Shader.Find("KSP/Particles/Additive"));
#elif KSP_VERSION_1_7_3
UnityEngine.Shader.Find("Particles/Additive"));
9 changes: 5 additions & 4 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -276,10 +276,11 @@ private readonly Dictionary<uint, PartCentredForceHolder[]>
"error; it might get damaged.";
bad_installation_dialog_.Show();
}
#if KSP_VERSION_1_8_1
#if KSP_VERSION_1_9_1
if (!(Versioning.version_major == 1 &&
(Versioning.version_minor == 8 && Versioning.Revision == 1))) {
string expected_version = "1.8.1";
(Versioning.version_minor == 8 && Versioning.Revision == 1) ||
(Versioning.version_minor == 9 && Versioning.Revision == 1))) {
string expected_version = "1.8.1 and 1.9.1";
#elif KSP_VERSION_1_7_3
if (!(Versioning.version_major == 1 &&
(Versioning.version_minor == 5 && Versioning.Revision == 1) ||
@@ -1173,7 +1174,7 @@ private System.Collections.IEnumerator WaitedForFixedUpdate() {
plugin_.ReportGroundCollision(
closest_physical_parent(part1).flightID);
}
#if KSP_VERSION_1_8_1
#if KSP_VERSION_1_9_1
foreach (var collider in part1.currentCollisions.Keys) {
#elif KSP_VERSION_1_7_3
foreach (var collider in part1.currentCollisions) {
24 changes: 12 additions & 12 deletions ksp_plugin_adapter/ksp_plugin_adapter.csproj
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Debug\GameData\Principia\</OutputPath>
<DefineConstants>TRACE;DEBUG;KSP_VERSION_1_8_1</DefineConstants>
<DefineConstants>TRACE;DEBUG;KSP_VERSION_1_9_1</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
@@ -28,7 +28,7 @@
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Release\GameData\Principia\</OutputPath>
<DefineConstants>TRACE;KSP_VERSION_1_8_1</DefineConstants>
<DefineConstants>TRACE;KSP_VERSION_1_9_1</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
@@ -65,40 +65,40 @@
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug'">
<Reference Include="Assembly-CSharp">
<HintPath>..\..\KSP Assemblies\1.8.1\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine">
<HintPath>..\..\KSP Assemblies\1.8.1\UnityEngine.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\KSP Assemblies\1.8.1\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.ImageConversionModule">
<HintPath>..\..\KSP Assemblies\1.8.1\UnityEngine.ImageConversionModule.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\UnityEngine.ImageConversionModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>..\..\KSP Assemblies\1.8.1\UnityEngine.IMGUIModule.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>..\..\KSP Assemblies\1.8.1\UnityEngine.InputLegacyModule.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\UnityEngine.InputLegacyModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\KSP Assemblies\1.8.1\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>..\..\KSP Assemblies\1.8.1\UnityEngine.TextRenderingModule.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\UnityEngine.TextRenderingModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\KSP Assemblies\1.8.1\UnityEngine.UI.dll</HintPath>
<HintPath>..\..\KSP Assemblies\1.9.1\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
@@ -178,7 +178,7 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>