From 4beebd08fd9d04166dbe3a42a882989aee5ba675 Mon Sep 17 00:00:00 2001 From: Oliver Bevan Date: Sat, 12 Oct 2024 20:48:51 +0100 Subject: [PATCH] Fix PNG export for empty RWTX assets #53 Fixes #53 --- .../ArchiveEditor/ArchiveEditorFunctions_Textures.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_Textures.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_Textures.cs index 11389679..c1fad92e 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_Textures.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_Textures.cs @@ -340,7 +340,17 @@ public Dictionary GetTexturesAsBitmaps(string[] textureNames) foreach (AssetRWTX RWTX in GetAllAssets().OfType()) { - foreach (TextureNative_0015 texture in ((TextureDictionary_0016)ReadFileMethods.ReadRenderWareFile(RWTX.Data)[0]).textureNativeList) + var data = RWTX.Data; + + // Some RWTX files seem to have no data, causing a crash when exporting as PNG + // e.g. bubble_wand.RW3 in JF01.hop + if (data.Length == 0) + continue; + + var textureDictionary = ReadFileMethods.ReadRenderWareFile(data)[0] as TextureDictionary_0016; + var texNativeList = textureDictionary.textureNativeList; + + foreach (TextureNative_0015 texture in texNativeList) { texture.textureNativeStruct.textureName = RWTX.assetName; textures.Add(texture);