forked from josh4364/IL2cppStartProcess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInternalServerProcess.cs
More file actions
53 lines (45 loc) · 1.47 KB
/
InternalServerProcess.cs
File metadata and controls
53 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System.IO;
using System.Runtime.InteropServices;
using UnityEngine;
namespace Lavender.Systems
{
internal static class InternalServerProcess
{
static uint ptr = 0;
public static void Start()
{
var processPath = Directory.GetCurrentDirectory() + "/Lavender.exe";
Debug.Log($"ProcessPath:{processPath}");
if (File.Exists(processPath))
{
Debug.Log($"File Exists, preping ini settings");
Settings.SetSetting("Server_StartMap", true);
var settings = Settings.ExportSettings();
var args = $" -batchmode -nographics -server -logFile \"server_log.txt\" -ini ~{settings}~";
Debug.Log($"Args:{args}");
if (ptr != 0)
{
Debug.Log("Internal server process already exists");
}
else
{
ptr = StartExternalProcess.StartProcess(Directory.GetCurrentDirectory(), processPath + args);
Debug.Log($"pid:{ptr}");
}
}
else
{
Debug.Log($"File doesnt exist");
}
}
public static void Stop()
{
Debug.Log($"killing if running pid:{ptr}");
if (ptr != 0)
{
Debug.Log($"killing");
StartExternalProcess.KillProcess(ptr);
}
}
}
}