From d33a54560505a3a561559c222b61ed168034ff00 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 18 May 2014 00:09:01 +0000 Subject: [PATCH] Virtual Pads - Fix out of range exception when virtual pad is open, a movie is playing, and the movie goes into finished mode --- .../tools/VirtualPads/VirtualPadForm.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPadForm.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPadForm.cs index e3039842f7..56ade6df5a 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPadForm.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPadForm.cs @@ -88,9 +88,13 @@ namespace BizHawk.Client.EmuHawk if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished) { - for (int i = 0; i < Pads.Count; i++) + var inputs = CurrentFrameInputs; // THis is necessary because of the weird situation on the frame after the end of the movie, it goes into finished mode AFTER the input is read so this will be empty on that frame + if (inputs.Any()) { - Pads[i].SetButtons(CurrentFrameInputs[i]); + for (int i = 0; i < Pads.Count; i++) + { + Pads[i].SetButtons(inputs[i]); + } } } else if (!Global.Config.VirtualPadSticky)