diff --git a/src/d_main.c b/src/d_main.c index 996d879e3..3d0aeeb7a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -451,6 +451,8 @@ static boolean D_Display(void) { if (players[displayplayers[i]].mo || players[displayplayers[i]].playerstate == PST_DEAD) { + viewssnum = i; + if (i == 0) // Initialize for P1 { viewwindowy = 0; @@ -460,8 +462,6 @@ static boolean D_Display(void) objectsdrawn = 0; } - viewssnum = i; - #ifdef HWRENDER if (rendermode == render_opengl) HWR_RenderPlayerView(i, &players[displayplayers[i]]); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5d243d4c3..eee9abea5 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5352,7 +5352,7 @@ static void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const HWR_PortalFrame(rootportal); else // current frame is not a portal frame but the main view! { - R_SetupFrame(player, false); + R_SetupFrame(viewssnum, false); portalclipline = NULL; } @@ -5621,12 +5621,12 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) drewsky = false; if (skybox) { - R_SkyboxFrame(player); + R_SkyboxFrame(viewssnum); HWR_RenderFrame(viewnumber, player, true); } PS_STOP_TIMING(ps_skyboxtime); - R_SetupFrame(player, false); // This can stay false because it is only used to set viewsky in r_main.c, which isn't used here + R_SetupFrame(viewssnum, false); // This can stay false because it is only used to set viewsky in r_main.c, which isn't used here framecount++; // for timedemo HWR_RenderFrame(viewnumber, player, false); } diff --git a/src/p_floor.c b/src/p_floor.c index febd521ff..de1e01a67 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2513,41 +2513,38 @@ void T_CameraScanner(elevator_t *elevator) if (leveltime != lastleveltime) // Back on the first camera scanner { - for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - camerascanned[i] = false; - } + memset(camerascanned, false, sizeof (camerascanned)); lastleveltime = leveltime; } for (UINT8 i = 0; i <= splitscreen; i++) { - if (players[displayplayers[i]].mo) - { - if (players[displayplayers[i]].mo->subsector->sector == elevator->actionsector) - { - if (t_cam_dist[i] == -42) - t_cam_dist[i] = cv_cam_dist[i].value; - if (t_cam_height[i] == -42) - t_cam_height[i] = cv_cam_height[i].value; - if (t_cam_rotate[i] == -42) - t_cam_rotate[i] = cv_cam_rotate[i].value; - CV_SetValue(&cv_cam_height[i], FixedInt(elevator->sector->floorheight)); - CV_SetValue(&cv_cam_dist[i], FixedInt(elevator->sector->ceilingheight)); - CV_SetValue(&cv_cam_rotate[i], elevator->distance); - camerascanned[i] = true; - } - else if (!camerascanned[i]) - { - if (t_cam_height[i] != -42 && cv_cam_height[i].value != t_cam_height[i]) - CV_Set(&cv_cam_height[i], va("%f", (double)FIXED_TO_FLOAT(t_cam_height[i]))); - if (t_cam_dist[i] != -42 && cv_cam_dist[i].value != t_cam_dist[i]) - CV_Set(&cv_cam_dist[i], va("%f", (double)FIXED_TO_FLOAT(t_cam_dist[i]))); - if (t_cam_rotate[i] != -42 && cv_cam_rotate[i].value != t_cam_rotate[i]) - CV_Set(&cv_cam_rotate[i], va("%f", (double)t_cam_rotate[i])); + if (!players[displayplayers[i]].mo || P_MobjWasRemoved(players[displayplayers[i]].mo)) + continue; - t_cam_dist[i] = t_cam_height[i] = t_cam_rotate[i] = -42; - } + if (players[displayplayers[i]].mo->subsector->sector == elevator->actionsector) + { + if (t_cam_dist[i] == -42) + t_cam_dist[i] = cv_cam_dist[i].value; + if (t_cam_height[i] == -42) + t_cam_height[i] = cv_cam_height[i].value; + if (t_cam_rotate[i] == -42) + t_cam_rotate[i] = cv_cam_rotate[i].value; + CV_SetValue(&cv_cam_height[i], FixedInt(elevator->sector->floorheight)); + CV_SetValue(&cv_cam_dist[i], FixedInt(elevator->sector->ceilingheight)); + CV_SetValue(&cv_cam_rotate[i], elevator->distance); + camerascanned[i] = true; + } + else if (!camerascanned[i]) + { + if (t_cam_height[i] != -42 && cv_cam_height[i].value != t_cam_height[i]) + CV_Set(&cv_cam_height[i], va("%f", (double)FIXED_TO_FLOAT(t_cam_height[i]))); + if (t_cam_dist[i] != -42 && cv_cam_dist[i].value != t_cam_dist[i]) + CV_Set(&cv_cam_dist[i], va("%f", (double)FIXED_TO_FLOAT(t_cam_dist[i]))); + if (t_cam_rotate[i] != -42 && cv_cam_rotate[i].value != t_cam_rotate[i]) + CV_Set(&cv_cam_rotate[i], va("%f", (double)t_cam_rotate[i])); + + t_cam_dist[i] = t_cam_height[i] = t_cam_rotate[i] = -42; } } } diff --git a/src/p_tick.c b/src/p_tick.c index 7405792d0..204b81e62 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -689,9 +689,9 @@ void P_Ticker(boolean run) if (isSkyVisibleForPlayer && skyboxmo[0] && cv_skybox.value) { - R_SkyboxFrame(player); + R_SkyboxFrame(i); } - R_SetupFrame(player, (skyboxmo[0] && cv_skybox.value)); + R_SetupFrame(i, (skyboxmo[0] && cv_skybox.value)); } } } diff --git a/src/p_user.c b/src/p_user.c index 71f756555..e3524235c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3437,6 +3437,23 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; + if (thiscam == &camera[1]) // Camera 2 + { + num = 1; + } + else if (thiscam == &camera[2]) // Camera 3 + { + num = 2; + } + else if (thiscam == &camera[3]) // Camera 4 + { + num = 3; + } + else // Camera 1 + { + num = 0; + } + if (demo.freecam) { P_DemoCameraMovement(thiscam); @@ -3461,34 +3478,14 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (player->spectator) // force cam off for spectators return true; - for (i = 0; i <= splitscreen; i++) - { - if (!cv_chasecam[i].value && thiscam == &camera[i]) - return true; - } + if (!cv_chasecam[num].value && thiscam == &camera[num]) + return true; } if (!thiscam->chase && !resetcalled) { - focusangle = mo->angle; - for (i = 0; i <= splitscreen; i++) - { - if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) - { - focusangle = localangle[i]; - break; - } - } - - camrotate = 0; - for (i = 0; i <= splitscreen; i++) - { - if (thiscam == &camera[i]) - { - camrotate = cv_cam_rotate[i].value; - break; - } - } + focusangle = localangle[num]; + camrotate = cv_cam_rotate[num].value; if (leveltime < introtime) // Whoooshy camera! { @@ -3504,11 +3501,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall thiscam->radius = 20*mapobjectscale; thiscam->height = 16*mapobjectscale; - // Don't run while respawning from a starpost - // Inu 4/8/13 Why not?! -// if (leveltime > 0 && timeinmap <= 0) -// return true; - if (demo.playback) { focusangle = mo->angle; @@ -3516,37 +3508,19 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else { - focusangle = mo->angle; - focusaiming = player->aiming; - } - - for (i = 0; i <= splitscreen; i++) - { - if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) - { - focusangle = localangle[i]; - focusaiming = localaiming[i]; - break; - } + focusangle = localangle[num]; + focusaiming = localaiming[num]; } if (P_CameraThinker(player, thiscam, resetcalled)) return true; - for (i = 0; i <= splitscreen; i++) - { - if (thiscam == &camera[i]) - { - num = i; - camspeed = cv_cam_speed[i].value; - camstill = cv_cam_still[i].value; - camrotate = cv_cam_rotate[i].value; - camdist = FixedMul(cv_cam_dist[i].value, mapobjectscale); - camheight = FixedMul(cv_cam_height[i].value, mapobjectscale); - lookback = camspin[i]; - break; - } - } + camspeed = cv_cam_speed[num].value; + camstill = cv_cam_still[num].value; // RR: seasaws lock the camera so that it isn't disorienting. + camrotate = cv_cam_rotate[num].value; + camdist = FixedMul(cv_cam_dist[num].value, mapobjectscale); + camheight = FixedMul(cv_cam_height[num].value, mapobjectscale); + lookback = camspin[i]; if (timeover) { @@ -3610,10 +3584,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } if (!resetcalled && (leveltime > starttime && timeover != 2) - && ((thiscam == &camera[0] && t_cam_rotate[0] != -42) - || (thiscam == &camera[1] && t_cam_rotate[1] != -42) - || (thiscam == &camera[2] && t_cam_rotate[2] != -42) - || (thiscam == &camera[3] && t_cam_rotate[3] != -42))) + && (t_cam_rotate[num] != -42)) { angle = FixedAngle(camrotate*FRACUNIT); thiscam->angle = angle; diff --git a/src/r_main.c b/src/r_main.c index 80d6961fa..db49694b2 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1183,20 +1183,12 @@ static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) } } -void R_SkyboxFrame(player_t *player) +void R_SkyboxFrame(int s) { - camera_t *thiscam = &camera[0]; - UINT8 i; + player_t *player = &players[displayplayers[s]]; + camera_t *thiscam = &camera[s]; - for (i = 0; i <= splitscreen; i++) - { - if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) - { - thiscam = &camera[i]; - R_SetViewContext(VIEWCONTEXT_SKY1 + i); - break; - } - } + R_SetViewContext(VIEWCONTEXT_SKY1 + s); // cut-away view stuff newview->sky = true; @@ -1284,25 +1276,17 @@ void R_SkyboxFrame(player_t *player) R_SetupCommonFrame(player, viewmobj->subsector); } -void R_SetupFrame(player_t *player, boolean skybox) +void R_SetupFrame(int s, boolean skybox) { - camera_t *thiscam; - boolean chasecam = false; + player_t *player = &players[displayplayers[s]]; + camera_t *thiscam = &camera[s]; + boolean chasecam = (cv_chasecam[s].value != 0); - for (UINT8 i = 0; i <= splitscreen; i++) + R_SetViewContext(VIEWCONTEXT_PLAYER1 + s); + if (thiscam->reset) { - if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) - { - thiscam = &camera[i]; - chasecam = cv_chasecam[i].value; - R_SetViewContext(VIEWCONTEXT_PLAYER1 + i); - if (thiscam->reset) - { - R_ResetViewInterpolation(i); - thiscam->reset = false; - } - break; - } + R_ResetViewInterpolation(s); + thiscam->reset = false; } if (player->spectator) // no spectator chasecam @@ -1520,7 +1504,7 @@ void R_RenderPlayerView(player_t *player) PS_START_TIMING(ps_skyboxtime); if (skybox && skyVisible) { - R_SkyboxFrame(player); + R_SkyboxFrame(viewssnum); R_ClearClipSegs(); R_ClearDrawSegs(); @@ -1540,7 +1524,7 @@ void R_RenderPlayerView(player_t *player) } PS_STOP_TIMING(ps_skyboxtime); - R_SetupFrame(player, skybox); + R_SetupFrame(viewssnum, skybox); skyVisible = false; framecount++; validcount++; diff --git a/src/r_main.h b/src/r_main.h index 450fe9c93..619b7f3da 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -163,9 +163,9 @@ void R_SetViewSize(void); // do it (sometimes explicitly called) void R_ExecuteSetViewSize(void); -void R_SkyboxFrame(player_t *player); +void R_SkyboxFrame(int s); +void R_SetupFrame(int s, boolean skybox); -void R_SetupFrame(player_t *player, boolean skybox); // Called by G_Drawer. void R_RenderPlayerView(player_t *player);