Ok.. heres the deal.. that "More than one server in server list" got me thinking.. shit that would be cool.. have like a test server and then live..
so for the past 4 hours ive been rescripting ServerList.cs ( to no avil )
Code:
// RunUO
// Serverlist.cs
// Tyson Clark ( tyson@tysonclark.com )
using System;
using System.Net;
using System.Net.Sockets;
using Server;
using Server.Network;
namespace Server.Misc
{
public class ServerList
{
int NumOfServers = 2; // Number of Servers ( Including Server A )
// YOUR SERVERS NAME
public const string ServerName = "ServerA"; // Server A's Name AKA Login Server
public const string ServerNameB = "ServerB"; // Server B's Name
//public const string ServerNameA = "ServerC"; // Server C's Name
//public const string ServerNameA = "ServerD"; // Server D's Name
//public const string ServerNameA = "ServerE"; // Server E's Name
//public const string ServerNameA = "ServerF"; // Server F's Name
//public const string ServerNameA = "ServerG"; // Server G's Name
// SERVER ADDRESSES
public static string Address = "192.168.1.142"; // Server A's IP AKA Login Server's IP
public static string AddressB = "192.168.1.142"; // Server B's IP
//public static string AddressC = "aoa.servebeer.com"; // Server C's IP
//public static string AddressD = "aoa.servebeer.com"; // Server D's IP
//public static string AddressE = "aoa.servebeer.com"; // Server E's IP
//public static string AddressF = "aoa.servebeer.com"; // Server F's IP
//public static string AddressG = "aoa.servebeer.com"; // Server G's IP
// SERVER PORTS
public const int PortA = 2593; // Server A's Port
public const int PortB = 2594; // Server B's Port
//public const int PortC = 2595; // Server C's Port
//public const int PortD = 2596; // Server D's Port
//public const int PortE = 2597; // Server E's Port
//public const int PortF = 2598; // Server F's Port
//public const int PortG = 2599; // Server G's Port
// ======================================================================================================================================
// Initialization
// ======================================================================================================================================
public static void Initialize()
{
Listener.Port = 2594; //THIS SERVER's port
EventSink.ServerList += new ServerListEventHandler(EventSink_ServerList);
Console.WriteLine("MultiServerList 2.0.1.1a");
Console.WriteLine("By Tyson Clark (tyson@tysonclark.com)");
Console.WriteLine("Adding Other Servers to list (god i hope)");
}
// ======================================================================================================================================
// EventSink_ServerList
// ======================================================================================================================================
public static void EventSink_ServerList(ServerListEventArgs e)
{
try
{
IPAddress ipAddrA;
IPAddress ipAddrB;
//IPAddress ipAddrC;
//IPAddress ipAddrD;
//IPAddress ipAddrE;
//IPAddress ipAddrF;
//IPAddress ipAddrG;
bool bIpAddrA = Resolve(Address != null && !IsLocalMachine(e.State) ? Address : Dns.GetHostName(), out ipAddrA);
bool bIpAddrB = Resolve(AddressB != null && !IsLocalMachine(e.State) ? Address : Dns.GetHostName(), out ipAddrB);
//bool bIpAddrC = Resolve( AddressC != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrC );
//bool bIpAddrD = Resolve( AddressD != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrD );
//bool bIpAddrE = Resolve( AddressE != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrE );
//bool bIpAddrF = Resolve( AddressF != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrF );
//bool bIpAddrG = Resolve( AddressG != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddrG );
// cout the current server info
Console.WriteLine("This Server Shit (address you gota know port tho is real)");
Console.Write(ipAddrA);
Console.Write(":");
Console.Write(Listener.Port);
Console.WriteLine(" ");
// ----------------------------------------------------
// Setup Server List
// ----------------------------------------------------
if (bIpAddrA)
{
Console.Write("Server A Address ");
Console.Write(ipAddrA);
Console.Write(":");
Console.Write(PortA);
Console.WriteLine(" ");
e.AddServer(ServerName, new IPEndPoint(ipAddrA, PortA));
}
else
e.Rejected = true;
if (bIpAddrB)
{
Console.Write("Server B Address ");
Console.Write(ipAddrB);
Console.Write(":");
Console.Write(PortB);
Console.WriteLine(" ");
e.AddServer(ServerNameB, new IPEndPoint(ipAddrB, PortB));
}
else
e.Rejected = true;
//if ( bIpAddrC )
// e.AddServer(ServerNameC, new IPEndPoint(ipAddrC, PortC));
//else
// e.Rejected = true;
//if ( bIpAddrD )
// e.AddServer(ServerNameD, new IPEndPoint(ipAddrD, PortD));
//else
// e.Rejected = true;
//if ( bIpAddrE )
// e.AddServer(ServerNameE, new IPEndPoint(ipAddrE, PortE));
// else
// e.Rejected = true;
//if ( bIpAddrF )
// e.AddServer(ServerNameF, new IPEndPoint(ipAddrF, PortF));
// else
// e.Rejected = true;
//if ( bIpAddrG )
// e.AddServer(ServerNameG, new IPEndPoint(ipAddrG, PortG));
// else
// e.Rejected = true;
}
catch
{
e.Rejected = true;
}
}
public static bool Resolve(string addr, out IPAddress outValue)
{
if (IPAddress.TryParse(addr, out outValue))
return true;
try
{
IPHostEntry iphe = Dns.GetHostEntry(addr);
if (iphe.AddressList.Length > 0)
{
outValue = iphe.AddressList[iphe.AddressList.Length - 1];
return true;
}
}
catch
{
}
outValue = IPAddress.None;
return false;
}
private static bool IsLocalMachine(NetState state)
{
Socket sock = state.Socket;
IPAddress theirAddress = ((IPEndPoint)sock.RemoteEndPoint).Address;
if (IPAddress.IsLoopback(theirAddress))
return true;
bool contains = false;
IPHostEntry iphe = Dns.GetHostEntry(Dns.GetHostName());
for (int i = 0; !contains && i < iphe.AddressList.Length; ++i)
contains = theirAddress.Equals(iphe.AddressList[i]);
return contains;
}
}
}
The servers show up on the list but no mater what one you pick it goes to server A