Skip to content

Commit

Permalink
Merge pull request #31 from JPLRepo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Jamie Leighton committed Oct 30, 2015
2 parents 149bb85 + 017290f commit d591ff1
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 156 deletions.
Binary file modified DeepFreeze.zip
Binary file not shown.
Binary file modified GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll
Binary file not shown.
Binary file not shown.
7 changes: 6 additions & 1 deletion Source/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[B]V0.19.1.0 "Bug fixes & Enhancements"[/B]
[B]V0.19.2.0 "Bug fixes & Enhancements"[/B]
Fix distribution to include missing Editor group icon from V0.19.0.0 that somehow got left out of V0.19.1.0.
Fix bug that V0.19.2.0 introduced that was causing invalid seat placements and
Add more robust checking of Seat placements for frozen kerbals to avoid bugs that have been occurring for some users.
Fix seat placement when a freeze/thaw process is aborted.
[B]V0.19.1.0 "Bug fixes & Enhancements"[/B]
Added comatose function for when EC or Heat options are ON and Fatal option is OFF. Now when you run out of EC or overheat with these options set kerbals will be emergency thawed
and become comatose (tourists) for a period of 5 minutes (can be changed in the settings menu).
Fixed bug with new pop-up windows when EC is critical or overheat - this pop-up will now NOT appear if the active vessel is the vessel that has run out of EC or overheat.
Expand Down
32 changes: 21 additions & 11 deletions Source/DFIntMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ private void FixedUpdate()
{
if (HighLogic.LoadedSceneIsEditor || Time.timeSinceLevelLoad < 5f) return; //Wait 5 seconds on level load before executing

//Check if the active vessel has changed and if so, process.
if (HighLogic.LoadedSceneIsFlight)
{
if (FlightGlobals.ActiveVessel.id != ActVslID)
{
onVesselChange(FlightGlobals.ActiveVessel);
}
}
//We check/update kerbal Dictionary for comatose kerbals in EVERY Game Scene.
try
{
Expand All @@ -332,8 +340,7 @@ private void FixedUpdate()
//We check/update Vessel and Part Dictionary in EVERY Game Scene.
try
{
if (DeepFreeze.Instance.DFgameSettings.knownVessels.Count() > 0)
CheckVslUpdate();
CheckVslUpdate();
}
catch (Exception ex)
{
Expand All @@ -360,22 +367,23 @@ private void CheckComaUpdate()
{
// Check the knownfrozenkerbals for any tourists kerbals (IE: Comatose) if their time is up and reset them if it is.
var keysToDelete = new List<string>();
foreach (KeyValuePair<string, KerbalInfo> comaKerbals in DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals)
List<KeyValuePair<string, KerbalInfo>> comaKerbals = DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Where(e => e.Value.type == ProtoCrewMember.KerbalType.Tourist).ToList();
foreach (KeyValuePair<string, KerbalInfo> comaKerbal in comaKerbals)
{
if (comaKerbals.Value.type == ProtoCrewMember.KerbalType.Tourist)
if (comaKerbal.Value.type == ProtoCrewMember.KerbalType.Tourist)
{
if (Planetarium.GetUniversalTime() - comaKerbals.Value.lastUpdate > (double)DeepFreeze.Instance.DFsettings.comatoseTime) // Is time up?
if (Planetarium.GetUniversalTime() - comaKerbal.Value.lastUpdate > (double)DeepFreeze.Instance.DFsettings.comatoseTime) // Is time up?
{
ProtoCrewMember crew = HighLogic.CurrentGame.CrewRoster.Tourist.FirstOrDefault(a => a.name == comaKerbals.Key);
ProtoCrewMember crew = HighLogic.CurrentGame.CrewRoster.Tourist.FirstOrDefault(a => a.name == comaKerbal.Key);
if (crew != null)
{
Utilities.setComatoseKerbal(crew, ProtoCrewMember.KerbalType.Crew);
keysToDelete.Add(comaKerbals.Key);
keysToDelete.Add(comaKerbal.Key);
}
else
{
this.Log("Unable to set comatose crew member " + comaKerbals.Key + " back to crew status.");
}
this.Log("Unable to set comatose crew member " + comaKerbal.Key + " back to crew status.");
}
}
}
}
Expand Down Expand Up @@ -517,6 +525,7 @@ internal void onVesselCreate(Vessel vessel)
if (frznKerbals.Value.partID == frzr.part.flightID)
{
frznKerbals.Value.vesselID = vessel.id;
frznKerbals.Value.vesselName = vessel.vesselName;
}
}
//Update the Frzr Parts internal frozenkerbals list GUID
Expand All @@ -525,7 +534,7 @@ internal void onVesselCreate(Vessel vessel)
storedCrew.VesselID = vessel.id;
}
}
}
}
}

internal void onPartCouple(GameEvents.FromToAction<Part, Part> fromToAction)
Expand All @@ -548,6 +557,7 @@ internal void onPartCouple(GameEvents.FromToAction<Part, Part> fromToAction)
if (frznKerbals.Value.partID == frzr.part.flightID)
{
frznKerbals.Value.vesselID = fromToAction.to.vessel.id;
frznKerbals.Value.vesselName = fromToAction.to.vessel.vesselName;
}
}
//Update the Frzr Parts internal frozenkerbals list GUID
Expand All @@ -567,7 +577,7 @@ internal void onPartCouple(GameEvents.FromToAction<Part, Part> fromToAction)
}

internal void onVesselChange(Vessel vessel)
{
{
if (HighLogic.LoadedSceneIsFlight)
{
this.Log_Debug("OnVesselChange activevessel " + FlightGlobals.ActiveVessel.name + "(" + FlightGlobals.ActiveVessel.id + ") parametervessel " + vessel.name + "(" + vessel.id + ")");
Expand Down
62 changes: 46 additions & 16 deletions Source/DeepFreeze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,39 @@ protected void onVesselRecovered(ProtoVessel vessel)
KerbalInfo kerbalinfo = DFgameSettings.KnownFrozenKerbals[key];
if (kerbalinfo.vesselID == vessel.vesselID)
{
if (DeepFreeze.Instance.DFsettings.AutoRecoverFznKerbals)
if (kerbalinfo.type == ProtoCrewMember.KerbalType.Unowned) //Frozen crew
{
this.Log_Debug("AutoRecover is ON");
this.Log("Calling ThawFrozen Crew to thaw FrozenCrew " + key);
ThawFrozenCrew(key, vessel.vesselID);
}
else
{
this.Log("DeepFreeze AutoRecovery of frozen kerbals is set to off. Must be thawed manually.");
this.Log("DeepFreezeEvents frozenkerbal remains frozen =" + key);
ProtoCrewMember realkerbal = HighLogic.CurrentGame.CrewRoster.Unowned.FirstOrDefault(b => b.name == key);
if (realkerbal != null)
if (DeepFreeze.Instance.DFsettings.AutoRecoverFznKerbals)
{
this.Log_Debug("AutoRecover is ON");
this.Log("Calling ThawFrozen Crew to thaw FrozenCrew " + key);
ThawFrozenCrew(key, vessel.vesselID);
}
else
{
realkerbal.type = ProtoCrewMember.KerbalType.Unowned;
realkerbal.rosterStatus = ProtoCrewMember.RosterStatus.Dead;
this.Log_Debug("Kerbal " + realkerbal.name + " " + realkerbal.type + " " + realkerbal.rosterStatus);
ScreenMessages.PostScreenMessage(key + " was stored frozen at KSC", 5.0f, ScreenMessageStyle.UPPER_RIGHT);
this.Log("DeepFreeze AutoRecovery of frozen kerbals is set to off. Must be thawed manually.");
this.Log("DeepFreezeEvents frozenkerbal remains frozen =" + key);
ProtoCrewMember realkerbal = HighLogic.CurrentGame.CrewRoster.Unowned.FirstOrDefault(b => b.name == key);
if (realkerbal != null)
{
realkerbal.type = ProtoCrewMember.KerbalType.Unowned;
realkerbal.rosterStatus = ProtoCrewMember.RosterStatus.Dead;
this.Log_Debug("Kerbal " + realkerbal.name + " " + realkerbal.type + " " + realkerbal.rosterStatus);
ScreenMessages.PostScreenMessage(key + " was stored frozen at KSC", 5.0f, ScreenMessageStyle.UPPER_RIGHT);
}
}
}
else // Tourist/Comatose crew
{
this.Log_Debug("Comatose crew - reset to crew " + key);
ProtoCrewMember crew = HighLogic.CurrentGame.CrewRoster.Tourist.FirstOrDefault(c => c.name == key);
crew.type = ProtoCrewMember.KerbalType.Crew;
crew.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
this.Log_Debug("Kerbal " + crew.name + " " + crew.type + " " + crew.rosterStatus);
crew.ArchiveFlightLog();
crew.rosterStatus = ProtoCrewMember.RosterStatus.Available;
DFgameSettings.KnownFrozenKerbals.Remove(crew.name);
}
}
}
var alarmsToDelete = new List<string>();
Expand Down Expand Up @@ -317,7 +331,23 @@ internal void KillFrozenCrew(string FrozenCrew)
}
}
else
this.Log("DeepFreezeEvents " + kerbal.name + " couldn't find them to kill them.");
{
// check if comatose crew
ProtoCrewMember crew = HighLogic.CurrentGame.CrewRoster.Tourist.FirstOrDefault(a => a.name == FrozenCrew);
if (crew != null)
{
this.Log("DeepFreezeEvents " + kerbal.name + " killed");
kerbal.type = ProtoCrewMember.KerbalType.Crew;
kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Dead;
if (HighLogic.CurrentGame.Parameters.Difficulty.MissingCrewsRespawn == true)
{
kerbal.StartRespawnPeriod();
this.Log("DeepFreezeEvents " + kerbal.name + " respawn started.");
}
}
else
this.Log("DeepFreezeEvents " + kerbal.name + " couldn't find them to kill them.");
}
}

#endregion Events
Expand Down
3 changes: 2 additions & 1 deletion Source/DeepFreeze.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="PartInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="DeepFreezeGUI.cs" />
<None Include="RPMScreenDeepFreeze.cs" />
<Compile Include="RTWrapper.cs" />
<Compile Include="TRWrapper.cs" />
<Compile Include="USIWrapper.cs" />
Expand Down Expand Up @@ -103,7 +104,7 @@ if %25ERRORLEVEL%25 == 1 (
if exist "$(SolutionDir)..\$(ProjectName).zip" del "$(SolutionDir)..\$(ProjectName).zip"

c:\7za\7za a -tzip -r "$(SolutionDir)..\$(ProjectName).zip" "$(SolutionDir)..\GameData"
c:\7za\7za d -r -x!REPOSoftTech.png -x!Glykerol.png -x!DFtoolbar.png -x!DeepFreezeOff.png -x!DeepFreezeOn.png -x!alphaonly.png "$(SolutionDir)..\$(ProjectName).zip" "*.ddsified" "*.pdb" "*.mdb" "*.png"
c:\7za\7za d -r -x!REPOSoftTech.png -x!Glykerol.png -x!DFtoolbar.png -x!DeepFreezeOff.png -x!DeepFreezeOn.png -x!DeepFreezeEditor.png -x!alphaonly.png "$(SolutionDir)..\$(ProjectName).zip" "*.ddsified" "*.pdb" "*.mdb" "*.png"
xcopy /E /Y "$(SolutionDir)..\GameData" "%25KSP_DIR%25\GameData"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
8 changes: 4 additions & 4 deletions Source/DeepFreezeGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ private void windowDF(int id)
{
showSwitchVessel = true;
}
}
}
break;
}
}
Expand Down Expand Up @@ -722,7 +722,7 @@ private void windowDF(int id)
}
}
}
}
}
GUILayout.EndHorizontal();
//}
}
Expand Down Expand Up @@ -763,7 +763,7 @@ private void windowDF(int id)
frzr.beginFreezeKerbal(crewMember);
}
GUI.enabled = true;
}
}
GUILayout.EndHorizontal();
}
}
Expand Down Expand Up @@ -1417,7 +1417,7 @@ private void HandleResizeEventsDF(Rect resizeRect)
DFvslPrtElec = Mathf.Round((DFwindowPos.width - 28f) / 12.3f);
DFvslAlarms = Mathf.Round((DFwindowPos.width - 28f) / 8f);
DFvslLstUpd = Mathf.Round((DFwindowPos.width - 28f) / 5.5f);
DFvslRT = Mathf.Round((DFwindowPos.width - 28f) / 12.3f);
DFvslRT = Mathf.Round((DFwindowPos.width - 28f) / 12.3f);
}
else
{
Expand Down
Loading

0 comments on commit d591ff1

Please sign in to comment.