diff --git a/src/g_build_ticcmd.cpp b/src/g_build_ticcmd.cpp index 17ffcaf32..9ee6263f2 100644 --- a/src/g_build_ticcmd.cpp +++ b/src/g_build_ticcmd.cpp @@ -367,13 +367,13 @@ public: common_button_input(); }; - if (demo.freecam) + if (demo.freecam || player()->spectator) { // freecam is controllable even while paused *cmd = {}; - if (!typing_input()) + if (!typing_input() && !director_input()) { regular_input(); } diff --git a/src/g_demo.c b/src/g_demo.c index ede754ee7..7f58d289e 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -4127,8 +4127,6 @@ void G_StopDemo(void) singletics = false; demo.freecam = false; - // reset democam shit too: - democam.cam = NULL; Z_Free(demo.skinlist); demo.skinlist = NULL; diff --git a/src/menus/transient/pause-replay.c b/src/menus/transient/pause-replay.c index 6db7cee98..163a2885e 100644 --- a/src/menus/transient/pause-replay.c +++ b/src/menus/transient/pause-replay.c @@ -239,13 +239,10 @@ void M_PlaybackToggleFreecam(INT32 choice) if (!demo.freecam) // toggle on { demo.freecam = true; - democam.cam = &camera[0]; // this is rather useful } else // toggle off { demo.freecam = false; - // reset democam vars: - democam.cam = NULL; } } diff --git a/src/p_local.h b/src/p_local.h index 08b3293ed..22c593c21 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -131,14 +131,6 @@ struct camera_t angle_t old_angle, old_aiming; }; -// demo freecam or something before i commit die -struct demofreecam_s { - - camera_t *cam; // this is useful when the game is paused, notably -}; - -extern struct demofreecam_s democam; - extern camera_t camera[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS], cv_cam_still[MAXSPLITSCREENPLAYERS], cv_cam_height[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS], cv_cam_rotate[MAXSPLITSCREENPLAYERS]; diff --git a/src/p_tick.c b/src/p_tick.c index b6b470ce5..8e408e92b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -729,8 +729,8 @@ void P_Ticker(boolean run) timeinmap = (timeinmap-1) & ~3; G_PreviewRewind(leveltime); } - else if (demo.freecam && democam.cam) // special case: allow freecam to MOVE during pause! - P_DemoCameraMovement(democam.cam); + else + P_RunChaseCameras(); // special case: allow freecam to MOVE during pause! return; } diff --git a/src/p_user.c b/src/p_user.c index a6a5076b1..cec39ee8a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2359,45 +2359,6 @@ static void P_UpdatePlayerAngle(player_t *player) } } - -// -// P_SpectatorMovement -// -// Control for spectators in multiplayer -// -static void P_SpectatorMovement(player_t *player) -{ - ticcmd_t *cmd = &player->cmd; - - P_UpdatePlayerAngle(player); - - ticruned++; - if (!(cmd->flags & TICCMD_RECEIVED)) - ticmiss++; - - if (cmd->buttons & BT_ACCELERATE) - player->mo->z += 32*mapobjectscale; - else if (cmd->buttons & BT_BRAKE) - player->mo->z -= 32*mapobjectscale; - - if (!(player->mo->flags & MF_NOCLIPHEIGHT)) - { - if (player->mo->z > player->mo->ceilingz - player->mo->height) - player->mo->z = player->mo->ceilingz - player->mo->height; - if (player->mo->z < player->mo->floorz) - player->mo->z = player->mo->floorz; - } - - player->mo->momx = player->mo->momy = player->mo->momz = 0; - if (cmd->forwardmove != 0) - { - P_Thrust(player->mo, player->mo->angle, cmd->forwardmove*mapobjectscale); - - // Quake-style flying spectators :D - player->mo->momz += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(player->aiming)); - } -} - // // P_MovePlayer void P_MovePlayer(player_t *player) @@ -2424,7 +2385,6 @@ void P_MovePlayer(player_t *player) if (player->spectator) { player->mo->eflags &= ~MFE_VERTICALFLIP; // deflip... - P_SpectatorMovement(player); return; } @@ -2979,16 +2939,12 @@ fixed_t t_cam_dist[MAXSPLITSCREENPLAYERS] = {-42,-42,-42,-42}; fixed_t t_cam_height[MAXSPLITSCREENPLAYERS] = {-42,-42,-42,-42}; fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42,-42,-42,-42}; -struct demofreecam_s democam; - void P_DemoCameraMovement(camera_t *cam) { ticcmd_t *cmd; angle_t thrustangle; player_t *lastp; - // update democam stuff with what we got here: - democam.cam = cam; // first off we need to get button input cmd = D_LocalTiccmd(0); @@ -3004,7 +2960,7 @@ void P_DemoCameraMovement(camera_t *cam) cam->z -= 32*mapobjectscale; // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") - if (cmd->buttons & BT_ATTACK) + if (demo.freecam && cmd->buttons & BT_ATTACK) { lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); @@ -3102,12 +3058,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; - if (demo.freecam) + if (demo.freecam || player->spectator) { P_DemoCameraMovement(thiscam); return true; } + if (paused || P_AutoPause()) + return true; + playerScale = FixedDiv(player->mo->scale, mapobjectscale); scaleDiff = playerScale - FRACUNIT; diff --git a/src/r_main.c b/src/r_main.c index 6cf539574..8a9abd36c 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1266,8 +1266,12 @@ void R_SetupFrame(int s) R_SetViewContext(VIEWCONTEXT_PLAYER1 + s); - if (player->spectator) // no spectator chasecam - chasecam = false; // force chasecam off + if (player->spectator) + { + // Free flying spectator uses demo freecam. This + // requires chasecam to be enabled. + chasecam = true; + } if (chasecam && (thiscam && !thiscam->chase)) { @@ -1293,7 +1297,7 @@ void R_SetupFrame(int s) R_SetupCommonFrame(player, r_viewmobj->subsector); } - else if (!player->spectator && chasecam) + else if (chasecam) // use outside cam view { r_viewmobj = NULL; @@ -1431,10 +1435,8 @@ boolean R_ViewpointHasChasecam(player_t *player) } } - if (player->playerstate == PST_DEAD || gamestate == GS_TITLESCREEN) + if (player->playerstate == PST_DEAD || gamestate == GS_TITLESCREEN || player->spectator) chasecam = true; // force chasecam on - else if (player->spectator) // no spectator chasecam - chasecam = false; // force chasecam off return chasecam; } @@ -1447,7 +1449,7 @@ boolean R_IsViewpointThirdPerson(player_t *player, boolean skybox) if (player->awayview.tics || skybox) return chasecam; // use outside cam view - else if (!player->spectator && chasecam) + else if (chasecam) return true; // use the player's eyes view