mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Prevent some crashes when default values can't be obtained.
This commit is contained in:
parent
87e8f2599c
commit
3128c2017d
1 changed files with 52 additions and 32 deletions
|
|
@ -117,6 +117,8 @@ namespace Penumbra.Meta.Files
|
|||
|
||||
// Check that a given meta manipulation is an actual change to the default value. We don't need to keep changes to default.
|
||||
public bool CheckAgainstDefault( MetaManipulation m )
|
||||
{
|
||||
try
|
||||
{
|
||||
return m.Type switch
|
||||
{
|
||||
|
|
@ -128,7 +130,8 @@ namespace Penumbra.Meta.Files
|
|||
MetaType.Eqp => GetDefaultEqpFile()?.GetEntry( m.EqpIdentifier.SetId )
|
||||
.Reduce( m.EqpIdentifier.Slot )
|
||||
== m.EqpValue,
|
||||
MetaType.Eqdp => GetDefaultEqdpFile( m.EqdpIdentifier.Slot, m.EqdpIdentifier.GenderRace )?.GetEntry( m.EqdpIdentifier.SetId )
|
||||
MetaType.Eqdp => GetDefaultEqdpFile( m.EqdpIdentifier.Slot, m.EqdpIdentifier.GenderRace )
|
||||
?.GetEntry( m.EqdpIdentifier.SetId )
|
||||
.Reduce( m.EqdpIdentifier.Slot )
|
||||
== m.EqdpValue,
|
||||
MetaType.Est => GetDefaultEstFile( m.EstIdentifier.ObjectType, m.EstIdentifier.EquipSlot, m.EstIdentifier.BodySlot )
|
||||
|
|
@ -136,11 +139,20 @@ namespace Penumbra.Meta.Files
|
|||
== m.EstValue,
|
||||
MetaType.Rsp => GetDefaultCmpFile()?[ m.RspIdentifier.SubRace ][ m.RspIdentifier.Attribute ]
|
||||
== m.RspValue,
|
||||
_ => throw new NotImplementedException(),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Could not obtain default value for {m.CorrespondingFilename()} - {m.IdentifierString()}:\n{e}" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public object? GetDefaultValue( MetaManipulation m )
|
||||
{
|
||||
try
|
||||
{
|
||||
return m.Type switch
|
||||
{
|
||||
|
|
@ -149,14 +161,22 @@ namespace Penumbra.Meta.Files
|
|||
MetaType.Gmp => GetDefaultGmpFile()?.GetEntry( m.GmpIdentifier.SetId ),
|
||||
MetaType.Eqp => GetDefaultEqpFile()?.GetEntry( m.EqpIdentifier.SetId )
|
||||
.Reduce( m.EqpIdentifier.Slot ),
|
||||
MetaType.Eqdp => GetDefaultEqdpFile( m.EqdpIdentifier.Slot, m.EqdpIdentifier.GenderRace )?.GetEntry( m.EqdpIdentifier.SetId )
|
||||
MetaType.Eqdp => GetDefaultEqdpFile( m.EqdpIdentifier.Slot, m.EqdpIdentifier.GenderRace )
|
||||
?.GetEntry( m.EqdpIdentifier.SetId )
|
||||
.Reduce( m.EqdpIdentifier.Slot ),
|
||||
MetaType.Est => GetDefaultEstFile( m.EstIdentifier.ObjectType, m.EstIdentifier.EquipSlot, m.EstIdentifier.BodySlot )
|
||||
?.GetEntry( m.EstIdentifier.GenderRace, m.EstIdentifier.PrimaryId ),
|
||||
MetaType.Rsp => GetDefaultCmpFile()?[ m.RspIdentifier.SubRace ][ m.RspIdentifier.Attribute ],
|
||||
_ => throw new NotImplementedException(),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Could not obtain default value for {m.CorrespondingFilename()} - {m.IdentifierString()}:\n{e}" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a deep copy of a default file as a new file.
|
||||
public object? CreateNewFile( MetaManipulation m )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue