using System;
using System.IO;
using Microsoft.Win32;
using Server;
namespace Server.Misc
{
public class DataPath
{
/* If you have not installed Ultima Online,
* or wish the server to use a separate set of datafiles,
* change the 'CustomPath' value, example:
*
* private const string CustomPath = @"C:\Program Files\Ultima Online";
*/
private static string CustomPath = null;
/* The following is a list of files which a required for proper execution:
*
* Multi.idx
* Multi.mul
* VerData.mul
* TileData.mul
* Map*.mul
* StaIdx*.mul
* Statics*.mul
* MapDif*.mul
* MapDifL*.mul
* StaDif*.mul
* StaDifL*.mul
* StaDifI*.mul
*/
public static void Configure()
{
//AddPath( CustomPath );
AddPath( GetPath( @"Origin Worlds Online\Ultima Online\1.0", "ExePath" ) );
AddPath( GetPath( @"Origin Worlds Online\Ultima Online Third Dawn\1.0", "ExePath" ) ); //These refer to 2D & 3D, not the Third Dawn expansion
AddPath( GetPath( @"Origin Worlds Online\Ultima Online\KR Legacy Beta", "ExePath" ) ); //After KR, This is the new registry key for the 2D client
AddPath( GetPath( @"Electronic Arts\EA Games\Ultima Online Stygian Abyss Classic", "InstallDir" ) );
AddPath( GetPath( @"Electronic Arts\EA Games\Ultima Online Classic", "InstallDir" ) );
if ( Core.DataDirectories.Count == 0 && !Core.Service )
{
Console.WriteLine( "Enter the Ultima Online directory:" );
Console.Write( "> " );
Core.DataDirectories.Add( Console.ReadLine() );
}
}
private static void AddPath( string path )
{
if ( path != null && path.Length > 0 )
Core.DataDirectories.Add( path );
}
private static string GetPath( string subName, string keyName )
{
try
{
string keyString;
if( Core.Is64Bit )
keyString = @"SOFTWARE\Wow6432Node\{0}";
else
keyString = @"SOFTWARE\{0}";
using( RegistryKey key = Registry.LocalMachine.OpenSubKey( String.Format( keyString, subName ) ) )
{
if( key == null )
return null;
string v = key.GetValue( keyName ) as string;
if( String.IsNullOrEmpty( v ) )
return null;
if ( keyName == "InstallDir" )
v = v + @"\";
v = Path.GetDirectoryName( v );
if ( String.IsNullOrEmpty( v ) )
return null;
return v;
}
}
catch
{
return null;
}
}
}
}
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using Server;
using Server.Misc;
using Server.Network;
namespace Server
{
public class SocketOptions
{
private const bool NagleEnabled = false; // Should the Nagle algorithm be enabled? This may reduce performance
private const int CoalesceBufferSize = 512; // MSS that the core will use when buffering packets
//private const int PooledSockets = 32; // The number of sockets to initially pool. Ideal value is expected client count.
private static IPEndPoint[] m_ListenerEndPoints = new IPEndPoint[] {
new IPEndPoint( IPAddress.Any, 5555 ), // Default: Listen on port 5555 on all IP addresses
new IPEndPoint( IPAddress.Any, 2599), // Default: Listen on port 2593 on all IP addresses
// Examples:
// new IPEndPoint( IPAddress.Any, 80 ), // Listen on port 80 on all IP addresses
// new IPEndPoint( IPAddress.Parse( "1.2.3.4" ), 2593 ), // Listen on port 2593 on IP address 1.2.3.4
};
public static void Initialize()
{
SendQueue.CoalesceBufferSize = CoalesceBufferSize;
//SocketPool.InitialCapacity = PooledSockets;
EventSink.SocketConnect += new SocketConnectEventHandler( EventSink_SocketConnect );
Listener.EndPoints = m_ListenerEndPoints;
}
private static void EventSink_SocketConnect( SocketConnectEventArgs e )
{
if ( e.AllowConnection && !NagleEnabled )
e.Socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 ); // RunUO uses its own algorithm
}
}
}
using System;
using System.Net;
using System.Net.Sockets;
using Server;
using Server.Network;
namespace Server.Misc
{
public class ServerList
{
//public const string Address = "192.168.123.173"; // server LAN IP
public const string Address = "75.88.***.***"; // WAN IP
//public const string Address = "192.168.123.254"; // Router Gateway IP
public const string ServerName = "Pandora 2.0";
public static void Initialize()
{
Listener.Port = 2593;
//Listener.Port = 110;
EventSink.ServerList += new ServerListEventHandler( EventSink_ServerList );
}
public static void EventSink_ServerList( ServerListEventArgs e )
{
try
{
IPAddress ipAddr;
if ( Resolve( Address != null && !IsLocalMachine( e.State ) ? Address : Dns.GetHostName(), out ipAddr ) )
e.AddServer( ServerName, new IPEndPoint( ipAddr, Listener.Port ) );
else
e.Rejected = true;
}
catch
{
e.Rejected = true;
}
}
public static bool Resolve( string addr, out IPAddress outValue )
{
try
{
outValue = IPAddress.Parse( addr );
return true;
}
catch
{
try
{
IPHostEntry iphe = Dns.Resolve( 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.Resolve( Dns.GetHostName() );
for ( int i = 0; !contains && i < iphe.AddressList.Length; ++i )
contains = theirAddress.Equals( iphe.AddressList[i] );
return contains;
}
}
}