public ServerMonitor(Server server, GameExit exit) { this.server = server; this.LoadConfig(); this.Exit = exit; this.monitorClients = new Dictionary <int, MonitorClient>(); }
public ServerMonitor(Server server, GameExit exit) { this.server = server; this.LoadConfig(); this.Exit = exit; this.monitorClients = new Dictionary<int, MonitorClient>(); }
public ServerConsole(Server server, GameExit exit) { this.server = server; this.Exit = exit; // run command line reader as seperate thread Thread consoleInterpreterThread = new Thread(new ThreadStart(this.CommandLineReader)); consoleInterpreterThread.Start(); }
public AudioTask(GameExit gameexit, AudioDataCs sample, AudioOpenAl audio) { this.gameexit = gameexit; this.sample = sample; this.audio = audio; }
private LaunchResult Launch(LaunchSetting setting) { try { IsBusyLaunching = true; lock (launchLocker) { if (Java == null) { return(new LaunchResult(new NullJavaException())); } if (setting.AuthenticateResult == null) { return(new LaunchResult(new ArgumentException("启动所需必要的验证参数为空"))); } if (setting.Version == null) { return(new LaunchResult(new ArgumentException("启动所需必要的版本参数为空"))); } if (setting.MaxMemory == 0) { setting.MaxMemory = SystemTools.GetBestMemory(this.Java); } Stopwatch sw = new Stopwatch(); sw.Start(); if (setting.LaunchType == LaunchType.SAFE) { setting.AdvencedGameArguments = null; setting.AdvencedJvmArguments = null; setting.GCArgument = null; setting.JavaAgent = null; } string arg = argumentsParser.Parse(setting); if (setting.LaunchType == LaunchType.CREATE_SHORT) { File.WriteAllText(Environment.CurrentDirectory + "\\LaunchMinecraft.bat", string.Format("\"{0}\" {1}", Java.Path, arg)); return(new LaunchResult() { IsSuccess = true, LaunchArguments = arg }); } #region 处理库文件 foreach (var item in setting.Version.Natives) { string nativePath = GetNativePath(item); if (File.Exists(nativePath)) { AppendLaunchInfoLog(string.Format("检查并解压不存在的库文件:{0}", nativePath)); Unzip.UnZipNativeFile(nativePath, GetGameVersionRootDir(setting.Version) + @"\$natives", item.Exclude, setting.LaunchType != LaunchType.SAFE); } else { return(new LaunchResult(new NativeNotFoundException(item, nativePath))); } } #endregion AppendLaunchInfoLog(string.Format("开始启动游戏进程,使用JAVA路径:{0}", this.Java.Path)); ProcessStartInfo startInfo = new ProcessStartInfo(Java.Path, arg) { RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false, WorkingDirectory = GetGameVersionRootDir(setting.Version) }; var process = Process.Start(startInfo); sw.Stop(); long launchUsingMsTime = sw.ElapsedMilliseconds; AppendLaunchInfoLog(string.Format("成功启动游戏进程,总共用时:{0}ms", launchUsingMsTime)); Task.Factory.StartNew(() => { process.WaitForExit(); AppendLaunchInfoLog("游戏进程退出,代码:" + process.ExitCode); GameExit?.Invoke(this, new GameExitArg() { Process = process, Version = setting.Version, ExitCode = process.ExitCode, Duration = (process.StartTime - process.ExitTime) }); }); process.OutputDataReceived += Process_OutputDataReceived; process.ErrorDataReceived += Process_ErrorDataReceived; process.BeginErrorReadLine(); process.BeginOutputReadLine(); return(new LaunchResult() { Process = process, IsSuccess = true, LaunchArguments = arg, LaunchUsingMs = launchUsingMsTime }); } } catch (LaunchException.LaunchException ex) { return(new LaunchResult(ex)); } catch (Exception ex) { return(new LaunchResult(ex)); } finally { IsBusyLaunching = false; } }
private LaunchResult Launch(LaunchSetting setting) { try { if (setting.AuthenticateAccessToken == null || setting.AuthenticateUUID == null) { return(new LaunchResult(new ArgumentException("启动所需必要的验证参数为空"))); } if (setting.Version == null) { return(new LaunchResult(new ArgumentException("启动所需必要的版本参数为空"))); } if (setting.MaxMemory == 0) { setting.MaxMemory = SystemTools.GetBestMemory(this.Java); } Stopwatch sw = new Stopwatch(); sw.Start(); string arg = argumentsParser.Parse(setting); #region 处理库文件 foreach (var item in setting.Version.Natives) { string nativePath = GetNativePath(item); if (File.Exists(nativePath)) { App.logHandler.AppendDebug(string.Format("检查并解压不存在的库文件:{0}", nativePath)); Unzip.UnZipFile(nativePath, GetGameVersionRootDir(setting.Version) + @"\$natives", item.Exclude); } else { return(new LaunchResult(new NativeNotFoundException(item, nativePath))); } } #endregion ProcessStartInfo startInfo = new ProcessStartInfo(Java.Path, arg) { RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false, WorkingDirectory = GetGameVersionRootDir(setting.Version) }; var process = Process.Start(startInfo); sw.Stop(); App.logHandler.AppendInfo(string.Format("成功启动游戏进程,总共用时:{0}ms", sw.ElapsedMilliseconds)); Task.Factory.StartNew(() => { process.WaitForExit(); App.logHandler.AppendInfo("游戏进程退出,代码:" + process.ExitCode); GameExit?.Invoke(this, process.ExitCode); }); process.OutputDataReceived += Process_OutputDataReceived; process.ErrorDataReceived += Process_ErrorDataReceived; process.BeginErrorReadLine(); process.BeginOutputReadLine(); #region 配置文件 App.config.MainConfig.History.LastLaunchUsingMs = sw.ElapsedMilliseconds; App.config.MainConfig.History.LastLaunchTime = DateTime.Now; App.config.MainConfig.History.LastLaunchVersion = setting.Version.ID; App.config.Save(); #endregion return(new LaunchResult() { Process = process, IsSuccess = true, LaunchArguments = arg }); } catch (LaunchException.LaunchException ex) { return(new LaunchResult(ex)); } catch (Exception ex) { return(new LaunchResult(ex)); } }
public void SetExit(GameExit exit) { gameexit = exit; }
private void GameStart_Tick(object sender, EventArgs e) { GameStart.Stop(); KillGameProcess(); Debug.Print("InitLevel - " + InitLevel + " - "); switch (InitLevel) { case 1: // 서버 연결 확인 HttpWebRequest request; HttpWebResponse response; HttpStatusCode[] statuscode = new HttpStatusCode[2]; try { request = (HttpWebRequest)WebRequest.Create(new Uri(Program.InfowebURL)); request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); response = (HttpWebResponse)request.GetResponse(); statuscode[0] = response.StatusCode; response.Close(); request = (HttpWebRequest)WebRequest.Create(new Uri(Program.LauncherURL)); request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); response = (HttpWebResponse)request.GetResponse(); statuscode[1] = response.StatusCode; response.Close(); } catch { statuscode[0] = statuscode[1] = HttpStatusCode.NotFound; } if (statuscode[0] != HttpStatusCode.OK && statuscode[1] != HttpStatusCode.OK) { PercentageLabel.Text = "서버에 연결할 수 없습니다."; Button_2_1.Text = "인포웹"; Button_2_2.Text = "종료"; SetButtonEvent(Button_2_1, ButtonEvent_OpenInfoweb); SetButtonEvent(Button_2_2, ButtonEvent_Exit); ShowButtons(2); this.TopMost = true; this.TopMost = false; } else { GameStart.Start(); } break; case 2: // 런처 업데이트 StartUpdate(); break; case 3: // 게임 구성 파일 변조 검사 및 패치 // 비인가 프로그램 차단 (파일 변조 검사 제외) ResetAuthorizedFiles(); LoadAuthorizedFilesFromServer(Program.LauncherURL + "/getfilelist.do?type=allowedfiles"); LoadAuthorizedFilesFromServer(Program.LauncherURL + "/getfilelist.do?type=patch"); LoadAuthorizedFilesFromServer(Program.LauncherURL + "/getfilelist.do?type=launcher"); if (BlockUnauthorizedPrograms()) { return; } // 검사 및 패치 if (!CompareMD5OfGameFile(Program.LauncherURL + "/getfilelist.do?type=patch")) { StartPatch(Program.LauncherURL + "/patch", GetDissimilarFiles()); } else { // 게임 실행 단계 진행 GameStart.Start(); } break; case 4: // 게임 실행 // 비인가 프로그램 차단 (파일 변조 검사 포함) if (BlockUnauthorizedPrograms()) { return; } // 닉네임 레지스트리 동기화 SaveUsernameToRegistry(); if (GetNewLauncherPath() != String.Empty) { // URL Scheme CreateUrlSchemeRegistry(); // 최신 런처 실행 RunNewLauncher(); } else if (string.Compare(GetUsername(), "NULL") == 0) { Button_2_1.Text = "인포웹"; Button_2_2.Text = "종료"; SetButtonEvent(Button_2_1, ButtonEvent_OpenInfoweb); SetButtonEvent(Button_2_2, ButtonEvent_Exit); ShowButtons(2); alert("설치 완료", false); } else if (!GenerateToken(ref CToken, Program.LauncherURL + "/auth.do", "conn")) { Button_1_1.Text = "종료"; SetButtonEvent(Button_1_1, ButtonEvent_Exit); ShowButtons(1); alert("접속 인증 실패", false); } else { PercentageLabel.Text = "게임에 접속중입니다."; // IP 등록 RegisterIP(); // SAMP 실행 StartedGamePath = GetGamePath(); Process.Start(Path.Combine(StartedGamePath, "samp.exe"), "server.la-rp.co.kr"); GameExit.Start(); GameAuth.Start(); } break; } InitLevel++; }