summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/ServerInfo.cs
blob: f952619702138b28e0e7890a78f95047b5744ca4 (plain)
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
using System;
using System.IO;
using System.Net;

public class ServerInfo
{
	public string Name = "Custom";

	public string Ip = "0.0.0.0";

	public bool Default;

	public void Serialize(BinaryWriter writer)
	{
		writer.Write(this.Name);
		writer.Write(this.Ip);
		writer.Write(this.Default);
	}

	public static ServerInfo Deserialize(BinaryReader reader)
	{
		ServerInfo serverInfo = new ServerInfo();
		serverInfo.Name = reader.ReadString();
		serverInfo.Ip = reader.ReadString();
		IPAddress ipaddress;
		if (!IPAddress.TryParse(serverInfo.Ip, out ipaddress))
		{
			return null;
		}
		serverInfo.Default = reader.ReadBoolean();
		return serverInfo;
	}

	internal static ServerInfo Deserialize(string[] parts)
	{
		return new ServerInfo
		{
			Name = parts[0],
			Ip = parts[1],
			Default = bool.Parse(parts[2])
		};
	}
}