Repository navigation
Expand file tree
/
Copy pathCommandLine.cs
More file actions
executable file
·51 lines (45 loc) · 1.52 KB
/
Copy pathCommandLine.cs
File metadata and controls
executable file
·51 lines (45 loc) · 1.52 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
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace AMP.DedicatedServer {
public class CommandLine {
private Dictionary<string, string> args = new Dictionary<string, string>();
public CommandLine(string[] args) {
if (UsingOldCommandLine(args)) {
if (args.Length > 0) {
this.args["port"] = args[0];
}
if (args.Length > 1) {
this.args["max_players"] = args[1];
}
} else {
for (int i=0; i<args.Length; i++) {
if (args[i].StartsWith("-") || args[i].StartsWith("/")) {
if ((args.Length - 1) > i) {
this.args[args[i].Substring(1)] = args[i + 1];
} else {
this.args[args[i].Substring(1)] = "";
}
}
}
}
}
public bool HasArg(string name) {
return args.ContainsKey(name);
}
public string GetArg(string name)
{
return args[name];
}
private bool UsingOldCommandLine(string[] args) {
if (args.Length > 0) {
for (int i=0; i<args.Length; i++) {
if (args[i].StartsWith("-") || args[i].StartsWith("/")) {
return false;
}
}
}
return true;
}
}
}