Skip to content

Commit

Permalink
Update to .25, radial decoupler feed off, v3.1 FINAL
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed Oct 8, 2014
1 parent be58a6c commit 024b4fd
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 49 deletions.
29 changes: 18 additions & 11 deletions CrossFeedEnabler/AddToRadialTanks.cfg
Original file line number Diff line number Diff line change
@@ -1,88 +1,95 @@
//Powered by ialdabaoth's ModuleManager
@PART[radialRCSTank]
@PART[radialRCSTank]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[rcsTankRadialLong]
@PART[rcsTankRadialLong]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[MicroRCS]
@PART[MicroRCS]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[*]:HAS[@MODULE[StretchyTanks]]
@PART[*]:HAS[@MODULE[StretchyTanks]]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[*]:HAS[@MODULE[StretchyConicTank]]
@PART[*]:HAS[@MODULE[StretchyConicTank]]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[proceduralTank*]
@PART[proceduralTank*]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[*]:HAS[@MODULE[WingManipulator]]
@PART[*]:HAS[@MODULE[WingManipulator]]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[cl_radial_cylTankOxy]
@PART[cl_radial_cylTankOxy]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[cl_radial_cylTankFuel]
@PART[cl_radial_cylTankFuel]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[cl_radial_sphereTankFuel]
@PART[cl_radial_sphereTankFuel]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
@PART[cl_radial_sphereTankOxy]
@PART[cl_radial_sphereTankOxy]:FOR[CrossFeedEnabler]
{
%MODULE[ModuleCrossFeed]
{
%name = ModuleCrossFeed
}
}
// NOTE: Normally, radial decouplers have crossfeed (HUH!?) so that could be bad.
// I turn it off here, so you don't get weird effects.
@PART[radialDecoupler1-2|radialDecoupler|radialDecoupler2]:FOR[CrossFeedEnabler]
{
%fuelCrossFeed = False
}
7 changes: 7 additions & 0 deletions CrossFeedEnabler/Readme_CFE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ A partmodule: adds a fuel crossfeed between the part it's added to, and the part

License CC-BY-SA

Includes Module Manager (by sarbian, swamp_ig, and ialdabaoth). See thread for details, license, and source: http://forum.kerbalspaceprogram.com/threads/55219

Source on GitHub at https://github.com/NathanKell/CrossFeedEnabler/

Installation: Extract folder in zip to GameData. By default includes cfg to apply to radial RCS tanks, the mini radial RCS from Realism Overhaul, and all procedural wings and tanks. (NOTE: Requires ModuleManager, which by now you really should have.)
Expand All @@ -29,6 +31,11 @@ For example, create a MM node and add it to some cfg.
=================
Changelog:
=================
v3.1
*Recompiled for KSP 0.25
*Turns off crossfeed on Squad radial decouplers to prevent weird things from happening. The pylon, however, still has it, so you can still make droptanks (or just use a fuel line).
*Bundle Module Manager

v3.0.2
*Bugfix: No more NREs in editor
*Removed unneeded update code
Expand Down
88 changes: 54 additions & 34 deletions Source/Checkers.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
/**

/**
* Copyright (c) 2014, Majiir
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

Expand All @@ -38,7 +39,7 @@ namespace CrossFeedEnabler
/**
* This utility displays a warning with a list of mods that determine themselves
* to be incompatible with the current running version of Kerbal Space Program.
*
*
* See this forum thread for details:
* http://forum.kerbalspaceprogram.com/threads/65395-Voluntarily-Locking-Plugins-to-a-Particular-KSP-Version
*/
Expand All @@ -57,14 +58,14 @@ public static bool IsCompatible()
// If you want to disable some behavior when incompatible, other parts of the plugin
// should query this method:
//
// if (!CompatibilityChecker.IsCompatible()) {
// if (!CompatibilityChecker.IsAllCompatible()) {
// ...disable some features...
// }
//
// Even if you don't lock down functionality, you should return true if your users
// Even if you don't lock down functionality, you should return true if your users
// can expect a future update to be available.
//
return Versioning.version_major == 0 && Versioning.version_minor == 24 && Versioning.Revision == 2;
return Versioning.version_major == 0 && Versioning.version_minor == 25 && Versioning.Revision == 0;

/*-----------------------------------------------*\
| IMPLEMENTERS SHOULD NOT EDIT BEYOND THIS POINT! |
Expand All @@ -79,17 +80,16 @@ public static bool IsUnityCompatible()

// TODO: Implement your own Unity compatibility check.
//
if (Application.unityVersion.Equals("4.5.2f1"))
return true;
return false;
// not going to care about the fact that KSP .25 OSX uses a different Unity...
return true;

/*-----------------------------------------------*\
| IMPLEMENTERS SHOULD NOT EDIT BEYOND THIS POINT! |
\*-----------------------------------------------*/
}

// Version of the compatibility checker itself.
private static int _version = 3;
private static int _version = 4;

public void Start()
{
Expand Down Expand Up @@ -159,28 +159,48 @@ public void Start()
Array.Sort(incompatible);
Array.Sort(incompatibleUnity);

String message = "Some installed mods may be incompatible with this version of Kerbal Space Program. Features may be broken or disabled. Please check for updates to the listed mods.";
String message = String.Empty;

if (incompatible.Length > 0)
if (IsWin64())
{
Debug.LogWarning("[CompatibilityChecker] Incompatible mods detected: " + String.Join(", ", incompatible));
message += String.Format("\n\nThese mods are incompatible with KSP {0}.{1}.{2}:\n\n", Versioning.version_major, Versioning.version_minor, Versioning.Revision);
message += String.Join("\n", incompatible);
message += "WARNING: You are using 64-bit KSP on Windows. This version of KSP is known to cause crashes. It's highly recommended that you use either 32-bit KSP on Windows or switch to Linux.";
}

if (incompatibleUnity.Length > 0)
if ((incompatible.Length > 0) || (incompatibleUnity.Length > 0))
{
Debug.LogWarning("[CompatibilityChecker] Incompatible mods (Unity) detected: " + String.Join(", ", incompatibleUnity));
message += String.Format("\n\nThese mods are incompatible with Unity {0}:\n\n", Application.unityVersion);
message += String.Join("\n", incompatibleUnity);
message += ((message == String.Empty) ? "Some" : "\n\nAdditionally, some") + " installed mods may be incompatible with this version of Kerbal Space Program. Features may be broken or disabled. Please check for updates to the listed mods.";

if (incompatible.Length > 0)
{
Debug.LogWarning("[CompatibilityChecker] Incompatible mods detected: " + String.Join(", ", incompatible));
message += String.Format("\n\nThese mods are incompatible with KSP {0}.{1}.{2}:\n\n", Versioning.version_major, Versioning.version_minor, Versioning.Revision);
message += String.Join("\n", incompatible);
}

if (incompatibleUnity.Length > 0)
{
Debug.LogWarning("[CompatibilityChecker] Incompatible mods (Unity) detected: " + String.Join(", ", incompatibleUnity));
message += String.Format("\n\nThese mods are incompatible with Unity {0}:\n\n", Application.unityVersion);
message += String.Join("\n", incompatibleUnity);
}
}

if ((incompatible.Length > 0) || (incompatibleUnity.Length > 0))
if ((incompatible.Length > 0) || (incompatibleUnity.Length > 0) || IsWin64())
{
PopupDialog.SpawnPopupDialog("Incompatible Mods Detected", message, "OK", true, HighLogic.Skin);
}
}

public static bool IsWin64()
{
return (IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT);
}

public static bool IsAllCompatible()
{
return IsCompatible() && IsUnityCompatible() && !IsWin64();
}

private static IEnumerable<Type> getAllTypes()
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
Expand Down
27 changes: 26 additions & 1 deletion Source/CrossFeedEnabler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ UIPartActionWindow myWindow
}
}

protected bool compatible = true;

public Part parentPart = null;
[KSPField(isPersistant = true)]
public bool crossFeedOverride = true;
Expand Down Expand Up @@ -63,6 +65,13 @@ public void UpdateCrossFeed()
// belt-and-suspenders: do this everywhere and everywhen.
public override void OnLoad(ConfigNode node)
{
if (!CompatibilityChecker.IsAllCompatible())
{
Events["ToggleCrossFeed"].guiActive = false;
Events["ToggleCrossFeed"].guiActiveEditor = false;
compatible = false;
return;
}
base.OnLoad(node);
UpdateCrossFeed();
Events["ToggleCrossFeed"].guiActive = actionVisible;
Expand All @@ -71,6 +80,13 @@ public override void OnLoad(ConfigNode node)

public override void OnStart(PartModule.StartState state)
{
if (!CompatibilityChecker.IsAllCompatible())
{
Events["ToggleCrossFeed"].guiActive = false;
Events["ToggleCrossFeed"].guiActiveEditor = false;
compatible = false;
return;
}
base.OnStart(state);
UpdateCrossFeed();
Events["ToggleCrossFeed"].guiActive = actionVisible;
Expand All @@ -79,14 +95,21 @@ public override void OnStart(PartModule.StartState state)

public override void OnInitialize()
{
if (!CompatibilityChecker.IsAllCompatible())
{
Events["ToggleCrossFeed"].guiActive = false;
Events["ToggleCrossFeed"].guiActiveEditor = false;
compatible = false;
return;
}
base.OnInitialize();
UpdateCrossFeed();
Events["ToggleCrossFeed"].guiActive = actionVisible;
Events["ToggleCrossFeed"].guiActiveEditor = actionVisible;
}
public virtual void Update()
{
if (HighLogic.LoadedSceneIsEditor)
if (compatible && HighLogic.LoadedSceneIsEditor)
{
if (parentPart != part.parent)
{
Expand All @@ -105,6 +128,8 @@ public virtual void Update()

public void OnDestroy()
{
if (!compatible)
return;
if ((object)(part.parent) != null && part.parent.fuelLookupTargets != null)
{
part.parent.fuelLookupTargets.Remove(part);
Expand Down
4 changes: 2 additions & 2 deletions Source/CrossFeedEnabler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\Games\KSP_win64\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\KSP_025clean\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\..\Games\KSP_win64\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\KSP_025clean\KSP_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.*")]
[assembly: AssemblyFileVersion("0.3.0.2")]
[assembly: AssemblyFileVersion("0.3.1.0")]

0 comments on commit 024b4fd

Please sign in to comment.