diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5beca1173..5b4141328 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1338,7 +1338,7 @@ static void CL_ReloadReceivedSavegame(void) neededtic = gametic; maketic = neededtic; - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { P_ForceLocalAngle(&players[displayplayers[i]], players[displayplayers[i]].angleturn); } @@ -2375,7 +2375,7 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason) LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting // don't look through someone's view who isn't there - if (playernum == displayplayers[0]) + if (playernum == displayplayers[0] && !demo.playback) { // Call ViewpointSwitch hooks here. // The viewpoint was forcibly changed. @@ -2404,9 +2404,6 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason) RemoveAdminPlayer(playernum); // don't stay admin after you're gone } - if (playernum == displayplayers[0] && !demo.playback) - displayplayers[0] = consoleplayer; // don't look through someone's view who isn't there - LUA_InvalidatePlayer(&players[playernum]); K_CheckBumpers(); diff --git a/src/g_game.c b/src/g_game.c index 50b759c70..ed21c30f1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1263,7 +1263,7 @@ void G_DoLoadLevel(boolean resetplayer) for (i = 0; i <= r_splitscreen; i++) { if (camera[i].chase) - P_ResetCamera(&players[g_localplayers[i]], &camera[i]); + P_ResetCamera(&players[displayplayers[i]], &camera[i]); } // clear cmd building stuff diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index 0354c0d10..e510a474c 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -50,10 +50,10 @@ G_ResetSplitscreen (INT32 playernum) displayplayers[i] = g_localplayers[i]; P_ResetCamera(&players[displayplayers[i]], &camera[i]); } + while (i < MAXSPLITSCREENPLAYERS) { displayplayers[i] = consoleplayer; - i++; } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index a76eb1990..0cbe15c73 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -128,7 +128,7 @@ static int lib_iterateDisplayplayers(lua_State *L) for (i++; i < MAXSPLITSCREENPLAYERS; i++) { - if (i > splitscreen || !playeringame[displayplayers[i]]) + if (i > r_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. LUA_PushUserdata(L, &players[displayplayers[i]], META_PLAYER); @@ -147,7 +147,7 @@ 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) + if (i > r_splitscreen) return 0; if (!playeringame[displayplayers[i]]) return 0; diff --git a/src/lua_script.c b/src/lua_script.c index 6ef32daf9..94ba64767 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -178,7 +178,7 @@ int LUA_PushGlobals(lua_State *L, const char *word) lua_pushboolean(L, modeattacking); return 1; } else if (fastcmp(word,"splitscreen")) { - lua_pushboolean(L, splitscreen); + lua_pushinteger(L, splitscreen); return 1; } else if (fastcmp(word,"gamecomplete")) { lua_pushboolean(L, (gamecomplete != 0)); diff --git a/src/p_setup.c b/src/p_setup.c index 87bcc9595..1c2d46e9f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3729,10 +3729,10 @@ static void P_InitCamera(void) { UINT8 i; - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { - P_SetupCamera(i, &camera[i]); - displayplayers[i] = g_localplayers[i]; // Start with your OWN view, please! + //displayplayers[i] = g_localplayers[i]; // Start with your OWN view, please! + P_SetupCamera(displayplayers[i], &camera[i]); } } }