From 1a3e883b4ef657cbad3a61c9c44295176735f286 Mon Sep 17 00:00:00 2001 From: James R <justsomejames2@gmail.com> Date: Tue, 24 Nov 2020 19:32:01 -0800 Subject: [PATCH] Lua: "defrosting" global to tell how many tics are processing in the preticker --- src/dehacked.c | 3 +++ src/lua_hook.h | 1 + src/lua_script.c | 2 ++ src/p_tick.c | 8 ++++++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 39fc94144..d509cd499 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9687,6 +9687,9 @@ static inline int lib_getenum(lua_State *L) } else if (fastcmp(word,"leveltime")) { lua_pushinteger(L, leveltime); return 1; + } else if (fastcmp(word,"defrosting")) { + lua_pushinteger(L, hook_defrosting); + return 1; } else if (fastcmp(word,"curWeather")) { lua_pushinteger(L, curWeather); return 1; diff --git a/src/lua_hook.h b/src/lua_hook.h index 3f2dfd7a5..a17a7ac78 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -63,6 +63,7 @@ enum hook { extern const char *const hookNames[]; extern boolean hook_cmd_running; // This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd. +extern int hook_defrosting; void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load) void LUAh_MapLoad(void); // Hook for map load diff --git a/src/lua_script.c b/src/lua_script.c index ee49efcc1..5aff53808 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -35,6 +35,8 @@ lua_State *gL = NULL; +int hook_defrosting; + // List of internal libraries to load from SRB2 static lua_CFunction liblist[] = { LUA_EnumLib, // global metatable for enums diff --git a/src/p_tick.c b/src/p_tick.c index bf0344477..6a85027f6 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -807,13 +807,15 @@ void P_Ticker(boolean run) // Abbreviated ticker for pre-loading, calls thinkers and assorted things void P_PreTicker(INT32 frames) { - INT32 i,framecnt; + INT32 i; ticcmd_t temptic; for (i = 0; i <= splitscreen; i++) postimgtype[i] = postimg_none; - for (framecnt = 0; framecnt < frames; ++framecnt) + hook_defrosting = frames; + + while (hook_defrosting) { P_MapStart(); @@ -860,5 +862,7 @@ void P_PreTicker(INT32 frames) #endif P_MapEnd(); + + hook_defrosting--; } } -- GitLab