Skip to content

Commit 68154a8

Browse files
author
LocalIdentity
committed
Fix crash on missing dat file
When opening the exporter and missing a dat file, the exporter would crash trying to run rawFile:read on a nil entry It now also tells you in client if you are missing a dat
1 parent 1c107fe commit 68154a8

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/Export/Classes/GGPKData.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,22 @@ end
127127

128128
function GGPKClass:AddDat64Files()
129129
local datFiles = self:GetNeededFiles()
130+
local missingCount = 0
130131
table.sort(datFiles, function(a, b) return a:lower() < b:lower() end)
131132
for _, fname in ipairs(datFiles) do
132133
local record = { }
133134
record.name = fname:match("([^/\\]+)$") .. "c64"
134135
local rawFile = io.open(self.oozPath .. fname:gsub("/", "\\") .. "c64", 'rb')
135-
record.data = rawFile:read("*all")
136-
rawFile:close()
137-
t_insert(self.dat, record)
136+
if rawFile then
137+
record.data = rawFile:read("*all")
138+
rawFile:close()
139+
t_insert(self.dat, record)
140+
else
141+
missingCount = missingCount + 1
142+
end
143+
end
144+
if missingCount > 0 then
145+
t_insert(main.scriptOutput, { "^7"..string.format("Skipped %d missing cached GGPK data files. Press Ctrl+F5 to refresh GGPK data.", missingCount), height = 14 })
138146
end
139147
end
140148

src/Export/Main.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ local remainingScripts = { }
6767
function main:Init()
6868
self.inputEvents = { }
6969
self.popups = { }
70+
self.scriptOutput = { }
7071

7172
self.datSpecs = LoadModule("spec")
7273

@@ -98,7 +99,6 @@ function main:Init()
9899
break
99100
end
100101
end
101-
self.scriptOutput = { }
102102

103103
function print(text)
104104
for line in text:gmatch("[^\r\n]+") do

0 commit comments

Comments
 (0)