Lua: "defrosting" global to tell how many tics are processing in the preticker

This commit is contained in:
James R 2020-11-24 19:32:01 -08:00
parent 5ec44ba3fa
commit 1a3e883b4e
4 changed files with 12 additions and 2 deletions

View file

@ -9687,6 +9687,9 @@ static inline int lib_getenum(lua_State *L)
} else if (fastcmp(word,"leveltime")) { } else if (fastcmp(word,"leveltime")) {
lua_pushinteger(L, leveltime); lua_pushinteger(L, leveltime);
return 1; return 1;
} else if (fastcmp(word,"defrosting")) {
lua_pushinteger(L, hook_defrosting);
return 1;
} else if (fastcmp(word,"curWeather")) { } else if (fastcmp(word,"curWeather")) {
lua_pushinteger(L, curWeather); lua_pushinteger(L, curWeather);
return 1; return 1;

View file

@ -63,6 +63,7 @@ enum hook {
extern const char *const hookNames[]; 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 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_MapChange(INT16 mapnumber); // Hook for map change (before load)
void LUAh_MapLoad(void); // Hook for map load void LUAh_MapLoad(void); // Hook for map load

View file

@ -35,6 +35,8 @@
lua_State *gL = NULL; lua_State *gL = NULL;
int hook_defrosting;
// List of internal libraries to load from SRB2 // List of internal libraries to load from SRB2
static lua_CFunction liblist[] = { static lua_CFunction liblist[] = {
LUA_EnumLib, // global metatable for enums LUA_EnumLib, // global metatable for enums

View file

@ -807,13 +807,15 @@ void P_Ticker(boolean run)
// Abbreviated ticker for pre-loading, calls thinkers and assorted things // Abbreviated ticker for pre-loading, calls thinkers and assorted things
void P_PreTicker(INT32 frames) void P_PreTicker(INT32 frames)
{ {
INT32 i,framecnt; INT32 i;
ticcmd_t temptic; ticcmd_t temptic;
for (i = 0; i <= splitscreen; i++) for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none; postimgtype[i] = postimg_none;
for (framecnt = 0; framecnt < frames; ++framecnt) hook_defrosting = frames;
while (hook_defrosting)
{ {
P_MapStart(); P_MapStart();
@ -860,5 +862,7 @@ void P_PreTicker(INT32 frames)
#endif #endif
P_MapEnd(); P_MapEnd();
hook_defrosting--;
} }
} }