From 406e9dcaf2c125d13802c1ac270e418ccbb8b09a Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Sun, 10 Nov 2024 17:56:00 +0100 Subject: [PATCH] HUD interpolation for BLUAJIT Still glitches for a single tic with JIT on... --- src/lua_hudlib_drawlist.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 1cef45a87..7cc0b0f28 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -12,7 +12,11 @@ #include "lua_hudlib_drawlist.h" #include "lua_hud.h" +#ifdef NOBLUAJIT #include "blua/lstate.h" // shhhhhh +#else +#include "lua_script.h" +#endif #include "lua_libs.h" #include @@ -325,8 +329,16 @@ static UINT64 GetItemId(void) if (!hud_interpolate) return 0; +#ifdef NOBLUAJIT + UINT64 id = (uintptr_t)gL->savedpc; +#else + // he who controls the JIT controls the API + const void *p = lua_getpc(gL, 1); + I_Assert(p != NULL); + UINT64 id = (uintptr_t)p; +#endif // leave bits 0 and 1 free for the string mode - UINT64 id = ((UINT64)(uintptr_t)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); + id = (id << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); if (hud_interplatch) {