Repository navigation
Expand file tree
/
Copy pathServerBootstrap.cs
More file actions
executable file
·77 lines (68 loc) · 3.04 KB
/
Copy pathServerBootstrap.cs
File metadata and controls
executable file
·77 lines (68 loc) · 3.04 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using AMP.DedicatedServer;
using AMP.Logging;
namespace AMP.Bootstrap {
class Launcher {
static void Main(string[] args) {
Main(new CommandLine(args));
}
private static List<string> missingFiles = new List<string>();
static void Main(CommandLine cmd) {
if(cmd.HasArg("?") || cmd.HasArg("help")) {
Console.WriteLine("Possible Arguments:");
Console.WriteLine("-port <port>\t\tSpecify a port, this will override the config file");
Console.WriteLine("-password <password>\tSpecify a password");
Console.WriteLine("-max_players <num>\tSpecify a max amount of player, this will override the config file");
Console.WriteLine("-pvp <true/false>\tSets PvP state");
} else {
try {
Rename("ZZZ_AMP.dll", "AMP.dll");
Rename("ZZZ_AMP.pdb", "AMP.pdb");
CheckFile("Netamite.dll");
CheckFile("Netamite.Steam.dll");
CheckFile("Netamite.Unity.dll");
CheckFile("Netamite.Unity.Voice.dll");
CheckFile("Newtonsoft.Json.dll");
CheckFile("Unity.ResourceManager.dll");
CheckFile("UnityEngine.CoreModule.dll");
CheckFile("UnityEngine.PhysicsModule.dll");
CheckFile("UnityEngine.SharedInternalsModule.dll");
CheckFile("ThunderRoad.dll");
CheckFile("ThunderRoad.Manikin.dll");
if(missingFiles.Count == 0) {
ServerInit.Start(cmd);
} else {
throw new Exception("Missing dependencies:\n" + string.Join("\n", missingFiles) + "\n\nRead which files are required in the README");
}
} catch(Exception ex) {
//Console.WriteLine(ex.ToString());
Log.Err("Error: " + ex.Message);
Log.Err("\nAn error occurred. See latest error.txt entry");
using(StreamWriter writer = new StreamWriter("error.txt", true)) {
writer.WriteLine("\n--- " + DateTime.Now.ToString() + " ---");
writer.Write(ex.ToString());
}
Thread.Sleep(10000);
}
}
}
public static void Rename(string file, string output) {
bool output_exists = File.Exists(output);
if (File.Exists(file) && !output_exists) {
File.Move(file, output);
Log.Warn("Found " + file + " renamed it to " + output);
} else if (!output_exists) {
missingFiles.Add(output);
}
}
public static void CheckFile(string file) {
if (!File.Exists(file)) {
missingFiles.Add(file);
}
}
}
}