This is a bit off topic, but here is a great way to always have a complete up to date server list in C#.
static class clsServers
{
public static List<clsServer> Servers = new List<clsServer>();
/// <summary>
/// Retrieve battle.net's server list.
/// </summary>
public static void Init()
{
//Populate server list
GetServerList("USWest.battle.net", "@USWest", "@Lordaeron");
GetServerList("USEast.battle.net", "@USEast", "@Azeroth");
GetServerList("Europe.battle.net", "@Europe", "@Northrend");
GetServerList("Asia.battle.net", "@Asia", "@Kalimdor");
}
private static void GetServerList(string server, string tag1, string tag2)
{
IPAddress[] result = Dns.GetHostEntry(server).AddressList;
Servers.Add(new clsServer(server, tag1, tag2));
foreach (IPAddress ip in result)
{
Servers.Add(new clsServer(ip.ToString(), tag1, tag2));
}
}
}
class clsServer
{
public string ServerIP;
public string LegacyTag;
public string WAR3Tag;
public clsServer(string serverip, string legacytag, string war3tag)
{
ServerIP = serverip;
LegacyTag = legacytag;
WAR3Tag = war3tag;
}
}
This allows for both domain names and IP's to be used as an address for the battle.net server.
IPAddress[] result = Dns.GetHostEntry(server).AddressList;
Gets all the IP's from the specified sub domain name that can be used to logon to battle.net
[MyndFyre edit: Split from the Regex for capturing topic /]
Do you want it to be 100% complete?
GetServerList("Beta.battle.net", "@ClassicBeta", "@Westfall");
GetServerList("demo.war3.battle.net", "", "");
The first is the PTR server on Battle.net, the second is the War3 Demo server, which has no namespace as far as i'm aware. Although, I haven't done much testing on it. It's basically a stripped down Battle.net server, but it is still a Battle.net server nonetheless.
Do you think it's wise to include beta servers to a bot the average user is going to be using?
the point is to handle all aspects, what's one line to make it less limited?
It may confuse the less educated.
Quote from: -MichaeL- on August 11, 2009, 08:30 PM
It may confuse the less educated.
Is that why you prefix a class name with "cls" (http://msdn.microsoft.com/en-us/library/ms229040.aspx)?
Yes, it's a VB6 habit however it doesn't hurt.
Quote from: -MichaeL- on August 11, 2009, 07:33 PM
Do you think it's wise to include beta servers to a bot the average user is going to be using?
Yes, otherwise you shouldn't say "complete up to date server list".