Exemple #1
0
 public static bool CheckGameDef(GameDef game)
 {
     Program.Game = new Game(game);
     Program.Game.TestBegin();
     var engine = new Engine(true);
     string[] terr = engine.TestScripts(Program.Game);
     Program.Game.End();
     if (terr.Length > 0)
     {
         String ewe = terr.Aggregate("",
                                     (current, s) =>
                                     current +
                                     (s + Environment.NewLine));
         var er = new Windows.ErrorWindow(ewe);
         er.ShowDialog();
     }
     return terr.Length == 0;
 }
Exemple #2
0
        public static bool CheckGameDef(GameDef game)
        {
            Program.Game = new Game(game);
            Program.Game.TestBegin();
            var engine = new Engine(true);

            string[] terr = engine.TestScripts(Program.Game);
            Program.Game.End();
            if (terr.Length > 0)
            {
                String ewe = terr.Aggregate("",
                                            (current, s) =>
                                            current +
                                            (s + Environment.NewLine));
                var er = new Windows.ErrorWindow(ewe);
                er.ShowDialog();
            }
            return(terr.Length == 0);
        }
        private void VerifyAllDefs()
        {
            UpdateStatus("Loading Game Definitions...");
            try
            {
                var g2R = new List<Data.Game>();
                using (MD5 md5 = new MD5CryptoServiceProvider())
                {
                    foreach (Data.Game g in Program.GamesRepository.Games)
                    {
                        string fhash = "";

                        UpdateStatus("Checking Game: " + g.Name);
                        var fpath = g.FullPath;
                        if (!File.Exists(fpath))
                        {
                            _errors.Add("[" + g.Name + "]: Def file doesn't exist at " + fpath);
                            continue;
                        }
                        using (var file = new FileStream(fpath, FileMode.Open))
                        {
                            byte[] retVal = md5.ComputeHash(file);
                            fhash = BitConverter.ToString(retVal).Replace("-", ""); // hex string
                        }
                        if (fhash.ToLower() == g.FileHash.ToLower()) continue;

                        Program.Game = new Game(GameDef.FromO8G(fpath));
                        Program.Game.TestBegin();
                        //IEnumerable<Player> plz = Player.All;
                        var engine = new Engine(true);
                        string[] terr = engine.TestScripts(Program.Game);
                        Program.Game.End();
                        if (terr.Length <= 0)
                        {
                            Program.GamesRepository.UpdateGameHash(g,fhash);
                            continue;
                        }
                        _errors.AddRange(terr);
                        g2R.Add(g);
                    }
                }
                foreach (Data.Game g in g2R)
                    Program.GamesRepository.Games.Remove(g);
                if (_errors.Count > 0)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                                                          {
                                                              String ewe = _errors.Aggregate("",
                                                                                             (current, s) =>
                                                                                             current +
                                                                                             (s + Environment.NewLine));
                                                              var er = new Windows.ErrorWindow(ewe);
                                                              er.ShowDialog();
                                                          }));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                if (Debugger.IsAttached) Debugger.Break();
            }
        }
Exemple #4
0
        private void VerifyAllDefs()
        {
            UpdateStatus("Loading Game Definitions...");
            try
            {
                var g2R = new List <Data.Game>();
                using (MD5 md5 = new MD5CryptoServiceProvider())
                {
                    foreach (Data.Game g in Program.GamesRepository.Games)
                    {
                        string fhash = "";

                        UpdateStatus("Checking Game: " + g.Name);
                        var fpath = g.FullPath;
                        if (!File.Exists(fpath))
                        {
                            _errors.Add("[" + g.Name + "]: Def file doesn't exist at " + fpath);
                            continue;
                        }
                        using (var file = new FileStream(fpath, FileMode.Open))
                        {
                            byte[] retVal = md5.ComputeHash(file);
                            fhash = BitConverter.ToString(retVal).Replace("-", ""); // hex string
                        }
                        if (fhash.ToLower() == g.FileHash.ToLower())
                        {
                            continue;
                        }

                        Program.Game = new Game(GameDef.FromO8G(fpath));
                        Program.Game.TestBegin();
                        //IEnumerable<Player> plz = Player.All;
                        var      engine = new Engine(true);
                        string[] terr   = engine.TestScripts(Program.Game);
                        Program.Game.End();
                        if (terr.Length <= 0)
                        {
                            Program.GamesRepository.UpdateGameHash(g, fhash);
                            continue;
                        }
                        _errors.AddRange(terr);
                        g2R.Add(g);
                    }
                }
                foreach (Data.Game g in g2R)
                {
                    Program.GamesRepository.Games.Remove(g);
                }
                if (_errors.Count > 0)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        String ewe = _errors.Aggregate("",
                                                       (current, s) =>
                                                       current +
                                                       (s + Environment.NewLine));
                        var er = new Windows.ErrorWindow(ewe);
                        er.ShowDialog();
                    }));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
            }
        }