From 512b9286feff8edfa904591063452e4057805a35 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 5 Apr 2013 17:52:59 +0000 Subject: [PATCH] LunaCON: ifsquished. git-svn-id: https://svn.eduke32.com/eduke32@3640 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gameexec.c | 17 +++++++++++++---- polymer/eduke32/source/lunatic/control.lua | 8 ++++++++ polymer/eduke32/source/lunatic/defs.ilua | 1 + polymer/eduke32/source/lunatic/dynsymlist | 1 + polymer/eduke32/source/lunatic/lunacon.lua | 7 +++---- polymer/eduke32/source/lunatic/test.elua | 7 +++++++ 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 9873853e6..36cd01dee 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -119,7 +119,6 @@ static void VM_KillIt(int32_t iActor, int32_t iPlayer) int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn) { #ifdef LUNATIC - int32_t killit; const double t = gethitickms(); // TODO: handling of RETURN gamevar / iReturn / this function's return value @@ -170,7 +169,7 @@ int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lD static inline int32_t VM_CheckSquished(void) { - sectortype *sc = §or[vm.g_sp->sectnum]; + const sectortype *sc = §or[vm.g_sp->sectnum]; if ((vm.g_sp->picnum == APLAYER && ud.noclip) || sc->lotag == ST_23_SWINGING_DOOR) return 0; @@ -182,7 +181,7 @@ static inline int32_t VM_CheckSquished(void) yax_getbunches(vm.g_sp->sectnum, &cb, &fb); if (cb >= 0 && (sc->ceilingstat&512)==0) // if ceiling non-blocking... - cz -= (32<<8); // don't squish unconditionally... yax_getneighborsect is slowish :/ + cz -= (32<<8); // unconditionally don't squish... yax_getneighborsect is slowish :/ if (fb >= 0 && (sc->floorstat&512)==0) fz += (32<<8); #endif @@ -195,7 +194,8 @@ static inline int32_t VM_CheckSquished(void) P_DoQuote(QUOTE_SQUISHED, g_player[vm.g_p].ps); - if (A_CheckEnemySprite(vm.g_sp)) vm.g_sp->xvel = 0; + if (A_CheckEnemySprite(vm.g_sp)) + vm.g_sp->xvel = 0; if (vm.g_sp->pal == 1) // frozen { @@ -5568,4 +5568,13 @@ int32_t VM_ResetPlayer2(int32_t snum) { return VM_ResetPlayer(snum, 0); } + +int32_t VM_CheckSquished2(int32_t i, int32_t snum) +{ + vm.g_i = i; + vm.g_sp = &sprite[i]; + vm.g_p = snum; + + return VM_CheckSquished(); +} #endif diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index f9f42ff92..6a41e9aa9 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -1431,6 +1431,14 @@ function _ifp(flags, pli, aci) return false end +function _squished(aci, pli) + check_sprite_idx(aci) + check_player_idx(pli) + check_sector_idx(sprite[aci].sectnum) + + return (ffiC.VM_CheckSquished2(aci, pli)~=0) +end + function _checkspace(sectnum, floorp) local sect = sector[sectnum] local picnum = floorp and sect.floorpicnum or sect.ceilingpicnum diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 2211f4cda..36303fd6d 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -578,6 +578,7 @@ void G_InitTimer(int32_t ticspersec); void G_GetTimeDate(int32_t *vals); int32_t G_ToggleWallInterpolation(int32_t w, int32_t doset); int32_t G_StartTrack(int32_t level); +int32_t VM_CheckSquished2(int32_t i, int32_t snum); const char *KB_ScanCodeToString(uint8_t scancode); diff --git a/polymer/eduke32/source/lunatic/dynsymlist b/polymer/eduke32/source/lunatic/dynsymlist index 98f5f9ac0..199ed9fcb 100644 --- a/polymer/eduke32/source/lunatic/dynsymlist +++ b/polymer/eduke32/source/lunatic/dynsymlist @@ -169,6 +169,7 @@ G_InitTimer; G_GetTimeDate; G_ToggleWallInterpolation; G_StartTrack; +VM_CheckSquished2; KB_ScanCodeToString; diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 2aacb7c37..5856de8cf 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -772,7 +772,8 @@ local function do_include_file(dirname, filename) if (fd==nil and g_defaultDir) then -- strip up to and including last slash (if any): filename = filename:gsub("^.*/", "") - fd, msg = io.open(g_defaultDir.."/"..filename) + dirname = g_defaultDir.."/" + fd, msg = io.open(dirname..filename) end if (fd == nil) then @@ -795,8 +796,6 @@ local function do_include_file(dirname, filename) return end - -- XXX: File name that's displayed here may not be the actual opened one - -- (esp. for stand-alone version). printf("%s[%d] Translating file \"%s\"", (g_recurslevel==-1 and "\n---- ") or "", g_recurslevel+1, dirname..filename); @@ -2437,7 +2436,7 @@ local Cif = { ifp = (sp1 * tok.define)^1 / function (...) return format("_con._ifp(%d,_pli,_aci)", bit.bor(...)) end, ifsquished = cmd() - / "false", -- TODO + / "_con._squished(_aci,_pli)", ifserver = cmd() / "false", -- TODO_MP ifrespawn = cmd() diff --git a/polymer/eduke32/source/lunatic/test.elua b/polymer/eduke32/source/lunatic/test.elua index dc35f821f..53dfe1ff5 100644 --- a/polymer/eduke32/source/lunatic/test.elua +++ b/polymer/eduke32/source/lunatic/test.elua @@ -424,6 +424,13 @@ gameevent("DISPLAYREST", function() end end) +-- APLAYER +gameactor(1405, actor.FLAGS.chain_beg, function(aci, pli) + if (con._squished(aci, pli)) then + printf("Squished LunaCON test") + end +end) + local CS = sprite.CSTAT gameevent("ANIMATESPRITES",