Skip to content

Commit

Permalink
Merge pull request #5 from RemoteTechnologiesGroup/master
Browse files Browse the repository at this point in the history
Merging in 1.6.3
  • Loading branch information
Pharylon committed Feb 6, 2015
2 parents df60981 + 11aba83 commit 3dc7652
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 31 deletions.
26 changes: 26 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
Version 1.6.3
========================================
Released February 06, 2015

Bug Fixes:
--------------------
- We've fixed an old issue where unloading a vessel can cause a log spamming with KeyNotFoundException
- We'll now log the current RemoteTech FileVersion to the ksp.log
- Stations will now properly re-registered as a station after unloading
- Stations will now properly registered as a station even if the first part is not the Remote Guidance Unit
- Fix for loading a saved RemoteTech EventCommand like 'activate antenna'


Version 1.6.2
========================================
Released January 24, 2015

Bug Fixes:
--------------------
- Fixed an issue that can cause the KSP UI to be not clickable anymore after docking (thx DaveTSG for reporting)
- Fixed an issue that can cause the flight computer to crash into a small gray dot while loading a saved EventCommand (thx Synighte for reporting)
- Fix for saving/loading a ManeuverCommand
- Reverted a change of the AssemblyVersion from 1.6.1 to 1.6.0 to prevent issues with other mods that use our API (thx jrossignol)
- We fixed an old issue where KSP can freeze by zero cost links between two satellites


Version 1.6.1
========================================
Released January 19, 2015
Expand Down
5 changes: 3 additions & 2 deletions GameData/RemoteTech/RemoteTech.version
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"NAME": "RemoteTech",
"URL": "https://raw.githubusercontent.com/RemoteTechnologiesGroup/RemoteTech/master/GameData/RemoteTech/RemoteTech.version",
"CHANGE_LOG_URL": "https://raw.githubusercontent.com/RemoteTechnologiesGroup/RemoteTech/master/CHANGES.md",
"CHANGE_LOG_URL": "https://raw.githubusercontent.com/RemoteTechnologiesGroup/RemoteTech/master/CHANGES.md",
"DOWNLOAD": "https://kerbalstuff.com/mod/134/RemoteTech",
"GITHUB":
{
"USERNAME": "RemoteTechnologiesGroup",
Expand All @@ -11,7 +12,7 @@
"VERSION":{
"MAJOR":1,
"MINOR":6,
"PATCH":1,
"PATCH":3,
"BUILD":0
},
"KSP_VERSION":{
Expand Down
24 changes: 15 additions & 9 deletions src/RemoteTech/FlightComputer/EventCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class EventCommand : AbstractCommand
{
// Guiname of the BaseEvent
[Persistent] public string GUIName;
// Name of the BaseEvent
[Persistent] public string Name;
// flight id of the part by this BaseEvent
[Persistent] public uint flightID;
// PartModule of the part by this BaseEvent
Expand All @@ -20,7 +22,7 @@ public override String Description
{
get
{
return ((this.BaseEvent != null) ? this.BaseEvent.listParent.part.partInfo.title + ": " + this.BaseEvent.GUIName : "none") +
return ((this.BaseEvent != null) ? this.BaseEvent.listParent.part.partInfo.title + ": " + this.GUIName : "none") +
Environment.NewLine + base.Description;
}
}
Expand All @@ -45,6 +47,7 @@ public static EventCommand Event(BaseEvent ev)
return new EventCommand()
{
BaseEvent = ev,
GUIName = ev.GUIName,
TimeStamp = RTUtil.GameTime,
};
}
Expand All @@ -65,11 +68,13 @@ public override void Load(ConfigNode n, FlightComputer fc)

if (n.HasValue("flightID"))
this.flightID = uint.Parse(n.GetValue("flightID"));

this.Module = n.GetValue("Module");
this.GUIName = n.GetValue("GUIName");
this.Name = n.GetValue("Name");

Module = n.GetValue("Module");
GUIName = n.GetValue("GUIName");

RTLog.Notify("Try to load an EventCommand from persistent with {0},{1},{2},{3}", PartId, flightID, Module, GUIName);
RTLog.Notify("Try to load an EventCommand from persistent with {0},{1},{2},{3},{4}",
PartId, this.flightID, this.Module, this.GUIName, this.Name);

Part part = null;
var partlist = FlightGlobals.ActiveVessel.parts;
Expand All @@ -93,7 +98,7 @@ public override void Load(ConfigNode n, FlightComputer fc)
BaseEventList eventlist = new BaseEventList(part, partmodule);
if (eventlist.Count > 0)
{
this.BaseEvent = eventlist.Where(ba => ba.GUIName == this.GUIName).FirstOrDefault();
this.BaseEvent = eventlist.Where(ba => (ba.GUIName == this.GUIName || ba.name == this.Name)).FirstOrDefault();
}
}
}
Expand All @@ -104,9 +109,10 @@ public override void Load(ConfigNode n, FlightComputer fc)
/// </summary>
public override void Save(ConfigNode n, FlightComputer fc)
{
GUIName = this.BaseEvent.GUIName;
flightID = this.BaseEvent.listParent.module.part.flightID;
Module = this.BaseEvent.listParent.module.ClassName.ToString();
this.GUIName = this.BaseEvent.GUIName;
this.flightID = this.BaseEvent.listParent.module.part.flightID;
this.Module = this.BaseEvent.listParent.module.ClassName.ToString();
this.Name = this.BaseEvent.name;

base.Save(n, fc);
}
Expand Down
21 changes: 15 additions & 6 deletions src/RemoteTech/Modules/ProtoSignalProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,24 @@ public ProtoSignalProcessor(ProtoPartModuleSnapshot ppms, Vessel v)
mVessel = v;
Powered = ppms.GetBool("IsRTPowered");

// get the crew count from the vessel
int crewcount = v.GetVesselCrew().Count;
// when the crewcount is eq 0 than look into the protoVessel
if (crewcount == 0 && v.protoVessel.GetVesselCrew() != null)
crewcount = v.protoVessel.GetVesselCrew().Count;

RTLog.Notify("ProtoSignalProcessor crew count of {0} is {1}", v.vesselName, crewcount);

try {
IsCommandStation = Powered && v.HasCommandStation() && v.GetVesselCrew().Count >= ppms.GetInt("RTCommandMinCrew");
RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2}/{3})",
Powered, v.HasCommandStation(), v.GetVesselCrew().Count, ppms.GetInt("RTCommandMinCrew"));
} catch (ArgumentException) {
IsCommandStation = Powered && v.HasCommandStation() && crewcount >= ppms.GetInt("RTCommandMinCrew");
RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2}/{3})",
Powered, v.HasCommandStation(), crewcount, ppms.GetInt("RTCommandMinCrew"));
} catch (ArgumentException argexeception) {
// I'm assuming this would get thrown by ppms.GetInt()... do the other functions have an exception spec?
IsCommandStation = false;
RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2})",
Powered, v.HasCommandStation(), v.GetVesselCrew().Count);
RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2})",
Powered, v.HasCommandStation(), crewcount);
RTLog.Notify("ProtoSignalProcessor ", argexeception);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/RemoteTech/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RemoteTech")]
[assembly: AssemblyCopyright("Copyright © 2013-2014")]
[assembly: AssemblyCopyright("Copyright © 2013-2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -37,7 +37,7 @@
// DLLs any time it changes. Breaking on a minor revision is probably acceptable - it's
// unlikely that there wouldn't be other breaking changes on a minor version change.
[assembly: AssemblyVersion("1.6")]
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.3")]

// Use KSPAssembly to allow other DLLs to make this DLL a dependency in a
// non-hacky way in KSP. Format is (AssemblyProduct, major, minor), and it
Expand Down
11 changes: 9 additions & 2 deletions src/RemoteTech/RTUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ public static partial class RTUtil
{
public static double GameTime { get { return Planetarium.GetUniversalTime(); } }
/// <summary>
/// Returns the current AssemplyVersion from AssemblyInfos.cs
/// Returns the current AssemplyFileVersion from AssemblyInfos.cs
/// </summary>
public static string Version { get{ return "v"+Assembly.GetExecutingAssembly().GetName().Version.ToString(); } }
public static string Version
{
get
{
Assembly executableAssembly = Assembly.GetExecutingAssembly();
return "v" + FileVersionInfo.GetVersionInfo(executableAssembly.Location).ProductVersion.ToString();
}
}

public static readonly String[]
DistanceUnits = { "", "k", "M", "G", "T" },
Expand Down
37 changes: 27 additions & 10 deletions src/RemoteTech/SatelliteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,24 +209,41 @@ public static bool IsSignalProcessor(this PartModule pm)
public static ISignalProcessor GetSignalProcessor(this Vessel v)
{
RTLog.Notify("GetSignalProcessor({0}): Check", v.vesselName);
if (v.loaded)

ISignalProcessor result = null;

if (v.loaded && v.parts.Count > 0)
{
foreach (PartModule pm in v.Parts.SelectMany(p => p.Modules.Cast<PartModule>()).Where(pm => pm.IsSignalProcessor()))
var partModuleList = v.Parts.SelectMany(p => p.Modules.Cast<PartModule>()).Where(pm => pm.IsSignalProcessor());
// try to look for a moduleSPU
result = partModuleList.Where(pm => pm.moduleName == "ModuleSPU").FirstOrDefault() as ISignalProcessor;

if (result == null)
{
RTLog.Notify("GetSignalProcessor({0}): Found", v.vesselName);
return pm as ISignalProcessor;
// otherwise get the first moduleSpuPassive
result = partModuleList.FirstOrDefault() as ISignalProcessor;
}

}
else
{
foreach (ProtoPartModuleSnapshot ppms in v.protoVessel.protoPartSnapshots.SelectMany(x => x.modules).Where(ppms => ppms.IsSignalProcessor()))
var protoPartList = v.protoVessel.protoPartSnapshots.SelectMany(x => x.modules).Where(ppms => ppms.IsSignalProcessor());
// try to look for a moduleSPU on a unloaded vessel
var protoPartProcessor = protoPartList.Where(ppms => ppms.moduleName == "ModuleSPU").FirstOrDefault();

if (protoPartProcessor == null)
{
RTLog.Notify("GetSignalProcessor({0}): Found", v.vesselName);
return new ProtoSignalProcessor(ppms, v);
// otherwise get the first moduleSpuPassive
protoPartProcessor = protoPartList.FirstOrDefault();
}

// convert the found protoPartSnapshots to a ProtoSignalProcessor
if (protoPartProcessor != null)
{
result = new ProtoSignalProcessor(protoPartProcessor, v);
}
}
return null;

return result;
}

public static bool IsCommandStation(this ProtoPartModuleSnapshot ppms)
Expand All @@ -242,7 +259,7 @@ public static bool IsCommandStation(this PartModule pm)
public static bool HasCommandStation(this Vessel v)
{
RTLog.Notify("HasCommandStation({0})", v.vesselName);
if (v.loaded)
if (v.loaded && v.parts.Count > 0)
{
return v.Parts.SelectMany(p => p.Modules.Cast<PartModule>()).Any(pm => pm.IsCommandStation());
}
Expand Down

0 comments on commit 3dc7652

Please sign in to comment.