From e6f6226bdb8c927bf30ac78ef3fe50b0e0f9a803 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 6 Dec 2017 11:50:16 -0500 Subject: [PATCH] BYOND updates block compiles and recompile the game using the staged version --- TGS.Interface/Enumerations.cs | 4 ++++ TGS.Server/Instance/Byond.cs | 8 ++++++-- TGS.Server/Instance/Compiler.cs | 19 +++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/TGS.Interface/Enumerations.cs b/TGS.Interface/Enumerations.cs index b1d9586769..caca32e31b 100644 --- a/TGS.Interface/Enumerations.cs +++ b/TGS.Interface/Enumerations.cs @@ -55,6 +55,10 @@ namespace TGS.Interface /// Revision is being applied /// Updating, + /// + /// Running game code is being recompiled under staged update + /// + CompilingStaged, } /// /// Type of byond version diff --git a/TGS.Server/Instance/Byond.cs b/TGS.Server/Instance/Byond.cs index 643a896292..04790bca9d 100644 --- a/TGS.Server/Instance/Byond.cs +++ b/TGS.Server/Instance/Byond.cs @@ -118,6 +118,7 @@ namespace TGS.Server case ByondStatus.Downloading: case ByondStatus.Staging: case ByondStatus.Updating: + case ByondStatus.CompilingStaged: return true; case ByondStatus.Idle: case ByondStatus.Staged: @@ -204,7 +205,7 @@ namespace TGS.Server return; updateStat = ByondStatus.Downloading; } - + bool staged = false; try { CleanByondStaging(); @@ -266,10 +267,11 @@ namespace TGS.Server lastError = "Failed to apply update!"; break; default: - RequestRestart(); + //Compile() will call RequestRestart() lastError = "Update staged. Awaiting server restart..."; SendMessage(String.Format("BYOND: Staging complete. Awaiting server restart...", major, minor), MessageType.DeveloperInfo); WriteInfo(String.Format("BYOND update {0}.{1} staged", major, minor), EventID.BYONDUpdateStaged); + staged = true; break; } } @@ -287,6 +289,8 @@ namespace TGS.Server RevisionStaging = null; } } + if(staged) + Compile(); } /// public bool UpdateToVersion(int major, int minor) diff --git a/TGS.Server/Instance/Compiler.cs b/TGS.Server/Instance/Compiler.cs index 9e8d87814d..87e933ea33 100644 --- a/TGS.Server/Instance/Compiler.cs +++ b/TGS.Server/Instance/Compiler.cs @@ -421,7 +421,14 @@ namespace TGS.Server using (var DM = new Process()) //will kill the process if the thread is terminated { - DM.StartInfo.FileName = RelativePath(ByondDirectory + "/bin/dm.exe"); + bool stagedBuild; + lock (ByondLock) + { + stagedBuild = updateStat == ByondStatus.Staged; + if (stagedBuild) + updateStat = ByondStatus.CompilingStaged; + } + DM.StartInfo.FileName = RelativePath(Path.Combine(stagedBuild ? StagingDirectoryInner : ByondDirectory, "bin/dm.exe")); DM.StartInfo.Arguments = String.Format("-clean {0}", dmePath); DM.StartInfo.RedirectStandardOutput = true; DM.StartInfo.UseShellExecute = false; @@ -469,6 +476,12 @@ namespace TGS.Server { canCancelCompilation = false; } + if (stagedBuild) + { + lock (ByondLock) + updateStat = ByondStatus.Staged; + RequestRestart(); + } } if (DM.ExitCode == 0) @@ -525,7 +538,6 @@ namespace TGS.Server } } } - } catch (ThreadAbortException) { @@ -564,6 +576,9 @@ namespace TGS.Server { if (compilerCurrentStatus != CompilerStatus.Initialized) return false; + lock (ByondLock) + if (updateStat == ByondStatus.Staged) + return false; silentCompile = silent; lastCompilerError = null; compilerCurrentStatus = CompilerStatus.Compiling;