Skip to content

Commit

Permalink
Fix DivideByZero exception
Browse files Browse the repository at this point in the history
  • Loading branch information
severedsolo committed Mar 31, 2019
1 parent 84a03c2 commit 7e07586
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 53 deletions.
16 changes: 9 additions & 7 deletions OhScrap/OhScrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>D:\Kerbal Space Program1.6.1\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>D:\Kerbal Space Program1.6.1\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="ScrapYard, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Scrap Hole\ScrapYard-1.1.1\ScrapYard\bin\Debug\ScrapYard.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\GameData\ScrapYard\ScrapYard.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -55,10 +55,10 @@
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\GameData\ScrapYard\ScrapYard.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>D:\Kerbal Space Program1.6.1\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>D:\Kerbal Space Program1.6.1\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -89,7 +89,9 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<PostBuildEvent>"C:\Users\evilp\OneDrive\Documents\pdb2mdb\pdb2mdb.exe" "$(TargetFileName)"
xcopy /Y "$(TargetPath)" "C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\GameData\Severedsolo\OhScrap\"
xcopy /Y "$(TargetDir)$(TargetName).pdb" "C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\GameData\Severedsolo\OhScrap\"
xcopy /Y "$(TargetDir)$(TargetName).dll.mdb" "C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - ModDev\GameData\Severedsolo\OhScrap\"</PostBuildEvent>
</PropertyGroup>
</Project>
31 changes: 3 additions & 28 deletions OhScrap/UPFMUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ private void Start()
{
GameEvents.onPartDie.Add(OnPartDie);
GameEvents.onGUIApplicationLauncherReady.Add(GUIReady);
GameEvents.onEditorShipModified.Add(onEditorShipModified);
GameEvents.OnFlightGlobalsReady.Add(OnFlightGlobalsReady);
GameEvents.onVesselSituationChange.Add(SituationChange);
//Remembers if the player had the windows opened for closed last time they loaded this scene.
Expand Down Expand Up @@ -257,32 +256,7 @@ public int GetGeneration(uint id, Part p)
generations.Add(id, i);
return i;
}
//When the Editor Vessel is modified check the safety ratings and update the UI
private void onEditorShipModified(ShipConstruct shipConstruct)
{
vesselSafetyRating = 0;
float worstPartChance = 1;
int bfmCount = 0;
editorConstruct = shipConstruct;
for (int i = 0; i < shipConstruct.parts.Count(); i++)
{
Part p = shipConstruct.parts.ElementAt(i);
List<BaseFailureModule> bfmList = p.FindModulesImplementing<BaseFailureModule>();
for (int b = 0; b < bfmList.Count(); b++)
{
BaseFailureModule bfm = bfmList.ElementAt(b);
if (bfm == null) continue;
if (bfm.chanceOfFailure > worstPartChance && !bfm.isSRB && !bfm.hasFailed)
{
worstPart = p;
worstPartChance = bfm.chanceOfFailure;
}
vesselSafetyRating += bfm.safetyRating;
bfmCount++;
}
}
vesselSafetyRating = vesselSafetyRating / bfmCount;
}

//This is mostly for use in the flight scene, will only run once assuming everything goes ok.
void Update()
{
Expand Down Expand Up @@ -312,8 +286,9 @@ void Update()
}
}
}
if (HighLogic.LoadedSceneIsEditor && editorConstruct != null)
if (HighLogic.LoadedSceneIsEditor)
{
if (editorConstruct == null) editorConstruct = EditorLogic.fetch.ship;
for (int i = 0; i < editorConstruct.parts.Count(); i++)
{
Part p = editorConstruct.parts.ElementAt(i);
Expand Down
2 changes: 2 additions & 0 deletions OhScrap/obj/Debug/OhScrap.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,5 @@ C:\Users\JeB KerMin\Documents\GitHub\OhScrap\OhScrap\obj\Debug\OhScrap.csproj.Co
C:\Users\JeB KerMin\Documents\GitHub\OhScrap\OhScrap\obj\Debug\OhScrap.dll
C:\Users\JeB KerMin\Documents\GitHub\OhScrap\OhScrap\obj\Debug\OhScrap.pdb
C:\Users\JeB KerMin\Documents\GitHub\OhScrap\OhScrap\obj\Debug\OhScrap.csprojAssemblyReference.cache
C:\Users\evilp\source\repos\OhScrap\OhScrap\obj\Debug\OhScrap.csprojAssemblyReference.cache
C:\Users\evilp\source\repos\OhScrap\OhScrap\obj\Debug\OhScrap.csproj.CoreCompileInputs.cache
34 changes: 16 additions & 18 deletions OhScrap/obj/Release/OhScrap.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/Assembly-CSharp-firstpass.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/ScrapYard.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/UnityEngine.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/obj/Release/OhScrap.csproj.CoreCompileInputs.cache
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/OhScrap.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/OhScrap.pdb
C:/Users/evilp/source/repos/OhScrap/OhScrap/obj/Release/OhScrap.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/obj/Release/OhScrap.pdb
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/Assembly-CSharp.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/UnityEngine.UI.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/KSPTrackIR.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/KSPAssets.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/Mono.Cecil.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/Ionic.Zip.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/TDx.TDxInput.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/bin/Release/RedShellSDK.dll
C:/Users/evilp/source/repos/OhScrap/OhScrap/obj/Release/OhScrap.csproj.CopyComplete
C:/Users/evilp/source/repos/OhScrap/OhScrap/obj/Release/OhScrap.csprojAssemblyReference.cache
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/bin/Release/OhScrap.dll
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/bin/Release/OhScrap.pdb
/home/martin/.steam/steam/steamapps/common/OhScrap-master/OhScrap/bin/Release/Assembly-CSharp-firstpass.dll
Expand Down Expand Up @@ -66,3 +48,19 @@ D:/OneDrive/Documents/Github/OhScrap/OhScrap/obj/Release/OhScrap.pdb
/home/martin/Documents/GitHub/OhScrap/OhScrap/obj/Release/OhScrap.pdb
/home/martin/Documents/GitHub/OhScrap/OhScrap/bin/Release/Assembly-CSharp-firstpass.dll
/home/martin/Documents/GitHub/OhScrap/OhScrap/bin/Release/Assembly-CSharp.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\OhScrap.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\OhScrap.pdb
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\Assembly-CSharp-firstpass.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\Assembly-CSharp.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\ScrapYard.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\UnityEngine.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\UnityEngine.UI.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\KSPTrackIR.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\KSPAssets.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\Mono.Cecil.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\Ionic.Zip.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\bin\Release\TDx.TDxInput.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\obj\Release\OhScrap.csproj.CoreCompileInputs.cache
C:\Users\evilp\source\repos\OhScrap\OhScrap\obj\Release\OhScrap.csproj.CopyComplete
C:\Users\evilp\source\repos\OhScrap\OhScrap\obj\Release\OhScrap.dll
C:\Users\evilp\source\repos\OhScrap\OhScrap\obj\Release\OhScrap.pdb

0 comments on commit 7e07586

Please sign in to comment.