File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ class DoubleCurvePreserveTangents : BasePatch
1111
1212 protected override void ApplyPatches ( )
1313 {
14- if ( ! KSPCommunityFixes . cleanedDll )
14+ if ( ! KSPCommunityFixes . IsCleanedDll )
1515 {
1616 AddPatch ( PatchType . Transpiler , typeof ( DoubleCurve ) , nameof ( DoubleCurve . RecomputeTangents ) ) ;
1717 }
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ protected override void ApplyPatches()
2323 {
2424 AddPatch ( PatchType . Transpiler , typeof ( ModuleDeployablePart ) , nameof ( ModuleDeployablePart . startFSM ) ) ;
2525
26- if ( ! KSPCommunityFixes . cleanedDll )
26+ if ( ! KSPCommunityFixes . IsCleanedDll )
2727 {
2828 AddPatch ( PatchType . Transpiler , typeof ( ModuleDeployableSolarPanel ) , nameof ( ModuleDeployablePart . OnStart ) ) ;
2929 }
Original file line number Diff line number Diff line change @@ -379,7 +379,7 @@ static IEnumerable<CodeInstruction> ShipConstruct_LoadShip_Transpiler(IEnumerabl
379379 // first, remove the original module load call
380380 bool originalFound = false ;
381381
382- if ( ! KSPCommunityFixes . cleanedDll )
382+ if ( ! KSPCommunityFixes . IsCleanedDll )
383383 {
384384 for ( int i = 0 ; i < code . Count - 6 ; i ++ )
385385 {
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ class RefundingOnRecovery : BasePatch
5858
5959 protected override void ApplyPatches ( )
6060 {
61- if ( ! KSPCommunityFixes . cleanedDll )
61+ if ( ! KSPCommunityFixes . IsCleanedDll )
6262 {
6363 AddPatch ( PatchType . Transpiler , typeof ( Funding ) , "onVesselRecoveryProcessing" ) ;
6464 }
Original file line number Diff line number Diff line change @@ -52,32 +52,27 @@ public static Version KspVersion
5252 }
5353 }
5454
55- public static bool cleanedDll
55+ //returns true if KSP Assembly-CSharp is probably a cleaned/deobfuscated image
56+ private static bool ? cleanedDllCachedValue = null ;
57+ public static bool IsCleanedDll
5658 {
5759 get
5860 {
59- String dllPath = "" ;
60- if ( Application . platform == RuntimePlatform . WindowsPlayer )
61+ if ( cleanedDllCachedValue != null )
6162 {
62- dllPath = KSPUtil . ApplicationRootPath + "KSP_x64_Data/Managed/Assembly-CSharp.dll" ;
63+ return ( bool ) cleanedDllCachedValue ;
6364 }
64- else if ( Application . platform == RuntimePlatform . OSXPlayer )
65+ else
6566 {
66- dllPath = KSPUtil . ApplicationRootPath + "KSP.app/Contents/Resources/Data/Managed/Assembly-CSharp.dll" ;
67- }
68- else if ( Application . platform == RuntimePlatform . LinuxPlayer )
69- {
70- dllPath = KSPUtil . ApplicationRootPath + "KSP_Data/Managed/Assembly-CSharp.dll" ;
71- }
72- if ( File . Exists ( dllPath ) )
73- {
74- Byte [ ] data = File . ReadAllBytes ( dllPath ) ;
75- if ( ( data . Length < 10000000 ) && ( KSPCommunityFixes . KspVersion >= new Version ( 1 , 12 , 0 ) ) )
67+ String dllPath = typeof ( GameDatabase ) . Assembly . Location ;
68+ if ( ( new FileInfo ( dllPath ) . Length < 10000000 ) && Versioning . version_minor . Equals ( 12 ) )
7669 {
70+ cleanedDllCachedValue = true ;
7771 return true ; //certainly a home-cleaned dll, no official 1.12.x build of Assembly-CSharp is less than 10MBs.
7872 }
73+ cleanedDllCachedValue = false ;
74+ return false ;
7975 }
80- return false ;
8176 }
8277 }
8378
You can’t perform that action at this time.
0 commit comments