mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix handling of weird TTMP files.
This commit is contained in:
parent
4a9b08de98
commit
c8293c9a6b
1 changed files with 369 additions and 363 deletions
|
|
@ -4,7 +4,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using Newtonsoft.Json;
|
||||
using Penumbra.GameData.Util;
|
||||
|
|
@ -14,10 +13,10 @@ using Penumbra.Structs;
|
|||
using Penumbra.Util;
|
||||
using FileMode = System.IO.FileMode;
|
||||
|
||||
namespace Penumbra.Importer
|
||||
namespace Penumbra.Importer;
|
||||
|
||||
internal class TexToolsImport
|
||||
{
|
||||
internal class TexToolsImport
|
||||
{
|
||||
private readonly DirectoryInfo _outDirectory;
|
||||
|
||||
private const string TempFileName = "textools-import";
|
||||
|
|
@ -53,7 +52,7 @@ namespace Penumbra.Importer
|
|||
}
|
||||
|
||||
private static DirectoryInfo NewOptionDirectory( DirectoryInfo baseDir, string optionName )
|
||||
=> new( Path.Combine( baseDir.FullName, optionName.ReplaceBadXivSymbols() ) );
|
||||
=> new(Path.Combine( baseDir.FullName, optionName.ReplaceBadXivSymbols() ));
|
||||
|
||||
public DirectoryInfo ImportModPack( FileInfo modPackFile )
|
||||
{
|
||||
|
|
@ -130,8 +129,7 @@ namespace Penumbra.Importer
|
|||
|
||||
return ImportV2ModPack( modPackFile, extractedModPack, modRaw );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( modPackFile.Extension != ".ttmp" )
|
||||
{
|
||||
PluginLog.Warning( $"File {modPackFile.FullName} seems to be a V1 TTMP, but has the wrong extension." );
|
||||
|
|
@ -139,7 +137,6 @@ namespace Penumbra.Importer
|
|||
|
||||
return ImportV1ModPack( modPackFile, extractedModPack, modRaw );
|
||||
}
|
||||
}
|
||||
|
||||
private DirectoryInfo ImportV1ModPack( FileInfo modPackFile, ZipFile extractedModPack, string modRaw )
|
||||
{
|
||||
|
|
@ -175,27 +172,37 @@ namespace Penumbra.Importer
|
|||
return ExtractedDirectory;
|
||||
}
|
||||
|
||||
private DirectoryInfo ImportV2ModPack( FileInfo modPackFile, ZipFile extractedModPack, string modRaw )
|
||||
private DirectoryInfo ImportV2ModPack( FileInfo _, ZipFile extractedModPack, string modRaw )
|
||||
{
|
||||
var modList = JsonConvert.DeserializeObject< SimpleModPack >( modRaw );
|
||||
var modList = JsonConvert.DeserializeObject<SimpleModPack>( modRaw );
|
||||
|
||||
if( modList?.TTMPVersion == null )
|
||||
{
|
||||
PluginLog.Error( "Could not extract V2 Modpack. No version given." );
|
||||
return new DirectoryInfo( "" );
|
||||
}
|
||||
|
||||
if( modList.TTMPVersion.EndsWith( "s" ) )
|
||||
if( modList.TTMPVersion?.EndsWith( "s" ) ?? false )
|
||||
{
|
||||
return ImportSimpleV2ModPack( extractedModPack, modList );
|
||||
}
|
||||
|
||||
if( modList.TTMPVersion.EndsWith( "w" ) )
|
||||
if( modList.TTMPVersion?.EndsWith( "w" ) ?? false )
|
||||
{
|
||||
return ImportExtendedV2ModPack( extractedModPack, modRaw );
|
||||
}
|
||||
|
||||
return new DirectoryInfo( "" );
|
||||
try
|
||||
{
|
||||
PluginLog.Warning( $"Unknown TTMPVersion {modList.TTMPVersion ?? "NULL"} given, trying to export as simple Modpack." );
|
||||
return ImportSimpleV2ModPack( extractedModPack, modList );
|
||||
}
|
||||
catch( Exception e1 )
|
||||
{
|
||||
PluginLog.Warning( $"Exporting as simple Modpack failed with following error, retrying as extended Modpack:\n{e1}" );
|
||||
try
|
||||
{
|
||||
return ImportExtendedV2ModPack( extractedModPack, modRaw );
|
||||
}
|
||||
catch( Exception e2 )
|
||||
{
|
||||
throw new IOException( "Exporting as extended Modpack failed, too. Version unsupported or file defect.", e2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static DirectoryInfo CreateModFolder( DirectoryInfo outDirectory, string modListName )
|
||||
|
|
@ -417,5 +424,4 @@ namespace Penumbra.Importer
|
|||
s.CopyTo( ms );
|
||||
return encoding.GetString( ms.ToArray() );
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue