From be7a143a9938d0bb373bb475b04a8a42107a3548 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sat, 19 Mar 2022 14:45:51 -0400 Subject: [PATCH] don't crash if the AFS does not include table of contents (in case that's possible) --- .../DataFormats/FileSystem/AFS/AFSDataFormat.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/AFS/AFSDataFormat.cs b/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/AFS/AFSDataFormat.cs index 69bb46ca..5c808b68 100644 --- a/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/AFS/AFSDataFormat.cs +++ b/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/AFS/AFSDataFormat.cs @@ -19,9 +19,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; - +using MBS.Framework; using UniversalEditor.IO; using UniversalEditor.ObjectModels.FileSystem; +using UniversalEditor.UserInterface; namespace UniversalEditor.Plugins.CRI.DataFormats.FileSystem.AFS { @@ -72,7 +73,15 @@ namespace UniversalEditor.Plugins.CRI.DataFormats.FileSystem.AFS if (tocOffset == 0) { - throw new InvalidDataFormatException("table of contents not found"); + ((EditorApplication)Application.Instance)?.Messages.Add(HostApplicationMessageSeverity.Warning, "table of contents not found", Accessor.GetFileName()); + for (int j = 0; j < fileCount; j++) + { + fileinfos[j].name = String.Format("file_{0}", j); + File f = fsom.AddFile(fileinfos[j].name); + f.Properties.Add("fileinfo", fileinfos[j]); + f.Size = fileinfos[j].length; + f.DataRequest += f_DataRequest; + } } else {