From 7e0b605f34c1da3a938cd2ed5cac94c56a653e22 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 15 May 2020 14:21:25 -0700 Subject: [PATCH] Properly bound lua displayplayers and displayplayers.iterate to splitscreen This is fixes crashes in replays because splitscreen displayplayers are initialized to INT32_MAX there. --- src/lua_playerlib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index d9766513..0ece0d2c 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -118,7 +118,7 @@ static int lib_iterateDisplayplayers(lua_State *L) for (i++; i < MAXSPLITSCREENPLAYERS; i++) { - if (!playeringame[displayplayers[i]] || i > splitscreen) + if (i > splitscreen || !playeringame[displayplayers[i]]) return 0; // Stop! There are no more players for us to go through. There will never be a player gap in displayplayers. if (!players[displayplayers[i]].mo) @@ -139,6 +139,8 @@ static int lib_getDisplayplayers(lua_State *L) lua_Integer i = luaL_checkinteger(L, 2); if (i < 0 || i >= MAXSPLITSCREENPLAYERS) return luaL_error(L, "displayplayers[] index %d out of range (0 - %d)", i, MAXSPLITSCREENPLAYERS-1); + if (i > splitscreen) + return 0; if (!playeringame[displayplayers[i]]) return 0; if (!players[displayplayers[i]].mo)