Exemplo n.º 1
0
 public void CopyVerificationLog(IEnumerable <string> log)
 {
     foreach (string entry in log)
     {
         VerificationLog.Add(entry);
     }
 }
Exemplo n.º 2
0
        public virtual bool ExtractInputLog(TextReader reader, out string errorMessage)
        {
            errorMessage = string.Empty;
            int?stateFrame = null;

            // We are in record mode so replace the movie log with the one from the savestate
            if (!Global.MovieSession.MultiTrack.IsActive)
            {
                if (Global.Config.EnableBackupMovies && MakeBackup && _log.Count != 0)
                {
                    SaveBackup();
                    MakeBackup = false;
                }

                _log.Clear();
                while (true)
                {
                    var line = reader.ReadLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    // in BK2, this is part of the input log, and not involved with the core state at all
                    // accordingly, this case (for special neshawk format frame numbers) is irrelevant
                    // probably
                    else if (line.Contains("Frame 0x"))                     // NES stores frame count in hex, yay
                    {
                        var strs = line.Split('x');
                        try
                        {
                            stateFrame = int.Parse(strs[1], NumberStyles.HexNumber);
                        }
                        catch
                        {
                            errorMessage = "Savestate Frame number failed to parse";
                            return(false);
                        }
                    }
                    else if (line.Contains("Frame "))
                    {
                        var strs = line.Split(' ');
                        try
                        {
                            stateFrame = int.Parse(strs[1]);
                        }
                        catch
                        {
                            errorMessage = "Savestate Frame number failed to parse";
                            return(false);
                        }
                    }
                    else if (line.StartsWith("LogKey:"))
                    {
                        LogKey = line.Replace("LogKey:", "");
                    }
                    else if (line[0] == '|')
                    {
                        _log.Add(line);
                    }
                }
            }
            else
            {
                var i = 0;
                while (true)
                {
                    var line = reader.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    if (line.Contains("Frame 0x"))                     // NES stores frame count in hex, yay
                    {
                        var strs = line.Split('x');
                        try
                        {
                            stateFrame = int.Parse(strs[1], NumberStyles.HexNumber);
                        }
                        catch
                        {
                            errorMessage = "Savestate Frame number failed to parse";
                            return(false);
                        }
                    }
                    else if (line.Contains("Frame "))
                    {
                        var strs = line.Split(' ');
                        try
                        {
                            stateFrame = int.Parse(strs[1]);
                        }
                        catch
                        {
                            errorMessage = "Savestate Frame number failed to parse";
                            return(false);
                        }
                    }
                    else if (line.StartsWith("LogKey:"))
                    {
                        LogKey = line.Replace("LogKey:", "");
                    }
                    else if (line.StartsWith("|"))
                    {
                        SetFrameAt(i, line);
                        i++;
                    }
                }
            }

            if (!stateFrame.HasValue)
            {
                errorMessage = "Savestate Frame number failed to parse";
            }

            var stateFramei = stateFrame ?? 0;

            if (stateFramei > 0 && stateFramei < _log.Count)
            {
                if (!Global.Config.VBAStyleMovieLoadState)
                {
                    Truncate(stateFramei);
                }
            }
            else if (stateFramei > _log.Count)             // Post movie savestate
            {
                if (!Global.Config.VBAStyleMovieLoadState)
                {
                    Truncate(_log.Count);
                }

                _mode = Moviemode.Finished;
            }

            if (IsCountingRerecords)
            {
                Rerecords++;
            }

            return(true);
        }