Skip to content

Commit

Permalink
Merge pull request #654 from MOARdV/master
Browse files Browse the repository at this point in the history
Sync for 0.29.3
  • Loading branch information
MOARdV authored Jan 1, 2018
2 parents 99c90ef + dbdf26a commit c112a4f
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 138 deletions.
2 changes: 1 addition & 1 deletion GameData/JSI/RasterPropMonitor/RasterPropMonitor.version
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"VERSION": {
"MAJOR": 0,
"MINOR": 29,
"PATCH": 2
"PATCH": 3
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion RasterPropMonitor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ Global
$36.inheritsSet = Mono
$36.inheritsScope = text/plain
$36.scope = text/plain
version = 0.29.2
version = 0.29.3
EndGlobalSection
EndGlobal
8 changes: 4 additions & 4 deletions RasterPropMonitor/Core/RPMGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ internal static class RPMGlobals
internal static SortedDictionary<string, string> systemNamedResources = new SortedDictionary<string, string>();
internal static List<RasterPropMonitorComputer.TriggeredEventTemplate> triggeredEvents = new List<RasterPropMonitorComputer.TriggeredEventTemplate>();

/// List of parts where all PartModule should be ignored.
internal static List<string> ignoreAllPartModules = new List<string>();
/// List of parts where some PartModules should be ignored. Part names are the Key, list of module names is the Value.
internal static Dictionary<string, List<string>> ignorePartModules = new Dictionary<string, List<string>>();
/// List of parts where all PartModule should be ignored.
internal static List<string> ignoreAllPartModules = new List<string>();
/// List of parts where some PartModules should be ignored. Part names are the Key, list of module names is the Value.
internal static Dictionary<string, List<string>> ignorePartModules = new Dictionary<string, List<string>>();
}
}
198 changes: 122 additions & 76 deletions RasterPropMonitor/Core/RPMVCPerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public partial class RPMVesselComputer : VesselModule
/// JSIInternalButtons methods is outright eliminated.

private bool listsInvalid = true;
private readonly static List<string> emptyIgnoreList = new List<string>();
private readonly static List<string> emptyIgnoreList = new List<string>();

//--- Docking Nodes
internal ModuleDockingNode mainDockingNode;
Expand Down Expand Up @@ -169,79 +169,124 @@ internal void UpdateModuleLists()
var partsList = vessel.parts;
for (int partsIdx = 0; partsIdx < partsList.Count; ++partsIdx)
{
string partName = partsList[partsIdx].partInfo.name;
if (!RPMGlobals.ignoreAllPartModules.Contains(partName)) {
List<string> modulesToIgnore;
if (!RPMGlobals.ignorePartModules.TryGetValue(partName, out modulesToIgnore)) {
modulesToIgnore = emptyIgnoreList;
}
foreach (PartModule module in partsList[partsIdx].Modules) {
if (module.isEnabled && !modulesToIgnore.Contains(module.moduleName)) {
if (module is ModuleEngines) {
availableEngines.Add(module as ModuleEngines);
} else if (module is MultiModeEngine) {
availableMultiModeEngines.Add(module as MultiModeEngine);
} else if (module is JSIThrustReverser) {
availableThrustReverser.Add(module as JSIThrustReverser);
} else if (module is ModuleAblator) {
availableAblators.Add(module as ModuleAblator);
} else if (module is ModuleResourceIntake) {
if ((module as ModuleResourceIntake).resourceName == "IntakeAir") {
availableAirIntakes.Add(module as ModuleResourceIntake);
} else {
JUtil.LogMessage(this, "intake resource is {0}?", (module as ModuleResourceIntake).resourceName);
}
} else if (module is ModuleAlternator) {
ModuleAlternator alt = module as ModuleAlternator;
for (int i = 0; i < alt.resHandler.outputResources.Count; ++i) {
if (alt.resHandler.outputResources[i].name == "ElectricCharge") {
availableAlternators.Add(alt);
break;
}
}
} else if (module is ModuleGenerator) {
ModuleGenerator gen = module as ModuleGenerator;
for (int i = 0; i < gen.resHandler.outputResources.Count; ++i) {
if (gen.resHandler.outputResources[i].name == "ElectricCharge") {
availableGenerators.Add(gen);
availableGeneratorOutput.Add((float)gen.resHandler.outputResources[i].rate);
break;
}
}
} else if (module is ModuleResourceConverter) {
ModuleResourceConverter gen = module as ModuleResourceConverter;
ConversionRecipe recipe = gen.Recipe;
for (int i = 0; i < recipe.Outputs.Count; ++i) {
if (recipe.Outputs[i].ResourceName == "ElectricCharge") {
availableFuelCells.Add(gen);
availableFuelCellOutput.Add((float)recipe.Outputs[i].Ratio);
break;
}
}
} else if (module is ModuleDeployableSolarPanel) {
ModuleDeployableSolarPanel sp = module as ModuleDeployableSolarPanel;

if (sp.resourceName == "ElectricCharge") {
availableSolarPanels.Add(sp);
}
} else if (module is ModuleGimbal) {
availableGimbals.Add(module as ModuleGimbal);
} else if (module is JSIRadar) {
availableRadars.Add(module as JSIRadar);
} else if (module is ModuleParachute) {
availableParachutes.Add(module as ModuleParachute);
} else if (module is ModuleWheels.ModuleWheelDeployment) {
availableDeployableWheels.Add(module as ModuleWheels.ModuleWheelDeployment);
} else if (module is ModuleWheels.ModuleWheelDamage) {
availableWheelDamage.Add(module as ModuleWheels.ModuleWheelDamage);
} else if (module is ModuleWheels.ModuleWheelBrakes) {
availableWheelBrakes.Add(module as ModuleWheels.ModuleWheelBrakes);
} else if (JSIParachute.rcFound && module.GetType() == JSIParachute.rcModuleRealChute) {
availableRealChutes.Add(module);
}
}
}
}
string partName = partsList[partsIdx].partInfo.name;
if (!RPMGlobals.ignoreAllPartModules.Contains(partName))
{
List<string> modulesToIgnore;
if (!RPMGlobals.ignorePartModules.TryGetValue(partName, out modulesToIgnore))
{
modulesToIgnore = emptyIgnoreList;
}
foreach (PartModule module in partsList[partsIdx].Modules)
{
if (module.isEnabled && !modulesToIgnore.Contains(module.moduleName))
{
if (module is ModuleEngines)
{
availableEngines.Add(module as ModuleEngines);
}
else if (module is MultiModeEngine)
{
availableMultiModeEngines.Add(module as MultiModeEngine);
}
else if (module is JSIThrustReverser)
{
availableThrustReverser.Add(module as JSIThrustReverser);
}
else if (module is ModuleAblator)
{
availableAblators.Add(module as ModuleAblator);
}
else if (module is ModuleResourceIntake)
{
if ((module as ModuleResourceIntake).resourceName == "IntakeAir")
{
availableAirIntakes.Add(module as ModuleResourceIntake);
}
else
{
JUtil.LogMessage(this, "intake resource is {0}?", (module as ModuleResourceIntake).resourceName);
}
}
else if (module is ModuleAlternator)
{
ModuleAlternator alt = module as ModuleAlternator;
for (int i = 0; i < alt.resHandler.outputResources.Count; ++i)
{
if (alt.resHandler.outputResources[i].name == "ElectricCharge")
{
availableAlternators.Add(alt);
break;
}
}
}
else if (module is ModuleGenerator)
{
ModuleGenerator gen = module as ModuleGenerator;
for (int i = 0; i < gen.resHandler.outputResources.Count; ++i)
{
if (gen.resHandler.outputResources[i].name == "ElectricCharge")
{
availableGenerators.Add(gen);
availableGeneratorOutput.Add((float)gen.resHandler.outputResources[i].rate);
break;
}
}
}
else if (module is ModuleResourceConverter)
{
ModuleResourceConverter gen = module as ModuleResourceConverter;
ConversionRecipe recipe = gen.Recipe;
for (int i = 0; i < recipe.Outputs.Count; ++i)
{
if (recipe.Outputs[i].ResourceName == "ElectricCharge")
{
availableFuelCells.Add(gen);
availableFuelCellOutput.Add((float)recipe.Outputs[i].Ratio);
break;
}
}
}
else if (module is ModuleDeployableSolarPanel)
{
ModuleDeployableSolarPanel sp = module as ModuleDeployableSolarPanel;

if (sp.resourceName == "ElectricCharge")
{
availableSolarPanels.Add(sp);
}
}
else if (module is ModuleGimbal)
{
availableGimbals.Add(module as ModuleGimbal);
}
else if (module is JSIRadar)
{
availableRadars.Add(module as JSIRadar);
}
else if (module is ModuleParachute)
{
availableParachutes.Add(module as ModuleParachute);
}
else if (module is ModuleWheels.ModuleWheelDeployment)
{
availableDeployableWheels.Add(module as ModuleWheels.ModuleWheelDeployment);
}
else if (module is ModuleWheels.ModuleWheelDamage)
{
availableWheelDamage.Add(module as ModuleWheels.ModuleWheelDamage);
}
else if (module is ModuleWheels.ModuleWheelBrakes)
{
availableWheelBrakes.Add(module as ModuleWheels.ModuleWheelBrakes);
}
else if (JSIParachute.rcFound && module.GetType() == JSIParachute.rcModuleRealChute)
{
availableRealChutes.Add(module);
}
}
}
}

if (vessel.currentStage <= partsList[partsIdx].inverseStage)
{
Expand Down Expand Up @@ -767,8 +812,9 @@ internal void SetEnableEngines(bool state)
{
Part thatPart = availableEngines[i].part;

if (StageManager.CurrentStage == StageManager.StageCount && thatPart.inverseStage == StageManager.StageCount - 1 || //This line allows to start engines of the first stage before the initial launch
thatPart.inverseStage == StageManager.CurrentStage || !state)
// The first line allows to start engines of the first stage before the initial launch
if ((StageManager.CurrentStage == StageManager.StageCount && thatPart.inverseStage == StageManager.StageCount - 1) ||
thatPart.inverseStage == StageManager.CurrentStage || !state)
{
if (availableEngines[i].EngineIgnited != state)
{
Expand Down
2 changes: 1 addition & 1 deletion RasterPropMonitor/Core/RPMVesselComputer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ internal double SuicideBurnCountdown()
return impactTime - decelTime / 2.0 - Planetarium.GetUniversalTime();
}

/// <summary>
/// <summary>
/// Determines if enough screen updates have passed to trigger another data update.
/// </summary>
/// <returns>true if it's time to update things</returns>
Expand Down
56 changes: 32 additions & 24 deletions RasterPropMonitor/Core/UtilityFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2034,30 +2034,38 @@ private IEnumerator LoadRasterPropMonitorValues()
}
}

RPMGlobals.ignoreAllPartModules.Clear();
RPMGlobals.ignorePartModules.Clear();
nodes = GameDatabase.Instance.GetConfigNodes("RPM_IGNORE_MODULES");
for (int idx = 0; idx < nodes.Length; ++idx) {
foreach (string nameExpression in nodes[idx].GetValuesList("moduleName")) {
string[] splitted = nameExpression.Split(':'); //splitted[0] - part name, splitted[1] - module name
if (splitted.Length != 2 || splitted[0].Length == 0 || splitted[1].Length == 0) {
continue; //just skipping in case of bad syntax
}
string partName = splitted[0].Replace('_','.'); //KSP does it, so we do
if (splitted[1] == "*") {
RPMGlobals.ignoreAllPartModules.Add(partName);
} else {
List<string> moduleNameList;
if (!RPMGlobals.ignorePartModules.TryGetValue(partName, out moduleNameList)) {
moduleNameList = new List<string>();
RPMGlobals.ignorePartModules.Add(partName, moduleNameList);
}
if (!moduleNameList.Contains(splitted[1])) {
moduleNameList.Add(splitted[1]);
}
}
}
}
RPMGlobals.ignoreAllPartModules.Clear();
RPMGlobals.ignorePartModules.Clear();
nodes = GameDatabase.Instance.GetConfigNodes("RPM_IGNORE_MODULES");
for (int idx = 0; idx < nodes.Length; ++idx)
{
foreach (string nameExpression in nodes[idx].GetValuesList("moduleName"))
{
string[] splitted = nameExpression.Split(':'); //splitted[0] - part name, splitted[1] - module name
if (splitted.Length != 2 || splitted[0].Length == 0 || splitted[1].Length == 0)
{
continue; //just skipping in case of bad syntax
}
string partName = splitted[0].Replace('_', '.'); //KSP does it, so we do
if (splitted[1] == "*")
{
RPMGlobals.ignoreAllPartModules.Add(partName);
}
else
{
List<string> moduleNameList;
if (!RPMGlobals.ignorePartModules.TryGetValue(partName, out moduleNameList))
{
moduleNameList = new List<string>();
RPMGlobals.ignorePartModules.Add(partName, moduleNameList);
}
if (!moduleNameList.Contains(splitted[1]))
{
moduleNameList.Add(splitted[1]);
}
}
}
}

RPMGlobals.knownLoadedAssemblies.Clear();
for (int i = 0; i < AssemblyLoader.loadedAssemblies.Count; ++i)
Expand Down
Loading

0 comments on commit c112a4f

Please sign in to comment.