add some failsafes around assignment and application of data

This commit is contained in:
Stanley Dimant
2022-07-24 19:29:50 +02:00
parent db4854cba9
commit 03414c9c94
3 changed files with 40 additions and 10 deletions

View File

@@ -68,8 +68,11 @@ public class CharacterDataFactory
{ {
var indentation = GetIndentationForInheritanceLevel(inheritanceLevel); var indentation = GetIndentationForInheritanceLevel(inheritanceLevel);
Logger.Verbose(indentation.Item1 + objectKind + resourceType + " [" + string.Join(", ", fileReplacement.GamePaths) + "]"); if (fileReplacement.HasFileReplacement)
Logger.Verbose(indentation.Item2 + "=> " + fileReplacement.ResolvedPath); {
Logger.Verbose(indentation.Item1 + objectKind + resourceType + " [" + string.Join(", ", fileReplacement.GamePaths) + "]");
Logger.Verbose(indentation.Item2 + "=> " + fileReplacement.ResolvedPath);
}
} }
private unsafe void AddReplacementsFromRenderModel(RenderModel* mdl, ObjectKind objectKind, CharacterData cache, int inheritanceLevel = 0) private unsafe void AddReplacementsFromRenderModel(RenderModel* mdl, ObjectKind objectKind, CharacterData cache, int inheritanceLevel = 0)
@@ -89,7 +92,7 @@ public class CharacterDataFactory
Logger.Warn("Could not get model data for " + objectKind); Logger.Warn("Could not get model data for " + objectKind);
return; return;
} }
Logger.Verbose("Adding File Replacement for Model " + mdlPath); //Logger.Verbose("Adding File Replacement for Model " + mdlPath);
FileReplacement mdlFileReplacement = CreateFileReplacement(mdlPath); FileReplacement mdlFileReplacement = CreateFileReplacement(mdlPath);
DebugPrint(mdlFileReplacement, objectKind, "Model", inheritanceLevel); DebugPrint(mdlFileReplacement, objectKind, "Model", inheritanceLevel);
@@ -119,7 +122,7 @@ public class CharacterDataFactory
return; return;
} }
Logger.Verbose("Adding File Replacement for Material " + fileName); //Logger.Verbose("Adding File Replacement for Material " + fileName);
var mtrlPath = fileName.Split("|")[2]; var mtrlPath = fileName.Split("|")[2];
var mtrlFileReplacement = CreateFileReplacement(mtrlPath); var mtrlFileReplacement = CreateFileReplacement(mtrlPath);
@@ -130,7 +133,15 @@ public class CharacterDataFactory
var mtrlResourceHandle = (MtrlResource*)mtrl->ResourceHandle; var mtrlResourceHandle = (MtrlResource*)mtrl->ResourceHandle;
for (var resIdx = 0; resIdx < mtrlResourceHandle->NumTex; resIdx++) for (var resIdx = 0; resIdx < mtrlResourceHandle->NumTex; resIdx++)
{ {
var texPath = new Utf8String(mtrlResourceHandle->TexString(resIdx)).ToString(); string? texPath = null;
try
{
texPath = new Utf8String(mtrlResourceHandle->TexString(resIdx)).ToString();
}
catch
{
Logger.Warn("Could not get Texture data for Material " + fileName);
}
if (string.IsNullOrEmpty(texPath)) continue; if (string.IsNullOrEmpty(texPath)) continue;
@@ -142,7 +153,7 @@ public class CharacterDataFactory
{ {
if (texPath.IsNullOrEmpty()) return; if (texPath.IsNullOrEmpty()) return;
Logger.Verbose("Adding File Replacement for Texture " + texPath); //Logger.Verbose("Adding File Replacement for Texture " + texPath);
var texFileReplacement = CreateFileReplacement(texPath, doNotReverseResolve); var texFileReplacement = CreateFileReplacement(texPath, doNotReverseResolve);
DebugPrint(texFileReplacement, objectKind, "Texture", inheritanceLevel); DebugPrint(texFileReplacement, objectKind, "Texture", inheritanceLevel);
@@ -213,8 +224,22 @@ public class CharacterDataFactory
} }
AddReplacementSkeleton(((HumanExt*)human)->Human.RaceSexId, objectKind, previousData); AddReplacementSkeleton(((HumanExt*)human)->Human.RaceSexId, objectKind, previousData);
AddReplacementsFromTexture(new Utf8String(((HumanExt*)human)->Decal->FileName()).ToString(), objectKind, previousData, 0, false); try
AddReplacementsFromTexture(new Utf8String(((HumanExt*)human)->LegacyBodyDecal->FileName()).ToString(), objectKind, previousData, 0, false); {
AddReplacementsFromTexture(new Utf8String(((HumanExt*)human)->Decal->FileName()).ToString(), objectKind, previousData, 0, false);
}
catch
{
Logger.Warn("Could not get Decal data");
}
try
{
AddReplacementsFromTexture(new Utf8String(((HumanExt*)human)->LegacyBodyDecal->FileName()).ToString(), objectKind, previousData, 0, false);
}
catch
{
Logger.Warn("Could not get Legacy Body Decal Data");
}
} }
st.Stop(); st.Stop();

View File

@@ -138,7 +138,10 @@ public class CachedPlayer
foreach (var kind in objectKind) foreach (var kind in objectKind)
{ {
ApplyCustomizationData(kind); if (_cachedData.GlamourerData.ContainsKey(kind))
{
ApplyCustomizationData(kind);
}
} }
}, downloadToken).ContinueWith(task => }, downloadToken).ContinueWith(task =>
{ {
@@ -147,6 +150,8 @@ public class CachedPlayer
Logger.Debug("Download Task was cancelled"); Logger.Debug("Download Task was cancelled");
_apiController.CancelDownload(downloadId); _apiController.CancelDownload(downloadId);
}); });
_downloadCancellationTokenSource = null;
} }
private List<FileReplacementDto> TryCalculateModdedDictionary(out Dictionary<string, string> moddedDictionary) private List<FileReplacementDto> TryCalculateModdedDictionary(out Dictionary<string, string> moddedDictionary)

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>0.2.0.0</Version> <Version>0.2.1.0</Version>
<Description></Description> <Description></Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl> <PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>