From 7ce18078f0f15a9c301e5055b773b84180c26d02 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 2 Oct 2023 12:31:36 +0300 Subject: [PATCH 1/3] Fix v.drawPingNum flickering in any fps higher than 35 --- src/lua_hudlib.c | 12 ++++++++++++ src/lua_hudlib_drawlist.c | 23 +++++++++++++++++++++++ src/lua_hudlib_drawlist.h | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index bd3fb19c8..9a4a4d641 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -640,6 +640,8 @@ static int libd_drawPingNum(lua_State *L) { INT32 x, y, flags, num; const UINT8 *colormap = NULL; + huddrawlist_h list; + HUDONLY x = luaL_checkinteger(L, 1); y = luaL_checkinteger(L, 2); @@ -649,7 +651,17 @@ static int libd_drawPingNum(lua_State *L) if (!lua_isnoneornil(L, 5)) colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); + lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); + list = (huddrawlist_h) lua_touserdata(L, -1); + lua_pop(L, 1); + V_DrawPingNum(x, y, flags, num, colormap); + + if (LUA_HUD_IsDrawListValid(list)) + LUA_HUD_AddDrawPingNum(list, x, y, num, flags, colormap); + else + V_DrawPingNum(x, y, flags, num, colormap); + return 0; } diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index d36d99dd4..8be0bd9c6 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -22,6 +22,7 @@ enum drawitem_e { DI_DrawScaled, DI_DrawNum, DI_DrawPaddedNum, + DI_DrawPingNum, DI_DrawFill, DI_DrawString, DI_DrawKartString, @@ -251,6 +252,25 @@ void LUA_HUD_AddDrawPaddedNum( item->flags = flags; } +void LUA_HUD_AddDrawPingNum( + huddrawlist_h list, + INT32 x, + INT32 y, + INT32 num, + INT32 flags, + UINT8 *colormap +) +{ + size_t i = AllocateDrawItem(list); + drawitem_t *item = &list->items[i]; + item->type = DI_DrawPingNum; + item->x = x; + item->y = y; + item->num = num; + item->flags = flags; + item->colormap = colormap; +} + void LUA_HUD_AddDrawFill( huddrawlist_h list, INT32 x, @@ -363,6 +383,9 @@ void LUA_HUD_DrawList(huddrawlist_h list) case DI_DrawPaddedNum: V_DrawPaddedTallNum(item->x, item->y, item->flags, item->num, item->digits); break; + case DI_DrawPingNum: + V_DrawPingNum(item->x, item->y, item->flags, item->num, item->colormap); + break; case DI_DrawFill: V_DrawFill(item->x, item->y, item->w, item->h, item->c); break; diff --git a/src/lua_hudlib_drawlist.h b/src/lua_hudlib_drawlist.h index 43190c411..754d56435 100644 --- a/src/lua_hudlib_drawlist.h +++ b/src/lua_hudlib_drawlist.h @@ -66,6 +66,14 @@ void LUA_HUD_AddDrawPaddedNum( INT32 digits, INT32 flags ); +void LUA_HUD_AddDrawPingNum( + huddrawlist_h list, + INT32 x, + INT32 y, + INT32 num, + INT32 flags, + UINT8 *colormap +); void LUA_HUD_AddDrawFill( huddrawlist_h list, INT32 x, -- 2.54.0 From 26fae628da589060ff281c11e86079084b0f0e92 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 2 Oct 2023 13:01:36 +0300 Subject: [PATCH 2/3] Forgor to remove first V_DrawPingNum, also change colormap type to const to silence warning --- src/lua_hudlib.c | 2 -- src/lua_hudlib_drawlist.c | 2 +- src/lua_hudlib_drawlist.h | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 9a4a4d641..271a548ce 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -655,8 +655,6 @@ static int libd_drawPingNum(lua_State *L) list = (huddrawlist_h) lua_touserdata(L, -1); lua_pop(L, 1); - V_DrawPingNum(x, y, flags, num, colormap); - if (LUA_HUD_IsDrawListValid(list)) LUA_HUD_AddDrawPingNum(list, x, y, num, flags, colormap); else diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 8be0bd9c6..60642eb1d 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -258,7 +258,7 @@ void LUA_HUD_AddDrawPingNum( INT32 y, INT32 num, INT32 flags, - UINT8 *colormap + const UINT8 *colormap ) { size_t i = AllocateDrawItem(list); diff --git a/src/lua_hudlib_drawlist.h b/src/lua_hudlib_drawlist.h index 754d56435..992578778 100644 --- a/src/lua_hudlib_drawlist.h +++ b/src/lua_hudlib_drawlist.h @@ -72,7 +72,7 @@ void LUA_HUD_AddDrawPingNum( INT32 y, INT32 num, INT32 flags, - UINT8 *colormap + const UINT8 *colormap ); void LUA_HUD_AddDrawFill( huddrawlist_h list, -- 2.54.0 From 6a8bfb0da2bcc45c16ffcd8c59bd508b60d0867e Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 2 Oct 2023 13:08:05 +0300 Subject: [PATCH 3/3] This can be const too --- src/lua_hudlib_drawlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 60642eb1d..eedbff910 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -46,7 +46,7 @@ typedef struct drawitem_s { INT32 flags; UINT16 basecolor; UINT16 outlinecolor; - UINT8 *colormap; + const UINT8 *colormap; UINT8 *basecolormap; UINT8 *outlinecolormap; fixed_t sx; -- 2.54.0