Skip to content

Commit d86f4b2

Browse files
committed
Updated for 1.4.1
Added error-checking to the events, fixes some nullref exceptions
1 parent df55be4 commit d86f4b2

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed
0 Bytes
Binary file not shown.

GameData/MandatoryRCS/MandatoryRCS.version

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@
1111
"VERSION":
1212
{
1313
"MAJOR":1,
14-
"MINOR":4,
14+
"MINOR":5,
1515
"PATCH":0,
1616
"BUILD":0
1717
},
1818
"KSP_VERSION":
1919
{
2020
"MAJOR":1,
21-
"MINOR":3,
21+
"MINOR":4,
2222
"PATCH":1
2323
},
2424
"KSP_VERSION_MIN":
2525
{
2626
"MAJOR":1,
27-
"MINOR":3,
27+
"MINOR":4,
2828
"PATCH":1
2929
},
3030
"KSP_VERSION_MAX":
3131
{
3232
"MAJOR":1,
33-
"MINOR":3,
33+
"MINOR":4,
3434
"PATCH":1
3535
}
3636
}

MandatoryRCS-Source/MandatoryRCS.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<ItemGroup>
4141
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
4242
<SpecificVersion>False</SpecificVersion>
43-
<HintPath>..\..\..\..\..\Kerbal Space Program 1.3.1 DEV\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
43+
<HintPath>..\..\..\..\..\..\..\..\..\SteamLibrary\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
4444
</Reference>
4545
<Reference Include="System">
4646
<HintPath>..\..\..\..\..\Kerbal Space Program 1.3.1 DEV\KSP_x64_Data\Managed\System.dll</HintPath>
@@ -50,18 +50,18 @@
5050
</Reference>
5151
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
5252
<SpecificVersion>False</SpecificVersion>
53-
<HintPath>..\..\..\..\..\Kerbal Space Program 1.3.1 DEV\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
53+
<HintPath>..\..\..\..\..\..\..\..\..\SteamLibrary\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
5454
</Reference>
5555
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
5656
<SpecificVersion>False</SpecificVersion>
57-
<HintPath>..\..\..\..\..\Kerbal Space Program 1.3.1 DEV\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
57+
<HintPath>..\..\..\..\..\..\..\..\..\SteamLibrary\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
5858
</Reference>
5959
</ItemGroup>
6060
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6161
<PropertyGroup>
6262
<PostBuildEvent>"C:\Users\Got\Desktop\KSP\Tools\pdb2mdb\pdb2mdb.exe" "C:\Users\Got\Desktop\KSP\SPE source\Mod project\MandatoryRCS\MandatoryRCS\MandatoryRCS-Source\bin\Debug\MandatoryRCS.dll"
63-
xcopy /Y "C:\Users\Got\Desktop\KSP\SPE source\Mod project\MandatoryRCS\MandatoryRCS\MandatoryRCS-Source\bin\Debug\MandatoryRCS.dll" "C:\Users\Got\Desktop\KSP\Kerbal Space Program 1.3.1 DEV\GameData\MandatoryRCS\"
64-
xcopy /Y "C:\Users\Got\Desktop\KSP\SPE source\Mod project\MandatoryRCS\MandatoryRCS\MandatoryRCS-Source\bin\Debug\MandatoryRCS.dll.mdb" "C:\Users\Got\Desktop\KSP\Kerbal Space Program 1.3.1 DEV\GameData\MandatoryRCS\"</PostBuildEvent>
63+
xcopy /Y "C:\Users\Got\Desktop\KSP\SPE source\Mod project\MandatoryRCS\MandatoryRCS\MandatoryRCS-Source\bin\Debug\MandatoryRCS.dll" "C:\Users\Got\Desktop\KSP\Kerbal Space Program 1.4.1 DEV\GameData\MandatoryRCS\"
64+
xcopy /Y "C:\Users\Got\Desktop\KSP\SPE source\Mod project\MandatoryRCS\MandatoryRCS\MandatoryRCS-Source\bin\Debug\MandatoryRCS.dll.mdb" "C:\Users\Got\Desktop\KSP\Kerbal Space Program 1.4.1 DEV\GameData\MandatoryRCS\"</PostBuildEvent>
6565
</PropertyGroup>
6666
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
6767
Other similar extension points exist, see Microsoft.Common.targets.

MandatoryRCS-Source/MandatoryRCSEvents.cs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,28 @@ private void FixedUpdate()
3232
// Update the total reaction wheels torque capacity for the vessel
3333
private void onVesselStandardModification(Vessel v)
3434
{
35-
v.vesselModules.OfType<VesselModuleRotation>().First().updateWheelsTotalMaxTorque = true;
35+
if (v.vesselModules.OfType<VesselModuleRotation>().Count() > 0)
36+
{
37+
v.vesselModules.OfType<VesselModuleRotation>().First().updateWheelsTotalMaxTorque = true;
38+
}
3639
}
3740

3841
// Detect active vessel change when switching vessel in the physics bubble
3942
private void onVesselChange(Vessel v)
4043
{
41-
v.vesselModules.OfType<VesselModuleRotation>().First().vesselSASHasChanged = true;
44+
if (v.vesselModules.OfType<VesselModuleRotation>().Count() > 0)
45+
{
46+
v.vesselModules.OfType<VesselModuleRotation>().First().vesselSASHasChanged = true;
47+
}
4248
}
4349

4450
// Detect navball context (orbit/surface/target) changes
4551
private void onSetSpeedMode(FlightGlobals.SpeedDisplayModes mode)
4652
{
47-
FlightGlobals.ActiveVessel.vesselModules.OfType<VesselModuleRotation>().First().autopilotContextCurrent = (int)mode;
53+
if (FlightGlobals.ActiveVessel.vesselModules.OfType<VesselModuleRotation>().Count() > 0)
54+
{
55+
FlightGlobals.ActiveVessel.vesselModules.OfType<VesselModuleRotation>().First().autopilotContextCurrent = (int)mode;
56+
}
4857
}
4958

5059
private void OnDestroy()
@@ -68,16 +77,21 @@ private void onVesselSOIChanged(GameEvents.HostedFromToAction<Vessel, CelestialB
6877
{
6978
if (data.host.loaded)
7079
{
71-
if (data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotTargetHold
72-
&& data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotMode >= 1
73-
&& data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotMode <= 6)
80+
if (data.host.vesselModules != null && data.host.vesselModules.OfType<VesselModuleRotation>().Count() > 0)
7481
{
75-
data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotTargetHold = false;
76-
data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotMode = 0;
82+
if (data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotTargetHold
83+
&& data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotMode >= 1
84+
&& data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotMode <= 6)
85+
{
86+
data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotTargetHold = false;
87+
data.host.vesselModules.OfType<VesselModuleRotation>().First().autopilotMode = 0;
88+
}
7789
}
7890
}
7991
else
8092
{
93+
if (data.host.protoVessel.vesselModules == null || !data.host.protoVessel.vesselModules.HasNode("VesselModuleRotation"))
94+
{ return; }
8195
bool autopilotTargetHoldCurrent = false;
8296
int autopilotModeCurrent = 0;
8397
if (!data.host.protoVessel.vesselModules.GetNode("VesselModuleRotation").TryGetValue("autopilotTargetHold", ref autopilotTargetHoldCurrent))

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ So public domain, feel free to do anything, especially updating this plugin if I
7070
- Getting out of timewarps with the SAS direction hold activated input a large roll "kick", most visible at high timewarp levels. I tried a lot of things to find out why this happen or fix it, and failed.
7171
- When switching to an unloaded vessel with its SAS in "target", "antitarget" or "maneuver" mode, the orientation change is applied a few frames after the vessel is unpacked, leading to the rotation event being visible to the player. Won't fix as this is minor, purely cosmetic and fixing would require large modifications.
7272

73+
#### v1.5 for KSP 1.4.1
74+
- Recompiled for KSP 1.4.1
75+
- (bugfix) Fixed NRE on asteroids changing SOI
76+
- (bugfix) Fixed NRE on planting flags
77+
7378
#### v1.4 for KSP 1.3.1
7479
- Recompiled for KSP 1.3.1
7580
- Tweaks to the settings menu

0 commit comments

Comments
 (0)