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 void LoadGameFilesFromFileSystem() { Log.Trace("Checking for Ultima Online installation..."); Log.PushIndent(); try { UOFileManager.UoFolderPath = Settings.GlobalSettings.UltimaOnlineDirectory; } catch (FileNotFoundException) { Log.Error("Wrong Ultima Online installation folder."); throw; } Log.Trace("Done!"); Log.Trace($"Ultima Online installation folder: {UOFileManager.UoFolderPath}"); Log.PopIndent(); Log.Trace("Loading files..."); Log.PushIndent(); UOFileManager.LoadFiles(); Log.PopIndent(); uint[] hues = UOFileManager.Hues.CreateShaderColors(); int size = UOFileManager.Hues.HuesCount; Texture2D texture0 = new Texture2D(GraphicsDevice, 32, size * 2); texture0.SetData(hues, 0, size * 2); Texture2D texture1 = new Texture2D(GraphicsDevice, 32, size); texture1.SetData(hues, size, size); GraphicsDevice.Textures[1] = texture0; GraphicsDevice.Textures[2] = texture1; AuraManager.CreateAuraTexture(); Log.Trace("Network calibration..."); Log.PushIndent(); PacketHandlers.Load(); //ATTENTION: you will need to enable ALSO ultimalive server-side, or this code will have absolutely no effect! UltimaLive.Enable(); PacketsTable.AdjustPacketSizeByVersion(UOFileManager.ClientVersion); Log.Trace("Done!"); Log.PopIndent(); Log.Trace("Loading plugins..."); Log.PushIndent(); UIManager.InitializeGameCursor(); foreach (var p in Settings.GlobalSettings.Plugins) { Plugin.Create(p); } Log.Trace("Done!"); Log.PopIndent(); UoAssist.Start(); }
protected override void Initialize() { Settings settings = ConfigurationResolver.Load <Settings>(Path.Combine(Bootstrap.ExeDirectory, "settings.json")); if (settings == null) { Log.Message(LogTypes.Trace, "settings.json file was not found creating default"); settings = new Settings(); ConfigurationResolver.Save(settings, "settings.json"); Process.Start("notepad.exe", "settings.json"); Exit(); return; } Service.Register(settings); Log.Message(LogTypes.Trace, "Checking for Ultima Online installation..."); try { FileManager.UoFolderPath = settings.UltimaOnlineDirectory; } catch (FileNotFoundException e) { Log.Message(LogTypes.Error, "Wrong Ultima Online installation folder."); throw e; } Log.Message(LogTypes.Trace, "Done!"); Log.Message(LogTypes.Trace, $"Ultima Online installation folder: {FileManager.UoFolderPath}"); Log.Message(LogTypes.Trace, "Loading files..."); Stopwatch stopwatch = Stopwatch.StartNew(); FileManager.LoadFiles(); uint[] hues = Hues.CreateShaderColors(); Texture2D texture0 = new Texture2D(GraphicsDevice, 32, Hues.HuesCount); texture0.SetData(hues, 0, 32 * Hues.HuesCount); Texture2D texture1 = new Texture2D(GraphicsDevice, 32, Hues.HuesCount); texture1.SetData(hues, 32 * Hues.HuesCount, 32 * Hues.HuesCount); GraphicsDevice.Textures[1] = texture0; GraphicsDevice.Textures[2] = texture1; Log.Message(LogTypes.Trace, $"Files loaded in: {stopwatch.ElapsedMilliseconds} ms!"); stopwatch.Stop(); InputManager.Initialize(); //Register Service Stack Service.Register(this); Service.Register(_sb3D = new SpriteBatch3D(GraphicsDevice)); Service.Register(_sbUI = new SpriteBatchUI(GraphicsDevice)); Service.Register(_uiManager = new UIManager()); //Register Command Stack Commands.Initialize(); Log.Message(LogTypes.Trace, "Network calibration..."); PacketHandlers.Load(); PacketsTable.AdjustPacketSizeByVersion(FileManager.ClientVersion); Log.Message(LogTypes.Trace, "Done!"); MaxFPS = settings.MaxFPS; _infoText = new RenderedText { IsUnicode = true, Font = 3, FontStyle = FontStyle.BlackBorder, Align = TEXT_ALIGN_TYPE.TS_LEFT, MaxWidth = 150 }; base.Initialize(); }
protected override void Initialize() { //uncomment it and fill it to save your first settings //Settings settings1 = new Settings() //{ //}; //ConfigurationResolver.Save(settings1, "settings.json"); Settings settings = ConfigurationResolver.Load <Settings>(Path.Combine(Bootstrap.ExeDirectory, "settings.json")); Service.Register(settings); Log.Message(LogTypes.Trace, "Checking for Ultima Online installation..."); try { FileManager.UoFolderPath = settings.UltimaOnlineDirectory; } catch (FileNotFoundException e) { Log.Message(LogTypes.Error, "Wrong Ultima Online installation folder."); throw e; } Log.Message(LogTypes.Trace, "Done!"); Log.Message(LogTypes.Trace, $"Ultima Online installation folder: {FileManager.UoFolderPath}"); Log.Message(LogTypes.Trace, "Loading files..."); Stopwatch stopwatch = Stopwatch.StartNew(); FileManager.LoadFiles(); uint[] hues = Hues.CreateShaderColors(); Texture2D texture0 = new Texture2D(GraphicsDevice, 32, 3000); texture0.SetData(hues, 0, 32 * 3000); Texture2D texture1 = new Texture2D(GraphicsDevice, 32, 3000); texture1.SetData(hues, 32 * 3000, 32 * 3000); GraphicsDevice.Textures[1] = texture0; GraphicsDevice.Textures[2] = texture1; Log.Message(LogTypes.Trace, $"Files loaded in: {stopwatch.ElapsedMilliseconds} ms!"); stopwatch.Stop(); //Register Service Stack Service.Register(this); Service.Register(new SpriteBatch3D(GraphicsDevice)); Service.Register(new SpriteBatchUI(GraphicsDevice)); Service.Register(new InputManager()); Service.Register(_uiManager = new UIManager()); Service.Register(_sceneManager = new SceneManager()); Service.Register(_journalManager = new JournalData()); //Register Command Stack PartySystem.RegisterCommands(); _inputManager = Service.Get <InputManager>(); _sb3D = Service.Get <SpriteBatch3D>(); _sbUI = Service.Get <SpriteBatchUI>(); Log.Message(LogTypes.Trace, "Network calibration..."); PacketHandlers.Load(); PacketsTable.AdjustPacketSizeByVersion(FileManager.ClientVersion); Log.Message(LogTypes.Trace, "Done!"); MaxFPS = settings.MaxFPS; _sceneManager.ChangeScene(ScenesType.Login); _infoText = new RenderedText { IsUnicode = true, Font = 3, FontStyle = FontStyle.BlackBorder, Align = TEXT_ALIGN_TYPE.TS_LEFT, MaxWidth = 150 }; base.Initialize(); }