fix mods not applying race condition, fix service settings empty maybe
This commit is contained in:
		| @@ -183,8 +183,6 @@ public class PlayerDataFactory | |||||||
|  |  | ||||||
|             if (string.IsNullOrEmpty(texPath)) continue; |             if (string.IsNullOrEmpty(texPath)) continue; | ||||||
|  |  | ||||||
|             _logger.LogTrace("Checking File Replacement for Texture {file}", texPath); |  | ||||||
|  |  | ||||||
|             AddReplacementsFromTexture(texPath, forwardResolve, reverseResolve); |             AddReplacementsFromTexture(texPath, forwardResolve, reverseResolve); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -234,7 +232,7 @@ public class PlayerDataFactory | |||||||
|     { |     { | ||||||
|         if (string.IsNullOrEmpty(texPath)) return; |         if (string.IsNullOrEmpty(texPath)) return; | ||||||
|  |  | ||||||
|         _logger.LogTrace("Checking file Replacement for texture {path}", texPath); |         _logger.LogTrace("Checking File Replacement for Texture {path}", texPath); | ||||||
|  |  | ||||||
|         if (doNotReverseResolve) |         if (doNotReverseResolve) | ||||||
|             forwardResolve.Add(texPath); |             forwardResolve.Add(texPath); | ||||||
|   | |||||||
| @@ -59,6 +59,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase | |||||||
|         Mediator.Subscribe<FrameworkUpdateMessage>(this, (_) => FrameworkUpdate()); |         Mediator.Subscribe<FrameworkUpdateMessage>(this, (_) => FrameworkUpdate()); | ||||||
|         Mediator.Subscribe<ZoneSwitchStartMessage>(this, (_) => |         Mediator.Subscribe<ZoneSwitchStartMessage>(this, (_) => | ||||||
|         { |         { | ||||||
|  |             MediatorUnsubscribeFromCharacterChanged(); | ||||||
|             _charaHandler?.Invalidate(); |             _charaHandler?.Invalidate(); | ||||||
|             IsVisible = false; |             IsVisible = false; | ||||||
|         }); |         }); | ||||||
| @@ -89,7 +90,9 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase | |||||||
|         { |         { | ||||||
|             Logger.LogDebug("[BASE-{appBase}] Received data but player was in invalid state, charaHandlerIsNull: {charaIsNull}, playerPointerIsNull: {ptrIsNull}", |             Logger.LogDebug("[BASE-{appBase}] Received data but player was in invalid state, charaHandlerIsNull: {charaIsNull}, playerPointerIsNull: {ptrIsNull}", | ||||||
|                 applicationBase, _charaHandler == null, PlayerCharacter == IntPtr.Zero); |                 applicationBase, _charaHandler == null, PlayerCharacter == IntPtr.Zero); | ||||||
|             _forceApplyMods = _forceApplyMods || (PlayerCharacter == IntPtr.Zero && _cachedData == null); |             var hasDiffMods = characterData.CheckUpdatedData(applicationBase, _cachedData, Logger, | ||||||
|  |                 this, forceApplyCustomization, false).Any(p => p.Value.Contains(PlayerChanges.ModManip) || p.Value.Contains(PlayerChanges.ModFiles)); | ||||||
|  |             _forceApplyMods = hasDiffMods || _forceApplyMods || (PlayerCharacter == IntPtr.Zero && _cachedData == null); | ||||||
|             _cachedData = characterData; |             _cachedData = characterData; | ||||||
|             Logger.LogDebug("[BASE-{appBase}] Setting data: {hash}, forceApplyMods: {force}", applicationBase, _cachedData.DataHash.Value, _forceApplyMods); |             Logger.LogDebug("[BASE-{appBase}] Setting data: {hash}, forceApplyMods: {force}", applicationBase, _cachedData.DataHash.Value, _forceApplyMods); | ||||||
|             return; |             return; | ||||||
| @@ -100,14 +103,11 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase | |||||||
|         Logger.LogDebug("[BASE-{appbase}] Applying data for {player}, forceApplyCustomization: {forced}, forceApplyMods: {forceMods}", applicationBase, this, forceApplyCustomization, _forceApplyMods); |         Logger.LogDebug("[BASE-{appbase}] Applying data for {player}, forceApplyCustomization: {forced}, forceApplyMods: {forceMods}", applicationBase, this, forceApplyCustomization, _forceApplyMods); | ||||||
|         Logger.LogDebug("[BASE-{appbase}] Hash for data is {newHash}, current cache hash is {oldHash}", applicationBase, characterData.DataHash.Value, _cachedData?.DataHash.Value ?? "NODATA"); |         Logger.LogDebug("[BASE-{appbase}] Hash for data is {newHash}, current cache hash is {oldHash}", applicationBase, characterData.DataHash.Value, _cachedData?.DataHash.Value ?? "NODATA"); | ||||||
|  |  | ||||||
|         if (!_ipcManager.CheckPenumbraApi()) return; |  | ||||||
|         if (!_ipcManager.CheckGlamourerApi()) return; |  | ||||||
|  |  | ||||||
|         if (string.Equals(characterData.DataHash.Value, _cachedData?.DataHash.Value ?? string.Empty, StringComparison.Ordinal) && !forceApplyCustomization) return; |         if (string.Equals(characterData.DataHash.Value, _cachedData?.DataHash.Value ?? string.Empty, StringComparison.Ordinal) && !forceApplyCustomization) return; | ||||||
|  |  | ||||||
|         if (_dalamudUtil.IsInCutscene || _dalamudUtil.IsInGpose) |         if (_dalamudUtil.IsInCutscene || _dalamudUtil.IsInGpose || !_ipcManager.CheckPenumbraApi() || !_ipcManager.CheckGlamourerApi()) | ||||||
|         { |         { | ||||||
|             Logger.LogInformation("[BASE-{appbase}] Application of data for {player} while in cutscene/gpose, returning", applicationBase, this); |             Logger.LogInformation("[BASE-{appbase}] Application of data for {player} while in cutscene/gpose or Penumbra/Glamourer unavailable, returning", applicationBase, this); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -396,12 +396,12 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase | |||||||
|  |  | ||||||
|         if (_charaHandler?.Address != nint.Zero && !IsVisible) |         if (_charaHandler?.Address != nint.Zero && !IsVisible) | ||||||
|         { |         { | ||||||
|  |             Guid appData = Guid.NewGuid(); | ||||||
|             IsVisible = true; |             IsVisible = true; | ||||||
|             Mediator.Publish(new PairHandlerVisibleMessage(this)); |             Mediator.Publish(new PairHandlerVisibleMessage(this)); | ||||||
|             if (_cachedData != null) |             if (_cachedData != null) | ||||||
|             { |             { | ||||||
|                 Guid appData = Guid.NewGuid(); |                 Logger.LogTrace("[BASE-{appBase}] {this} visibility changed, now: {visi}, cached data exists", appData, this, IsVisible); | ||||||
|                 Logger.LogTrace("{this} visibility changed, now: {visi}, cached data exists => application {app}", this, IsVisible, appData); |  | ||||||
|  |  | ||||||
|                 Task.Run(async () => |                 Task.Run(async () => | ||||||
|                 { |                 { | ||||||
| @@ -413,11 +413,14 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase | |||||||
|             { |             { | ||||||
|                 Logger.LogTrace("{this} visibility changed, now: {visi}, no cached data exists", this, IsVisible); |                 Logger.LogTrace("{this} visibility changed, now: {visi}, no cached data exists", this, IsVisible); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             MediatorSubscribeToCharacterChanged(); | ||||||
|         } |         } | ||||||
|         else if (_charaHandler?.Address == nint.Zero && IsVisible) |         else if (_charaHandler?.Address == nint.Zero && IsVisible) | ||||||
|         { |         { | ||||||
|             IsVisible = false; |             IsVisible = false; | ||||||
|             _charaHandler?.Invalidate(); |             _charaHandler?.Invalidate(); | ||||||
|  |             MediatorUnsubscribeFromCharacterChanged(); | ||||||
|             Logger.LogTrace("{this} visibility changed, now: {visi}", this, IsVisible); |             Logger.LogTrace("{this} visibility changed, now: {visi}", this, IsVisible); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -430,18 +433,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase | |||||||
|         _originalGlamourerData = _ipcManager.GlamourerGetCharacterCustomizationAsync(PlayerCharacter).ConfigureAwait(false).GetAwaiter().GetResult(); |         _originalGlamourerData = _ipcManager.GlamourerGetCharacterCustomizationAsync(PlayerCharacter).ConfigureAwait(false).GetAwaiter().GetResult(); | ||||||
|         _lastGlamourerData = _originalGlamourerData; |         _lastGlamourerData = _originalGlamourerData; | ||||||
|         Mediator.Subscribe<PenumbraRedrawMessage>(this, IpcManagerOnPenumbraRedrawEvent); |         Mediator.Subscribe<PenumbraRedrawMessage>(this, IpcManagerOnPenumbraRedrawEvent); | ||||||
|         Mediator.Subscribe<CharacterChangedMessage>(this, async (msg) => |  | ||||||
|         { |  | ||||||
|             if (msg.GameObjectHandler == _charaHandler && (_applicationTask?.IsCompleted ?? true)) |  | ||||||
|             { |  | ||||||
|                 Logger.LogTrace("Saving new Glamourer Data for {this}", this); |  | ||||||
|                 _lastGlamourerData = await _ipcManager.GlamourerGetCharacterCustomizationAsync(PlayerCharacter).ConfigureAwait(false); |  | ||||||
|                 if (_cachedData != null) |  | ||||||
|                 { |  | ||||||
|                     ApplyCharacterData(Guid.NewGuid(), _cachedData!, true); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|         Mediator.Subscribe<HonorificReadyMessage>(this, async (_) => |         Mediator.Subscribe<HonorificReadyMessage>(this, async (_) => | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(_cachedData?.HonorificData)) return; |             if (string.IsNullOrEmpty(_cachedData?.HonorificData)) return; | ||||||
| @@ -476,6 +467,33 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase | |||||||
|         }, token); |         }, token); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private void MediatorSubscribeToCharacterChanged() | ||||||
|  |     { | ||||||
|  |         Mediator.Subscribe<CharacterChangedMessage>(this, (msg) => | ||||||
|  |         { | ||||||
|  |             if (msg.GameObjectHandler == _charaHandler && (_applicationTask?.IsCompleted ?? true)) | ||||||
|  |             { | ||||||
|  |                 Guid appBase = Guid.NewGuid(); | ||||||
|  |                 var newGlamData = _ipcManager.GlamourerGetCharacterCustomizationAsync(PlayerCharacter).ConfigureAwait(false).GetAwaiter().GetResult(); | ||||||
|  |                 if (!string.Equals(_lastGlamourerData, newGlamData, StringComparison.OrdinalIgnoreCase)) | ||||||
|  |                 { | ||||||
|  |                     Logger.LogTrace("[BASE-{appBase}] Saving new Glamourer Data for {this}", appBase, this); | ||||||
|  |  | ||||||
|  |                     _lastGlamourerData = newGlamData; | ||||||
|  |                     if (_cachedData != null) | ||||||
|  |                     { | ||||||
|  |                         ApplyCharacterData(appBase, _cachedData!, true); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void MediatorUnsubscribeFromCharacterChanged() | ||||||
|  |     { | ||||||
|  |         Mediator.Unsubscribe<CharacterChangedMessage>(this); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     private async Task RevertCustomizationDataAsync(ObjectKind objectKind, string name, Guid applicationId) |     private async Task RevertCustomizationDataAsync(ObjectKind objectKind, string name, Guid applicationId) | ||||||
|     { |     { | ||||||
|         nint address = _dalamudUtil.GetPlayerCharacterFromCachedTableByIdent(OnlineUser.Ident); |         nint address = _dalamudUtil.GetPlayerCharacterFromCachedTableByIdent(OnlineUser.Ident); | ||||||
|   | |||||||
| @@ -23,6 +23,7 @@ public class ServerConfigurationManager | |||||||
|         _serverTagConfig = serverTagConfig; |         _serverTagConfig = serverTagConfig; | ||||||
|         _notesConfig = notesConfig; |         _notesConfig = notesConfig; | ||||||
|         _dalamudUtil = dalamudUtil; |         _dalamudUtil = dalamudUtil; | ||||||
|  |         EnsureMainExists(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public string CurrentApiUrl => CurrentServer.ServerUri; |     public string CurrentApiUrl => CurrentServer.ServerUri; | ||||||
| @@ -96,11 +97,7 @@ public class ServerConfigurationManager | |||||||
|         catch |         catch | ||||||
|         { |         { | ||||||
|             _configService.Current.CurrentServer = 0; |             _configService.Current.CurrentServer = 0; | ||||||
|             if (!string.Equals(_configService.Current.ServerStorage[0].ServerUri, ApiController.MainServer, StringComparison.OrdinalIgnoreCase)) |             EnsureMainExists(); | ||||||
|             { |  | ||||||
|                 _configService.Current.ServerStorage.Insert(0, new ServerStorage() { ServerUri = ApiController.MainServiceUri, ServerName = ApiController.MainServer }); |  | ||||||
|             } |  | ||||||
|             Save(); |  | ||||||
|             return CurrentServer!; |             return CurrentServer!; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -341,6 +338,15 @@ public class ServerConfigurationManager | |||||||
|         return _serverTagConfig.Current.ServerTagStorage[CurrentApiUrl]; |         return _serverTagConfig.Current.ServerTagStorage[CurrentApiUrl]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private void EnsureMainExists() | ||||||
|  |     { | ||||||
|  |         if (_configService.Current.ServerStorage.Count == 0 || !string.Equals(_configService.Current.ServerStorage[0].ServerUri, ApiController.MainServiceUri, StringComparison.OrdinalIgnoreCase)) | ||||||
|  |         { | ||||||
|  |             _configService.Current.ServerStorage.Insert(0, new ServerStorage() { ServerUri = ApiController.MainServiceUri, ServerName = ApiController.MainServer }); | ||||||
|  |         } | ||||||
|  |         Save(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     private void TryCreateCurrentNotesStorage() |     private void TryCreateCurrentNotesStorage() | ||||||
|     { |     { | ||||||
|         if (!_notesConfig.Current.ServerNotes.ContainsKey(CurrentApiUrl)) |         if (!_notesConfig.Current.ServerNotes.ContainsKey(CurrentApiUrl)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 rootdarkarchon
					rootdarkarchon