Skip to content

Commit

Permalink
Merge branch 'v1.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
jwvanderbeck committed Mar 17, 2016
2 parents 82410fa + 9f771f2 commit 5af2a7d
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 26 deletions.
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Make sure you have read and understood the contributing guidelines!
-------------------------------------------------------------------

Pull Requests that don't follow the guidelines will be rejected. If you need help or are confused just ask, and we will be glad to help.

-[ ] PR being applied to the correct **Feature Branch** or **dev**
-[ ] PR is **not** being sent to **master**
20 changes: 20 additions & 0 deletions .github/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Contributing Information
========================

To better coordinate multiple developers as well as community additions, the TestFlight project now uses the [Gitflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) style workflow. You can read more nerdy details about this [here](http://nvie.com/posts/a-successful-git-branching-model/).

The short of it is that we use multiple branches to better manage the code coming in. All contributions to TestFlight, including those by core team members, need to follow these rules, the most important of which is...

Don't ever commit anything to Master
------------------------------------
No code change or pull request should ever be directly to master. Any PR opened against master will be rejected. Full stop. Any code directly commited to master outside of the normal process of merging changes in for release will be froned upon and most likely reverted.

At any given moment in time the master branch is expected to be ready for release opn a moment's notice.

Pull Requests and normal development commits either go to the dev branch or to a feature branch
-----------------------------------------------------------------------------------------------
In general you shoud have a branch specifically for any feature you are adding. This branch should be branched off of **dev** and will be merged back into dev once complete. If you are making a small quick fix, then it is ok to commit to, or make a PR against, the dev branch directly.

When in doubt, ASK
-------------------
Seriously I understand this can be confusing, especially if you don't know Git very well. Don't be afraid to ask if you are unsure. PReferabbly before you start your work as it is easier to start on the right foot than it is to try and change after the fact.
Binary file modified GameData/TestFlight/Plugins/TestFlight.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightAPI.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightContracts.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightCore.dll
Binary file not shown.
1 change: 1 addition & 0 deletions TestFlight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<Compile Include="TestFlightFailure_IgnitionFail.cs" />
<Compile Include="TestFlightFailure_Engine.cs" />
<Compile Include="TestFlightReliability_TestFail.cs" />
<Compile Include="TestFlightFailure_EnginePerformanceLoss.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
13 changes: 11 additions & 2 deletions TestFlightAPI/TestFlightAPI/FlightDataRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ public bool TestFlightEnabled
}
public string Configuration
{
get { return configuration; }
set { configuration = value; }
get
{
if (configuration.Equals(string.Empty))
configuration = TestFlightUtil.GetPartName(this.part);

return configuration;
}
set
{
configuration = value;
}
}

public override void OnStart(StartState state)
Expand Down
13 changes: 11 additions & 2 deletions TestFlightAPI/TestFlightAPI/TestFlightFailure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,17 @@ public bool TestFlightEnabled
}
public string Configuration
{
get { return configuration; }
set { configuration = value; }
get
{
if (configuration.Equals(string.Empty))
configuration = TestFlightUtil.GetPartName(this.part);

return configuration;
}
set
{
configuration = value;
}
}

public bool OneShot
Expand Down
5 changes: 5 additions & 0 deletions TestFlightAPI/TestFlightAPI/TestFlightInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public InteropValue GetInterop(string name)
return returnVal;
}
}
public override void OnAwake()
{
base.OnAwake();
AddInteropValue("kspPartName", TestFlightUtil.GetPartName(this.part), "TestFlight");
}
}
}

80 changes: 70 additions & 10 deletions TestFlightAPI/TestFlightAPI/TestFlightPartData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,27 @@ public int GetInt(string key)
return returnValue;
}

public void AddValue(string key, float value)
public void SetValue(string key, float value)
{
AddValue(key, value.ToString());
SetValue(key, value.ToString());
}

public void AddValue(string key, int value)
public void SetValue(string key, int value)
{
AddValue(key, value.ToString());
SetValue(key, value.ToString());
}

public void AddValue(string key, bool value)
public void SetValue(string key, bool value)
{
AddValue(key, value.ToString());
SetValue(key, value.ToString());
}

public void AddValue(string key, double value)
public void SetValue(string key, double value)
{
AddValue(key, value.ToString());
SetValue(key, value.ToString());
}

public void AddValue(string key, string value)
public void SetValue(string key, string value)
{
key = key.ToLowerInvariant();
if (partData.ContainsKey(key))
Expand All @@ -124,13 +124,73 @@ public void AddValue(string key, string value)
partData.Add(key, value);
}

public void AddValue(string key, float value)
{
key = key.ToLowerInvariant();
if (partData.ContainsKey(key))
{
float existingValue;
if (float.TryParse(partData[key], out existingValue))
{
SetValue(key, existingValue + value);
}
}
else
SetValue(key, value);
}

public void AddValue(string key, int value)
{
key = key.ToLowerInvariant();
if (partData.ContainsKey(key))
{
int existingValue;
if (int.TryParse(partData[key], out existingValue))
{
SetValue(key, existingValue + value);
}
}
else
SetValue(key, value);
}

public void ToggleValue(string key, bool value)
{
key = key.ToLowerInvariant();
if (partData.ContainsKey(key))
{
bool existingValue;
if (bool.TryParse(partData[key], out existingValue))
{
SetValue(key, !existingValue);
}
}
else
SetValue(key, value);
}

public void AddValue(string key, double value)
{
key = key.ToLowerInvariant();
if (partData.ContainsKey(key))
{
double existingValue;
if (double.TryParse(partData[key], out existingValue))
{
SetValue(key, existingValue + value);
}
}
else
SetValue(key, value);
}

private void decodeRawPartData()
{
string[] propertyGroups = rawPartdata.Split(new char[1]{ ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string propertyGroup in propertyGroups)
{
string[] keyValuePair = propertyGroup.Split(new char[1]{ ':' });
AddValue(keyValuePair[0], keyValuePair[1]);
SetValue(keyValuePair[0], keyValuePair[1]);
}
}

Expand Down
13 changes: 11 additions & 2 deletions TestFlightAPI/TestFlightAPI/TestFlightReliability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,17 @@ public bool TestFlightEnabled

public string Configuration
{
get { return configuration; }
set { configuration = value; }
get
{
if (configuration.Equals(string.Empty))
configuration = TestFlightUtil.GetPartName(this.part);

return configuration;
}
set
{
configuration = value;
}
}

internal void Log(string message)
Expand Down
21 changes: 17 additions & 4 deletions TestFlightCore/TestFlightCore/TestFlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -875,12 +875,25 @@ public float GetFlightDataForPartName(string partName)
public void SetFlightDataForPartName(string partName, float data)
{
if (partData.ContainsKey(partName))
partData[partName].AddValue("flightData", data.ToString());
partData[partName].SetValue("flightData", data.ToString());
else
{
TestFlightPartData newData = new TestFlightPartData();
newData.PartName = partName;
newData.AddValue("flightData", data.ToString());
newData.SetValue("flightData", data.ToString());
partData.Add(partName, newData);
}
}
// This is a utility method that adds the "flightData" value directly
public void AddFlightDataForPartName(string partName, float data)
{
if (partData.ContainsKey(partName))
partData[partName].AddValue("flightData", data);
else
{
TestFlightPartData newData = new TestFlightPartData();
newData.PartName = partName;
newData.SetValue("flightData", data);
partData.Add(partName, newData);
}
}
Expand Down Expand Up @@ -926,8 +939,8 @@ public override void OnLoad(ConfigNode node)
totalData += data.flightData;
totalTime += data.flightTime;
}
storedPartData.AddValue("flightData", totalData.ToString());
storedPartData.AddValue("flightTime", totalTime.ToString());
storedPartData.SetValue("flightData", totalData.ToString());
storedPartData.SetValue("flightTime", totalTime.ToString());
partData.Add(storedPartData.PartName, storedPartData);
}
}
Expand Down
25 changes: 20 additions & 5 deletions TestFlightCore/TestFlightCore/TestFlightCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TestFlightCore : PartModuleExtended, ITestFlightCore
public float currentFlightData;
[KSPField(isPersistant=true)]
public float initialFlightData;
[KSPField(isPersistant=true)]
[KSPField]
public float startFlightData;

[KSPField]
Expand Down Expand Up @@ -97,8 +97,20 @@ public bool TestFlightEnabled
}
public string Configuration
{
get { return configuration; }
set { configuration = value; }
get
{
if (configuration.Equals(string.Empty))
{
configuration = "kspPartName = " + TestFlightUtil.GetPartName(this.part);
configuration = configuration + ":" + TestFlightUtil.GetPartName(this.part);
}

return configuration;
}
set
{
configuration = value;
}
}
public string Title
{
Expand Down Expand Up @@ -486,7 +498,7 @@ public void SetFlightTime(float flightTime)
{
if (TestFlightManagerScenario.Instance != null)
{
TestFlightManagerScenario.Instance.GetPartDataForPart(TestFlightUtil.GetFullPartName(this.part)).AddValue("flightTime", flightTime);
TestFlightManagerScenario.Instance.GetPartDataForPart(TestFlightUtil.GetFullPartName(this.part)).SetValue("flightTime", flightTime);
}
}

Expand Down Expand Up @@ -543,7 +555,7 @@ public float ModifyFlightTime(float flightTime, bool additive)
newFlightTime += flightTime;
else
newFlightTime *= flightTime;
TestFlightManagerScenario.Instance.GetPartDataForPart(TestFlightUtil.GetFullPartName(this.part)).AddValue("flightTime", newFlightTime);
TestFlightManagerScenario.Instance.GetPartDataForPart(TestFlightUtil.GetFullPartName(this.part)).SetValue("flightTime", newFlightTime);
}

return newFlightTime;
Expand Down Expand Up @@ -825,7 +837,10 @@ public void InitializeFlightData(float flightData)
flightData = AttemptTechTransfer();

if (startFlightData > flightData)
{
TestFlightManagerScenario.Instance.AddFlightDataForPartName(TestFlightUtil.GetFullPartName(this.part), startFlightData);
flightData = startFlightData;
}

currentFlightData = flightData;
initialFlightData = flightData;
Expand Down
50 changes: 50 additions & 0 deletions TestFlightFailure_EnginePerformanceLoss.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;

using UnityEngine;
using KSPPluginFramework;
using TestFlightAPI;

namespace TestFlight
{
public class TestFlightFailure_EnginePerformanceLoss : TestFlightFailure_Engine
{
[KSPField]
public float ispMultiplier = 0.7f;
[KSPField]
public float ispMultiplierJitter = 0.1f;

public override void OnStart(StartState state)
{
base.OnStart(state);
base.Startup();
}
/// <summary>
/// Triggers the failure controlled by the failure module
/// </summary>
public override void DoFailure()
{
base.DoFailure();
// for each engine change its fuelFlow which will affect thrust
foreach (EngineHandler engine in engines)
{
float jitter = ispMultiplierJitter - ((float)TestFlightUtil.GetCore(this.part).RandomGenerator.NextDouble() * (ispMultiplierJitter * 2));
float actualMultiplier = ispMultiplier + jitter;
engine.engine.SetFuelIspMult(actualMultiplier);
}
}

public override float DoRepair()
{
base.DoRepair();
// for each engine restore its fuell flow back to 1.0
foreach (EngineHandler engine in engines)
{
engine.engine.SetFuelFlowMult(1.0f);
}
return 0;
}
}
}

2 changes: 1 addition & 1 deletion TestFlightFailure_ResourceLeak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public override void DoFailure()
if (part.Resources.Count > 0)
{
List<PartResource> allResources = this.part.Resources.list;
int randomResource = UnityEngine.Random.Range(0, allResources.Count());
int randomResource = TestFlightUtil.GetCore(this.part).RandomGenerator.Next(0, allResources.Count());
resId = allResources[randomResource].info.id;
found = true;
}
Expand Down

0 comments on commit 5af2a7d

Please sign in to comment.