fix some random texture loading issues I don't understand, fix loading issues
This commit is contained in:
		| @@ -40,17 +40,6 @@ namespace MareSynchronos.Factories | ||||
|             { | ||||
|                 fileReplacement.GamePaths = new List<string> { path }; | ||||
|                 fileReplacement.SetResolvedPath(_ipcManager.PenumbraResolvePath(path, _dalamudUtil.PlayerName)!); | ||||
|                 if (!fileReplacement.HasFileReplacement) | ||||
|                 { | ||||
|                     // try resolving tex with -- in name instead | ||||
|                     path = path.Insert(path.LastIndexOf('/') + 1, "--"); | ||||
|                     var reResolvedPath = _ipcManager.PenumbraResolvePath(path, _dalamudUtil.PlayerName)!; | ||||
|                     if (reResolvedPath != path) | ||||
|                     { | ||||
|                         fileReplacement.GamePaths = new List<string>() { path }; | ||||
|                         fileReplacement.SetResolvedPath(reResolvedPath); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return fileReplacement; | ||||
| @@ -93,8 +82,8 @@ namespace MareSynchronos.Factories | ||||
|                 var mdlPath = new Utf8String(mdl->ResourceHandle->FileName()).ToString(); | ||||
|  | ||||
|                 FileReplacement mdlFileReplacement = CreateFileReplacement(mdlPath); | ||||
|                 Logger.Verbose("Model " + string.Join(", ", mdlFileReplacement.GamePaths)); | ||||
|                 Logger.Verbose("\t\t=> " + mdlFileReplacement.ResolvedPath); | ||||
|                 Logger.Debug("Model " + string.Join(", ", mdlFileReplacement.GamePaths)); | ||||
|                 Logger.Debug("\t\t=> " + mdlFileReplacement.ResolvedPath); | ||||
|  | ||||
|                 cache.AddFileReplacement(mdlFileReplacement); | ||||
|  | ||||
| @@ -104,9 +93,11 @@ namespace MareSynchronos.Factories | ||||
|                     if (mtrl == null) continue; | ||||
|  | ||||
|                     var mtrlPath = new Utf8String(mtrl->ResourceHandle->FileName()).ToString().Split("|")[2]; | ||||
|  | ||||
|                     var mtrlFileReplacement = CreateFileReplacement(mtrlPath); | ||||
|                     Logger.Verbose("\tMaterial " + string.Join(", ", mtrlFileReplacement.GamePaths)); | ||||
|                     Logger.Verbose("\t\t\t=> " + mtrlFileReplacement.ResolvedPath); | ||||
|                     Logger.Debug("\tMaterial " + string.Join(", ", mtrlFileReplacement.GamePaths)); | ||||
|                     Logger.Debug("\t\t\t=> " + mtrlFileReplacement.ResolvedPath); | ||||
|  | ||||
|                     cache.AddFileReplacement(mtrlFileReplacement); | ||||
|  | ||||
|                     var mtrlResourceHandle = (MtrlResource*)mtrl->ResourceHandle; | ||||
| @@ -117,9 +108,19 @@ namespace MareSynchronos.Factories | ||||
|                         if (string.IsNullOrEmpty(texPath)) continue; | ||||
|  | ||||
|                         var texFileReplacement = CreateFileReplacement(texPath); | ||||
|                         Logger.Verbose("\t\tTexture " + string.Join(", ", texFileReplacement.GamePaths)); | ||||
|                         Logger.Verbose("\t\t\t\t=> " + texFileReplacement.ResolvedPath); | ||||
|                         Logger.Debug("\t\tTexture " + string.Join(", ", texFileReplacement.GamePaths)); | ||||
|                         Logger.Debug("\t\t\t\t=> " + texFileReplacement.ResolvedPath); | ||||
|  | ||||
|                         cache.AddFileReplacement(texFileReplacement); | ||||
|  | ||||
|                         if (texPath.Contains("/--")) continue; | ||||
|  | ||||
|                         var texDoubleMinusFileReplacement = | ||||
|                             CreateFileReplacement(texPath.Insert(texPath.LastIndexOf('/') + 1, "--")); | ||||
|  | ||||
|                         Logger.Debug("\t\tTexture-- " + string.Join(", ", texDoubleMinusFileReplacement.GamePaths)); | ||||
|                         Logger.Debug("\t\t\t\t=> " + texDoubleMinusFileReplacement.ResolvedPath); | ||||
|                         cache.AddFileReplacement(texDoubleMinusFileReplacement); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -39,6 +39,7 @@ public class CachedPlayer | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private bool _isDisposed = false; | ||||
|     private CancellationTokenSource? _downloadCancellationTokenSource; | ||||
|  | ||||
|     private string _lastGlamourerData = string.Empty; | ||||
| @@ -172,7 +173,8 @@ public class CachedPlayer | ||||
|  | ||||
|     public void DisposePlayer() | ||||
|     { | ||||
|         Logger.Debug("Disposing " + PlayerNameHash); | ||||
|         Logger.Debug("Disposing " + PlayerName + " (" + PlayerNameHash + ")"); | ||||
|         if (_isDisposed) return; | ||||
|         if (string.IsNullOrEmpty(PlayerName)) return; | ||||
|         try | ||||
|         { | ||||
| @@ -199,6 +201,7 @@ public class CachedPlayer | ||||
|             PlayerName = string.Empty; | ||||
|             PlayerCharacter = null; | ||||
|             IsVisible = false; | ||||
|             _isDisposed = true; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -212,6 +215,7 @@ public class CachedPlayer | ||||
|         _ipcManager.PenumbraRedrawEvent += IpcManagerOnPenumbraRedrawEvent; | ||||
|         _originalGlamourerData = _ipcManager.GlamourerGetCharacterCustomization(PlayerCharacter); | ||||
|         _currentCharacterEquipment = new CharacterEquipment(PlayerCharacter); | ||||
|         _isDisposed = false; | ||||
|         if (cache != null) | ||||
|         { | ||||
|             ApplyCharacterData(cache); | ||||
|   | ||||
| @@ -7,6 +7,7 @@ using MareSynchronos.API; | ||||
| using MareSynchronos.Utils; | ||||
| using MareSynchronos.WebAPI; | ||||
| using MareSynchronos.WebAPI.Utils; | ||||
| using Newtonsoft.Json; | ||||
|  | ||||
| namespace MareSynchronos.Managers; | ||||
|  | ||||
| @@ -70,7 +71,7 @@ public class OnlinePlayerManager : IDisposable | ||||
|  | ||||
|     private void PlayerManagerOnPlayerHasChanged(CharacterCacheDto characterCache) | ||||
|     { | ||||
|         _ = _apiController.PushCharacterData(characterCache, OnlineVisiblePlayerHashes); | ||||
|         PushCharacterData(OnlineVisiblePlayerHashes); | ||||
|     } | ||||
|  | ||||
|     private void ApiControllerOnConnected(object? sender, EventArgs e) | ||||
| @@ -215,16 +216,22 @@ public class OnlinePlayerManager : IDisposable | ||||
|         var newlyVisiblePlayers = _onlineCachedPlayers | ||||
|             .Where(p => p.PlayerCharacter != null && p.IsVisible && !p.WasVisible).Select(p => p.PlayerNameHash) | ||||
|             .ToList(); | ||||
|         if (newlyVisiblePlayers.Any() && _playerManager.LastSentCharacterData != null) | ||||
|         PushCharacterData(newlyVisiblePlayers); | ||||
|  | ||||
|         _lastPlayerObjectCheck = DateTime.Now; | ||||
|     } | ||||
|  | ||||
|     private void PushCharacterData(List<string> visiblePlayers) | ||||
|     { | ||||
|         if (visiblePlayers.Any() && _playerManager.LastSentCharacterData != null) | ||||
|         { | ||||
|             Task.Run(async () => | ||||
|             { | ||||
|                 Logger.Verbose(JsonConvert.SerializeObject(_playerManager.LastSentCharacterData!.ToCharacterCacheDto(), Formatting.Indented)); | ||||
|                 await _apiController.PushCharacterData(_playerManager.LastSentCharacterData.ToCharacterCacheDto(), | ||||
|                     newlyVisiblePlayers); | ||||
|                     visiblePlayers); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         _lastPlayerObjectCheck = DateTime.Now; | ||||
|     } | ||||
|  | ||||
|     private CachedPlayer CreateCachedPlayer(string hashedName) | ||||
|   | ||||
| @@ -34,11 +34,6 @@ namespace MareSynchronos.Models | ||||
|         [JsonProperty] | ||||
|         public string Hash { get; set; } = string.Empty; | ||||
|          | ||||
|         [JsonProperty] | ||||
|         public string ImcData { get; set; } = string.Empty; | ||||
|  | ||||
|         public bool IsInUse { get; set; } = false; | ||||
|  | ||||
|         [JsonProperty] | ||||
|         public string ResolvedPath { get; set; } = string.Empty; | ||||
|          | ||||
|   | ||||
| @@ -1,14 +1,23 @@ | ||||
| using System.Diagnostics; | ||||
| using System.Text; | ||||
| using Dalamud.Logging; | ||||
| using Dalamud.Utility; | ||||
|  | ||||
| namespace MareSynchronos.Utils | ||||
| { | ||||
|     internal class Logger | ||||
|     { | ||||
|         public static void Debug(string debug) | ||||
|         public static void Debug(string debug, string stringToHighlight = "") | ||||
|         { | ||||
|             var caller = new StackTrace().GetFrame(1)?.GetMethod()?.ReflectedType?.Name ?? "Unknown"; | ||||
|             PluginLog.Debug($"[{caller}] {debug}"); | ||||
|             if (debug.Contains(stringToHighlight) && !stringToHighlight.IsNullOrEmpty()) | ||||
|             { | ||||
|                 PluginLog.Warning($"[{caller}] {debug}"); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 PluginLog.Debug($"[{caller}] {debug}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public static void Warn(string warn) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Stanley Dimant
					Stanley Dimant