From e68ff858f2680bf94c4bb91771de5a0569886968 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 01:55:52 +0200 Subject: [PATCH 01/12] attempt to clean up cam shit even more --- src/r_main.c | 398 ++++++++++++++++++--------------------------------- 1 file changed, 143 insertions(+), 255 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index ef1560470..a45500ea1 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1124,6 +1124,69 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) mobj_t *viewmobj; +static void +R_SetupCommonFrame +( player_t * player, + subsector_t * subsector) +{ + newview->player = player; + + newview->x += quake.x; + newview->y += quake.y; + newview->z += quake.z; + + newview->roll = R_ViewRollAngle(player); + + if (subsector) + newview->sector = subsector->sector; + else + newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; + + R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); +} + +static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) +{ + UINT8 i; + + if (player->awayviewtics) + { + newview->aim = player->awayviewaiming; + newview->angle = player->awayviewmobj->angle; + } + else if (thiscam->chase) + { + newview->aim = thiscam->aiming; + newview->angle = thiscam->angle; + } + else + { + newview->aim = player->aiming; + newview->angle = player->mo->angle; + + if (!demo.playback && player->playerstate != PST_DEAD) + { + if (player == &players[consoleplayer]) + { + newview->angle = localangle[0]; // WARNING: camera uses this + newview->aim = localaiming[0]; + } + else if (splitscreen) + { + for (i = 1; i <= splitscreen; i++) + { + if (player == &players[displayplayers[i]]) + { + newview->angle = localangle[i]; + newview->aim = localaiming[i]; + break; + } + } + } + } + } +} + void R_SkyboxFrame(player_t *player) { camera_t *thiscam = &camera[0]; @@ -1156,45 +1219,9 @@ void R_SkyboxFrame(player_t *player) I_Error("R_SkyboxFrame: viewmobj null (player %s)", sizeu1(playeri)); } #endif - if (player->awayviewtics) - { - newview->aim = player->awayviewaiming; - newview->angle = player->awayviewmobj->angle; - } - else if (thiscam->chase) - { - newview->aim = thiscam->aiming; - newview->angle = thiscam->angle; - } - else - { - newview->aim = player->aiming; - newview->angle = player->mo->angle; - if (!demo.playback && player->playerstate != PST_DEAD) - { - if (player == &players[consoleplayer]) - { - newview->angle = localangle[0]; // WARNING: camera uses this - newview->aim = localaiming[0]; - } - else if (splitscreen) - { - for (i = 1; i <= splitscreen; i++) - { - if (player == &players[displayplayers[i]]) - { - newview->angle = localangle[i]; - newview->aim = localaiming[i]; - break; - } - } - } - } - } - newview->angle += viewmobj->angle; - newview->roll = R_ViewRollAngle(player); + R_SetupAimingFrame(player, thiscam); - newview->player = player; + newview->angle += viewmobj->angle; newview->x = viewmobj->x; newview->y = viewmobj->y; @@ -1202,185 +1229,87 @@ void R_SkyboxFrame(player_t *player) if (viewmobj->spawnpoint) newview->z = ((fixed_t)viewmobj->spawnpoint->angle)<x += quake.x; - newview->y += quake.y; - newview->z += quake.z; +#define SETUPSKYVIEW(viewmo, zscale)\ + if (skyboxmo[1])\ + {\ + fixed_t x = 0, y = 0;\ + if (mh->skybox_scalex > 0)\ + x = (viewmo->x - skyboxmo[1]->x) / mh->skybox_scalex;\ + else if (mh->skybox_scalex < 0)\ + x = (viewmo->x - skyboxmo[1]->x) * -mh->skybox_scalex;\ + if (mh->skybox_scaley > 0)\ + y = (viewmo->y - skyboxmo[1]->y) / mh->skybox_scaley;\ + else if (mh->skybox_scaley < 0)\ + y = (viewmo->y - skyboxmo[1]->y) * -mh->skybox_scaley;\ + if (viewmobj->angle == 0)\ + {\ + newview->x += x;\ + newview->y += y;\ + }\ + else if (viewmobj->angle == ANGLE_90)\ + {\ + newview->x -= y;\ + newview->y += x;\ + }\ + else if (viewmobj->angle == ANGLE_180)\ + {\ + newview->x -= x;\ + newview->y -= y;\ + }\ + else if (viewmobj->angle == ANGLE_270)\ + {\ + newview->x += y;\ + newview->y -= x;\ + }\ + else\ + {\ + angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;\ + newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));\ + newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));\ + }\ + }\ + if (mh->skybox_scalez > 0)\ + newview->z += zscale / mh->skybox_scalez;\ + else if (mh->skybox_scalez < 0)\ + newview->z += zscale * -mh->skybox_scalez; if (mapheaderinfo[gamemap-1]) { mapheader_t *mh = mapheaderinfo[gamemap-1]; + if (player->awayviewtics) { - if (skyboxmo[1]) - { - fixed_t x = 0, y = 0; - if (mh->skybox_scalex > 0) - x = (player->awayviewmobj->x - skyboxmo[1]->x) / mh->skybox_scalex; - else if (mh->skybox_scalex < 0) - x = (player->awayviewmobj->x - skyboxmo[1]->x) * -mh->skybox_scalex; - - if (mh->skybox_scaley > 0) - y = (player->awayviewmobj->y - skyboxmo[1]->y) / mh->skybox_scaley; - else if (mh->skybox_scaley < 0) - y = (player->awayviewmobj->y - skyboxmo[1]->y) * -mh->skybox_scaley; - - if (viewmobj->angle == 0) - { - newview->x += x; - newview->y += y; - } - else if (viewmobj->angle == ANGLE_90) - { - newview->x -= y; - newview->y += x; - } - else if (viewmobj->angle == ANGLE_180) - { - newview->x -= x; - newview->y -= y; - } - else if (viewmobj->angle == ANGLE_270) - { - newview->x += y; - newview->y -= x; - } - else - { - angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT; - newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); - newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); - } - } - if (mh->skybox_scalez > 0) - newview->z += (player->awayviewmobj->z + 20*FRACUNIT) / mh->skybox_scalez; - else if (mh->skybox_scalez < 0) - newview->z += (player->awayviewmobj->z + 20*FRACUNIT) * -mh->skybox_scalez; + SETUPSKYVIEW(player->awayviewmobj, (player->awayviewmobj->z + 20*FRACUNIT)); } else if (thiscam->chase) { - if (skyboxmo[1]) - { - fixed_t x = 0, y = 0; - if (mh->skybox_scalex > 0) - x = (thiscam->x - skyboxmo[1]->x) / mh->skybox_scalex; - else if (mh->skybox_scalex < 0) - x = (thiscam->x - skyboxmo[1]->x) * -mh->skybox_scalex; - - if (mh->skybox_scaley > 0) - y = (thiscam->y - skyboxmo[1]->y) / mh->skybox_scaley; - else if (mh->skybox_scaley < 0) - y = (thiscam->y - skyboxmo[1]->y) * -mh->skybox_scaley; - - if (viewmobj->angle == 0) - { - newview->x += x; - newview->y += y; - } - else if (viewmobj->angle == ANGLE_90) - { - newview->x -= y; - newview->y += x; - } - else if (viewmobj->angle == ANGLE_180) - { - newview->x -= x; - newview->y -= y; - } - else if (viewmobj->angle == ANGLE_270) - { - newview->x += y; - newview->y -= x; - } - else - { - angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT; - newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); - newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); - } - } - if (mh->skybox_scalez > 0) - newview->z += (thiscam->z + (thiscam->height>>1)) / mh->skybox_scalez; - else if (mh->skybox_scalez < 0) - newview->z += (thiscam->z + (thiscam->height>>1)) * -mh->skybox_scalez; + SETUPSKYVIEW(thiscam, (thiscam->z + (thiscam->height>>1))); } else { - if (skyboxmo[1]) - { - fixed_t x = 0, y = 0; - if (mh->skybox_scalex > 0) - x = (player->mo->x - skyboxmo[1]->x) / mh->skybox_scalex; - else if (mh->skybox_scalex < 0) - x = (player->mo->x - skyboxmo[1]->x) * -mh->skybox_scalex; - if (mh->skybox_scaley > 0) - y = (player->mo->y - skyboxmo[1]->y) / mh->skybox_scaley; - else if (mh->skybox_scaley < 0) - y = (player->mo->y - skyboxmo[1]->y) * -mh->skybox_scaley; - - if (viewmobj->angle == 0) - { - newview->x += x; - newview->y += y; - } - else if (viewmobj->angle == ANGLE_90) - { - newview->x -= y; - newview->y += x; - } - else if (viewmobj->angle == ANGLE_180) - { - newview->x -= x; - newview->y -= y; - } - else if (viewmobj->angle == ANGLE_270) - { - newview->x += y; - newview->y -= x; - } - else - { - angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT; - newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); - newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); - } - } - if (mh->skybox_scalez > 0) - newview->z += player->viewz / mh->skybox_scalez; - else if (mh->skybox_scalez < 0) - newview->z += player->viewz * -mh->skybox_scalez; + SETUPSKYVIEW(player->mo, player->viewz); } } +#undef SETUPSKYVIEW - if (viewmobj->subsector) - newview->sector = viewmobj->subsector->sector; - else - newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - - // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); - // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - - R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); + R_SetupCommonFrame(player, viewmobj->subsector); } -static void -R_SetupCommonFrame -( player_t * player, - subsector_t * subsector) +static inline UINT8 R_GetCamVar(UINT8 num) { - newview->player = player; - - newview->x += quake.x; - newview->y += quake.y; - newview->z += quake.z; - - newview->roll = R_ViewRollAngle(player); - - if (subsector) - newview->sector = subsector->sector; - else - newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - - R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); + switch (num) + { + case 0: + return cv_chasecam.value; + case 1: + return cv_chasecam2.value; + case 2: + return cv_chasecam3.value; + case 3: + return cv_chasecam4.value; + default: + return cv_chasecam.value; + } } void R_SetupFrame(player_t *player, boolean skybox) @@ -1388,33 +1317,21 @@ void R_SetupFrame(player_t *player, boolean skybox) camera_t *thiscam; boolean chasecam = false; -#define SETUPCAM(num, var, context)\ - thiscam = &camera[num];\ - chasecam = (var.value != 0);\ - R_SetViewContext(context);\ - if (thiscam->reset)\ - {\ - R_ResetViewInterpolation(num+1);\ - thiscam->reset = false;\ - } - - if (splitscreen > 2 && player == &players[displayplayers[3]]) + for (UINT8 i = 0; i <= splitscreen; i++) { - SETUPCAM(3, cv_chasecam4, VIEWCONTEXT_PLAYER4) + if (player == &players[displayplayers[i]]) + { + thiscam = &camera[i]; + chasecam = R_GetCamVar(i); + R_SetViewContext(VIEWCONTEXT_PLAYER1 + i); + if (thiscam->reset) + { + R_ResetViewInterpolation(i); + thiscam->reset = false; + } + break; + } } - else if (splitscreen > 1 && player == &players[displayplayers[2]]) - { - SETUPCAM(2, cv_chasecam3, VIEWCONTEXT_PLAYER3) - } - else if (splitscreen && player == &players[displayplayers[1]]) - { - SETUPCAM(1, cv_chasecam2, VIEWCONTEXT_PLAYER2) - } - else - { - SETUPCAM(0, cv_chasecam, VIEWCONTEXT_PLAYER1) - } -#undef SETUPCAM if (player->spectator) // no spectator chasecam chasecam = false; // force chasecam off @@ -1431,6 +1348,8 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->sky = !skybox; + R_SetupAimingFrame(player, thiscam); + if (player->awayviewtics) // cut-away view stuff { viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN @@ -1440,9 +1359,6 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; - newview->aim = player->awayviewaiming; - newview->angle = viewmobj->angle; - R_SetupCommonFrame(player, viewmobj->subsector); } else if (!player->spectator && (thiscam && chasecam)) // use outside cam view @@ -1453,9 +1369,6 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); - newview->aim = thiscam->aiming; - newview->angle = thiscam->angle; - R_SetupCommonFrame(player, thiscam->subsector); } else // use the player's eyes view @@ -1467,31 +1380,6 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->y = viewmobj->y; newview->z = player->viewz; - newview->aim = player->aiming; - newview->angle = viewmobj->angle; - - if (!demo.playback && player->playerstate != PST_DEAD) - { - if (player == &players[consoleplayer]) - { - newview->angle = localangle[0]; // WARNING: camera uses this - newview->aim = localaiming[0]; - } - else if (splitscreen) - { - UINT8 i; - for (i = 1; i <= splitscreen; i++) - { - if (player == &players[displayplayers[i]]) - { - newview->angle = localangle[i]; - newview->aim = localaiming[i]; - break; - } - } - } - } - R_SetupCommonFrame(player, viewmobj->subsector); } } From 4180949307eef9656877e076a19be2e332dda1c2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 02:01:02 +0200 Subject: [PATCH 02/12] dont need this splitscreen check --- src/r_main.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index a45500ea1..ece996a52 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1147,8 +1147,6 @@ R_SetupCommonFrame static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) { - UINT8 i; - if (player->awayviewtics) { newview->aim = player->awayviewaiming; @@ -1166,21 +1164,13 @@ static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) if (!demo.playback && player->playerstate != PST_DEAD) { - if (player == &players[consoleplayer]) + for (UINT8 i = 0; i <= splitscreen; i++) { - newview->angle = localangle[0]; // WARNING: camera uses this - newview->aim = localaiming[0]; - } - else if (splitscreen) - { - for (i = 1; i <= splitscreen; i++) + if (player == &players[displayplayers[i]]) { - if (player == &players[displayplayers[i]]) - { - newview->angle = localangle[i]; - newview->aim = localaiming[i]; - break; - } + newview->angle = localangle[i]; + newview->aim = localaiming[i]; + break; } } } From ab4bbbff728ac814f41a814f64fcc20de67fab4b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 22:44:37 +0200 Subject: [PATCH 03/12] use arrays for all the cam cvars --- src/d_netcmd.c | 8 +- src/g_game.c | 16 +-- src/m_menu.c | 48 ++++----- src/p_floor.c | 140 ++++++------------------- src/p_local.h | 24 ++--- src/p_setup.c | 33 ++---- src/p_user.c | 271 ++++++++++++++++++++++--------------------------- src/r_main.c | 107 +++++++++---------- src/r_main.h | 4 +- 9 files changed, 256 insertions(+), 395 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ceaa38e2b..e3e57b29c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2241,7 +2241,7 @@ void SendWeaponPref(void) UINT8 buf[1]; buf[0] = 0; - if (cv_flipcam.value) + if (cv_flipcam[0].value) buf[0] |= 1; if (cv_analog.value) buf[0] |= 2; @@ -2253,7 +2253,7 @@ void SendWeaponPref2(void) UINT8 buf[1]; buf[0] = 0; - if (cv_flipcam2.value) + if (cv_flipcam[1].value) buf[0] |= 1; if (cv_analog2.value) buf[0] |= 2; @@ -2265,7 +2265,7 @@ void SendWeaponPref3(void) UINT8 buf[1]; buf[0] = 0; - if (cv_flipcam3.value) + if (cv_flipcam[2].value) buf[0] |= 1; if (cv_analog3.value) buf[0] |= 2; @@ -2277,7 +2277,7 @@ void SendWeaponPref4(void) UINT8 buf[1]; buf[0] = 0; - if (cv_flipcam4.value) + if (cv_flipcam[3].value) buf[0] |= 1; if (cv_analog4.value) buf[0] |= 2; diff --git a/src/g_game.c b/src/g_game.c index 2d2fe7bb6..ddfa43063 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1498,7 +1498,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) static void Analog_OnChange(void) { - if (!cv_cam_dist.string) + if (!cv_cam_dist[0].string) return; SendWeaponPref(); @@ -1506,7 +1506,7 @@ static void Analog_OnChange(void) static void Analog2_OnChange(void) { - if (!(splitscreen || botingame) || !cv_cam2_dist.string) + if (!splitscreen || !cv_cam_dist[1].string) return; SendWeaponPref2(); @@ -1514,7 +1514,7 @@ static void Analog2_OnChange(void) static void Analog3_OnChange(void) { - if (splitscreen < 2 || !cv_cam3_dist.string) + if (splitscreen < 2 || !cv_cam_dist[2].string) return; SendWeaponPref3(); @@ -1522,7 +1522,7 @@ static void Analog3_OnChange(void) static void Analog4_OnChange(void) { - if (splitscreen < 3 || !cv_cam4_dist.string) + if (splitscreen < 3 || !cv_cam_dist[3].string) return; SendWeaponPref4(); @@ -1790,7 +1790,7 @@ boolean G_Responder(event_t *ev) if (!camtoggledelay) { camtoggledelay = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam, cv_chasecam.value ? 0 : 1); + CV_SetValue(&cv_chasecam[0], cv_chasecam[0].value ? 0 : 1); } } if (ev->data1 == gamecontrolbis[gc_camtoggle][0] @@ -1799,7 +1799,7 @@ boolean G_Responder(event_t *ev) if (!camtoggledelay2) { camtoggledelay2 = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam2, cv_chasecam2.value ? 0 : 1); + CV_SetValue(&cv_chasecam[1], cv_chasecam[1].value ? 0 : 1); } } if (ev->data1 == gamecontrol3[gc_camtoggle][0] @@ -1808,7 +1808,7 @@ boolean G_Responder(event_t *ev) if (!camtoggledelay3) { camtoggledelay3 = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam3, cv_chasecam3.value ? 0 : 1); + CV_SetValue(&cv_chasecam[2], cv_chasecam[2].value ? 0 : 1); } } if (ev->data1 == gamecontrol4[gc_camtoggle][0] @@ -1817,7 +1817,7 @@ boolean G_Responder(event_t *ev) if (!camtoggledelay4) { camtoggledelay4 = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam4, cv_chasecam4.value ? 0 : 1); + CV_SetValue(&cv_chasecam[3], cv_chasecam[3].value ? 0 : 1); } } if (ev->data1 == gamecontrol[gc_spectate][0] diff --git a/src/m_menu.c b/src/m_menu.c index 101afbd8d..f14a3473a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1851,52 +1851,52 @@ static menuitem_t OP_Player1CamOptionsMenu[] = { {IT_HEADER, NULL, "Player 1 Camera Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam, 30}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist, 40}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height, 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed, 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed, 70}, + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[0], 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[0], 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[0], 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[0], 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed[0], 70}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam, 85}, + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[0], 85}, }; static menuitem_t OP_Player2CamOptionsMenu[] = { {IT_HEADER, NULL, "Player 2 Camera Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam2, 30}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam2_dist, 40}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam2_height, 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam2_speed, 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam2_rotspeed, 70}, + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[1], 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[1], 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[1], 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[1], 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed[1], 70}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam2, 85}, + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[1], 85}, }; static menuitem_t OP_Player3CamOptionsMenu[] = { {IT_HEADER, NULL, "Player 3 Camera Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam3, 30}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam3_dist, 40}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam3_height, 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam3_speed, 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam3_rotspeed, 70}, + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[2], 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[2], 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[2], 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[2], 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed[2], 70}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam3, 85}, + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[2], 85}, }; static menuitem_t OP_Player4CamOptionsMenu[] = { {IT_HEADER, NULL, "Player 4 Camera Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam4, 30}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam4_dist, 40}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam4_height, 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam4_speed, 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam4_rotspeed, 70}, + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[3], 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[3], 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[3], 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[3], 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed[3], 70}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam4, 85}, + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[3], 85}, }; static const char* OP_PlayerCamOptionsTooltips[] = diff --git a/src/p_floor.c b/src/p_floor.c index bebc9a272..febd521ff 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2507,123 +2507,47 @@ void T_CameraScanner(elevator_t *elevator) { // leveltime is compared to make multiple scanners in one map function correctly. static tic_t lastleveltime = 32000; // any number other than 0 should do here - static boolean camerascanned, camerascanned2, camerascanned3, camerascanned4; + static boolean camerascanned[MAXSPLITSCREENPLAYERS]; + static fixed_t t_cam_dist[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; + static fixed_t t_cam_height[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; if (leveltime != lastleveltime) // Back on the first camera scanner { - camerascanned = camerascanned2 = camerascanned3 = camerascanned4 = false; + for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + camerascanned[i] = false; + } lastleveltime = leveltime; } - if (players[displayplayers[0]].mo) + for (UINT8 i = 0; i <= splitscreen; i++) { - if (players[displayplayers[0]].mo->subsector->sector == elevator->actionsector) + if (players[displayplayers[i]].mo) { - if (t_cam_dist == -42) - t_cam_dist = cv_cam_dist.value; - if (t_cam_height == -42) - t_cam_height = cv_cam_height.value; - if (t_cam_rotate == -42) - t_cam_rotate = cv_cam_rotate.value; - CV_SetValue(&cv_cam_height, FixedInt(elevator->sector->floorheight)); - CV_SetValue(&cv_cam_dist, FixedInt(elevator->sector->ceilingheight)); - CV_SetValue(&cv_cam_rotate, elevator->distance); - camerascanned = true; - } - else if (!camerascanned) - { - if (t_cam_height != -42 && cv_cam_height.value != t_cam_height) - CV_Set(&cv_cam_height, va("%f", (double)FIXED_TO_FLOAT(t_cam_height))); - if (t_cam_dist != -42 && cv_cam_dist.value != t_cam_dist) - CV_Set(&cv_cam_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam_dist))); - if (t_cam_rotate != -42 && cv_cam_rotate.value != t_cam_rotate) - CV_Set(&cv_cam_rotate, va("%f", (double)t_cam_rotate)); + 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 = t_cam_height = t_cam_rotate = -42; - } - } - - if (splitscreen && players[displayplayers[1]].mo) - { - if (players[displayplayers[1]].mo->subsector->sector == elevator->actionsector) - { - if (t_cam2_rotate == -42) - t_cam2_dist = cv_cam2_dist.value; - if (t_cam2_rotate == -42) - t_cam2_height = cv_cam2_height.value; - if (t_cam2_rotate == -42) - t_cam2_rotate = cv_cam2_rotate.value; - CV_SetValue(&cv_cam2_height, FixedInt(elevator->sector->floorheight)); - CV_SetValue(&cv_cam2_dist, FixedInt(elevator->sector->ceilingheight)); - CV_SetValue(&cv_cam2_rotate, elevator->distance); - camerascanned2 = true; - } - else if (!camerascanned2) - { - if (t_cam2_height != -42 && cv_cam2_height.value != t_cam2_height) - CV_Set(&cv_cam2_height, va("%f", (double)FIXED_TO_FLOAT(t_cam2_height))); - if (t_cam2_dist != -42 && cv_cam2_dist.value != t_cam2_dist) - CV_Set(&cv_cam2_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam2_dist))); - if (t_cam2_rotate != -42 && cv_cam2_rotate.value != t_cam2_rotate) - CV_Set(&cv_cam2_rotate, va("%f", (double)t_cam2_rotate)); - - t_cam2_dist = t_cam2_height = t_cam2_rotate = -42; - } - } - - if (splitscreen > 1 && players[displayplayers[2]].mo) - { - if (players[displayplayers[2]].mo->subsector->sector == elevator->actionsector) - { - if (t_cam3_rotate == -42) - t_cam3_dist = cv_cam3_dist.value; - if (t_cam3_rotate == -42) - t_cam3_height = cv_cam3_height.value; - if (t_cam3_rotate == -42) - t_cam3_rotate = cv_cam3_rotate.value; - CV_SetValue(&cv_cam3_height, FixedInt(elevator->sector->floorheight)); - CV_SetValue(&cv_cam3_dist, FixedInt(elevator->sector->ceilingheight)); - CV_SetValue(&cv_cam3_rotate, elevator->distance); - camerascanned3 = true; - } - else if (!camerascanned3) - { - if (t_cam3_height != -42 && cv_cam3_height.value != t_cam3_height) - CV_Set(&cv_cam3_height, va("%f", (double)FIXED_TO_FLOAT(t_cam3_height))); - if (t_cam3_dist != -42 && cv_cam3_dist.value != t_cam3_dist) - CV_Set(&cv_cam3_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam3_dist))); - if (t_cam3_rotate != -42 && cv_cam3_rotate.value != t_cam3_rotate) - CV_Set(&cv_cam3_rotate, va("%f", (double)t_cam3_rotate)); - - t_cam3_dist = t_cam3_height = t_cam3_rotate = -42; - } - } - - if (splitscreen > 2 && players[displayplayers[3]].mo) - { - if (players[displayplayers[3]].mo->subsector->sector == elevator->actionsector) - { - if (t_cam4_rotate == -42) - t_cam4_dist = cv_cam4_dist.value; - if (t_cam4_rotate == -42) - t_cam4_height = cv_cam4_height.value; - if (t_cam4_rotate == -42) - t_cam4_rotate = cv_cam4_rotate.value; - CV_SetValue(&cv_cam4_height, FixedInt(elevator->sector->floorheight)); - CV_SetValue(&cv_cam4_dist, FixedInt(elevator->sector->ceilingheight)); - CV_SetValue(&cv_cam4_rotate, elevator->distance); - camerascanned4 = true; - } - else if (!camerascanned4) - { - if (t_cam4_height != -42 && cv_cam4_height.value != t_cam4_height) - CV_Set(&cv_cam4_height, va("%f", (double)FIXED_TO_FLOAT(t_cam4_height))); - if (t_cam4_dist != -42 && cv_cam4_dist.value != t_cam4_dist) - CV_Set(&cv_cam4_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam4_dist))); - if (t_cam4_rotate != -42 && cv_cam4_rotate.value != t_cam4_rotate) - CV_Set(&cv_cam4_rotate, va("%f", (double)t_cam4_rotate)); - - t_cam4_dist = t_cam4_height = t_cam4_rotate = -42; + t_cam_dist[i] = t_cam_height[i] = t_cam_rotate[i] = -42; + } } } } diff --git a/src/p_local.h b/src/p_local.h index 0902c8b3d..cbfce9433 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -116,7 +116,7 @@ struct demofreecam_s { camera_t *cam; // this is useful when the game is paused, notably mobj_t *soundmobj; // mobj to play sound from, used in s_sound - + angle_t localangle; // keeps track of the cam angle for cmds angle_t localaiming; // ditto with aiming boolean turnheld; // holding turn button for gradual turn speed @@ -126,17 +126,12 @@ struct demofreecam_s { extern struct demofreecam_s democam; extern camera_t camera[MAXSPLITSCREENPLAYERS]; -extern consvar_t cv_cam_dist, cv_cam_still, cv_cam_height; -extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed; - -extern consvar_t cv_cam2_dist, cv_cam2_still, cv_cam2_height; -extern consvar_t cv_cam2_speed, cv_cam2_rotate, cv_cam2_rotspeed; - -extern consvar_t cv_cam3_dist, cv_cam3_still, cv_cam3_height; -extern consvar_t cv_cam3_speed, cv_cam3_rotate, cv_cam3_rotspeed; - -extern consvar_t cv_cam4_dist, cv_cam4_still, cv_cam4_height; -extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed; +extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_tilting; extern consvar_t cv_quaketilt; @@ -146,10 +141,7 @@ extern consvar_t cv_actionmovie; extern consvar_t cv_lookbackmom; -extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; -extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; -extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate; -extern fixed_t t_cam4_dist, t_cam4_height, t_cam4_rotate; +extern fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS]; fixed_t P_GetPlayerHeight(player_t *player); fixed_t P_GetPlayerSpinHeight(player_t *player); diff --git a/src/p_setup.c b/src/p_setup.c index 672b1b347..048e5d629 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2466,17 +2466,11 @@ static void P_InitCamera(void) P_SetupCamera(displayplayers[i], &camera[i]); // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P - if (!cv_cam_rotate.changed) - CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue); - - if (!cv_cam2_rotate.changed) - CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue); - - if (!cv_cam3_rotate.changed) - CV_Set(&cv_cam3_rotate, cv_cam3_rotate.defaultvalue); - - if (!cv_cam4_rotate.changed) - CV_Set(&cv_cam4_rotate, cv_cam4_rotate.defaultvalue); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!cv_cam_rotate[i].changed) + CV_Set(&cv_cam_rotate[i], cv_cam_rotate[i].defaultvalue); + } displayplayers[0] = consoleplayer; // Start with your OWN view, please! } @@ -2600,18 +2594,11 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) if (!dedicated) { - if (!cv_chasecam.changed) - CV_SetValue(&cv_chasecam, chase); - - // same for second player - if (!cv_chasecam2.changed) - CV_SetValue(&cv_chasecam2, chase); - - if (!cv_chasecam3.changed) - CV_SetValue(&cv_chasecam3, chase); - - if (!cv_chasecam4.changed) - CV_SetValue(&cv_chasecam4, chase); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!cv_chasecam[i].changed) + CV_SetValue(&cv_chasecam[i], chase); + } } // Initial height of PointOfView diff --git a/src/p_user.c b/src/p_user.c index 7c57fb107..825b86d11 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2976,34 +2976,34 @@ camera_t camera[MAXSPLITSCREENPLAYERS]; // Four cameras, three for splitscreen static void CV_CamRotate_OnChange(void) { - if (cv_cam_rotate.value < 0) - CV_SetValue(&cv_cam_rotate, cv_cam_rotate.value + 360); - else if (cv_cam_rotate.value > 359) - CV_SetValue(&cv_cam_rotate, cv_cam_rotate.value % 360); + if (cv_cam_rotate[0].value < 0) + CV_SetValue(&cv_cam_rotate[0], cv_cam_rotate[0].value + 360); + else if (cv_cam_rotate[0].value > 359) + CV_SetValue(&cv_cam_rotate[0], cv_cam_rotate[0].value % 360); } static void CV_CamRotate2_OnChange(void) { - if (cv_cam2_rotate.value < 0) - CV_SetValue(&cv_cam2_rotate, cv_cam2_rotate.value + 360); - else if (cv_cam2_rotate.value > 359) - CV_SetValue(&cv_cam2_rotate, cv_cam2_rotate.value % 360); + if (cv_cam_rotate[1].value < 0) + CV_SetValue(&cv_cam_rotate[1], cv_cam_rotate[1].value + 360); + else if (cv_cam_rotate[1].value > 359) + CV_SetValue(&cv_cam_rotate[1], cv_cam_rotate[1].value % 360); } static void CV_CamRotate3_OnChange(void) { - if (cv_cam3_rotate.value < 0) - CV_SetValue(&cv_cam3_rotate, cv_cam3_rotate.value + 360); - else if (cv_cam3_rotate.value > 359) - CV_SetValue(&cv_cam3_rotate, cv_cam3_rotate.value % 360); + if (cv_cam_rotate[2].value < 0) + CV_SetValue(&cv_cam_rotate[2], cv_cam_rotate[2].value + 360); + else if (cv_cam_rotate[2].value > 359) + CV_SetValue(&cv_cam_rotate[2], cv_cam_rotate[2].value % 360); } static void CV_CamRotate4_OnChange(void) { - if (cv_cam4_rotate.value < 0) - CV_SetValue(&cv_cam4_rotate, cv_cam4_rotate.value + 360); - else if (cv_cam4_rotate.value > 359) - CV_SetValue(&cv_cam4_rotate, cv_cam4_rotate.value % 360); + if (cv_cam_rotate[3].value < 0) + CV_SetValue(&cv_cam_rotate[3], cv_cam_rotate[3].value + 360); + else if (cv_cam_rotate[3].value > 359) + CV_SetValue(&cv_cam_rotate[3], cv_cam_rotate[3].value % 360); } static CV_PossibleValue_t CV_CamSpeed[] = {{0, "MIN"}, {1*FRACUNIT, "MAX"}, {0, NULL}}; @@ -3074,33 +3074,47 @@ static void CV_PlayerCam4_OnChange(void) P_ResetCamera(&players[displayplayers[3]], &camera[3]); } -consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_height = {"cam_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_still = {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_speed = {"cam_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_rotate = {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_rotspeed = {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS] = { + {"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; -consvar_t cv_cam2_dist = {"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_height = {"cam2_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_still = {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_speed = {"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_rotate = {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_rotspeed = {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS] = { + {"cam_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}, +}; -consvar_t cv_cam3_dist = {"cam3_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam3_height = {"cam3_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam3_still = {"cam3_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam3_speed = {"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam3_rotate = {"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam3_rotspeed = {"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS] = { + {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; -consvar_t cv_cam4_dist = {"cam4_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam4_height = {"cam4_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam4_still = {"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam4_speed = {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS] = { + {"cam_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + +consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS] = { + {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; + +consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS] = { + {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; consvar_t cv_tilting = {"tilting", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_quaketilt = {"quaketilt", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3111,18 +3125,7 @@ consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NU static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Double"}, {0, NULL}}; consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -fixed_t t_cam_dist = -42; -fixed_t t_cam_height = -42; -fixed_t t_cam_rotate = -42; -fixed_t t_cam2_dist = -42; -fixed_t t_cam2_height = -42; -fixed_t t_cam2_rotate = -42; -fixed_t t_cam3_dist = -42; -fixed_t t_cam3_height = -42; -fixed_t t_cam3_rotate = -42; -fixed_t t_cam4_dist = -42; -fixed_t t_cam4_height = -42; -fixed_t t_cam4_rotate = -42; +fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; #define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode) @@ -3388,10 +3391,10 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->z = z; thiscam->reset = true; - if (!(thiscam == &camera[0] && (cv_cam_still.value || cv_analog.value)) - && !(thiscam == &camera[1] && (cv_cam2_still.value || cv_analog2.value)) - && !(thiscam == &camera[2] && (cv_cam3_still.value || cv_analog3.value)) - && !(thiscam == &camera[3] && (cv_cam4_still.value || cv_analog4.value))) + if (!(thiscam == &camera[0] && (cv_cam_still[0].value || cv_analog.value)) + && !(thiscam == &camera[1] && (cv_cam_still[1].value || cv_analog2.value)) + && !(thiscam == &camera[2] && (cv_cam_still[2].value || cv_analog3.value)) + && !(thiscam == &camera[3] && (cv_cam_still[3].value || cv_analog4.value))) { thiscam->angle = player->mo->angle; thiscam->aiming = 0; @@ -3410,7 +3413,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { static boolean lookbackactive[MAXSPLITSCREENPLAYERS]; static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS]; - UINT8 num; + UINT8 i, num; angle_t angle = 0, focusangle = 0, focusaiming = 0; fixed_t x, y, z, dist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight; fixed_t pan, xpan, ypan; @@ -3458,42 +3461,40 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (player->spectator) // force cam off for spectators return true; - if (!cv_chasecam.value && thiscam == &camera[0]) - return true; - - if (!cv_chasecam2.value && thiscam == &camera[1]) - return true; - - if (!cv_chasecam3.value && thiscam == &camera[2]) - return true; - - if (!cv_chasecam4.value && thiscam == &camera[3]) - return true; + for (i = 0; i <= splitscreen; i++) + { + if (!cv_chasecam[i].value && thiscam == &camera[i]) + return true; + } } if (!thiscam->chase && !resetcalled) { - if (player == &players[consoleplayer]) - focusangle = localangle[0]; - else if (player == &players[displayplayers[1]]) - focusangle = localangle[1]; - else if (player == &players[displayplayers[2]]) - focusangle = localangle[2]; - else if (player == &players[displayplayers[3]]) - focusangle = localangle[3]; - else - focusangle = mo->angle; + for (i = 0; i <= splitscreen; i++) + { + if (player == &players[displayplayers[i]]) + { + focusangle = localangle[i]; + break; + } + else + { + focusangle = mo->angle; + } + } - if (thiscam == &camera[0]) - camrotate = cv_cam_rotate.value; - else if (thiscam == &camera[1]) - camrotate = cv_cam2_rotate.value; - else if (thiscam == &camera[2]) - camrotate = cv_cam3_rotate.value; - else if (thiscam == &camera[3]) - camrotate = cv_cam4_rotate.value; - else - camrotate = 0; + for (i = 0; i <= splitscreen; i++) + { + if (thiscam == &camera[i]) + { + camrotate = cv_cam_rotate[i].value; + break; + } + else + { + camrotate = 0; + } + } if (leveltime < introtime) // Whoooshy camera! { @@ -3519,74 +3520,40 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusangle = mo->angle; focusaiming = 0; } - else if (player == &players[consoleplayer]) - { - focusangle = localangle[0]; - focusaiming = localaiming[0]; - } - else if (player == &players[displayplayers[1]]) - { - focusangle = localangle[1]; - focusaiming = localaiming[1]; - } - else if (player == &players[displayplayers[2]]) - { - focusangle = localangle[2]; - focusaiming = localaiming[2]; - } - else if (player == &players[displayplayers[3]]) - { - focusangle = localangle[3]; - focusaiming = localaiming[3]; - } else { - focusangle = mo->angle; - focusaiming = player->aiming; + for (i = 0; i <= splitscreen; i++) + { + if (player == &players[displayplayers[i]]) + { + focusangle = localangle[i]; + focusaiming = localaiming[i]; + break; + } + else + { + focusangle = mo->angle; + focusaiming = player->aiming; + } + } } if (P_CameraThinker(player, thiscam, resetcalled)) return true; - if (thiscam == &camera[1]) // Camera 2 + for (i = 0; i <= splitscreen; i++) { - num = 1; - camspeed = cv_cam2_speed.value; - camstill = cv_cam2_still.value; - camrotate = cv_cam2_rotate.value; - camdist = FixedMul(cv_cam2_dist.value, mapobjectscale); - camheight = FixedMul(cv_cam2_height.value, mapobjectscale); - lookback = camspin[1]; - } - else if (thiscam == &camera[2]) // Camera 3 - { - num = 2; - camspeed = cv_cam3_speed.value; - camstill = cv_cam3_still.value; - camrotate = cv_cam3_rotate.value; - camdist = FixedMul(cv_cam3_dist.value, mapobjectscale); - camheight = FixedMul(cv_cam3_height.value, mapobjectscale); - lookback = camspin[2]; - } - else if (thiscam == &camera[3]) // Camera 4 - { - num = 3; - camspeed = cv_cam4_speed.value; - camstill = cv_cam4_still.value; - camrotate = cv_cam4_rotate.value; - camdist = FixedMul(cv_cam4_dist.value, mapobjectscale); - camheight = FixedMul(cv_cam4_height.value, mapobjectscale); - lookback = camspin[3]; - } - else // Camera 1 - { - num = 0; - camspeed = cv_cam_speed.value; - camstill = cv_cam_still.value; - camrotate = cv_cam_rotate.value; - camdist = FixedMul(cv_cam_dist.value, mapobjectscale); - camheight = FixedMul(cv_cam_height.value, mapobjectscale); - lookback = camspin[0]; + 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; + } } if (timeover) @@ -3651,10 +3618,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } if (!resetcalled && (leveltime > starttime && timeover != 2) - && ((thiscam == &camera[0] && t_cam_rotate != -42) - || (thiscam == &camera[1] && t_cam2_rotate != -42) - || (thiscam == &camera[2] && t_cam3_rotate != -42) - || (thiscam == &camera[3] && t_cam4_rotate != -42))) + && ((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))) { angle = FixedAngle(camrotate*FRACUNIT); thiscam->angle = angle; diff --git a/src/r_main.c b/src/r_main.c index ece996a52..e979c436d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -168,14 +168,20 @@ void SendWeaponPref4(void); static void Precipstuff_OnChange(void); consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasecam = {"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasecam2 = {"chasecam2", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasecam3 = {"chasecam3", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasecam4 = {"chasecam4", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_flipcam = {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_flipcam2 = {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_flipcam3 = {"flipcam3", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_flipcam4 = {"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS] = { + {"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"chasecam2", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"chasecam3", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"chasecam4", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + +consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS] = { + {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"flipcam3", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1285,23 +1291,6 @@ void R_SkyboxFrame(player_t *player) R_SetupCommonFrame(player, viewmobj->subsector); } -static inline UINT8 R_GetCamVar(UINT8 num) -{ - switch (num) - { - case 0: - return cv_chasecam.value; - case 1: - return cv_chasecam2.value; - case 2: - return cv_chasecam3.value; - case 3: - return cv_chasecam4.value; - default: - return cv_chasecam.value; - } -} - void R_SetupFrame(player_t *player, boolean skybox) { camera_t *thiscam; @@ -1312,7 +1301,7 @@ void R_SetupFrame(player_t *player, boolean skybox) if (player == &players[displayplayers[i]]) { thiscam = &camera[i]; - chasecam = R_GetCamVar(i); + chasecam = cv_chasecam[i].value; R_SetViewContext(VIEWCONTEXT_PLAYER1 + i); if (thiscam->reset) { @@ -1665,10 +1654,10 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_soniccd); CV_RegisterVar(&cv_allowmlook); CV_RegisterVar(&cv_homremoval); - CV_RegisterVar(&cv_flipcam); - CV_RegisterVar(&cv_flipcam2); - CV_RegisterVar(&cv_flipcam3); - CV_RegisterVar(&cv_flipcam4); + CV_RegisterVar(&cv_flipcam[0]); + CV_RegisterVar(&cv_flipcam[1]); + CV_RegisterVar(&cv_flipcam[2]); + CV_RegisterVar(&cv_flipcam[3]); // Enough for dedicated server if (dedicated) @@ -1681,43 +1670,45 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_mobjscaleprecip); CV_RegisterVar(&cv_fov); - CV_RegisterVar(&cv_chasecam); - CV_RegisterVar(&cv_chasecam2); - CV_RegisterVar(&cv_chasecam3); - CV_RegisterVar(&cv_chasecam4); + CV_RegisterVar(&cv_chasecam[0]); + CV_RegisterVar(&cv_chasecam[1]); + CV_RegisterVar(&cv_chasecam[2]); + CV_RegisterVar(&cv_chasecam[3]); CV_RegisterVar(&cv_shadow); CV_RegisterVar(&cv_shadowoffs); CV_RegisterVar(&cv_skybox); CV_RegisterVar(&cv_ffloorclip); CV_RegisterVar(&cv_spriteclip); - CV_RegisterVar(&cv_cam_dist); - CV_RegisterVar(&cv_cam_still); - CV_RegisterVar(&cv_cam_height); - CV_RegisterVar(&cv_cam_speed); - CV_RegisterVar(&cv_cam_rotate); - CV_RegisterVar(&cv_cam_rotspeed); + CV_RegisterVar(&cv_cam_dist[0]); + CV_RegisterVar(&cv_cam_dist[1]); + CV_RegisterVar(&cv_cam_dist[2]); + CV_RegisterVar(&cv_cam_dist[3]); - CV_RegisterVar(&cv_cam2_dist); - CV_RegisterVar(&cv_cam2_still); - CV_RegisterVar(&cv_cam2_height); - CV_RegisterVar(&cv_cam2_speed); - CV_RegisterVar(&cv_cam2_rotate); - CV_RegisterVar(&cv_cam2_rotspeed); + CV_RegisterVar(&cv_cam_still[0]); + CV_RegisterVar(&cv_cam_still[1]); + CV_RegisterVar(&cv_cam_still[2]); + CV_RegisterVar(&cv_cam_still[3]); - CV_RegisterVar(&cv_cam3_dist); - CV_RegisterVar(&cv_cam3_still); - CV_RegisterVar(&cv_cam3_height); - CV_RegisterVar(&cv_cam3_speed); - CV_RegisterVar(&cv_cam3_rotate); - CV_RegisterVar(&cv_cam3_rotspeed); + CV_RegisterVar(&cv_cam_height[0]); + CV_RegisterVar(&cv_cam_height[1]); + CV_RegisterVar(&cv_cam_height[2]); + CV_RegisterVar(&cv_cam_height[3]); - CV_RegisterVar(&cv_cam4_dist); - CV_RegisterVar(&cv_cam4_still); - CV_RegisterVar(&cv_cam4_height); - CV_RegisterVar(&cv_cam4_speed); - CV_RegisterVar(&cv_cam4_rotate); - CV_RegisterVar(&cv_cam4_rotspeed); + CV_RegisterVar(&cv_cam_speed[0]); + CV_RegisterVar(&cv_cam_speed[1]); + CV_RegisterVar(&cv_cam_speed[2]); + CV_RegisterVar(&cv_cam_speed[3]); + + CV_RegisterVar(&cv_cam_rotate[0]); + CV_RegisterVar(&cv_cam_rotate[1]); + CV_RegisterVar(&cv_cam_rotate[2]); + CV_RegisterVar(&cv_cam_rotate[3]); + + CV_RegisterVar(&cv_cam_rotspeed[0]); + CV_RegisterVar(&cv_cam_rotspeed[1]); + CV_RegisterVar(&cv_cam_rotspeed[2]); + CV_RegisterVar(&cv_cam_rotspeed[3]); CV_RegisterVar(&cv_tilting); CV_RegisterVar(&cv_quaketilt); diff --git a/src/r_main.h b/src/r_main.h index 2d7503ea7..450fe9c93 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -137,8 +137,8 @@ extern ps_metric_t ps_numpolyobjects; extern consvar_t cv_showhud, cv_translucenthud, cv_uncappedhud; extern consvar_t cv_homremoval; -extern consvar_t cv_chasecam, cv_chasecam2, cv_chasecam3, cv_chasecam4; -extern consvar_t cv_flipcam, cv_flipcam2, cv_flipcam3, cv_flipcam4; +extern consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_shadow, cv_shadowoffs; extern consvar_t cv_ffloorclip, cv_spriteclip; extern consvar_t cv_translucency; From b8fb74fef3df54a51c590c6b19771408e2a70f83 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 21:47:56 +0200 Subject: [PATCH 04/12] fix the cam loops --- src/p_user.c | 34 +++++++++++++--------------------- src/r_main.c | 21 +++++++-------------- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 825b86d11..71f756555 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3470,19 +3470,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (!thiscam->chase && !resetcalled) { + focusangle = mo->angle; for (i = 0; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) + if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) { focusangle = localangle[i]; break; } - else - { - focusangle = mo->angle; - } } + camrotate = 0; for (i = 0; i <= splitscreen; i++) { if (thiscam == &camera[i]) @@ -3490,10 +3488,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam_rotate[i].value; break; } - else - { - camrotate = 0; - } } if (leveltime < introtime) // Whoooshy camera! @@ -3522,19 +3516,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else { - for (i = 0; i <= splitscreen; i++) + focusangle = mo->angle; + focusaiming = player->aiming; + } + + for (i = 0; i <= splitscreen; i++) + { + if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) { - if (player == &players[displayplayers[i]]) - { - focusangle = localangle[i]; - focusaiming = localaiming[i]; - break; - } - else - { - focusangle = mo->angle; - focusaiming = player->aiming; - } + focusangle = localangle[i]; + focusaiming = localaiming[i]; + break; } } diff --git a/src/r_main.c b/src/r_main.c index e979c436d..80d6961fa 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1172,7 +1172,7 @@ static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) { for (UINT8 i = 0; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) + if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) { newview->angle = localangle[i]; newview->aim = localaiming[i]; @@ -1188,22 +1188,15 @@ void R_SkyboxFrame(player_t *player) camera_t *thiscam = &camera[0]; UINT8 i; - if (splitscreen) + for (i = 0; i <= splitscreen; i++) { - for (i = 0; i <= splitscreen; i++) + if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) { - if (player == &players[displayplayers[i]]) - { - thiscam = &camera[i]; - R_SetViewContext(VIEWCONTEXT_SKY1 + i); - break; - } + thiscam = &camera[i]; + R_SetViewContext(VIEWCONTEXT_SKY1 + i); + break; } } - else - { - R_SetViewContext(VIEWCONTEXT_SKY1); - } // cut-away view stuff newview->sky = true; @@ -1298,7 +1291,7 @@ void R_SetupFrame(player_t *player, boolean skybox) for (UINT8 i = 0; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) + if (player == (i == 0 ? &players[consoleplayer] : &players[displayplayers[i]])) { thiscam = &camera[i]; chasecam = cv_chasecam[i].value; From d640ce06d76bfaa99a2ccca8f2066e39e4c102fb Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 22:20:56 +0200 Subject: [PATCH 05/12] fix cam stuff for good + huge cleanup --- src/d_main.c | 4 +- src/hardware/hw_main.c | 6 +-- src/p_floor.c | 55 ++++++++++++-------------- src/p_tick.c | 4 +- src/p_user.c | 89 ++++++++++++++---------------------------- src/r_main.c | 44 +++++++-------------- src/r_main.h | 4 +- 7 files changed, 79 insertions(+), 127 deletions(-) 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); From 82f96dd080e85d138c33f82fa835241bc14d97a6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 22:39:26 +0200 Subject: [PATCH 06/12] remove unused/nonunsable analog cvars --- src/b_bot.c | 3 --- src/d_netcmd.c | 18 ------------------ src/g_game.c | 44 -------------------------------------------- src/g_game.h | 2 -- src/m_cheat.c | 2 +- src/p_user.c | 10 ++-------- 6 files changed, 3 insertions(+), 76 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index edaf477ad..67bb1be10 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -118,9 +118,6 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) return; } - // Bot AI isn't programmed in analog. - //CV_SetValue(&cv_analog2, false); - // Let Lua scripts build ticcmds if (LUAh_BotTiccmd(player, cmd)) return; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e3e57b29c..aa61f2159 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1129,16 +1129,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_joyscale3); CV_RegisterVar(&cv_joyscale4); - // Analog Control - /*CV_RegisterVar(&cv_analog); - CV_RegisterVar(&cv_analog2); - CV_RegisterVar(&cv_analog3); - CV_RegisterVar(&cv_analog4); - CV_RegisterVar(&cv_useranalog); - CV_RegisterVar(&cv_useranalog2); - CV_RegisterVar(&cv_useranalog3); - CV_RegisterVar(&cv_useranalog4);*/ - // s_sound.c CV_RegisterVar(&cv_soundvolume); CV_RegisterVar(&cv_digmusicvolume); @@ -2243,8 +2233,6 @@ void SendWeaponPref(void) buf[0] = 0; if (cv_flipcam[0].value) buf[0] |= 1; - if (cv_analog.value) - buf[0] |= 2; SendNetXCmd(XD_WEAPONPREF, buf, 1); } @@ -2255,8 +2243,6 @@ void SendWeaponPref2(void) buf[0] = 0; if (cv_flipcam[1].value) buf[0] |= 1; - if (cv_analog2.value) - buf[0] |= 2; SendNetXCmd2(XD_WEAPONPREF, buf, 1); } @@ -2267,8 +2253,6 @@ void SendWeaponPref3(void) buf[0] = 0; if (cv_flipcam[2].value) buf[0] |= 1; - if (cv_analog3.value) - buf[0] |= 2; SendNetXCmd3(XD_WEAPONPREF, buf, 1); } @@ -2279,8 +2263,6 @@ void SendWeaponPref4(void) buf[0] = 0; if (cv_flipcam[3].value) buf[0] |= 1; - if (cv_analog4.value) - buf[0] |= 2; SendNetXCmd4(XD_WEAPONPREF, buf, 1); } diff --git a/src/g_game.c b/src/g_game.c index ddfa43063..27e6fb449 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -357,10 +357,6 @@ consvar_t cv_demochangemap = {"netdemo_savemapchange", "Disabled", CV_SAVE, demo static UINT8 *savebuffer; // Analog Control -static void Analog_OnChange(void); -static void Analog2_OnChange(void); -static void Analog3_OnChange(void); -static void Analog4_OnChange(void); void SendWeaponPref(void); void SendWeaponPref2(void); void SendWeaponPref3(void); @@ -438,14 +434,6 @@ consvar_t cv_chasefreelook = {"chasemlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, N consvar_t cv_chasefreelook2 = {"chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mousemove2 = {"mousemove2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};*/ -consvar_t cv_analog = {"analog", "Off", CV_CALL, CV_OnOff, Analog_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_analog2 = {"analog2", "Off", CV_CALL, CV_OnOff, Analog2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_analog3 = {"analog3", "Off", CV_CALL, CV_OnOff, Analog3_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_analog4 = {"analog4", "Off", CV_CALL, CV_OnOff, Analog4_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_useranalog = {"useranalog", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_useranalog2 = {"useranalog2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_useranalog3 = {"useranalog3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_useranalog4 = {"useranalog4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnaxis = {"joyaxis_turn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_moveaxis = {"joyaxis_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1496,38 +1484,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } -static void Analog_OnChange(void) -{ - if (!cv_cam_dist[0].string) - return; - - SendWeaponPref(); -} - -static void Analog2_OnChange(void) -{ - if (!splitscreen || !cv_cam_dist[1].string) - return; - - SendWeaponPref2(); -} - -static void Analog3_OnChange(void) -{ - if (splitscreen < 2 || !cv_cam_dist[2].string) - return; - - SendWeaponPref3(); -} - -static void Analog4_OnChange(void) -{ - if (splitscreen < 3 || !cv_cam_dist[3].string) - return; - - SendWeaponPref4(); -} - // // G_DoLoadLevel // diff --git a/src/g_game.h b/src/g_game.h index aaafa233c..e66213815 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -120,8 +120,6 @@ extern consvar_t cv_pauseifunfocused; //extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4; extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove*/; extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/; -extern consvar_t cv_useranalog, cv_useranalog2, cv_useranalog3, cv_useranalog4; -extern consvar_t cv_analog, cv_analog2, cv_analog3, cv_analog4; extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis,cv_lookbackaxis,cv_custom1axis,cv_custom2axis,cv_custom3axis,cv_xdeadzone,cv_ydeadzone; extern consvar_t cv_turnaxis2,cv_moveaxis2,cv_brakeaxis2,cv_aimaxis2,cv_lookaxis2,cv_fireaxis2,cv_driftaxis2,cv_lookbackaxis2,cv_custom1axis2,cv_custom2axis2,cv_custom3axis2,cv_xdeadzone2,cv_ydeadzone2; extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis3,cv_fireaxis3,cv_driftaxis3,cv_lookbackaxis3,cv_custom1axis3,cv_custom2axis3,cv_custom3axis3,cv_xdeadzone3,cv_ydeadzone3; diff --git a/src/m_cheat.c b/src/m_cheat.c index abada4be5..5f8648cbd 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1091,7 +1091,7 @@ void OP_ObjectplaceMovement(player_t *player) { ticcmd_t *cmd = &player->cmd; - if (!player->climbing && (netgame || !cv_analog.value || (player->pflags & PF_SPINNING))) + if (!player->climbing && (netgame || (player->pflags & PF_SPINNING))) player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); ticruned++; diff --git a/src/p_user.c b/src/p_user.c index e3524235c..217320642 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3391,14 +3391,8 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->z = z; thiscam->reset = true; - if (!(thiscam == &camera[0] && (cv_cam_still[0].value || cv_analog.value)) - && !(thiscam == &camera[1] && (cv_cam_still[1].value || cv_analog2.value)) - && !(thiscam == &camera[2] && (cv_cam_still[2].value || cv_analog3.value)) - && !(thiscam == &camera[3] && (cv_cam_still[3].value || cv_analog4.value))) - { - thiscam->angle = player->mo->angle; - thiscam->aiming = 0; - } + thiscam->angle = player->mo->angle; + thiscam->aiming = 0; thiscam->relativex = 0; thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y); From b3750f78ff2e9f8dae0c329e6e5cc14b9a4c0668 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 23:07:32 +0200 Subject: [PATCH 07/12] only do this in software renderer doesent work even with pal rendering in ogl --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 3d0aeeb7a..9cff44a4e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -568,7 +568,7 @@ static boolean D_Display(void) V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - SHORT(patch->width))/2, py, V_SNAPTOTOP, patch); } - if (demo.rewinding) + if (rendermode == render_soft && demo.rewinding) V_DrawFadeScreen(TC_RAINBOW, (leveltime & 0x20) ? SKINCOLOR_PASTEL : SKINCOLOR_MOONSLAM); // vid size change is now finished if it was on... From 0d6faed3d5e0fe1a718d013492ae198cf0ba2734 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 23:13:14 +0200 Subject: [PATCH 08/12] lol --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 217320642..558530a90 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3510,7 +3510,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall return true; camspeed = cv_cam_speed[num].value; - camstill = cv_cam_still[num].value; // RR: seasaws lock the camera so that it isn't disorienting. + camstill = cv_cam_still[num].value; camrotate = cv_cam_rotate[num].value; camdist = FixedMul(cv_cam_dist[num].value, mapobjectscale); camheight = FixedMul(cv_cam_height[num].value, mapobjectscale); From d1b023c8c853a0b835e6f11d09eafd569e691782 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 23:25:38 +0200 Subject: [PATCH 09/12] whoops forgor --- src/p_user.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 558530a90..b98f925d3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3407,7 +3407,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { static boolean lookbackactive[MAXSPLITSCREENPLAYERS]; static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS]; - UINT8 i, num; + UINT8 num; angle_t angle = 0, focusangle = 0, focusaiming = 0; fixed_t x, y, z, dist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight; fixed_t pan, xpan, ypan; @@ -3514,7 +3514,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall 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]; + lookback = camspin[num]; if (timeover) { @@ -3944,7 +3944,6 @@ boolean P_SpectatorJoinGame(player_t *player) { if (P_IsLocalPlayer(player)) CONS_Printf(M_GetText("Server does not allow team change.\n")); - //player->powers[pw_flashing] = TICRATE + 1; //to prevent message spam. } // Team changing in Team Match and CTF // Pressing fire assigns you to a team that needs players if allowed. @@ -4871,7 +4870,6 @@ void P_PlayerAfterThink(player_t *player) if (player->pflags & PF_NIGHTSMODE) { player->powers[pw_gravityboots] = 0; - //player->mo->eflags &= ~MFE_VERTICALFLIP; } if (player->pflags & PF_SLIDING) From 9a9aa756841d5bc23516b273277195a942e14e9d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 13 Oct 2024 21:33:17 +0200 Subject: [PATCH 10/12] forgor about shadows lol --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index eee9abea5..15dca48f4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3460,13 +3460,13 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch) // Set direction if (splitscreen && stplyr == &players[displayplayers[1]]) - shadowdir = localangle[1] + FixedAngle(cv_cam2_rotate.value); + shadowdir = localangle[1] + FixedAngle(cv_cam_rotate[1].value); else if (splitscreen > 1 && stplyr == &players[displayplayers[2]]) - shadowdir = localangle[2] + FixedAngle(cv_cam3_rotate.value); + shadowdir = localangle[2] + FixedAngle(cv_cam_rotate[2].value); else if (splitscreen > 2 && stplyr == &players[displayplayers[3]]) - shadowdir = localangle[3] + FixedAngle(cv_cam4_rotate.value); + shadowdir = localangle[3] + FixedAngle(cv_cam_rotate[3].value); else - shadowdir = localangle[0] + FixedAngle(cv_cam_rotate.value); + shadowdir = localangle[0] + FixedAngle(cv_cam_rotate[0].value); // Find floorheight floorheight = HWR_OpaqueFloorAtPos( From 991f1b17dde0b7a5af5233dadd843c7b0e47d557 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 14 Oct 2024 19:20:19 +0200 Subject: [PATCH 11/12] spec cam needs mo angle and aiming atleast now ik why it checks for consoleplayer Zzz... --- src/p_user.c | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index b98f925d3..efb55e0d1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3407,7 +3407,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { static boolean lookbackactive[MAXSPLITSCREENPLAYERS]; static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS]; - UINT8 num; + UINT8 num, plyrnum; angle_t angle = 0, focusangle = 0, focusaiming = 0; fixed_t x, y, z, dist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight; fixed_t pan, xpan, ypan; @@ -3431,6 +3431,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; + if (demo.freecam) + { + P_DemoCameraMovement(thiscam); + return true; + } + if (thiscam == &camera[1]) // Camera 2 { num = 1; @@ -3448,10 +3454,25 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } - if (demo.freecam) + if (player == &players[consoleplayer]) { - P_DemoCameraMovement(thiscam); - return true; + plyrnum = 0; + } + else if (player == &players[displayplayers[1]]) + { + plyrnum = 1; + } + else if (player == &players[displayplayers[2]]) + { + plyrnum = 2; + } + else if (player == &players[displayplayers[3]]) + { + plyrnum = 3; + } + else + { + plyrnum = 255; } mo = player->mo; @@ -3478,7 +3499,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (!thiscam->chase && !resetcalled) { - focusangle = localangle[num]; + if (plyrnum != 255) + { + focusangle = localangle[plyrnum]; + } + else + { + focusangle = mo->angle; + } + camrotate = cv_cam_rotate[num].value; if (leveltime < introtime) // Whoooshy camera! @@ -3500,10 +3529,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusangle = mo->angle; focusaiming = 0; } + else if (plyrnum != 255) + { + focusangle = localangle[plyrnum]; + focusaiming = localaiming[plyrnum]; + } else { - focusangle = localangle[num]; - focusaiming = localaiming[num]; + focusangle = mo->angle; + focusaiming = player->aiming; } if (P_CameraThinker(player, thiscam, resetcalled)) From eb40eec4c101a22f0a5835ec0c12d6865fc6c54c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 16 Oct 2024 11:22:08 +0200 Subject: [PATCH 12/12] clean up cvar register a bit --- src/r_main.c | 57 ++++++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index db49694b2..173601e6c 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1626,15 +1626,18 @@ void R_RenderPlayerView(player_t *player) void R_RegisterEngineStuff(void) { + INT32 i; + CV_RegisterVar(&cv_gravity); CV_RegisterVar(&cv_tailspickup); CV_RegisterVar(&cv_soniccd); CV_RegisterVar(&cv_allowmlook); CV_RegisterVar(&cv_homremoval); - CV_RegisterVar(&cv_flipcam[0]); - CV_RegisterVar(&cv_flipcam[1]); - CV_RegisterVar(&cv_flipcam[2]); - CV_RegisterVar(&cv_flipcam[3]); + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + CV_RegisterVar(&cv_flipcam[i]); + } // Enough for dedicated server if (dedicated) @@ -1647,45 +1650,25 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_mobjscaleprecip); CV_RegisterVar(&cv_fov); - CV_RegisterVar(&cv_chasecam[0]); - CV_RegisterVar(&cv_chasecam[1]); - CV_RegisterVar(&cv_chasecam[2]); - CV_RegisterVar(&cv_chasecam[3]); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + CV_RegisterVar(&cv_chasecam[i]); + } CV_RegisterVar(&cv_shadow); CV_RegisterVar(&cv_shadowoffs); CV_RegisterVar(&cv_skybox); CV_RegisterVar(&cv_ffloorclip); CV_RegisterVar(&cv_spriteclip); - CV_RegisterVar(&cv_cam_dist[0]); - CV_RegisterVar(&cv_cam_dist[1]); - CV_RegisterVar(&cv_cam_dist[2]); - CV_RegisterVar(&cv_cam_dist[3]); - - CV_RegisterVar(&cv_cam_still[0]); - CV_RegisterVar(&cv_cam_still[1]); - CV_RegisterVar(&cv_cam_still[2]); - CV_RegisterVar(&cv_cam_still[3]); - - CV_RegisterVar(&cv_cam_height[0]); - CV_RegisterVar(&cv_cam_height[1]); - CV_RegisterVar(&cv_cam_height[2]); - CV_RegisterVar(&cv_cam_height[3]); - - CV_RegisterVar(&cv_cam_speed[0]); - CV_RegisterVar(&cv_cam_speed[1]); - CV_RegisterVar(&cv_cam_speed[2]); - CV_RegisterVar(&cv_cam_speed[3]); - - CV_RegisterVar(&cv_cam_rotate[0]); - CV_RegisterVar(&cv_cam_rotate[1]); - CV_RegisterVar(&cv_cam_rotate[2]); - CV_RegisterVar(&cv_cam_rotate[3]); - - CV_RegisterVar(&cv_cam_rotspeed[0]); - CV_RegisterVar(&cv_cam_rotspeed[1]); - CV_RegisterVar(&cv_cam_rotspeed[2]); - CV_RegisterVar(&cv_cam_rotspeed[3]); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + CV_RegisterVar(&cv_cam_dist[i]); + CV_RegisterVar(&cv_cam_still[i]); + CV_RegisterVar(&cv_cam_height[i]); + CV_RegisterVar(&cv_cam_speed[i]); + CV_RegisterVar(&cv_cam_rotate[i]); + CV_RegisterVar(&cv_cam_rotspeed[i]); + } CV_RegisterVar(&cv_tilting); CV_RegisterVar(&cv_quaketilt);