Skip to content

Commit

Permalink
Prep for FAR v0.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ferram4 committed Oct 7, 2014
1 parent 0095e10 commit 3de7ed9
Show file tree
Hide file tree
Showing 34 changed files with 723 additions and 263 deletions.
Binary file modified FerramAerospaceResearch.v12.suo
Binary file not shown.
85 changes: 52 additions & 33 deletions FerramAerospaceResearch/CompatibilityChecker.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 ferram4
/**
* 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 @@ -61,10 +62,10 @@ public static bool IsCompatible()
// ...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 == 1 || Versioning.Revision == 2);
return Versioning.version_minor == 25;

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

// TODO: Implement your own Unity compatibility check.
//
bool compat = Application.unityVersion == "4.3.3f1"; //Mac / Linux
compat |= Application.unityVersion == "4.5.2f1"; //Windows
return compat;
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 +158,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
2 changes: 1 addition & 1 deletion FerramAerospaceResearch/FARAPI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Ferram Aerospace Research v0.14.1.2
Ferram Aerospace Research v0.14.2
Copyright 2014, Michael Ferrara, aka Ferram4
This file is part of Ferram Aerospace Research.
Expand Down
2 changes: 1 addition & 1 deletion FerramAerospaceResearch/FARAction.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Ferram Aerospace Research v0.14.1.2
Ferram Aerospace Research v0.14.2
Copyright 2014, Michael Ferrara, aka Ferram4
This file is part of Ferram Aerospace Research.
Expand Down
2 changes: 1 addition & 1 deletion FerramAerospaceResearch/FARAeroStress.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Ferram Aerospace Research v0.14.1.2
Ferram Aerospace Research v0.14.2
Copyright 2014, Michael Ferrara, aka Ferram4
This file is part of Ferram Aerospace Research.
Expand Down
2 changes: 1 addition & 1 deletion FerramAerospaceResearch/FARAeroUtil.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Ferram Aerospace Research v0.14.1.2
Ferram Aerospace Research v0.14.2
Copyright 2014, Michael Ferrara, aka Ferram4
This file is part of Ferram Aerospace Research.
Expand Down
15 changes: 7 additions & 8 deletions FerramAerospaceResearch/FARBaseAerodynamics.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Ferram Aerospace Research v0.14.1.2
Ferram Aerospace Research v0.14.2
Copyright 2014, Michael Ferrara, aka Ferram4
This file is part of Ferram Aerospace Research.
Expand Down Expand Up @@ -95,8 +95,6 @@ public override void Start()
{
Fields["Cl"].guiActive = Fields["Cd"].guiActive = Fields["Cm"].guiActive = FARDebugValues.displayCoefficients;
}

FARGUIUtils.defaultHighlightColor = part.highlightColor;
}

public virtual void LateUpdate()
Expand All @@ -108,22 +106,23 @@ public virtual void LateUpdate()
bool active = FARControlSys.tintForCl || FARControlSys.tintForCd;

if (FARControlSys.tintForCl)
satCl = (float)FARMathUtil.Clamp(Math.Abs(this.Cl / FARControlSys.fullySaturatedCl), 0, 1) * 255;
satCl = (float)Math.Abs(this.Cl / FARControlSys.fullySaturatedCl) * 10;
if (FARControlSys.tintForCd)
satCd = (float)FARMathUtil.Clamp(Math.Abs(this.Cd / FARControlSys.fullySaturatedCd), 0, 1) * 255;
satCd = (float)Math.Abs(this.Cd / FARControlSys.fullySaturatedCd) * 10;

Color tintColor = new Color(satCd, 0.5f * (satCl + satCd), satCl, 1);

if (active)
{
this.part.SetHighlightType(Part.HighlightType.AlwaysOn);
this.part.SetHighlightColor(tintColor);
this.part.highlightRecurse = false;
this.part.SetHighlight(true);
}
else if (part.highlightType != Part.HighlightType.OnMouseOver)
{
this.part.SetHighlightType(Part.HighlightType.OnMouseOver);
this.part.SetHighlightColor(FARGUIUtils.defaultHighlightColor);
this.part.SetHighlightColor(Part.defaultHighlightPart);
this.part.SetHighlight(false);
}
}
Expand Down Expand Up @@ -268,8 +267,8 @@ public void OnCenterOfLiftQuery(CenterOfLiftQuery CoLMarker)

// Feed the precomputed values to the vanilla indicator
CoLMarker.pos = GlobalCoL;
CoLMarker.dir = CoLForce.normalized;
CoLMarker.lift = CoLForce.magnitude * 50f;
CoLMarker.dir = Vector3.zero;
CoLMarker.lift = CoLForce.magnitude;
}

public override void OnLoad(ConfigNode node)
Expand Down
4 changes: 2 additions & 2 deletions FerramAerospaceResearch/FARBasicDragModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Ferram Aerospace Research v0.14.1.2
Ferram Aerospace Research v0.14.2
Copyright 2014, Michael Ferrara, aka Ferram4
This file is part of Ferram Aerospace Research.
Expand Down Expand Up @@ -208,7 +208,7 @@ public override void Start()

OnVesselPartsChange += AttachNodeCdAdjust;

UpdateUpVector(false);
UpdateUpVector(false || this.part.Modules.Contains("ModuleResourceIntake"));
//PartModelTransforms = FARGeoUtil.PartModelTransformArray(part);
AttachNodeCdAdjust();
AnimationSetup();
Expand Down
30 changes: 29 additions & 1 deletion FerramAerospaceResearch/FARCargoBayModule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Ferram Aerospace Research v0.14.1.2
Ferram Aerospace Research v0.14.2
Copyright 2014, Michael Ferrara, aka Ferram4
This file is part of Ferram Aerospace Research.
Expand Down Expand Up @@ -252,6 +252,18 @@ private void FindShieldedParts()

double y_margin = Math.Max(0.12, 0.03 * (maxBounds.y-minBounds.y));

Collider[] colliders;
try
{
colliders = part.GetComponentsInChildren<Collider>();
}
catch (Exception e)
{
//Fail silently because it's the only way to avoid issues with pWings
//Debug.LogException(e);
colliders = new Collider[1] { part.collider };
}

for (int i = 0; i < VesselPartList.Count; i++)
{
Part p = VesselPartList[i];
Expand Down Expand Up @@ -293,6 +305,22 @@ private void FindShieldedParts()
p.parent == this.part && p.attachMode == AttachModes.STACK)
continue;
}
Vector3 vecFromPToCargoBayCenter = this.part.partTransform.position - p.partTransform.position;

RaycastHit[] hits = Physics.RaycastAll(p.partTransform.position, vecFromPToCargoBayCenter, vecFromPToCargoBayCenter.magnitude, FARAeroUtil.RaycastMask);

bool outsideMesh = false;

for (int j = 0; j < hits.Length; j++)
{
if (colliders.Contains(hits[j].collider))
{
outsideMesh = true;
break;
}
}
if (outsideMesh)
break;

FARShieldedParts.Add(p);
if (b)
Expand Down
2 changes: 1 addition & 1 deletion FerramAerospaceResearch/FARCenterQuery.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Ferram Aerospace Research v0.14.1.2
Ferram Aerospace Research v0.14.2
Copyright 2014, Michael Ferrara, aka Ferram4
This file is part of Ferram Aerospace Research.
Expand Down
Loading

0 comments on commit 3de7ed9

Please sign in to comment.