public override Task Load() { return(Task.Run ( () => { string path = UOFileManager.GetUOFilePath("hues.mul"); FileSystemHelper.EnsureFileExists(path); UOFileMul file = new UOFileMul(path); int groupSize = Marshal.SizeOf <HuesGroup>(); int entrycount = (int)file.Length / groupSize; HuesCount = entrycount * 8; HuesRange = new HuesGroup[entrycount]; ulong addr = (ulong)file.StartAddress; for (int i = 0; i < entrycount; i++) { HuesRange[i] = Marshal.PtrToStructure <HuesGroup>((IntPtr)(addr + (ulong)(i * groupSize))); } path = UOFileManager.GetUOFilePath("radarcol.mul"); FileSystemHelper.EnsureFileExists(path); UOFileMul radarcol = new UOFileMul(path); RadarCol = radarcol.ReadArray <ushort>((int)radarcol.Length >> 1); file.Dispose(); radarcol.Dispose(); } )); }
public UOFontRenderer(GraphicsDevice device) { const int ATLAS_SIZE = 1024; _atlas = new TextureAtlas(device, ATLAS_SIZE, ATLAS_SIZE, SurfaceFormat.Color); const string ASCII_UO_FILE = "fonts.mul"; const string UNICODE_UO_FILE = "unifont{0}.mul"; string path = UOFileManager.GetUOFilePath(ASCII_UO_FILE); if (File.Exists(path)) { _asciiFontFile = new UOFile(path, true); _asciiFontCount = GetFontCount(_asciiFontFile, ASCII_CHARS_COUNT); } for (int i = 0; i < 20; ++i) { path = UOFileManager.GetUOFilePath(string.Format(UNICODE_UO_FILE, (i == 0 ? string.Empty : i.ToString()))); if (File.Exists(path)) { _unicodeFontFiles[i] = new UOFile(path, true); } } }
public override Task Load() { return(Task.Run(() => { string filepath = UOFileManager.GetUOFilePath("artLegacyMUL.uop"); if (File.Exists(filepath)) { _file = new UOFileUop(filepath, "build/artlegacymul/{0:D8}.tga"); Entries = new UOFileIndex[Constants.MAX_STATIC_DATA_INDEX_COUNT]; } else { filepath = UOFileManager.GetUOFilePath("art.mul"); string idxpath = UOFileManager.GetUOFilePath("artidx.mul"); if (File.Exists(filepath) && File.Exists(idxpath)) { _file = new UOFileMul(filepath, idxpath, Constants.MAX_STATIC_DATA_INDEX_COUNT); } } _file.FillEntries(ref Entries); })); }
public override Task Load() { return(Task.Run(() => { string uopPath = UOFileManager.GetUOFilePath("MultiCollection.uop"); if (File.Exists(uopPath)) { Count = Constants.MAX_MULTI_DATA_INDEX_COUNT; _file = new UOFileUop(uopPath, "build/multicollection/{0:D6}.bin"); Entries = new UOFileIndex[Count]; _reader = new DataReader(); } else { string path = UOFileManager.GetUOFilePath("multi.mul"); string pathidx = UOFileManager.GetUOFilePath("multi.idx"); if (File.Exists(path) && File.Exists(pathidx)) { _file = new UOFileMul(path, pathidx, Constants.MAX_MULTI_DATA_INDEX_COUNT, 14); Count = _itemOffset = UOFileManager.ClientVersion >= ClientVersions.CV_7090 ? UnsafeMemoryManager.SizeOf <MultiBlockNew>() : UnsafeMemoryManager.SizeOf <MultiBlock>(); } } _file.FillEntries(ref Entries); })); }
public override unsafe Task Load() { return(Task.Run(() => { string path = UOFileManager.GetUOFilePath("speech.mul"); if (!File.Exists(path)) { _speech = Array.Empty <SpeechEntry>(); return; } UOFileMul file = new UOFileMul(path); List <SpeechEntry> entries = new List <SpeechEntry>(); while (file.Position < file.Length) { int id = file.ReadUShortReversed(); int length = file.ReadUShortReversed(); if (length > 0) { entries.Add(new SpeechEntry(id, string.Intern(Encoding.UTF8.GetString((byte *)file.PositionAddress, length)))); file.Skip(length); } } _speech = entries.ToArray(); file.Dispose(); })); }
public override Task Load() { return(Task.Run(() => { if (SkillsCount > 0) { return; } string path = UOFileManager.GetUOFilePath("skills.mul"); string pathidx = UOFileManager.GetUOFilePath("Skills.idx"); FileSystemHelper.EnsureFileExists(path); FileSystemHelper.EnsureFileExists(pathidx); _file = new UOFileMul(path, pathidx, 0, 16); _file.FillEntries(ref Entries); for (int i = 0; i < Entries.Length; i++) { GetSkill(i); } SkillNames = _skills.Select(o => o.Value.Name).ToArray(); })); }
public override Task Load() { return(Task.Run ( () => { string path = UOFileManager.GetUOFilePath("Multimap.rle"); if (File.Exists(path)) { _file = new UOFile(path, true); } for (int i = 0; i < 6; i++) { path = UOFileManager.GetUOFilePath($"facet0{i}.mul"); if (File.Exists(path)) { _facets[i] = new UOFileMul(path); } } } )); }
public override Task Load() { return(Task.Run ( () => { string filePath = UOFileManager.GetUOFilePath("artLegacyMUL.uop"); if (Client.IsUOPInstallation && File.Exists(filePath)) { _file = new UOFileUop(filePath, "build/artlegacymul/{0:D8}.tga"); Entries = new UOFileIndex[Math.Max(((UOFileUop)_file).TotalEntriesCount, Constants.MAX_STATIC_DATA_INDEX_COUNT)]; } else { filePath = UOFileManager.GetUOFilePath("art.mul"); string idxPath = UOFileManager.GetUOFilePath("artidx.mul"); if (File.Exists(filePath) && File.Exists(idxPath)) { _file = new UOFileMul(filePath, idxPath, Constants.MAX_STATIC_DATA_INDEX_COUNT); } } _file.FillEntries(ref Entries); _spriteInfos = new SpriteInfo[Entries.Length]; } )); }
public override Task Load() { return Task.Run(() => { if (string.IsNullOrEmpty(_cliloc)) _cliloc = "Cliloc.enu"; string path = UOFileManager.GetUOFilePath(_cliloc); if (!File.Exists(path)) return; using (BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read))) { reader.ReadInt32(); reader.ReadInt16(); byte[] buffer = new byte[1024]; while (reader.BaseStream.Length != reader.BaseStream.Position) { int number = reader.ReadInt32(); byte flag = reader.ReadByte(); int length = reader.ReadInt16(); if (length > buffer.Length) buffer = new byte[(length + 1023) & ~1023]; reader.Read(buffer, 0, length); string text = string.Intern(Encoding.UTF8.GetString(buffer, 0, length)); _entries[number] = text; } } }); }
public override unsafe Task Load() { return(Task.Run(() => { string uopPath = UOFileManager.GetUOFilePath("MultiCollection.uop"); if (Client.IsUOPInstallation && System.IO.File.Exists(uopPath)) { Count = Constants.MAX_MULTI_DATA_INDEX_COUNT; _file = new UOFileUop(uopPath, "build/multicollection/{0:D6}.bin"); Entries = new UOFileIndex[Count]; _reader = new DataReader(); IsUOP = true; } else { string path = UOFileManager.GetUOFilePath("multi.mul"); string pathidx = UOFileManager.GetUOFilePath("multi.idx"); if (System.IO.File.Exists(path) && System.IO.File.Exists(pathidx)) { _file = new UOFileMul(path, pathidx, Constants.MAX_MULTI_DATA_INDEX_COUNT, 14); Count = _itemOffset = Client.Version >= ClientVersion.CV_7090 ? sizeof(MultiBlockNew) + 2 : sizeof(MultiBlock); } } _file.FillEntries(ref Entries); })); }
internal void CheckForShardMapFile(int mapID) { if (Entries == null) { Entries = new UOFileIndex[MapLoader.MAPS_COUNT][]; } string oldmap = UOFileManager.GetUOFilePath($"map{mapID}.mul"); string oldstaidx = UOFileManager.GetUOFilePath($"staidx{mapID}.mul"); string oldstatics = UOFileManager.GetUOFilePath($"statics{mapID}.mul"); //create file names string mapPath = Path.Combine(_UL.ShardName, $"map{mapID}.mul"); string staidxPath = Path.Combine(_UL.ShardName, $"staidx{mapID}.mul"); string staticsPath = Path.Combine(_UL.ShardName, $"statics{mapID}.mul"); if (!File.Exists(mapPath)) { UOFile mapfile = GetMapFile(mapID); if (mapfile == null) { CreateNewPersistantMap(mapID, mapPath, staidxPath, staticsPath); } else { if (mapfile is UOFileUop uop) { Entries[mapID] = new UOFileIndex[uop.TotalEntriesCount]; uop.FillEntries(ref Entries[mapID]); Log.Trace($"UltimaLive -> converting file:\t{mapPath} from {uop.FilePath}"); using (FileStream stream = File.Create(mapPath)) { for (int x = 0; x < Entries[mapID].Length; x++) { uop.Seek(Entries[mapID][x].Offset); stream.Write(uop.ReadArray(Entries[mapID][x].Length), 0, Entries[mapID][x].Length); } stream.Flush(); } } else { CopyFile(oldmap, mapPath); } } } if (!File.Exists(staticsPath)) { CopyFile(oldstatics, staticsPath); } if (!File.Exists(staidxPath)) { CopyFile(oldstaidx, staidxPath); } }
public Task Load(string cliloc) { _cliloc = cliloc; if (!File.Exists(UOFileManager.GetUOFilePath(cliloc))) _cliloc = "Cliloc.enu"; return Load(); }
public override Task Load() { return(Task.Run ( () => { string path = UOFileManager.GetUOFilePath("texmaps.mul"); string pathidx = UOFileManager.GetUOFilePath("texidx.mul"); FileSystemHelper.EnsureFileExists(path); FileSystemHelper.EnsureFileExists(pathidx); _file = new UOFileMul(path, pathidx, Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT, 10); _file.FillEntries(ref Entries); string pathdef = UOFileManager.GetUOFilePath("TexTerr.def"); if (!File.Exists(pathdef)) { return; } using (DefReader defReader = new DefReader(pathdef)) { while (defReader.Next()) { int index = defReader.ReadInt(); if (index < 0 || index >= Entries.Length) { continue; } int[] group = defReader.ReadGroup(); if (group == null) { continue; } for (int i = 0; i < group.Length; i++) { int checkindex = group[i]; if (checkindex < 0 || checkindex >= Entries.Length) { continue; } Entries[index] = Entries[checkindex]; } } } _spriteInfos = new SpriteInfo[Entries.Length]; } )); }
public override Task Load() { return(Task.Run(() => { string path = UOFileManager.GetUOFilePath("animdata.mul"); if (File.Exists(path)) { _file = new UOFileMul(path); } })); }
public override Task Load() { return(Task.Run(() => { string path = UOFileManager.GetUOFilePath("light.mul"); string pathidx = UOFileManager.GetUOFilePath("lightidx.mul"); FileSystemHelper.EnsureFileExists(path); FileSystemHelper.EnsureFileExists(pathidx); _file = new UOFileMul(path, pathidx, Constants.MAX_LIGHTS_DATA_INDEX_COUNT); _file.FillEntries(ref Entries); })); }
public override Task Load() { return(Task.Run ( () => { if (SkillsCount > 0) { return; } string path = UOFileManager.GetUOFilePath("skills.mul"); string pathidx = UOFileManager.GetUOFilePath("Skills.idx"); FileSystemHelper.EnsureFileExists(path); FileSystemHelper.EnsureFileExists(pathidx); _file = new UOFileMul(path, pathidx, 0, 16); _file.FillEntries(ref Entries); for (int i = 0, count = 0; i < Entries.Length; i++) { ref UOFileIndex entry = ref GetValidRefEntry(i); if (entry.Length > 0) { _file.SetData(entry.Address, entry.FileSize); _file.Seek(entry.Offset); bool hasAction = _file.ReadBool(); string name = Encoding.UTF8.GetString(_file.ReadArray <byte>(entry.Length - 1)).TrimEnd('\0'); /* * if(skillUseless.Contains(name)) // giga487, UoMars * { * continue; // se carico le skill che ho messo dentro il vettore string skillUseless vado avanti. * } */ SkillEntry skill = new SkillEntry(count++, name, hasAction); Skills.Add(skill); } } SortedSkills.AddRange(Skills); SortedSkills.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.InvariantCulture)); }
public Task Load(string lang) { if (string.IsNullOrEmpty(lang)) { lang = "enu"; } _cliloc = $"Cliloc.{lang}"; Log.Trace($"searching for: '{_cliloc}'"); if (!File.Exists(UOFileManager.GetUOFilePath(_cliloc))) { Log.Warn($"'{_cliloc}' not found. Rolled back to Cliloc.enu"); _cliloc = "Cliloc.enu"; } return(Load()); }
public override Task Load() { return(Task.Run ( () => { if (SkillsCount > 0) { return; } string path = UOFileManager.GetUOFilePath("skills.mul"); string pathidx = UOFileManager.GetUOFilePath("Skills.idx"); FileSystemHelper.EnsureFileExists(path); FileSystemHelper.EnsureFileExists(pathidx); _file = new UOFileMul(path, pathidx, 0, 16); _file.FillEntries(ref Entries); for (int i = 0, count = 0; i < Entries.Length; i++) { ref UOFileIndex entry = ref GetValidRefEntry(i); if (entry.Length > 0) { _file.Seek(entry.Offset); bool hasAction = _file.ReadBool(); string name = Encoding.UTF8.GetString (_file.ReadArray <byte>(entry.Length - 1)) .TrimEnd('\0'); SkillEntry skill = new SkillEntry(count++, name, hasAction); Skills.Add(skill); } } SortedSkills.AddRange(Skills); SortedSkills.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.InvariantCulture)); }
public override Task Load() { return(Task.Run(() => { if (SkillsCount > 0) { return; } string path = UOFileManager.GetUOFilePath("skills.mul"); string pathidx = UOFileManager.GetUOFilePath("Skills.idx"); FileSystemHelper.EnsureFileExists(path); FileSystemHelper.EnsureFileExists(pathidx); _file = new UOFileMul(path, pathidx, 0, 16); _file.FillEntries(ref Entries); for (int i = 0, count = 0; i < Entries.Length; i++) { ref readonly var entry = ref GetValidRefEntry(i);
public static void MakeDefault() { Clear(); if (!LoadMULFile(UOFileManager.GetUOFilePath("skillgrp.mul"))) { MakeDefaultMiscellaneous(); MakeDefaultCombat(); MakeDefaultTradeSkills(); MakeDefaultMagic(); MakeDefaultWilderness(); MakeDefaultThieving(); MakeDefaultBard(); } foreach (SkillsGroup g in Groups) { g.Sort(); } Save(); }
static Verdata() { string path = UOFileManager.GetUOFilePath("verdata.mul"); if (!System.IO.File.Exists(path)) { Patches = new UOFileIndex5D[0]; File = null; } else { File = new UOFileMul(path); // the scope of this try/catch is to avoid unexpected crashes if servers redestribuite wrong verdata try { Patches = File.ReadArray <UOFileIndex5D>(File.ReadInt()); } catch { Patches = new UOFileIndex5D[0]; } } }
public override Task Load() { return(Task.Run(() => { if (MapLoader.Instance is ULMapLoader) { return; } UOFileManager.MapLoaderReLoad(this); _UL._EOF = new uint[NumMaps]; _filesStaticsStream = new FileStream[NumMaps]; bool foundedOneMap = false; for (int i = 0; i < NumMaps; i++) { string path = Path.Combine(_UL.ShardName, $"map{i}.mul"); if (File.Exists(path)) { _filesMap[i] = new ULFileMul(path, false); foundedOneMap = true; } path = Path.Combine(_UL.ShardName, $"statics{i}.mul"); if (!File.Exists(path)) { foundedOneMap = false; break; } _filesStatics[i] = new ULFileMul(path, true); _filesStaticsStream[i] = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); _UL._EOF[i] = (uint)new FileInfo(path).Length; path = Path.Combine(_UL.ShardName, $"staidx{i}.mul"); if (!File.Exists(path)) { foundedOneMap = false; break; } _filesIdxStatics[i] = new ULFileMul(path, false); } if (!foundedOneMap) { throw new FileNotFoundException($"No maps, staidx or statics found on {_UL.ShardName}."); } for (int i = 0; i < NumMaps; i++) { MapBlocksSize[i, 0] = MapsDefaultSize[i, 0] >> 3; MapBlocksSize[i, 1] = MapsDefaultSize[i, 1] >> 3; //on ultimalive map always preload LoadMap(i); } })); }
static void Main(string[] args) { // - check for update // - launcher & user setup // - game setup // - game launch // - enjoy CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Log.Start(LogTypes.All); CUOEnviroment.GameThread = Thread.CurrentThread; CUOEnviroment.GameThread.Name = "CUO_MAIN_THREAD"; #if !DEBUG AppDomain.CurrentDomain.UnhandledException += (s, e) => { StringBuilder sb = new StringBuilder(); sb.AppendLine("######################## [START LOG] ########################"); #if DEV_BUILD sb.AppendLine($"ClassicUO [DEV_BUILD] - {CUOEnviroment.Version}"); #else sb.AppendLine($"ClassicUO [STANDARD_BUILD] - {CUOEnviroment.Version}"); #endif sb.AppendLine($"OS: {Environment.OSVersion.Platform} x{(Environment.Is64BitOperatingSystem ? "64" : "86")}"); sb.AppendLine($"Thread: {Thread.CurrentThread.Name}"); sb.AppendLine(); sb.AppendLine($"Protocol: {Client.Protocol}"); sb.AppendLine($"ClientFeatures: {World.ClientFeatures.Flags}"); sb.AppendLine($"ClientLockedFeatures: {World.ClientLockedFeatures.Flags}"); sb.AppendLine($"ClientVersion: {Client.Version}"); sb.AppendLine(); sb.AppendFormat("Exception:\n{0}\n", e.ExceptionObject); sb.AppendLine("######################## [END LOG] ########################"); sb.AppendLine(); sb.AppendLine(); Log.Panic(e.ExceptionObject.ToString()); string path = Path.Combine(CUOEnviroment.ExecutablePath, "Logs"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (LogFile crashfile = new LogFile(path, "crash.txt")) { crashfile.WriteAsync(sb.ToString()).RunSynchronously(); } }; #endif ReadSettingsFromArgs(args); #if DEV_BUILD if (!_skipUpdates) { Updater updater = new Updater(); if (updater.Check()) { return; } } #endif if (!_skipUpdates) { if (CheckUpdate(args)) { return; } } if (CUOEnviroment.IsHighDPI) { Log.Trace("HIGH DPI - ENABLED"); Environment.SetEnvironmentVariable("FNA_GRAPHICS_ENABLE_HIGHDPI", "1"); } Environment.SetEnvironmentVariable("FNA3D_BACKBUFFER_SCALE_NEAREST", "1"); Environment.SetEnvironmentVariable("FNA3D_OPENGL_FORCE_COMPATIBILITY_PROFILE", "1"); Environment.SetEnvironmentVariable(SDL.SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + Path.Combine(CUOEnviroment.ExecutablePath, "Data", "Plugins")); string globalSettingsPath = Settings.GetSettingsFilepath(); if ((!Directory.Exists(Path.GetDirectoryName(globalSettingsPath)) || !File.Exists(globalSettingsPath))) { // settings specified in path does not exists, make new one { // TODO: Settings.GlobalSettings.Save(); } } Settings.GlobalSettings = ConfigurationResolver.Load <Settings>(globalSettingsPath); CUOEnviroment.IsOutlands = Settings.GlobalSettings.ShardType == 2; ReadSettingsFromArgs(args); // still invalid, cannot load settings if (Settings.GlobalSettings == null) { Settings.GlobalSettings = new Settings(); Settings.GlobalSettings.Save(); } if (!CUOEnviroment.IsUnix) { string libsPath = Path.Combine(CUOEnviroment.ExecutablePath, Environment.Is64BitProcess ? "x64" : "x86"); SetDllDirectory(libsPath); } // FIXME: force to use OpenGL in osx and linux contexts. Metal wants texture converted in .Color instead of BGRA5551. // Check the branch "fna3d-macos-fix" /*if (CUOEnviroment.IsUnix) * { * Environment.SetEnvironmentVariable("FNA3D_FORCE_DRIVER", "OpenGL"); * } */ if (string.IsNullOrWhiteSpace(Settings.GlobalSettings.UltimaOnlineDirectory)) { Settings.GlobalSettings.UltimaOnlineDirectory = CUOEnviroment.ExecutablePath; } const uint INVALID_UO_DIRECTORY = 0x100; const uint INVALID_UO_VERSION = 0x200; uint flags = 0; if (!Directory.Exists(Settings.GlobalSettings.UltimaOnlineDirectory) || !File.Exists(UOFileManager.GetUOFilePath("tiledata.mul"))) { flags |= INVALID_UO_DIRECTORY; } string clientVersionText = Settings.GlobalSettings.ClientVersion; if (!ClientVersionHelper.IsClientVersionValid(Settings.GlobalSettings.ClientVersion, out var clientVersion)) { Log.Warn($"Client version [{clientVersionText}] is invalid, let's try to read the client.exe"); // mmm something bad happened, try to load from client.exe [windows only] if (!ClientVersionHelper.TryParseFromFile(Path.Combine(Settings.GlobalSettings.UltimaOnlineDirectory, "client.exe"), out clientVersionText) || !ClientVersionHelper.IsClientVersionValid(clientVersionText, out clientVersion)) { Log.Error("Invalid client version: " + clientVersionText); flags |= INVALID_UO_VERSION; } else { Log.Trace($"Found a valid client.exe [{clientVersionText} - {clientVersion}]"); // update the wrong/missing client version in settings.json Settings.GlobalSettings.ClientVersion = clientVersionText; } } if (flags != 0) { if ((flags & INVALID_UO_DIRECTORY) != 0) { Client.ShowErrorMessage("Your Ultima Online directory seems to be invalid.\nDownload the official Launcher to setup and run your game.\n\nLink: classicuo.eu"); } else if ((flags & INVALID_UO_VERSION) != 0) { Client.ShowErrorMessage("Your Ultima Online client version seems to be invalid.\nDownload the official Launcher to setup and run your game.\n\nLink: classicuo.eu"); } try { Process.Start("https://classicuo.eu"); } catch { } } else { switch (Settings.GlobalSettings.ForceDriver) { case 1: // OpenGL Environment.SetEnvironmentVariable("FNA3D_FORCE_DRIVER", "OpenGL"); break; case 2: // Vulkan Environment.SetEnvironmentVariable("FNA3D_FORCE_DRIVER", "Vulkan"); break; } Client.Run(); } Log.Trace("Closing..."); }
public override Task Load() { return(Task.Run(() => { bool result = false; FileInfo file = new FileInfo(UOFileManager.GetUOFilePath("Prof.txt")); if (file.Exists) { if (file.Length > 0x100000) //1megabyte limit of string file { throw new InternalBufferOverflowException($"{file.FullName} exceeds the maximum 1Megabyte allowed size for a string text file, please, check that the file is correct and not corrupted -> {file.Length} file size"); } //what if file doesn't exist? we skip section completely...directly into advanced selection TextFileParser read = new TextFileParser(File.ReadAllText(file.FullName), new[] { ' ', '\t', ',' }, new[] { '#', ';' }, new[] { '"', '"' }); while (!read.IsEOF()) { List <string> strings = read.ReadTokens(); if (strings.Count > 0) { if (strings[0].ToLower() == "begin") { result = ParseFilePart(read); if (!result) { break; } } } } } Professions[new ProfessionInfo { Name = "Advanced", Localization = 1061176, Description = 1061226, Graphic = 5545, TopLevel = true, Type = PROF_TYPE.PROFESSION, DescriptionIndex = -1, TrueName = "advanced" }] = null; foreach (KeyValuePair <ProfessionInfo, List <ProfessionInfo> > kvp in Professions) { kvp.Key.Childrens = null; if (kvp.Value != null) { foreach (ProfessionInfo info in kvp.Value) { info.Childrens = null; } } } })); }
public override Task Load() { return(Task.Run ( () => { string path = UOFileManager.GetUOFilePath("soundLegacyMUL.uop"); if (Client.IsUOPInstallation && File.Exists(path)) { _file = new UOFileUop(path, "build/soundlegacymul/{0:D8}.dat"); Entries = new UOFileIndex[Math.Max(((UOFileUop)_file).TotalEntriesCount, Constants.MAX_SOUND_DATA_INDEX_COUNT)]; } else { path = UOFileManager.GetUOFilePath("sound.mul"); string idxpath = UOFileManager.GetUOFilePath("soundidx.mul"); if (File.Exists(path) && File.Exists(idxpath)) { _file = new UOFileMul(path, idxpath, Constants.MAX_SOUND_DATA_INDEX_COUNT); } else { throw new FileNotFoundException("no sounds found"); } } _file.FillEntries(ref Entries); string def = UOFileManager.GetUOFilePath("Sound.def"); if (File.Exists(def)) { using (DefReader reader = new DefReader(def)) { while (reader.Next()) { int index = reader.ReadInt(); if (index < 0 || index >= Constants.MAX_SOUND_DATA_INDEX_COUNT || index >= _file.Length || Entries[index].Length != 0) { continue; } int[] group = reader.ReadGroup(); if (group == null) { continue; } for (int i = 0; i < group.Length; i++) { int checkIndex = group[i]; if (checkIndex < -1 || checkIndex >= Constants.MAX_SOUND_DATA_INDEX_COUNT) { continue; } ref UOFileIndex ind = ref Entries[index]; if (checkIndex == -1) { ind = default; } else { ref readonly UOFileIndex outInd = ref Entries[checkIndex];
//private readonly List<uint> _usedIndex = new List<uint>(); public override Task Load() { return(Task.Run(() => { string path = UOFileManager.GetUOFilePath("texmaps.mul"); string pathidx = UOFileManager.GetUOFilePath("texidx.mul"); FileSystemHelper.EnsureFileExists(path); FileSystemHelper.EnsureFileExists(pathidx); _file = new UOFileMul(path, pathidx, Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT, 10); _file.FillEntries(ref Entries); string pathdef = UOFileManager.GetUOFilePath("TexTerr.def"); if (!File.Exists(pathdef)) { return; } using (DefReader defReader = new DefReader(pathdef)) { while (defReader.Next()) { int index = defReader.ReadInt(); if (index < 0 || index >= Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT) { continue; } int[] group = defReader.ReadGroup(); for (int i = 0; i < group.Length; i++) { int checkindex = group[i]; if (checkindex < 0 || checkindex >= Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT) { continue; } Entries[index] = Entries[checkindex]; } } } //using (StreamReader reader = new StreamReader(File.OpenRead(pathdef))) //{ // string line; // while ((line = reader.ReadLine()) != null) // { // line = line.Trim(); // if (line.Length <= 0 || line[0] == '#') // continue; // string[] defs = line.Split(new[] // { // '\t', ' ', '#' // }, StringSplitOptions.RemoveEmptyEntries); // if (defs.Length < 2) // continue; // int index = int.Parse(defs[0]); // if (index < 0 || index >= TEXTMAP_COUNT) // continue; // int first = defs[1].IndexOf("{"); // int last = defs[1].IndexOf("}"); // string[] newdef = defs[1].Substring(first + 1, last - 1).Split(new[] // { // ' ', ',' // }, StringSplitOptions.RemoveEmptyEntries); // foreach (string s in newdef) // { // int checkindex = int.Parse(s); // if (checkindex < 0 || checkindex >= TEXTMAP_COUNT) // continue; // _file.Entries[index] = _file.Entries[checkindex]; // } // } //} })); }
public static void Load() { Log.Trace(">>>>>>>>>>>>> Loading >>>>>>>>>>>>>"); string clientPath = Settings.GlobalSettings.UltimaOnlineDirectory; Log.Trace($"Ultima Online installation folder: {clientPath}"); Log.Trace("Loading files..."); if (!string.IsNullOrWhiteSpace(Settings.GlobalSettings.ClientVersion)) { // sanitize client version Settings.GlobalSettings.ClientVersion = Settings.GlobalSettings.ClientVersion.Replace(",", ".").Replace(" ", "").ToLower(); } string clientVersionText = Settings.GlobalSettings.ClientVersion; // check if directory is good if (!Directory.Exists(clientPath)) { Log.Error("Invalid client directory: " + clientPath); ShowErrorMessage($"'{clientPath}' is not a valid UO directory"); throw new InvalidClientDirectory($"'{clientPath}' is not a valid directory"); } // try to load the client version if (!ClientVersionHelper.IsClientVersionValid(clientVersionText, out ClientVersion clientVersion)) { Log.Warn($"Client version [{clientVersionText}] is invalid, let's try to read the client.exe"); // mmm something bad happened, try to load from client.exe if (!ClientVersionHelper.TryParseFromFile(Path.Combine(clientPath, "client.exe"), out clientVersionText) || !ClientVersionHelper.IsClientVersionValid(clientVersionText, out clientVersion)) { Log.Error("Invalid client version: " + clientVersionText); ShowErrorMessage($"Impossible to define the client version.\nClient version: '{clientVersionText}'"); throw new InvalidClientVersion($"Invalid client version: '{clientVersionText}'"); } Log.Trace($"Found a valid client.exe [{clientVersionText} - {clientVersion}]"); // update the wrong/missing client version in settings.json Settings.GlobalSettings.ClientVersion = clientVersionText; } Version = clientVersion; ClientPath = clientPath; IsUOPInstallation = Version >= ClientVersion.CV_7000 && File.Exists(UOFileManager.GetUOFilePath("MainMisc.uop")); Protocol = ClientFlags.CF_T2A; if (Version >= ClientVersion.CV_200) { Protocol |= ClientFlags.CF_RE; } if (Version >= ClientVersion.CV_300) { Protocol |= ClientFlags.CF_TD; } if (Version >= ClientVersion.CV_308) { Protocol |= ClientFlags.CF_LBR; } if (Version >= ClientVersion.CV_308Z) { Protocol |= ClientFlags.CF_AOS; } if (Version >= ClientVersion.CV_405A) { Protocol |= ClientFlags.CF_SE; } if (Version >= ClientVersion.CV_60144) { Protocol |= ClientFlags.CF_SA; } Log.Trace($"Client path: '{clientPath}'"); Log.Trace($"Client version: {clientVersion}"); Log.Trace($"Protocol: {Protocol}"); Log.Trace("UOP? " + (IsUOPInstallation ? "yes" : "no")); // ok now load uo files UOFileManager.Load(); StaticFilters.Load(); Log.Trace("Network calibration..."); PacketHandlers.Load(); //ATTENTION: you will need to enable ALSO ultimalive server-side, or this code will have absolutely no effect! //UltimaLive.Enable(); PacketsTable.AdjustPacketSizeByVersion(Version); if (Settings.GlobalSettings.Encryption != 0) { Log.Trace("Calculating encryption by client version..."); EncryptionHelper.CalculateEncryption(Version); Log.Trace($"encryption: {EncryptionHelper.Type}"); if (EncryptionHelper.Type != (ENCRYPTION_TYPE)Settings.GlobalSettings.Encryption) { Log.Warn($"Encryption found: {EncryptionHelper.Type}"); Settings.GlobalSettings.Encryption = (byte)EncryptionHelper.Type; } } Log.Trace("Done!"); Log.Trace("Loading plugins..."); foreach (var p in Settings.GlobalSettings.Plugins) { Plugin.Create(p); } Log.Trace("Done!"); //UoAssist.Start(); Log.Trace(">>>>>>>>>>>>> DONE >>>>>>>>>>>>>"); }
public override unsafe Task Load() { return(Task.Run(() => { bool foundOneMap = false; for (int i = 0; i < Constants.MAPS_COUNT; i++) { string path = UOFileManager.GetUOFilePath($"map{i}LegacyMUL.uop"); if (Client.IsUOPInstallation && File.Exists(path)) { _filesMap[i] = new UOFileUop(path, $"build/map{i}legacymul/{{0:D8}}.dat"); Entries[i] = new UOFileIndex[((UOFileUop)_filesMap[i]).TotalEntriesCount]; ((UOFileUop)_filesMap[i]).FillEntries(ref Entries[i], false); foundOneMap = true; } else { path = UOFileManager.GetUOFilePath($"map{i}.mul"); if (File.Exists(path)) { _filesMap[i] = new UOFileMul(path); foundOneMap = true; } path = UOFileManager.GetUOFilePath($"mapdifl{i}.mul"); if (File.Exists(path)) { _mapDifl[i] = new UOFileMul(path); _mapDif[i] = new UOFileMul(UOFileManager.GetUOFilePath($"mapdif{i}.mul")); _staDifl[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadifl{i}.mul")); _staDifi[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadifi{i}.mul")); _staDif[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadif{i}.mul")); } } path = UOFileManager.GetUOFilePath($"statics{i}.mul"); if (File.Exists(path)) { _filesStatics[i] = new UOFileMul(path); } path = UOFileManager.GetUOFilePath($"staidx{i}.mul"); if (File.Exists(path)) { _filesIdxStatics[i] = new UOFileMul(path); } } if (!foundOneMap) { throw new FileNotFoundException("No maps found."); } int mapblocksize = sizeof(MapBlock); if (_filesMap[0].Length / mapblocksize == 393216 || Client.Version < ClientVersion.CV_4011D) { MapsDefaultSize[0, 0] = MapsDefaultSize[1, 0] = 6144; } // This is an hack to patch correctly all maps when you have to fake map1 if (_filesMap[1] == null || _filesMap[1].StartAddress == IntPtr.Zero) { _filesMap[1] = _filesMap[0]; _filesStatics[1] = _filesStatics[0]; _filesIdxStatics[1] = _filesIdxStatics[0]; } //for (int i = 0; i < MAPS_COUNT; i++) Parallel.For(0, Constants.MAPS_COUNT, i => { MapBlocksSize[i, 0] = MapsDefaultSize[i, 0] >> 3; MapBlocksSize[i, 1] = MapsDefaultSize[i, 1] >> 3; LoadMap(i); }); Entries = null; })); }
public override Task Load() { return(Task.Run(() => { string path = UOFileManager.GetUOFilePath("gumpartLegacyMUL.uop"); if (Client.IsUOPInstallation && File.Exists(path)) { _file = new UOFileUop(path, "build/gumpartlegacymul/{0:D8}.tga", true); Entries = new UOFileIndex[Constants.MAX_GUMP_DATA_INDEX_COUNT]; Client.UseUOPGumps = true; } else { path = UOFileManager.GetUOFilePath("gumpart.mul"); string pathidx = UOFileManager.GetUOFilePath("gumpidx.mul"); if (!File.Exists(path)) { path = UOFileManager.GetUOFilePath("Gumpart.mul"); } if (!File.Exists(pathidx)) { pathidx = UOFileManager.GetUOFilePath("Gumpidx.mul"); } _file = new UOFileMul(path, pathidx, Constants.MAX_GUMP_DATA_INDEX_COUNT, 12); Client.UseUOPGumps = false; } _file.FillEntries(ref Entries); string pathdef = UOFileManager.GetUOFilePath("gump.def"); if (!File.Exists(pathdef)) { return; } using (DefReader defReader = new DefReader(pathdef, 3)) { while (defReader.Next()) { int ingump = defReader.ReadInt(); if (ingump < 0 || ingump >= Constants.MAX_GUMP_DATA_INDEX_COUNT || ingump >= Entries.Length || Entries[ingump].Length > 0) { continue; } int[] group = defReader.ReadGroup(); if (group == null) { continue; } for (int i = 0; i < group.Length; i++) { int checkIndex = group[i]; if (checkIndex < 0 || checkIndex >= Constants.MAX_GUMP_DATA_INDEX_COUNT || checkIndex >= Entries.Length || Entries[checkIndex].Length <= 0) { continue; } Entries[ingump] = Entries[checkIndex]; Entries[ingump].Hue = (ushort)defReader.ReadInt(); break; } } } })); }
private string[] ReadCityTextFile(int count) { string path = UOFileManager.GetUOFilePath("citytext.enu"); if (!File.Exists(path)) { return(null); } string[] descr = new string[count]; // TODO: stackalloc ? byte[] data = new byte[4]; StringBuilder name = new StringBuilder(); StringBuilder text = new StringBuilder(); using (FileStream stream = File.OpenRead(path)) { int cityIndex = 0; while (stream.Position < stream.Length) { int r = stream.Read(data, 0, 4); if (r == -1) { break; } string dataText = Encoding.UTF8.GetString(data, 0, 4); if (dataText == "END\0") { name.Clear(); while (stream.Position < stream.Length) { char b = (char)stream.ReadByte(); if (b == '<') { stream.Position -= 1; break; } name.Append(b); } text.Clear(); while (stream.Position < stream.Length) { char b; while ((b = (char)stream.ReadByte()) != '\0') { text.Append(b); } if (text.Length != 0) { string t = text + "\n\n"; text.Clear(); text.Append(t); } long pos = stream.Position; byte end = (byte)stream.ReadByte(); stream.Position = pos; if (end == 0x2E) { break; } int r1 = stream.Read(data, 0, 4); stream.Position = pos; if (r1 == -1) { break; } string dataText1 = Encoding.UTF8.GetString(data, 0, 4); if (dataText1 == "END\0") { break; } } if (descr.Length <= cityIndex) { break; } descr[cityIndex++] = text.ToString(); } else { stream.Position -= 3; } } } return(descr); }