runuo/Scripts/Misc/DataPath.cs

107 lines
2.7 KiB
C#
Raw Permalink Normal View History

2006-06-15 04:14:30 +00:00
using System;
using System.IO;
using Microsoft.Win32;
using Server;
namespace Server.Misc
{
public class DataPath
{
/* If you have not installed Ultima Online,
2006-06-21 22:41:20 +00:00
* or wish the server to use a separate set of datafiles,
* change the 'CustomPath' value.
* Example:
* private static string CustomPath = @"C:\Program Files\Ultima Online";
2006-06-15 04:14:30 +00:00
*/
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 or Map*LegacyMUL.uop
2006-06-15 04:14:30 +00:00
* StaIdx*.mul
* Statics*.mul
* MapDif*.mul
* MapDifL*.mul
* StaDif*.mul
* StaDifL*.mul
* StaDifI*.mul
*/
public static void Configure()
{
2010-06-17 08:13:41 +00:00
string pathUO = GetPath( @"Origin Worlds Online\Ultima Online\1.0", "ExePath" );
string pathTD = GetPath( @"Origin Worlds Online\Ultima Online Third Dawn\1.0", "ExePath" ); //These refer to 2D & 3D, not the Third Dawn expansion
string pathKR = GetPath( @"Origin Worlds Online\Ultima Online\KR Legacy Beta", "ExePath" ); //After KR, This is the new registry key for the 2D client
string pathSA = GetPath( @"Electronic Arts\EA Games\Ultima Online Stygian Abyss Classic", "InstallDir" );
2012-11-25 06:03:20 +00:00
string pathHS = GetPath( @"Electronic Arts\EA Games\Ultima Online Classic", "InstallDir" );
2010-04-25 06:09:43 +00:00
2006-06-15 04:14:30 +00:00
if ( CustomPath != null )
Core.DataDirectories.Add( CustomPath );
2010-06-17 08:13:41 +00:00
if ( pathUO != null )
Core.DataDirectories.Add( pathUO );
2006-06-15 04:14:30 +00:00
if ( pathTD != null )
2010-04-25 06:09:43 +00:00
Core.DataDirectories.Add( pathTD );
2010-06-17 08:13:41 +00:00
if ( pathKR != null )
Core.DataDirectories.Add( pathKR );
if ( pathSA != null )
Core.DataDirectories.Add( pathSA );
2006-06-15 04:14:30 +00:00
2012-11-25 06:03:20 +00:00
if ( pathHS != null )
Core.DataDirectories.Add( pathHS );
2009-08-07 07:07:15 +00:00
if ( Core.DataDirectories.Count == 0 && !Core.Service )
2006-06-15 04:14:30 +00:00
{
Console.WriteLine( "Enter the Ultima Online directory:" );
Console.Write( "> " );
Core.DataDirectories.Add( Console.ReadLine() );
}
}
2010-06-17 08:13:41 +00:00
private static string GetPath( string subName, string keyName )
2006-06-15 04:14:30 +00:00
{
try
{
2010-06-17 08:13:41 +00:00
string keyString;
2006-06-15 04:14:30 +00:00
if( Core.Is64Bit )
2010-06-17 08:13:41 +00:00
keyString = @"SOFTWARE\Wow6432Node\{0}";
2006-06-15 04:14:30 +00:00
else
2010-06-17 08:13:41 +00:00
keyString = @"SOFTWARE\{0}";
2006-06-15 04:14:30 +00:00
2010-06-17 08:13:41 +00:00
using( RegistryKey key = Registry.LocalMachine.OpenSubKey( String.Format( keyString, subName ) ) )
2006-06-15 04:14:30 +00:00
{
if( key == null )
return null;
2010-06-17 08:13:41 +00:00
string v = key.GetValue( keyName ) as string;
2006-06-15 04:14:30 +00:00
2010-06-17 08:13:41 +00:00
if( String.IsNullOrEmpty( v ) )
2006-06-15 04:14:30 +00:00
return null;
2010-06-17 08:13:41 +00:00
if ( keyName == "InstallDir" )
v = v + @"\";
2006-06-15 04:14:30 +00:00
v = Path.GetDirectoryName( v );
2010-06-17 08:13:41 +00:00
if ( String.IsNullOrEmpty( v ) )
2006-06-15 04:14:30 +00:00
return null;
return v;
}
}
catch
{
return null;
}
}
}
}