mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Lunatic: r/w gamearrays in binary mode, checks for mapdiff.sh, add test/gamearray.con.
git-svn-id: https://svn.eduke32.com/eduke32@4052 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
eef1977662
commit
7f37ac1303
4 changed files with 157 additions and 9 deletions
|
@ -1990,7 +1990,7 @@ local function gamearray_file_common(qnum, writep)
|
||||||
local f, errmsg
|
local f, errmsg
|
||||||
|
|
||||||
if (writep) then
|
if (writep) then
|
||||||
f, errmsg = io.open(fn)
|
f, errmsg = io.open(fn, "rb")
|
||||||
if (f == nil) then
|
if (f == nil) then
|
||||||
-- file, numints, isnewgar, filename
|
-- file, numints, isnewgar, filename
|
||||||
return nil, nil, true, fn
|
return nil, nil, true, fn
|
||||||
|
@ -2101,7 +2101,7 @@ local gamearray_methods = {
|
||||||
error("refusing to overwrite a file not created by a previous `writearraytofile'", 2)
|
error("refusing to overwrite a file not created by a previous `writearraytofile'", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local f, errmsg = io.open(fn, "w+")
|
local f, errmsg = io.open(fn, "wb+")
|
||||||
if (f == nil) then
|
if (f == nil) then
|
||||||
error([[failed opening "%s" for writing: %s]], fn, errmsg, 3)
|
error([[failed opening "%s" for writing: %s]], fn, errmsg, 3)
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,7 @@ ffi.cdef "const char **g_argv;"
|
||||||
-- dump: load LuaJIT's 'dump' module, printing generated IR/machine code
|
-- dump: load LuaJIT's 'dump' module, printing generated IR/machine code
|
||||||
-- (env var: LUAJIT_DUMPFILE)
|
-- (env var: LUAJIT_DUMPFILE)
|
||||||
-- strict: catch various conditions that may indicate an logical error
|
-- strict: catch various conditions that may indicate an logical error
|
||||||
|
-- TODO for strict: actor[], spriteext[], per-actor gamevars
|
||||||
local debug_flags = {}
|
local debug_flags = {}
|
||||||
local IS_DEBUG_FLAG = {
|
local IS_DEBUG_FLAG = {
|
||||||
diag=true, nojit=true, traces=true, dump=true,
|
diag=true, nojit=true, traces=true, dump=true,
|
||||||
|
|
135
polymer/eduke32/source/lunatic/test/gamearray.con
Normal file
135
polymer/eduke32/source/lunatic/test/gamearray.con
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
// Test for gamearrays / their persistence.
|
||||||
|
// Doesn't run in C-CON because redefinequote/qsprintf error out when passed a
|
||||||
|
// non-allocated quote as destination.
|
||||||
|
|
||||||
|
define QWESZ 10
|
||||||
|
define ASDSZ 12
|
||||||
|
|
||||||
|
define MAXTILES 30720 // XXX
|
||||||
|
|
||||||
|
gamearray qwe QWESZ
|
||||||
|
gamearray asd ASDSZ
|
||||||
|
|
||||||
|
define NEWQWESZ 9
|
||||||
|
define NEWASDSZ 14
|
||||||
|
|
||||||
|
gamearray qwe1 1 // should auto-resize when reading in
|
||||||
|
gamearray asd1 NEWASDSZ
|
||||||
|
|
||||||
|
gamevar qwesz 0 0
|
||||||
|
gamevar asdsz 0 0
|
||||||
|
|
||||||
|
// Test gamevars that are named like Lua keywords.
|
||||||
|
gamevar local 0 0
|
||||||
|
|
||||||
|
gamevar i 0 0
|
||||||
|
gamevar tmp 0 0
|
||||||
|
|
||||||
|
definequote 400 LTEST_QWE_ARRAY.bin
|
||||||
|
definequote 401 LTEST_ASD_ARRAY.bin
|
||||||
|
|
||||||
|
definequote 505 tile y sizes: 0:%d 1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 7:%d 8:%d
|
||||||
|
definequote 506 1: 0x0a0a0d0d==168430861 ? %d
|
||||||
|
definequote 507 2: 0x0a0a0d0d==168430861 ? %d
|
||||||
|
|
||||||
|
state error
|
||||||
|
setactor[-1].cstat 0
|
||||||
|
ends
|
||||||
|
|
||||||
|
onevent EVENT_ENTERLEVEL
|
||||||
|
setvar i 0
|
||||||
|
whilevarn i QWESZ
|
||||||
|
{
|
||||||
|
setarray qwe[i] i
|
||||||
|
addvar i 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test nested array syntax:
|
||||||
|
setarray qwe[qwe[5]] 0
|
||||||
|
|
||||||
|
// qwe[] now:
|
||||||
|
// 0 1 2 3 4 0 6 7 8 9
|
||||||
|
|
||||||
|
setvar i 0
|
||||||
|
whilevarn i ASDSZ
|
||||||
|
{
|
||||||
|
setvarvar tmp i
|
||||||
|
addvar tmp 100
|
||||||
|
setarray asd[i] tmp
|
||||||
|
setvarvar local tmp
|
||||||
|
addvar i 1
|
||||||
|
}
|
||||||
|
|
||||||
|
copy qwe[4] /*->*/ asd[3] 3
|
||||||
|
|
||||||
|
setarray asd[4] 0x0a0a0d0d
|
||||||
|
|
||||||
|
// asd[] now:
|
||||||
|
// 100 101 102 4 0x0a0a0d0d 6 106 107 108 109 110 111
|
||||||
|
|
||||||
|
qsprintf 506 506 asd[4]
|
||||||
|
userquote 506
|
||||||
|
|
||||||
|
resizearray qwe NEWQWESZ // shrink
|
||||||
|
resizearray asd NEWASDSZ // grow
|
||||||
|
|
||||||
|
writearraytofile qwe 400
|
||||||
|
writearraytofile asd 401
|
||||||
|
|
||||||
|
readarrayfromfile qwe1 400
|
||||||
|
readarrayfromfile asd1 401
|
||||||
|
|
||||||
|
qsprintf 507 507 asd[4]
|
||||||
|
userquote 507
|
||||||
|
|
||||||
|
ifvarn asd[4] 0x0a0a0d0d state error
|
||||||
|
|
||||||
|
// test array sizes
|
||||||
|
getarraysize qwe qwesz
|
||||||
|
getarraysize asd asdsz
|
||||||
|
|
||||||
|
ifvarn qwesz NEWQWESZ state error
|
||||||
|
ifvarn asdsz NEWASDSZ state error
|
||||||
|
|
||||||
|
// test array sizes with *1 arrays
|
||||||
|
getarraysize qwe1 qwesz
|
||||||
|
getarraysize asd1 asdsz
|
||||||
|
|
||||||
|
ifvarn qwesz NEWQWESZ state error
|
||||||
|
ifvarn asdsz NEWASDSZ state error
|
||||||
|
|
||||||
|
redefinequote 500 [%d]: qwe=%d, qwe1=%d, asd=%d, asd1=%d
|
||||||
|
setvar i 0
|
||||||
|
whilevarvarn i -1
|
||||||
|
{
|
||||||
|
ifvarl i NEWQWESZ
|
||||||
|
qsprintf 501 500 i qwe[i] qwe1[i] asd[i] asd1[i]
|
||||||
|
else
|
||||||
|
qsprintf 501 500 i -1 -1 asd[i] asd1[i]
|
||||||
|
userquote 501
|
||||||
|
addvar i 1
|
||||||
|
|
||||||
|
ifvare i NEWASDSZ
|
||||||
|
setvar i -1
|
||||||
|
}
|
||||||
|
|
||||||
|
redefinequote 500 MUST REACH
|
||||||
|
userquote 500
|
||||||
|
|
||||||
|
setvar i 120
|
||||||
|
modvar i 25
|
||||||
|
addlogvar i
|
||||||
|
|
||||||
|
|
||||||
|
//// Test system gamearrays
|
||||||
|
|
||||||
|
getarraysize tilesizx qwesz
|
||||||
|
ifvarn qwesz MAXTILES state error
|
||||||
|
|
||||||
|
copy tilesizy[0] /*->*/ qwe[0] 9
|
||||||
|
qsprintf 505 505 qwe[0] qwe[1] qwe[2] qwe[3] qwe[4] qwe[5] qwe[6] qwe[7] qwe[8]
|
||||||
|
userquote 505
|
||||||
|
|
||||||
|
// Must give a translation error:
|
||||||
|
// resizearray tilesizy 100
|
||||||
|
endevent
|
|
@ -5,11 +5,13 @@ CMD="/usr/bin/env luajit ./map2text.lua"
|
||||||
|
|
||||||
opt=""
|
opt=""
|
||||||
|
|
||||||
if [ `uname -s` != "Linux" ]; then
|
# Name of the 'tempfile' or 'mktemp' command (or full path).
|
||||||
# I think 'tempfile' isn't in POSIX. Feel free to use 'mktemp' or something
|
tempfile_cmd=tempfile
|
||||||
# but absolutely test it before.
|
|
||||||
echo "This helper script is for Linux only."
|
tempfile_path=`which "$tempfile_cmd"`
|
||||||
return 1
|
if [ -z "$tempfile_path" ]; then
|
||||||
|
echo "Error: tempfile_cmd ($tempfile_cmd) must be the name of existing 'tempfile' or 'mktemp' executable."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "-c" -o "$1" = "-C" ]; then
|
if [ "$1" = "-c" -o "$1" = "-C" ]; then
|
||||||
|
@ -22,8 +24,18 @@ if [ -z "$1" -o -z "$2" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tf1=`tempfile`
|
tf1=`"$tempfile_cmd"`
|
||||||
tf2=`tempfile`
|
if [ -z "$tf1" ]; then
|
||||||
|
echo Failed creating temp file
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
tf2=`"$tempfile_cmd"`
|
||||||
|
if [ -z "$tf2" ]; then
|
||||||
|
rm "$tf1"
|
||||||
|
echo Failed creating temp file
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
$CMD $opt "$1" > "$tf1"
|
$CMD $opt "$1" > "$tf1"
|
||||||
$CMD $opt "$2" > "$tf2"
|
$CMD $opt "$2" > "$tf2"
|
||||||
|
|
Loading…
Reference in a new issue