mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
LunaCON: readarrayfromfile: fail silently if file can't be opened.
git-svn-id: https://svn.eduke32.com/eduke32@3602 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
c7d97d55ec
commit
3a1c590572
2 changed files with 20 additions and 10 deletions
|
@ -1225,7 +1225,11 @@ function _cansee(aci, ps)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _canseespr(s1, s2)
|
function _canseespr(s1, s2)
|
||||||
return cansee(sprite[s1], sprite[s1].sectnum, sprite[s2], sprite[s2].sectnum) and 1 or 0
|
local spr1, spr2 = sprite[s1], sprite[s2]
|
||||||
|
-- Redundant, but points the error messages to the CON code:
|
||||||
|
check_sector_idx(spr1.sectnum)
|
||||||
|
check_sector_idx(spr2.sectnum)
|
||||||
|
return cansee(spr1, spr1.sectnum, spr2, spr2.sectnum) and 1 or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: replace ivec3 allocations with stores to a static ivec3, like in
|
-- TODO: replace ivec3 allocations with stores to a static ivec3, like in
|
||||||
|
@ -1742,17 +1746,19 @@ local function gamearray_file_common(qnum, writep)
|
||||||
|
|
||||||
if (writep) then
|
if (writep) then
|
||||||
f, errmsg = io.open(fn)
|
f, errmsg = io.open(fn)
|
||||||
else
|
if (f == nil) then
|
||||||
f = kopen4load(fn, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (f == nil) then
|
|
||||||
if (not writep) then
|
|
||||||
error(format([[failed opening "%s" for reading: %s]], fn, errmsg), 3)
|
|
||||||
else
|
|
||||||
-- file, numints, isnewgar, filename
|
-- file, numints, isnewgar, filename
|
||||||
return nil, nil, true, fn
|
return nil, nil, true, fn
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
f, errmsg = kopen4load(fn, 0)
|
||||||
|
if (f == nil) then
|
||||||
|
if (f==false) then
|
||||||
|
error(format([[failed opening "%s" for reading: %s]], fn, errmsg), 3)
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local fsize = assert(f:seek("end"))
|
local fsize = assert(f:seek("end"))
|
||||||
|
@ -1813,6 +1819,10 @@ local gamearray_methods = {
|
||||||
read = function(gar, qnum)
|
read = function(gar, qnum)
|
||||||
local f, nelts, isnewgar = gamearray_file_common(qnum, false)
|
local f, nelts, isnewgar = gamearray_file_common(qnum, false)
|
||||||
|
|
||||||
|
if (f==nil) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
assert(f:seek("set"))
|
assert(f:seek("set"))
|
||||||
local ints = f:read_le_int32(nelts)
|
local ints = f:read_le_int32(nelts)
|
||||||
if (ints == nil) then
|
if (ints == nil) then
|
||||||
|
|
|
@ -2132,7 +2132,7 @@ local Cinner = {
|
||||||
getarraysize = cmd(GARI,W)
|
getarraysize = cmd(GARI,W)
|
||||||
/ "%2=%1._size",
|
/ "%2=%1._size",
|
||||||
readarrayfromfile = cmd(GARI,D)
|
readarrayfromfile = cmd(GARI,D)
|
||||||
/ "%1:read(%2)",
|
/ "%1:read(%2,nil)", -- false: error on no file, nil: don't.
|
||||||
writearraytofile = cmd(GARI,D)
|
writearraytofile = cmd(GARI,D)
|
||||||
/ "%1:write(%2)",
|
/ "%1:write(%2)",
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue