Skip to content

Commit 9b1ec40

Browse files
committed
steamclient update check
1 parent 207f4c8 commit 9b1ec40

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

‎Torch.Server/Initializer.cs‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ public bool Initialize(string[] args)
9191
File.Copy(apiSource, apiTarget);
9292
}
9393

94+
95+
// Steam Client 64-bit DLL
96+
var clientSource64 = Path.Combine(basePath, "DedicatedServer64", "steamclient64.dll");
97+
var clientTarget64 = Path.Combine(basePath, "steamclient64.dll");
98+
CopyAndVerifyDll(clientSource64, clientTarget64, new Version("9.86.62.31"));
99+
100+
// Steam Client 32-bit DLL
101+
var clientSource = Path.Combine(basePath, "DedicatedServer64", "steamclient.dll");
102+
var clientTarget = Path.Combine(basePath, "steamclient.dll");
103+
CopyAndVerifyDll(clientSource, clientTarget, new Version("9.86.62.31"));
104+
94105
var havokSource = Path.Combine(basePath, "DedicatedServer64", "Havok.dll");
95106
var havokTarget = Path.Combine(basePath, "Havok.dll");
96107

@@ -233,6 +244,32 @@ public static void RunSteamCmd()
233244
Thread.Sleep(100);
234245
}
235246
}
247+
248+
private void CopyAndVerifyDll(string sourcePath, string targetPath, Version requiredVersion = null)
249+
{
250+
if (!File.Exists(targetPath))
251+
{
252+
File.Copy(sourcePath, targetPath);
253+
return;
254+
}
255+
256+
if (requiredVersion != null)
257+
{
258+
var targetVersion = FileVersionInfo.GetVersionInfo(targetPath);
259+
var currentVersion = new Version(targetVersion.FileVersion);
260+
261+
if (currentVersion != requiredVersion)
262+
{
263+
File.Delete(targetPath);
264+
File.Copy(sourcePath, targetPath);
265+
}
266+
}
267+
else if (File.GetLastWriteTime(targetPath) < File.GetLastWriteTime(sourcePath))
268+
{
269+
File.Delete(targetPath);
270+
File.Copy(sourcePath, targetPath);
271+
}
272+
}
236273

237274
private void LogException(Exception ex)
238275
{

0 commit comments

Comments
 (0)