Make meta parsing more robust.

This commit is contained in:
Ottermandias 2021-04-20 22:13:56 +02:00
parent a722acbc94
commit 5d97f77dc3
2 changed files with 19 additions and 10 deletions

View file

@ -139,13 +139,19 @@ namespace Penumbra.Importer
}
private void AddIfNotDefault( MetaManipulation manipulation )
{
try
{
if( !Service< MetaDefaults >.Get().CheckAgainstDefault( manipulation ) )
{
Service< MetaDefaults >.Get().CheckAgainstDefault( manipulation );
Manipulations.Add( manipulation );
}
}
catch( Exception e )
{
PluginLog.Debug("Skipped {Type}-manipulation:\n{e:l}", manipulation.Type, e );
}
}
private void DeserializeEqpEntry( Info info, byte[]? data )
{

View file

@ -9,6 +9,13 @@ using Penumbra.Mods;
namespace Penumbra.MetaData
{
public class InvalidImcVariantException : ArgumentOutOfRangeException
{
public InvalidImcVariantException()
: base("Trying to manipulate invalid variant.")
{ }
}
public static class ImcExtensions
{
public static bool Equal( this ImcFile.ImageChangeData lhs, ImcFile.ImageChangeData rhs )
@ -84,15 +91,11 @@ namespace Penumbra.MetaData
if( imc.Variant > parts[ idx ].Variants.Length )
{
PluginLog.Debug( "Trying to manipulate invalid variant {Variant} of {NumVariants} in file {FileName}.", imc.Variant,
parts[ idx ].Variants.Length, file.FilePath.Path );
return ref parts[ idx ].Variants[ parts[ idx ].Variants.Length - 1 ];
throw new InvalidImcVariantException();
}
else
{
return ref parts[ idx ].Variants[ imc.Variant - 1 ];
}
}
public static ImcFile Clone( this ImcFile file )
{