From ed0e73c84aeea18d03cc0caf3e046978145d77ce Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 3 Nov 2012 19:32:43 +0000 Subject: [PATCH] Lunatic: update structures, find maps case-insensitively in findmaps.sh. git-svn-id: https://svn.eduke32.com/eduke32@3109 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/defs.ilua | 18 +++++++++++++++--- polymer/eduke32/source/lunatic/findmaps.sh | 2 +- polymer/eduke32/source/lunatic/test.elua | 4 ++-- .../source/lunatic/test/test_rotspr.lua | 7 ++++++- polymer/eduke32/source/player.h | 2 ++ 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index ac9be83a4..fed19bf79 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -172,6 +172,7 @@ typedef struct { int32_t truefz, truecz, player_par; int32_t randomflamex, exitx, exity; int32_t runspeed, max_player_health, max_shield_amount; + int32_t autostep, autostep_sbw; uint32_t interface_toggle_flag; @@ -259,7 +260,7 @@ typedef struct { int32_t pcolor, pteam; uint8_t frags[MAXPLAYERS], wchoice[MAX_WEAPONS]; - char vote, gotvote, pingcnt, playerquitflag; + char vote, gotvote, pingcnt, playerquitflag, ready; char user_name[32]; uint32_t revision; } playerdata_t; @@ -274,6 +275,7 @@ enum NUMGAMEFUNCTIONS = 56, }; +// NOTE: not packed! typedef struct { vec3_t camera; int32_t const_visibility,uw_framerate; @@ -428,9 +430,19 @@ string.dump = nil -- sanity-check struct type sizes +local good = true for i=0,6 do - assert(ffi.sizeof(ffi.string(ffiC.g_sizes_of_what[i])) - == ffiC.g_sizes_of[i]) + local what = ffi.string(ffiC.g_sizes_of_what[i]) + local fsz = ffi.sizeof(what) + local csz = ffiC.g_sizes_of[i] + print(i..": "..what..": C sizeof = "..tostring(csz)..", FFI sizeof = "..tostring(fsz)) + if (fsz ~= csz) then + good = false; + end +end + +if (not good) then + error("Some sizes don't match between C and LuaJIT/FFI.") end diff --git a/polymer/eduke32/source/lunatic/findmaps.sh b/polymer/eduke32/source/lunatic/findmaps.sh index 2df7491c8..ad8f24f7a 100755 --- a/polymer/eduke32/source/lunatic/findmaps.sh +++ b/polymer/eduke32/source/lunatic/findmaps.sh @@ -13,4 +13,4 @@ if [ -z "$ok" ]; then exit 1 fi -find -L "$1" -name '*.map' -print0 | xargs -0 ./foreachmap.lua "-e$2" +find -L "$1" -iname '*.map' -print0 | xargs -0 ./foreachmap.lua "-e$2" diff --git a/polymer/eduke32/source/lunatic/test.elua b/polymer/eduke32/source/lunatic/test.elua index 67e028cbc..91f28f240 100644 --- a/polymer/eduke32/source/lunatic/test.elua +++ b/polymer/eduke32/source/lunatic/test.elua @@ -140,8 +140,8 @@ checkfail('print(nextspritesect[4].whatfield)', "attempt to index a number value -- creating new keys forbidden... handled by LuaJit checkfail('wall[4].QWE = 123', "has no member named 'QWE'") --- our 'require' disallows importing such dangerous stuff -checkfail("require('os')") +-- our 'require' has only safe stuff +--checkfail("require('os')") -- we must declare globals with 'gamevar' checkfail("new_global = 345", "attempt to write to undeclared variable 'new_global'") diff --git a/polymer/eduke32/source/lunatic/test/test_rotspr.lua b/polymer/eduke32/source/lunatic/test/test_rotspr.lua index 5ce1e0598..62e2a751a 100644 --- a/polymer/eduke32/source/lunatic/test/test_rotspr.lua +++ b/polymer/eduke32/source/lunatic/test/test_rotspr.lua @@ -10,10 +10,15 @@ local BAR1x5 = 3163 local function draw_hline_dotted(x1, x2, y, pal,stat) for x=x1,x2,2 do + local pl = player[0] local tile = (x==x1 or x==x2) and BAR1x5 or DOT1x5 - if (player[0].curr_weapon==2) then + + if (pl.curr_weapon==2) then x = x + 16*math.sin(2*math.pi*gv.totalclock/120) + elseif (pl.curr_weapon==1) then + x = x + (pl.ang - 1024)/100 end + rs(x,y, 65536, 0, tile, 0,pal,stat, 0,0,gv.xdim-1,gv.ydim-1) end end diff --git a/polymer/eduke32/source/player.h b/polymer/eduke32/source/player.h index de39cd455..0037fa89a 100644 --- a/polymer/eduke32/source/player.h +++ b/polymer/eduke32/source/player.h @@ -141,6 +141,7 @@ typedef struct { // * int16_t --> int8_t // * char --> int8_t // Need to carefully think about implications! +// KEEPINSYNC lunatic/defs.ilua typedef struct { vec3_t pos, opos, vel, npos; int32_t bobposx, bobposy; @@ -213,6 +214,7 @@ typedef struct { int8_t extbits, filler; // 2b } input_t; +// KEEPINSYNC lunatic/defs.ilua typedef struct { DukePlayer_t *ps; input_t *sync;