0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 08:30:45 -05:00
modules/project/SPT.Core/Utils/ValidationUtil.cs
Cj c0721317e4 Fix duplicate logging (!151)
Fixes a duplicate set of logging requests sent to the server for no reason.

Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com>
Reviewed-on: SPT/Modules#151
Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com>
Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
2024-07-25 21:58:35 +00:00

64 lines
2.0 KiB
C#

using SPT.Common.Utils;
using Microsoft.Win32;
using System.IO;
namespace SPT.Core.Utils
{
public static class ValidationUtil
{
private static bool _hasRun = false;
public static bool Validate()
{
var c0 = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov";
var v0 = 0;
try
{
var v1 = Registry.LocalMachine.OpenSubKey(c0, false).GetValue("InstallLocation");
var v2 = (v1 != null) ? v1.ToString() : string.Empty;
var v3 = new DirectoryInfo(v2);
var v4 = new FileSystemInfo[]
{
v3,
new FileInfo(Path.Combine(v2, @"BattlEye\BEClient_x64.dll")),
new FileInfo(Path.Combine(v2, @"BattlEye\BEService_x64.exe")),
new FileInfo(Path.Combine(v2, "ConsistencyInfo")),
new FileInfo(Path.Combine(v2, "Uninstall.exe")),
new FileInfo(Path.Combine(v2, "UnityCrashHandler64.exe"))
};
if (!_hasRun)
{
ServerLog.Debug("SPT.Core", Gfs(v2, "UnityCrashHandler64.exe")?.Length.ToString() ?? "0");
ServerLog.Debug("SPT.Core", Gfs(v2, "Uninstall.exe")?.Length.ToString() ?? "0");
ServerLog.Debug("SPT.Core", Gfs(v2, "Register.bat")?.Length.ToString() ?? "0");
_hasRun = true;
}
v0 = v4.Length - 1;
foreach (var value in v4)
{
if (File.Exists(value.FullName))
{
--v0;
}
}
}
catch
{
v0 = -1;
}
return v0 == 0;
}
private static FileInfo Gfs(string p, string f)
{
var a = Path.Combine(p, f);
return File.Exists(a) ? new FileInfo(a) : null;
}
}
}