Пример #1
0
        public GhostReplayServer(int port, string GameId, string Region, string gameepath, string LolDir, string replayfile)
            : base(port)
        {
            if (Process.GetProcessesByName("League of Legends").Length != 0)
            {
                return;
            }
            if (!File.Exists(replayfile))
            {
                //  [DISABLED] Console.WriteLine("Cannot find replay");
                return;
            }

            rep = new GhostReplay(replayfile, "0.0.0.0", false, AppDomain.CurrentDomain.BaseDirectory + @"\Temp");

            rep.ReadReplay(ReadMode.All);

            LatestChunk                         = 1;
            NextChunk                           = 2;
            LatestKeyframe                      = 1;
            FChunk                              = new ChunkInfo();
            FChunk.chunkId                      = rep.MetaData.startGameChunkId;
            FChunk.startGameChunkId             = rep.MetaData.startGameChunkId;
            FChunk.endGameChunkId               = 0;
            FChunk.endStartupChunkId            = rep.MetaData.endStartupChunkId;
            FChunk.nextAvailableChunk           = 500;
            FChunk.nextChunkId                  = rep.MetaData.startGameChunkId + 1;
            FChunk.keyFrameId                   = 1;
            FChunk.duration                     = 30000;
            FChunk.availableSince               = 30000;
            rep.MetaData.clientBackFetchingFreq = 50;
            foreach (GameData f in rep.Chunks)
            {
                int ChunkId = f.Id;
                if (ChunkId > LastChunk)
                {
                    LastChunk = ChunkId;
                }
            }



            foreach (GameData f in rep.Keys)
            {
                int KeyId = f.Id;
                if (KeyId < LatestKeyframe)
                {
                    LatestKeyframe = KeyId;
                }
            }

            Process p = new System.Diagnostics.Process();

            p.StartInfo.WorkingDirectory = LolDir;
            p.StartInfo.UseShellExecute  = false;
            p.EnableRaisingEvents        = true;
            p.Exited             += p_Exited;
            p.StartInfo.FileName  = Path.Combine(LolDir, "League of Legends.exe");
            p.StartInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"spectator "
                                    + "127.0.0.1:" + port.ToString() + " "
                                    + rep.ObserverKey + " "
                                    + GameId + " "
                                    + Region + "\"";

            p.Start();

            GhostOverlay.ShowOverlay(LolDir);


            SetHome(rep, GameId, Region);
        }
Пример #2
0
        static void Main()
        {
            try{
                if (!SingleInstance.Start())
                {
                    File.WriteAllLines(Application.StartupPath + @"\ARGS.t", Environment.GetCommandLineArgs());
                    SingleInstance.ShowFirstInstance();
                    return;
                }
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GhostBase.GhostbladeInstance.Init();
                RiotSharp.ApiCache.CacheEnabled = true;
                RiotSharp.ApiCache.Initialize();
                // Register App
                ApplicationInstance.Instance.Register("CID");

                if (!File.Exists(Application.StartupPath + @"\Config.txt"))
                {
                    SettingsManager.Default();

                    SettingsForm frm = new SettingsForm();
                    frm.ShowDialog();
                }
                else
                {
                    SettingsManager.Init();
                    if (System.Windows.Forms.SystemInformation.Network)
                    {
                        Thread thr = new Thread(new ThreadStart(CheckForUpdates));
                        thr.Start();
                        thr.Join();
                    }
                }
                // Api cache
                RiotSharp.ApiCache.CacheEnabled = SettingsManager.Settings.ApiCacheEnabled;



                Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                // Load Interfaces

                MethodInvoker mi = new MethodInvoker(NetworkManager.Init);
                mi.BeginInvoke(null, null);

                // GHOSTOVERLAY
                GhostOverlay.StartServer();

                MainFormInstance            = new MainForm();
                GhostbladeInstance.MainForm = MainFormInstance;
                Application.Run(MainFormInstance);
            }
            catch (Exception ex)
            {
                SendCrashReport(ex);
                Logger.Instance.Log.Fatal("Global fail", ex);
            }
            finally
            {
                if (RiotTool.pi != null)
                {
                    RiotTool.pi.Dispose();
                }

                if (SettingsManager.Settings.ProxyOption == ProxyType.Network && NetworkManager.DefaultProxy != null)
                {
                    ((NetworkInterfaceProxy)NetworkManager.DefaultProxy).Stop();
                }

                // Api cache
                RiotSharp.ApiCache.Close
                    ();
                GhostOverlay.Stop();
                StreamManager.Stop();
                SingleInstance.Stop();
            }
        }