diff --git a/Assets/Scripts/ExternalFilesGetter.cs b/Assets/Scripts/ExternalFilesGetter.cs index 33e6cad..13230fd 100644 --- a/Assets/Scripts/ExternalFilesGetter.cs +++ b/Assets/Scripts/ExternalFilesGetter.cs @@ -114,6 +114,33 @@ public static class ExternalFilesGetter } } + public static bool NeedToStartServer() + { + string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + string filePath = Path.Combine(docPath, GAMEDATA_FOLDER, "serverOn.rr"); + + try + { + // Проверяем существование файла + if (!File.Exists(filePath)) return false; + + // Читаем содержимое файла + string content = File.ReadAllText(filePath).Trim(); + if (string.IsNullOrWhiteSpace(content)) return false; + + if(content == "1") + return true; + else + return false; + } + catch (Exception ex) + { + Debug.LogError($"Ошибка при чтении файла пароля: {ex.Message}"); + return false; + } + } + + public static string GetElektroVersion() { string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); @@ -149,6 +176,7 @@ public static class ExternalFilesGetter } } + public static char GetSensorPositiveValue() { string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); diff --git a/Assets/Scripts/Server/WebServer.cs b/Assets/Scripts/Server/WebServer.cs index 416efba..e6cfdbd 100644 --- a/Assets/Scripts/Server/WebServer.cs +++ b/Assets/Scripts/Server/WebServer.cs @@ -33,6 +33,12 @@ public class WebServer : MonoBehaviour async void Start() { + if(ExternalFilesGetter.NeedToStartServer() == false) + { + Debug.Log("Web сервер не запущен (по настройке)"); + return; + } + AdminPassword = AuthManager.LoadPasswordOrFallback(adminPasswordFallback, passwordFileName); LoadCss();