diff --git a/minecraft-launcher-client/Launcher.LaunchGame.cs b/minecraft-launcher-client/Launcher.LaunchGame.cs
index ac9c73b..9f8243b 100644
--- a/minecraft-launcher-client/Launcher.LaunchGame.cs
+++ b/minecraft-launcher-client/Launcher.LaunchGame.cs
@@ -1,6 +1,4 @@
-using System.Diagnostics;
-
-namespace launcher_client;
+namespace launcher_client;
internal static partial class Launcher
{
diff --git a/minecraft-launcher-client/Launcher.cs b/minecraft-launcher-client/Launcher.cs
index 1c9f103..87ff070 100644
--- a/minecraft-launcher-client/Launcher.cs
+++ b/minecraft-launcher-client/Launcher.cs
@@ -20,7 +20,7 @@ namespace launcher_client;
internal static partial class Launcher
{
- private static FileLogger _fileLogger = new("launcher-logs", "launcher_client");
+ private static FileLogger _fileLogger = new("launcher-logs", "launcher-client");
private static ILogger logger = new CompositeLogger(
_fileLogger,
new ConsoleLogger());
@@ -50,7 +50,6 @@ internal static partial class Launcher
? LauncherConfig.CreateDefault()
: LauncherConfig.LoadFromFile();
- DTLibInternalLogging.SetLogger(logger);
logger.DebugLogEnabled = debug;
logger.LogInfo("Main", "launcher is starting");
@@ -133,9 +132,9 @@ internal static partial class Launcher
FSP.DownloadByManifest("download_if_not_exist", Directory.GetCurrent());
FSP.DownloadByManifest("sync_always", Directory.GetCurrent(), true);
foreach (string dir in new DtsodV23(FSP
- .DownloadFileToMemory("sync_and_remove\\dirlist.dtsod")
+ .DownloadFileToMemory(Path.Concat("sync_and_remove","dirlist.dtsod"))
.BytesToString())["dirs"])
- FSP.DownloadByManifest("sync_and_remove\\" + dir,
+ FSP.DownloadByManifest(Path.Concat("sync_and_remove", dir),
Directory.GetCurrent() + '\\' + dir, true, true);
logger.LogInfo("Main", "client updated");
}
@@ -149,7 +148,7 @@ internal static partial class Launcher
config.GameWindowHeight,
Directory.GetCurrent());
logger.LogDebug("LaunchGame", gameOptions);
- var gameProcess = Process.Start($"{config.JavaPath}\\java.exe", gameOptions);
+ var gameProcess = Process.Start(config.JavaPath.Str, gameOptions);
gameProcess.WaitForExit();
logger.LogInfo("Main", "minecraft closed");
}
@@ -202,7 +201,6 @@ internal static partial class Launcher
mainSocket.Close();
mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
FSP = new FSP(mainSocket);
- FSP.debug = debug;
}
while (true)
diff --git a/minecraft-launcher-client/LauncherConfig.cs b/minecraft-launcher-client/LauncherConfig.cs
index a0cb695..0663817 100644
--- a/minecraft-launcher-client/LauncherConfig.cs
+++ b/minecraft-launcher-client/LauncherConfig.cs
@@ -5,12 +5,12 @@ namespace launcher_client;
public class LauncherConfig
{
- public static string ConfigFilePath = "launcher.dtsod";
+ public static IOPath ConfigFilePath = "minecraft-launcher.dtsod";
public int GameMemory = 3000;
public int GameWindowHeight = 500;
public int GameWindowWidth = 900;
- public string JavaPath = "jre\\bin";
+ public IOPath JavaPath = "jre/bin/java.exe";
public string ServerAddress = "127.0.0.1";
public int ServerPort = 25000;
public string Username = "";
@@ -36,7 +36,7 @@ public class LauncherConfig
{ "gameMemory", GameMemory },
{ "gameWindowHeight", GameWindowHeight },
{ "gameWindowWidth", GameWindowWidth },
- { "javaPath", JavaPath },
+ { "javaPath", JavaPath.Str },
{ "serverAddress", ServerAddress },
{ "serverPort", ServerPort },
{ "username", Username },
diff --git a/minecraft-launcher-client/launcher-client.csproj b/minecraft-launcher-client/launcher-client.csproj
index 0fd9642..51efaf7 100644
--- a/minecraft-launcher-client/launcher-client.csproj
+++ b/minecraft-launcher-client/launcher-client.csproj
@@ -13,8 +13,8 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/minecraft-launcher-client/launcher.dtsod b/minecraft-launcher-client/launcher.dtsod
deleted file mode 100644
index 28aa226..0000000
--- a/minecraft-launcher-client/launcher.dtsod
+++ /dev/null
@@ -1,8 +0,0 @@
-gameMemory: "3000";
-gameWindowWidth: "1600";
-gameWindowHeight: "1000";
-javaPath: "java\bin";
-serverAddress: "127.0.0.1";
-serverPort: 25000;
-username: "";
-uuid: "";
diff --git a/minecraft-launcher-server/Server.cs b/minecraft-launcher-server/Server.cs
index 6341224..cfda015 100644
--- a/minecraft-launcher-server/Server.cs
+++ b/minecraft-launcher-server/Server.cs
@@ -1,5 +1,4 @@
using System;
-using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
@@ -15,11 +14,11 @@ namespace launcher_server;
static class Server
{
private static ILogger logger = new CompositeLogger(
- new FileLogger("logs","launcher_server"),
+ new FileLogger("logs","launcher-server"),
new ConsoleLogger());
static readonly Socket mainSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
static DtsodV23 config = null!;
- static bool debug;
+ private static readonly IOPath shared_dir = "public";
static object manifestLocker = new();
@@ -30,11 +29,11 @@ static class Server
Console.Title = "minecraft_launcher_server";
Console.InputEncoding = Encoding.Unicode;
Console.OutputEncoding = Encoding.Unicode;
- DTLibInternalLogging.SetLogger(logger);
- config = new DtsodV23(File.ReadAllText("launcher-server.dtsod"));
- if (args.Contains("debug")) debug = true;
+
+ config = new DtsodV23(File.ReadAllText("minecraft-launcher-server.dtsod"));
+
logger.LogInfo("Main", $"local address: {config["local_ip"]}");
- logger.LogInfo("Main", $"public address: {OldNetwork.GetPublicIP()}");
+ logger.LogInfo("Main", $"public address: {Functions.GetPublicIP()}");
logger.LogInfo("Main", $"port: {config["local_port"]}");
mainSocket.Bind(new IPEndPoint(IPAddress.Parse(config["local_ip"]), config["local_port"]));
mainSocket.Listen(1000);
@@ -67,7 +66,7 @@ static class Server
handlerSocket.SendPackage("requesting user name");
string connectionString = handlerSocket.GetPackage().BytesToString();
FSP fsp = new(handlerSocket);
- FSP.debug = debug;
+
// запрос от апдейтера
if (connectionString == "minecraft-launcher")
{
@@ -83,12 +82,14 @@ static class Server
{
case "requesting launcher update":
logger.LogInfo(nameof(HandleUser), "updater requested launcher update");
- fsp.UploadFile("share\\minecraft-launcher.exe");
+ // ReSharper disable once InconsistentlySynchronizedField
+ fsp.UploadFile(Path.Concat(shared_dir, "minecraft-launcher.exe"));
break;
case "requesting file download":
var file = handlerSocket.GetPackage().BytesToString();
logger.LogInfo(nameof(HandleUser), $"updater requested file {file}");
- fsp.UploadFile($"share\\{file}");
+ // ReSharper disable once InconsistentlySynchronizedField
+ fsp.UploadFile(Path.Concat(shared_dir, file));
break;
default:
throw new Exception("unknown request: " + request);
@@ -118,26 +119,23 @@ static class Server
{
lock (manifestLocker)
{
- FSP.CreateManifest("share\\download_if_not_exist");
- FSP.CreateManifest("share\\sync_always");
- if(!Directory.Exists("share\\sync_and_remove"))
- {
- Directory.Create("share\\sync_and_remove");
- logger.LogInfo(nameof(CreateManifests), "can't create manifest, dir doesn't exist");
- }
- else foreach (string dir in Directory.GetDirectories("share\\sync_and_remove"))
+ var sync_and_remove_dir = Path.Concat(shared_dir, "sync_and_remove");
+ FSP.CreateManifest(Path.Concat(shared_dir, "download_if_not_exist"));
+ FSP.CreateManifest(Path.Concat(shared_dir, "sync_always"));
+ if (!Directory.Exists(sync_and_remove_dir))
+ Directory.Create(sync_and_remove_dir);
+ else foreach (var dir in Directory.GetDirectories(sync_and_remove_dir))
FSP.CreateManifest(dir);
- if(Directory.GetDirectories("share\\sync_and_remove").Length==0)
- File.WriteAllText("share\\sync_and_remove\\dirlist.dtsod", "dirs: [ ];");
- else
+ string dirlist_content = "dirs: [ ];";
+ if(Directory.GetDirectories(sync_and_remove_dir).Length > 0)
{
- File.WriteAllText("share\\sync_and_remove\\dirlist.dtsod",
- "dirs: [\""
- + Directory.GetDirectories("share\\sync_and_remove")
- .MergeToString("\", \"")
- .Replace("share\\sync_and_remove\\", "")
- + "\"];");
+ dirlist_content = "dirs: [\""
+ + Directory.GetDirectories(sync_and_remove_dir)
+ .MergeToString("\", \"")
+ .Replace(sync_and_remove_dir.Str, "")
+ + "\"];";
}
+ File.WriteAllText(Path.Concat(sync_and_remove_dir, "dirlist.dtsod"), dirlist_content);
}
}
}
\ No newline at end of file
diff --git a/minecraft-launcher-server/launcher-server.csproj b/minecraft-launcher-server/launcher-server.csproj
index f792dc0..1bed1eb 100644
--- a/minecraft-launcher-server/launcher-server.csproj
+++ b/minecraft-launcher-server/launcher-server.csproj
@@ -9,13 +9,13 @@
launcher.ico
-
+
Always
-
-
-
+
+
+
\ No newline at end of file
diff --git a/minecraft-launcher-server/launcher-server.dtsod b/minecraft-launcher-server/minecraft-launcher-server.dtsod
similarity index 52%
rename from minecraft-launcher-server/launcher-server.dtsod
rename to minecraft-launcher-server/minecraft-launcher-server.dtsod
index 42b937d..7ed1467 100644
--- a/minecraft-launcher-server/launcher-server.dtsod
+++ b/minecraft-launcher-server/minecraft-launcher-server.dtsod
@@ -1,2 +1,2 @@
local_ip: "127.0.0.1";
-local_port: 25000;
\ No newline at end of file
+local_port: 25000;