Skip to content

Commit dc605c7

Browse files
Close the loophole of sneaking in other commands to execute during hibernation
1 parent 0566aab commit dc605c7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/RemoteTech/FlightComputer/Commands/HibernationCommand.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ public override bool Execute(FlightComputer fc, FlightCtrlState ctrlState)
113113
mStartHibernation = false;
114114
return false;
115115
}
116+
else
117+
{
118+
//drop any queued non-power command up to next hiberation command (wake)
119+
var cmdsToDrop = new List<ICommand>();
120+
for(int i=0; i<fc.QueuedCommands.Count(); i++)
121+
{
122+
if (!(fc.QueuedCommands.ElementAt(i) is HibernationCommand))
123+
cmdsToDrop.Add(fc.QueuedCommands.ElementAt(i));
124+
else
125+
break;//found next hiberation command
126+
}
127+
128+
for (int i = 0; i < cmdsToDrop.Count; i++)
129+
{
130+
fc.Remove(cmdsToDrop[i]);
131+
}
132+
}
116133

117134
return false;
118135
}

0 commit comments

Comments
 (0)