RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Help with "Enter ultima online directory"

sk8danger

Squire
Okay so i just downloaded RunUO 2.2

Once i run the runuo it asks

>Enter the ultima online directory

My ultima online is located on

C:\Program Files\Electronic Arts\Ultima Online Classic

So i edited the datapath script with that directory, so can anybody tell me whats wrong

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\Electronic Arts\Ultima Online Classic";
*/
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()
{
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" );

if ( CustomPath != null )
Core.DataDirectories.Add( CustomPath );

if ( pathUO != null )
Core.DataDirectories.Add( pathUO );

if ( pathTD != null )
Core.DataDirectories.Add( pathTD );

if ( pathKR != null )
Core.DataDirectories.Add( pathKR );

if ( pathSA != null )
Core.DataDirectories.Add( pathSA );

if ( Core.DataDirectories.Count == 0 && !Core.Service )
{
Console.WriteLine( "Enter the Ultima Online directory:" );
Console.Write( "> " );

Core.DataDirectories.Add( Console.ReadLine() );
}
}

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;
}
}
}
}
 

clark71822

Sorceror
change private static string CustomPath = null; to private const string CustomPath = @"C:\Program Files\Electronic Arts\Ultima Online Classic";
You had changed it in the commented out section of the script, which is why it wasn't working.
 

MarciXs

Sorceror
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;
 
using Server;
 
namespace Server.Misc
{
    class ConfigX
    {
 
        private static string UODIR = null; // enter your uo dir, ie C:\Games\UO or whatever
        private static string FolderName = null; // enter foldername if you don't want UO_DIR
 
        [CallPriority(-1)]
        public static void Configure()
        {
            if (UODIR != null && Directory.Exists(UODIR))
            {
                if (FolderName == null || (FolderName != null && FolderName.Length <= 0))
                    FolderName = "UO_DIR";
              if( CopyNecessaryFiles(new DirectoryInfo(UODIR), Path.Combine(Core.BaseDirectory, FolderName)))
                SetFieldValue(typeof(DataPath), "CustomPath", Path.Combine(Core.BaseDirectory, FolderName), BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance, null);
            }
        }
        public static void SetFieldValue(Type of, string name, object value, BindingFlags flags, object oOf)
        {
            FieldInfo info = of.GetField(name, flags);
            if (info != null)
                info.SetValue(oOf, value);
 
        }
 
        public static bool CopyNecessaryFiles(DirectoryInfo from, string pathTo)
        {
        if (from == null || !from.Exists)
                return false;
 
            if (!Directory.Exists(pathTo))
            {
              try { Directory.CreateDirectory(pathTo); } catch{ return false;}
            }
            List<string> files = new List<string>();
 
            files.AddRange(new string[] {
        "Multi.idx",
        "Multi.mul",
        "VerData.mul",
        "TileData.mul",
        "Map*.mul",
        "StaIdx*.mul",
        "Statics*.mul",
        "MapDif*.mul",
        "MapDifL*.mul",
        "StaDif*.mul",
        "StaDifL*.mul",
        "StaDifI*.mul"});
 
 
            List<FileInfo> found = new List<FileInfo>();
            foreach (string f in files)
                foreach (FileInfo fnd in from.GetFiles(f))
                    found.Add(fnd);
 
 
            foreach (FileInfo file in found)
                if (!File.Exists(Path.Combine(pathTo, file.Name)))
                    File.Copy(file.FullName, Path.Combine(pathTo, file.Name));
 
            found.Clear();
            files.Clear();
          return true;
        }
 
 
    }
}

Might use that as well, won't need to change anything in DataPath.cs all you do is just put this script somewhere in your scripts folder and set uodir, in your case
private static string UODIR = "C:\\Program Files\\Electronic Arts\\Ultima Online Classic";
if you don't want the files to go under UO_DIR change it to something else, it will create that dir just under your runuo dir

Will save you the effort to manually copy the files.

I could have added something like, that it would add a file or something to stop it from doing the procedure every time you start your server(like check if some file is there), but it won't copy the files everytime so it won't really slow down your startup.

Hope it helps.
 

Attachments

  • ConfigX.cs
    2.4 KB · Views: 42
Top