Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Commit

Permalink
fix equality not getting cloned, few missing log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed Apr 22, 2016
1 parent 3ec3523 commit 6506818
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 13 deletions.
1 change: 1 addition & 0 deletions FilterExtension/ConfigNodes/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public Check(Check c)
for (int i = 0; i < c.checks.Count; ++i)
checks.Add(new Check(c.checks[i]));
}
equality = c.equality;
}

public Check(string Type, string Value, bool Invert = false, bool Contains = true, Equality Compare = Equality.Equals)
Expand Down
29 changes: 17 additions & 12 deletions FilterExtension/Utility/PartType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,19 +462,13 @@ public static bool checkCrewCapacity(AvailablePart part, string[] value, ConfigN
if (value.Length > 1)
Core.Log("Crew comparisons against multiple values when not using Equals only use the first value. Value list is: {0}", string.Join(", ", value));

int i;
if (int.TryParse(value[0], out i))
double d;
if (double.TryParse(value[0], out d))
{
if (equality == ConfigNodes.Check.Equality.GreaterThan)
{
if (part.partPrefab.CrewCapacity > i)
return true;
}
else if (equality == ConfigNodes.Check.Equality.LessThan)
{
if (part.partPrefab.CrewCapacity < i)
return true;
}
if (equality == ConfigNodes.Check.Equality.GreaterThan && part.partPrefab.CrewCapacity > d)
return true;
else if (equality == ConfigNodes.Check.Equality.LessThan && part.partPrefab.CrewCapacity < d)
return true;
}
}
return false;
Expand All @@ -492,6 +486,9 @@ public static bool checkMass(AvailablePart part, string[] value, ConfigNodes.Che
return value.Contains(part.partPrefab.mass.ToString(), StringComparer.OrdinalIgnoreCase);
else
{
if (value.Length > 1)
Core.Log("Mass comparisons against multiple values when not using Equals only use the first value. Value list is: {0}", string.Join(", ", value));

double d;
if (double.TryParse(value[0], out d))
{
Expand All @@ -513,6 +510,9 @@ public static bool checkCost(AvailablePart part, string[] value, ConfigNodes.Che
return value.Contains(part.cost.ToString(), StringComparer.OrdinalIgnoreCase);
else
{
if (value.Length > 1)
Core.Log("Cost comparisons against multiple values when not using Equals only use the first value. Value list is: {0}", string.Join(", ", value));

double d;
if (double.TryParse(value[0], out d))
{
Expand All @@ -537,6 +537,9 @@ public static bool checkCrashTolerance(AvailablePart part, string[] value, Confi
return value.Contains(part.partPrefab.crashTolerance.ToString());
else
{
if (value.Length > 1)
Core.Log("Crash tolerance comparisons against multiple values when not using Equals only use the first value. Value list is: {0}", string.Join(", ", value));

float f;
if (float.TryParse(value[0], out f))
{
Expand All @@ -561,6 +564,8 @@ public static bool checkTemperature(AvailablePart part, string[] value, ConfigNo
return value.Contains(part.partPrefab.maxTemp.ToString(), StringComparer.OrdinalIgnoreCase);
else
{
if (value.Length > 1)
Core.Log("Temperature comparisons against multiple values when not using Equals only use the first value. Value list is: {0}", string.Join(", ", value));
double d;
if (double.TryParse(value[0], out d))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@CATEGORY[Filter?by?Function]
{
@SUBCATEGORIES
{
list = 0,Command and Crew
list = 1,Attitude Control
list = 2,Fuel Tanks
list = 3,Engines
list = 4,Structural
list = 5,General Aero
list = 6,Flight
list = 7,Misc
list = 8,Electrical
list = 9,Science
}
}
130 changes: 130 additions & 0 deletions GameData/000_FilterExtensions Configs/StockRework/Subcategories.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
SUBCATEGORY
{
name = Command and Crew
icon = stockIcon_pods
FILTER
{
CHECK
{
type = category
value = Pods
}
}
FILTER
{
CHECK
{
type = crew
value = 0
equality = greaterThan
}
}
}
SUBCATEGORY
{
name = Attitude Control
icon = stockIcon_cmdctrl
FILTER
{
CHECK
{
type = category
value = Control
}
}
FILTER
{
CHECK
{
type = subcategory
value = Control Surface
}
}
}
SUBCATEGORY
{
name = General Aero
icon = Fairing
FILTER
{
CHECK
{
type = category
value = Aerodynamics
}
CHECK
{
type = subcategory
value = Wings, Control Surface
invert = true
}
}
FILTER
{
CHECK
{
type = subcategory
value = Parachutes, Adapter, Cargo Bay
}
}
}
SUBCATEGORY
{
name = Flight
icon = Wings
FILTER
{
CHECK
{
type = subcategory
value = Wings, Control Surface
}
}
FILTER
{
CHECK
{
type = moduleName
value = ModuleAeroSurface
}
}
}
SUBCATEGORY
{
name = Misc
icon = stockIcon_utility
FILTER
{
CHECK
{
type = category
value = Utility
}
CHECK
{
type = subcategory
value = Generators, Lights, Power Storage, Solar Panels, Cargo Bay, Parachutes
invert = true
}
CHECK
{
type = crew
value = 0
invert = true
equality = greaterThan
}
}
}
SUBCATEGORY
{
name = Electrical
icon = ElectricCharge
FILTER
{
CHECK
{
type = subcategory
value = Generators, Lights, Power Storage, Solar Panels
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SUBCATEGORY
CHECK
{
type = category
value = Command and Control
value = Control
}
}
}
Expand Down
Binary file modified GameData/000_FilterExtensions/FilterExtensions.dll
Binary file not shown.

0 comments on commit 6506818

Please sign in to comment.