Skip to content

Commit cc18b59

Browse files
Fixed bug where coming out of timewarp to get science would lock the maneuver
1 parent 03b98b5 commit cc18b59

File tree

5 files changed

+59
-55
lines changed

5 files changed

+59
-55
lines changed

ChangeLog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
1.9.5
2+
Fixed bug where coming out of timewarp to get science would lock the maneuver node
13

24
1.9.4.4
35
Fixed download link in .version file

GameData/ScienceAlert/ScienceAlert.version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"VERSION": {
1010
"MAJOR": 1,
1111
"MINOR": 9,
12-
"PATCH": 4,
13-
"BUILD": 4
12+
"PATCH": 5,
13+
"BUILD": 0
1414
},
1515
"KSP_VERSION": {
1616
"MAJOR": 1,

ScienceAlert.version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"VERSION": {
1010
"MAJOR": 1,
1111
"MINOR": 9,
12-
"PATCH": 4,
13-
"BUILD": 4
12+
"PATCH": 5,
13+
"BUILD": 0
1414
},
1515
"KSP_VERSION": {
1616
"MAJOR": 1,

Source/AssemblyVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
using System.Reflection;
1111

12-
[assembly: AssemblyVersion("1.9.4.4")]
12+
[assembly: AssemblyVersion("1.9.5.0")]

Source/ScienceAlert.Experiments/ExperimentManager.cs

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class ExperimentManager : MonoBehaviour
2626

2727
string lastGoodBiome = string.Empty; // if BiomeFilter tells us the biome it got is probably not real, then we can use
2828

29-
AudioPlayer audio;
29+
AudioPlayer audio;
3030

3131
// --------------------------------------------------------------------
3232
// Events
@@ -115,71 +115,73 @@ private System.Collections.IEnumerator UpdateObservers()
115115
if (observers.Count == 0)
116116
{
117117
ScienceAlert.Instance.SetUnlit();
118-
} else
119-
for (int i = observers.Count - 1; i >= 0; i--)
120-
{
121-
ExperimentObserver observer = observers[i];
122-
try
118+
}
119+
else
120+
for (int i = observers.Count - 1; i >= 0; i--)
121+
{
122+
ExperimentObserver observer = observers[i];
123+
try
123124
{
124125
#if PROFILE
125126
float start = Time.realtimeSinceStartup;
126127
#endif
127-
bool newReport = false;
128+
bool newReport = false;
128129

129-
// Is exciting new research available?
130-
if (observer.UpdateStatus(expSituation, out newReport))
131-
{
132-
// if we're timewarping, resume normal time if that setting was used
133-
if (observer.StopWarpOnDiscovery || Settings.Instance.GlobalWarp == Settings.WarpSetting.GlobalOn)
134-
if (Settings.Instance.GlobalWarp != Settings.WarpSetting.GlobalOff)
135-
if (TimeWarp.CurrentRateIndex > 0)
136-
{
137-
OrbitSnapshot snap = new OrbitSnapshot(FlightGlobals.ActiveVessel.GetOrbitDriver().orbit);
138-
TimeWarp.SetRate(0, true);
139-
FlightGlobals.ActiveVessel.GetOrbitDriver().orbit = snap.Load();
140-
FlightGlobals.ActiveVessel.GetOrbitDriver().orbit.UpdateFromUT(Planetarium.GetUniversalTime());
141-
}
130+
// Is exciting new research available?
131+
if (observer.UpdateStatus(expSituation, out newReport))
132+
{
133+
// if we're timewarping, resume normal time if that setting was used
134+
if (observer.StopWarpOnDiscovery || Settings.Instance.GlobalWarp == Settings.WarpSetting.GlobalOn)
135+
if (Settings.Instance.GlobalWarp != Settings.WarpSetting.GlobalOff)
136+
if (TimeWarp.CurrentRateIndex > 0)
137+
{
138+
//OrbitSnapshot snap = new OrbitSnapshot(FlightGlobals.ActiveVessel.GetOrbitDriver().orbit);
139+
TimeWarp.fetch.CancelAutoWarp();
140+
TimeWarp.SetRate(0, true);
141+
//FlightGlobals.ActiveVessel.GetOrbitDriver().orbit = snap.Load();
142+
//FlightGlobals.ActiveVessel.GetOrbitDriver().orbit.UpdateFromUT(Planetarium.GetUniversalTime());
143+
}
142144

143145
#if false
144146
scienceAlert.Button.Important = true;
145147
#endif
146148

147-
if (observer.settings.AnimationOnDiscovery)
148-
ScienceAlert.Instance.PlayAnimation();
149-
else ScienceAlert.Instance.SetLit(); // if (scienceAlert.Button.IsNormal) scienceAlert.Button.SetLit();
150-
151-
switch (Settings.Instance.SoundNotification)
152-
{
153-
case Settings.SoundNotifySetting.ByExperiment:
154-
if (observer.settings.SoundOnDiscovery)
149+
if (observer.settings.AnimationOnDiscovery)
150+
ScienceAlert.Instance.PlayAnimation();
151+
else ScienceAlert.Instance.SetLit(); // if (scienceAlert.Button.IsNormal) scienceAlert.Button.SetLit();
152+
153+
switch (Settings.Instance.SoundNotification)
154+
{
155+
case Settings.SoundNotifySetting.ByExperiment:
156+
if (observer.settings.SoundOnDiscovery)
157+
audio.PlayUI("bubbles", 2f);
158+
break;
159+
case Settings.SoundNotifySetting.Always:
155160
audio.PlayUI("bubbles", 2f);
156-
break;
157-
case Settings.SoundNotifySetting.Always:
158-
audio.PlayUI("bubbles", 2f);
159-
break;
161+
break;
162+
}
163+
OnExperimentAvailable(observer.Experiment, observer.NextReportValue);
160164
}
161-
OnExperimentAvailable(observer.Experiment, observer.NextReportValue);
162-
}
163-
else if (!observers.Any(ob => ob.Available))
164-
{
165-
ScienceAlert.Instance.SetUnlit();
165+
else if (!observers.Any(ob => ob.Available))
166+
{
167+
ScienceAlert.Instance.SetUnlit();
166168
#if false
167169
scienceAlert.Button.Important = false;
168170
#endif
169171

170-
}
172+
}
171173
#if PROFILE
172174
Log.Warning("Tick time ({1}): {0} ms", (Time.realtimeSinceStartup - start) * 1000f, observer.ExperimentTitle);
173175
#endif
174-
}
175-
catch (Exception e)
176-
{
177-
Log.Debug("ExperimentManager.UpdateObservers: exception {0}", e);
178-
}
176+
}
177+
catch (Exception e)
178+
{
179+
Log.Debug("ExperimentManager.UpdateObservers: exception {0}", e);
180+
}
179181

180-
if (TimeWarp.CurrentRate < Settings.Instance.TimeWarpCheckThreshold)
181-
yield return 0; // pause until next frame
182-
} // end observer loop
182+
if (TimeWarp.CurrentRate < Settings.Instance.TimeWarpCheckThreshold)
183+
yield return 0; // pause until next frame
184+
} // end observer loop
183185
yield return 0;
184186
} // end infinite while loop
185187
}
@@ -204,7 +206,7 @@ public int RebuildObserverList()
204206
{
205207
var m = FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceExperiment>().Where(mse => mse.experimentID == expid).ToList();
206208
if (m.Count > 0)
207-
{
209+
{
208210
if (!ExcludeFilters.IsExcluded(m[0]))
209211
{
210212
observers.Add(new ExperimentObserver(vesselStorage, ProfileManager.ActiveProfile[expid], biomeFilter, scanInterface, expid, m[0]));
@@ -242,9 +244,9 @@ public int RebuildObserverList()
242244
return observers.Count;
243245
}
244246

245-
#endregion
247+
#endregion
246248

247-
#region Message handling functions
249+
#region Message handling functions
248250

249251
private void OnScanInterfaceChanged()
250252
{
@@ -256,7 +258,7 @@ private void OnToolbarButtonChanged()
256258
RebuildObserverList();
257259
}
258260

259-
#endregion
261+
#endregion
260262

261263
public ReadOnlyCollection<ExperimentObserver> Observers => new ReadOnlyCollection<ExperimentObserver>(observers);
262264
}

0 commit comments

Comments
 (0)