Exemplo n.º 1
0
        public static Tuple <ReplayParseResult, Replay> ParseReplay(string fileName, bool deleteFile, ParseOptions parseOptions)
        {
            try
            {
                var replay = new Replay();

                // File in the version numbers for later use.
                MpqHeader.ParseHeader(replay, fileName);

                if (!parseOptions.IgnoreErrors && replay.ReplayBuild < 32455)
                {
                    return(new Tuple <ReplayParseResult, Replay>(ReplayParseResult.PreAlphaWipe, null));
                }

                using (var archive = new MpqArchive(fileName))
                    ParseReplayArchive(replay, archive, parseOptions);

                if (deleteFile)
                {
                    File.Delete(fileName);
                }

                return(ParseReplayResults(replay, parseOptions.IgnoreErrors, parseOptions.AllowPTR));
            }
            catch
            {
                return(new Tuple <ReplayParseResult, Replay>(ReplayParseResult.Exception, null));
            }
        }
Exemplo n.º 2
0
        public static Tuple <ReplayParseResult, Replay> ParseReplay(byte[] bytes, ParseOptions parseOptions)
        {
            try
            {
                var replay = new Replay();

                // File in the version numbers for later use.
                MpqHeader.ParseHeader(replay, bytes);

                if (!parseOptions.IgnoreErrors && replay.ReplayBuild < 32455)
                {
                    return(new Tuple <ReplayParseResult, Replay>(ReplayParseResult.PreAlphaWipe, null));
                }
                using (var memoryStream = new MemoryStream(bytes))
                    using (var archive = new MpqArchive(memoryStream))
                        ParseReplayArchive(replay, archive, parseOptions);

                return(ParseReplayResults(replay, parseOptions.IgnoreErrors, parseOptions.AllowPTR));
            }
            catch
            {
                return(new Tuple <ReplayParseResult, Replay>(ReplayParseResult.Exception, null));
            }
        }