From 378382f3ad5a34f760d1cc0234ba4d625099b6db Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 23:34:09 +0100 Subject: [PATCH 01/76] use demo freecam for spec its more versataile and lets you pass through walls and floors just like in replays --- src/d_clisrv.c | 5 ++ src/d_clisrv.h | 2 + src/g_game.c | 1 - src/m_menu.c | 15 +----- src/p_local.h | 10 ++-- src/p_mobj.c | 24 +++++++--- src/p_setup.c | 2 + src/p_tick.c | 4 +- src/p_user.c | 128 ++++++++++++++++++++++++++++++++++++++----------- src/r_main.c | 13 +++-- src/s_sound.c | 25 ++++------ 11 files changed, 155 insertions(+), 74 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4820515ca..178309b80 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -467,6 +467,11 @@ void D_ResetTiccmds(void) D_Clearticcmd(textcmds[i]->tic); } +ticcmd_t *D_LocalTiccmd(UINT8 ss) +{ + return &localcmds[ss]; +} + // ----------------------------------------------------------------- // end of extra data function // ----------------------------------------------------------------- diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 4e81621d9..94c7c6827 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -645,7 +645,9 @@ extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; INT32 D_NumPlayers(void); + void D_ResetTiccmds(void); +ticcmd_t *D_LocalTiccmd(UINT8 ss); tic_t GetLag(INT32 node); //UINT8 GetFreeXCmdSize(UINT8 playerid); diff --git a/src/g_game.c b/src/g_game.c index 6c45c99a4..dadcee0e2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -7854,7 +7854,6 @@ void G_StopDemo(void) demo.freecam = false; // reset democam shit too: democam.cam = NULL; - democam.soundmobj = NULL; democam.localangle = 0; democam.localaiming = 0; democam.turnheld = false; diff --git a/src/m_menu.c b/src/m_menu.c index a4121d448..cf34db301 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7712,20 +7712,7 @@ static void M_PlaybackToggleFreecam(INT32 choice) splitscreen = 0; R_ExecuteSetViewSize(); - P_InitCameraCmd(); // init camera controls - 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; - democam.turnheld = false; - democam.keyboardlook = false; // reset only these. localangle / aiming gets set before the cam does anything anyway - } + P_ToggleDemoCamera(); } diff --git a/src/p_local.h b/src/p_local.h index ea0bff603..63dbed216 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -81,6 +81,10 @@ typedef struct camera_s boolean chase; angle_t aiming; + // Freecam: aiming needs to be reset after switching from chasecam + boolean reset_aiming; + + // Things used by FS cameras. fixed_t viewheight; angle_t startangle; @@ -114,14 +118,14 @@ typedef struct camera_s // demo freecam or something before i commit die 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 boolean keyboardlook; // keyboard look + + UINT8 button_a_held; // A button was held since entering from menu, so don't move camera }; extern struct demofreecam_s democam; @@ -153,7 +157,7 @@ void P_SlideCameraMove(camera_t *thiscam); void P_DemoCameraMovement(camera_t *cam); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); -void P_InitCameraCmd(void); +void P_ToggleDemoCamera(void); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index 03e7e9f99..d68cf9dcc 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10755,6 +10755,15 @@ void P_SpawnPlayer(INT32 playernum) P_SetScale(karmahitbox, mobj->scale); } } + + // TODO: handle splitscreen + // Spectators can switch to freecam. This should be + // disabled when they enter the race, or when the level + // changes. + if (playernum == consoleplayer && !demo.playback) + { + demo.freecam = false; + } } void P_AfterPlayerSpawn(INT32 playernum) @@ -10797,15 +10806,18 @@ void P_AfterPlayerSpawn(INT32 playernum) SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle); - for (i = 0; i <= splitscreen; i++) + if (p->spectator == false) { - if (!camera[i].chase) - continue; + for (i = 0; i <= splitscreen; i++) + { + if (!camera[i].chase) + continue; - if (displayplayers[i] != playernum) - continue; + if (displayplayers[i] != playernum) + continue; - P_ResetCamera(p, &camera[i]); + P_ResetCamera(p, &camera[i]); + } } if (CheckForReverseGravity) diff --git a/src/p_setup.c b/src/p_setup.c index c0ca1d0a6..75143d6c3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2464,6 +2464,8 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS); cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } + + cam->chase = false; // tell camera to reset its position next tic } static void P_InitCamera(void) diff --git a/src/p_tick.c b/src/p_tick.c index 3b0cadde8..0784957f3 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -497,8 +497,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 3133ee49b..59b223e9a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1056,6 +1056,15 @@ boolean P_IsDisplayPlayer(const player_t *player) { UINT8 i; + // Freecam still techically has a player in + // displayplayers. But since the camera is detached, it + // would be weird if sounds were heard from that player's + // perspective. + if (demo.freecam) + { + return false; + } + for (i = 0; i <= splitscreen; i++) // DON'T skip P1 { if (player == &players[displayplayers[i]]) @@ -3129,16 +3138,9 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn -static ticcmd_t cameracmd; - struct demofreecam_s democam; // called by m_menu to reinit cam input every time it's toggled -void P_InitCameraCmd(void) -{ - memset(&cameracmd, 0, sizeof(ticcmd_t)); // initialize cmd -} - static ticcmd_t *P_CameraCmd(camera_t *cam) { INT32 laim, th, tspeed, forward, side, axis; //i @@ -3150,12 +3152,12 @@ static ticcmd_t *P_CameraCmd(camera_t *cam) INT32 player_invert; INT32 screen_invert; - ticcmd_t *cmd = &cameracmd; + ticcmd_t *cmd = D_LocalTiccmd(0); (void)cam; - if (!demo.playback) - return cmd; // empty cmd, no. + //if (!demo.playback) + //return cmd; // empty cmd, no. lang = democam.localangle; laim = democam.localaiming; @@ -3295,11 +3297,32 @@ static ticcmd_t *P_CameraCmd(camera_t *cam) return cmd; } +void P_ToggleDemoCamera(void) +{ + if (!demo.freecam) // toggle on + { + demo.freecam = true; + democam.button_a_held = 2; + camera[0].reset_aiming = true; + democam.cam = &camera[0]; // this is rather useful + } + else // toggle off + { + demo.freecam = false; + // reset democam vars: + democam.cam = NULL; + democam.turnheld = false; + democam.keyboardlook = false; // reset only these. localangle / aiming gets set before the cam does anything anyway + } +} + +#define intsign(n) \ + ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) + void P_DemoCameraMovement(camera_t *cam) { ticcmd_t *cmd; angle_t thrustangle; - mobj_t *awayviewmobj_hack; player_t *lastp; // update democam stuff with what we got here: @@ -3307,6 +3330,8 @@ void P_DemoCameraMovement(camera_t *cam) democam.localangle = cam->angle; democam.localaiming = cam->aiming; + boolean moving = false; + // first off we need to get button input cmd = P_CameraCmd(cam); @@ -3314,11 +3339,24 @@ void P_DemoCameraMovement(camera_t *cam) cam->angle = cmd->angleturn<<16; // camera movement: + if (!democam.button_a_held) + { + if (cmd->buttons & BT_ACCELERATE) + { + cam->z += 32*mapobjectscale; + moving = true; + } + else if (cmd->buttons & BT_BRAKE) + { + cam->z -= 32*mapobjectscale; + moving = true; + } + } - if (cmd->buttons & BT_ACCELERATE) - cam->z += 32*mapobjectscale; - else if (cmd->buttons & BT_BRAKE) - cam->z -= 32*mapobjectscale; + if (!(cmd->buttons & (BT_ACCELERATE | BT_DRIFT)) && democam.button_a_held) + { + democam.button_a_held--; + } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") if (cmd->buttons & BT_ATTACK) @@ -3326,35 +3364,64 @@ void P_DemoCameraMovement(camera_t *cam) 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); cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + + cam->reset_aiming = false; } + if (cmd->forwardmove != 0) + { + moving = true; + } + + // After switching to democam, the vertical angle of + // chasecam is inherited. This is intentional because it + // creates a smooth transition. However, moving + // forward/back will have a slope. So, as long as democam + // controls haven't been used to alter the vertical angle, + // slowly reset it to flat. + if ((cam->reset_aiming && moving) || ((cmd->buttons & BT_DRIFT) && !democam.button_a_held)) + { + INT32 aiming = cam->aiming; + INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); + + if (abs(smooth) < abs(aiming)) + { + cam->aiming -= smooth * intsign(aiming); + } + else + { + cam->aiming = 0; + cam->reset_aiming = false; // completely smoothed out + } + } + + G_ClipAimingPitch((INT32 *)&cam->aiming); + cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) { - thrustangle = cam->angle >> ANGLETOFINESHIFT; cam->x += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle)); cam->y += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle)); - cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming)); + + if (!cam->reset_aiming) + { + cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming)); + } + // momentums are useless here, directly add to the coordinates // this.......... doesn't actually check for floors and walls and whatnot but the function to do that is a pure mess so fuck that. // besides freecam going inside walls sounds pretty cool on paper. } - // awayviewmobj hack; this is to prevent us from hearing sounds from the player's perspective - - awayviewmobj_hack = P_SpawnMobj(cam->x, cam->y, cam->z, MT_THOK); - awayviewmobj_hack->tics = 2; - awayviewmobj_hack->flags2 |= MF2_DONTDRAW; - - democam.soundmobj = awayviewmobj_hack; - // update subsector to avoid crashes; cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); } +#undef intsign + void P_ResetCamera(player_t *player, camera_t *thiscam) { tic_t tries = 0; @@ -3399,6 +3466,9 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->radius = 20*FRACUNIT; thiscam->height = 16*FRACUNIT; + thiscam->reset_aiming = true; + + while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE); } @@ -3420,8 +3490,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall subsector_t *newsubsec; #endif - democam.soundmobj = NULL; // reset this each frame, we don't want the game crashing for stupid reasons now do we - // We probably shouldn't move the camera if there is no player or player mobj somehow if (!player || !player->mo) return true; @@ -3430,12 +3498,16 @@ 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; + + if (thiscam == &camera[1]) // Camera 2 { num = 1; diff --git a/src/r_main.c b/src/r_main.c index 9541fef41..a6caf8614 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1224,9 +1224,14 @@ void R_SetupFrame(int s, boolean skybox) thiscam->reset = false; } - if (player->spectator) // no spectator chasecam - chasecam = false; // force chasecam off - else if (player->playerstate == PST_DEAD || player->exiting) + if (player->spectator) + { + // Free flying spectator uses demo freecam. This + // requires chasecam to be enabled. + chasecam = true; + } + + if (player->playerstate == PST_DEAD || player->exiting) chasecam = true; // force chasecam on if (chasecam && (thiscam && !thiscam->chase)) @@ -1255,7 +1260,7 @@ void R_SetupFrame(int s, boolean skybox) R_SetupCommonFrame(player, subsector); } - else if (!player->spectator && (thiscam && chasecam)) // use outside cam view + else if (thiscam && chasecam) // use outside cam view { viewmobj = NULL; diff --git a/src/s_sound.c b/src/s_sound.c index c770957b6..fa56ab8ad 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -491,11 +491,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) memset(&listener[i], 0, sizeof (listener[i])); listenmobj[i] = NULL; - if (i == 0 && democam.soundmobj) - { - listenmobj[i] = democam.soundmobj; - } - else if (player->awayviewtics) + if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; } @@ -504,7 +500,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) listenmobj[i] = player->mo; } - if (origin && origin == listenmobj[i]) + if (origin && origin == listenmobj[i] && !demo.freecam) { itsUs = true; } @@ -775,12 +771,6 @@ void S_UpdateSounds(void) memset(&listener[i], 0, sizeof (listener[i])); listenmobj[i] = NULL; - if (i == 0 && democam.soundmobj) - { - listenmobj[i] = democam.soundmobj; - continue; - } - if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; @@ -843,12 +833,15 @@ void S_UpdateSounds(void) { boolean itsUs = false; - for (i = splitscreen; i >= 0; i--) + if (!demo.freecam) { - if (c->origin != listenmobj[i]) - continue; + for (i = splitscreen; i >= 0; i--) + { + if (c->origin != listenmobj[i]) + continue; - itsUs = true; + itsUs = true; + } } if (itsUs == false) From 6bb72c363f159397af8ab930123bcc5354e8680c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 23:37:23 +0100 Subject: [PATCH 02/76] fix freecam not being interpolated when ingame --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index a6caf8614..7bd9f8630 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1078,7 +1078,7 @@ R_SetupCommonFrame else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? (demo.freecam ? rendertimefrac_unpaused : rendertimefrac) : FRACUNIT, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) From 1922b32799dd3c2ff0ca61fef433bc4fa8a74248 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Dec 2024 23:55:19 +0100 Subject: [PATCH 03/76] add bindable freecam toggle --- src/g_game.c | 5 ++++ src/g_input.c | 1 + src/g_input.h | 1 + src/m_menu.c | 64 +++++++++++++++++++++++++++------------------------ 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index dadcee0e2..b5569fbe0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1554,6 +1554,11 @@ boolean G_Responder(event_t *ev) { K_ToggleDirector(); } + if (ev->data1 == gamecontrol[gc_freecam][0] + || ev->data1 == gamecontrol[gc_freecam][1]) + { + P_ToggleDemoCamera(); + } return true; diff --git a/src/g_input.c b/src/g_input.c index 7f2fff283..3e6e056f6 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -902,6 +902,7 @@ static const char *gamecontrolname[num_gamecontrols] = "custom2", "custom3", "director", + "freecam", }; #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) diff --git a/src/g_input.h b/src/g_input.h index 18fff51a4..76d3a50c7 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -100,6 +100,7 @@ typedef enum gc_custom2, // Lua scriptable gc_custom3, // Lua scriptable gc_director, + gc_freecam, // Toggle for freecam while ingame num_gamecontrols } gamecontrols_e; diff --git a/src/m_menu.c b/src/m_menu.c index cf34db301..57be0699d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1182,6 +1182,7 @@ static menuitem_t OP_AllControlsMenu[] = { {IT_SUBMENU|IT_STRING, NULL, "Gamepad Options...", &OP_Joystick1Def, 0}, {IT_CALL|IT_STRING, NULL, "Reset to defaults", M_ResetControls, 8}, + //{IT_SPACE, NULL, NULL, NULL, 0}, {IT_HEADER, NULL, "Gameplay Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, @@ -1194,26 +1195,33 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Aim Forward", M_ChangeControl, gc_aimforward }, {IT_CONTROL, NULL, "Aim Backward", M_ChangeControl, gc_aimbackward}, {IT_CONTROL, NULL, "Look Backward", M_ChangeControl, gc_lookback }, + {IT_HEADER, NULL, "Miscelleanous Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Chat", M_ChangeControl, gc_talkkey }, - //{IT_CONTROL, NULL, "Team Chat", M_ChangeControl, gc_teamkey }, + //{IT_CONTROL, NULL, "Team Chat", M_ChangeControl, gc_teamkey }, {IT_CONTROL, NULL, "Show Rankings", M_ChangeControl, gc_scores }, - {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, - {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, - {IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, {IT_CONTROL, NULL, "Pause", M_ChangeControl, gc_pause }, {IT_CONTROL, NULL, "Screenshot", M_ChangeControl, gc_screenshot }, {IT_CONTROL, NULL, "Toggle GIF Recording", M_ChangeControl, gc_recordgif }, {IT_CONTROL, NULL, "Open/Close Menu (ESC)", M_ChangeControl, gc_systemmenu }, {IT_CONTROL, NULL, "Developer Console", M_ChangeControl, gc_console }, - {IT_HEADER, NULL, "Spectator Controls", NULL, 0}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, - {IT_CONTROL, NULL, "Become Spectator", M_ChangeControl, gc_spectate }, + {IT_CONTROL, NULL, "Toggle Freecam", M_ChangeControl, gc_freecam }, {IT_CONTROL, NULL, "Look Up", M_ChangeControl, gc_lookup }, {IT_CONTROL, NULL, "Look Down", M_ChangeControl, gc_lookdown }, {IT_CONTROL, NULL, "Center View", M_ChangeControl, gc_centerview }, + {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, + {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, + //{IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, + + {IT_HEADER, NULL, "Spectator Controls", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, + {IT_CONTROL, NULL, "Become Spectator", M_ChangeControl, gc_spectate }, {IT_CONTROL, NULL, "Toggle Director", M_ChangeControl, gc_director }, + {IT_HEADER, NULL, "Custom Lua Actions", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Custom Action 1", M_ChangeControl, gc_custom1 }, @@ -12082,12 +12090,11 @@ static void M_Setup1PControlsMenu(INT32 choice) // Unhide P1-only controls OP_AllControlsMenu[15].status = IT_CONTROL; // Chat OP_AllControlsMenu[16].status = IT_CONTROL; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_CONTROL; // Pause - OP_AllControlsMenu[21].status = IT_CONTROL; // Screenshot - OP_AllControlsMenu[22].status = IT_CONTROL; // GIF - OP_AllControlsMenu[23].status = IT_CONTROL; // System Menu - OP_AllControlsMenu[24].status = IT_CONTROL; // Console + OP_AllControlsMenu[17].status = IT_CONTROL; // Pause + OP_AllControlsMenu[18].status = IT_CONTROL; // Screenshot + OP_AllControlsMenu[19].status = IT_CONTROL; // GIF + OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu + OP_AllControlsMenu[21].status = IT_CONTROL; // Console M_SetupNextMenu(&OP_AllControlsDef); } @@ -12105,12 +12112,11 @@ static void M_Setup2PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console M_SetupNextMenu(&OP_AllControlsDef); } @@ -12128,12 +12134,11 @@ static void M_Setup3PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console M_SetupNextMenu(&OP_AllControlsDef); } @@ -12151,12 +12156,11 @@ static void M_Setup4PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console M_SetupNextMenu(&OP_AllControlsDef); } From 45d33b951ccec52b038fa89e1dd083e7186c01db Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 00:04:49 +0100 Subject: [PATCH 04/76] add alternative cam float and sink buttons --- src/g_input.c | 2 ++ src/g_input.h | 2 ++ src/m_menu.c | 2 ++ src/p_user.c | 4 ++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 3e6e056f6..c948ed751 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -903,6 +903,8 @@ static const char *gamecontrolname[num_gamecontrols] = "custom3", "director", "freecam", + "camfloat", + "camsink", }; #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) diff --git a/src/g_input.h b/src/g_input.h index 76d3a50c7..1dbbb937f 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -101,6 +101,8 @@ typedef enum gc_custom3, // Lua scriptable gc_director, gc_freecam, // Toggle for freecam while ingame + gc_camfloat, // alternative button for raising cam + gc_camsink, // alternative button for sinking num_gamecontrols } gamecontrols_e; diff --git a/src/m_menu.c b/src/m_menu.c index 57be0699d..ac6fc90db 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1213,6 +1213,8 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Look Up", M_ChangeControl, gc_lookup }, {IT_CONTROL, NULL, "Look Down", M_ChangeControl, gc_lookdown }, {IT_CONTROL, NULL, "Center View", M_ChangeControl, gc_centerview }, + {IT_CONTROL, NULL, "Float", M_ChangeControl, gc_camfloat }, + {IT_CONTROL, NULL, "Sink", M_ChangeControl, gc_camsink }, {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, //{IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, diff --git a/src/p_user.c b/src/p_user.c index 59b223e9a..54f67eec8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3341,12 +3341,12 @@ void P_DemoCameraMovement(camera_t *cam) // camera movement: if (!democam.button_a_held) { - if (cmd->buttons & BT_ACCELERATE) + if (cmd->buttons & BT_ACCELERATE || PLAYER1INPUTDOWN(gc_camfloat)) { cam->z += 32*mapobjectscale; moving = true; } - else if (cmd->buttons & BT_BRAKE) + else if (cmd->buttons & BT_BRAKE || PLAYER1INPUTDOWN(gc_camsink)) { cam->z -= 32*mapobjectscale; moving = true; From 3381f6af3a4b3a99dca672bce8b9eb3f700485f6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 00:21:41 +0100 Subject: [PATCH 05/76] set default controls for float and sink ig --- src/g_input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/g_input.c b/src/g_input.c index c948ed751..606f20770 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1142,6 +1142,12 @@ void G_Controldefault(UINT8 player) //gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up + + gamecontrol[gc_camfloat ][1] = 'a'; + gamecontrol[gc_camsink ][1] = 'd'; + + gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A + gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B } if (player == 0 || player == 2) From 332f7db32f79c5b6d482b5d02dca9edd170e61b5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 01:38:08 +0100 Subject: [PATCH 06/76] make freecam work in splitscreen banish cameracmd shit --- src/d_netcmd.c | 2 +- src/g_game.c | 49 +++++---- src/k_kart.c | 25 ++--- src/m_menu.c | 6 +- src/p_local.h | 24 ++--- src/p_mobj.c | 7 +- src/p_user.c | 279 ++++++++++++------------------------------------- src/r_fps.h | 4 + src/r_main.c | 3 +- src/s_sound.c | 16 +-- src/st_stuff.c | 4 +- 11 files changed, 135 insertions(+), 284 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e49f6c17a..5e1927ff0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2301,7 +2301,7 @@ static void Command_View_f(void) return; } - if (demo.freecam) + if (camera[viewnum-1].freecam) return; displayplayerp = &displayplayers[viewnum-1]; diff --git a/src/g_game.c b/src/g_game.c index b5569fbe0..1be80c944 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1402,7 +1402,7 @@ boolean G_Responder(event_t *ev) } } - if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback && !demo.freecam) + if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback) { if (ev->data1 == gamecontrolbis[gc_viewpoint][0] || ev->data1 == gamecontrolbis[gc_viewpoint][1]) { @@ -1554,10 +1554,22 @@ boolean G_Responder(event_t *ev) { K_ToggleDirector(); } - if (ev->data1 == gamecontrol[gc_freecam][0] - || ev->data1 == gamecontrol[gc_freecam][1]) + + if (ev->data1 == gamecontrol[gc_freecam][0] || ev->data1 == gamecontrol[gc_freecam][1]) { - P_ToggleDemoCamera(); + P_ToggleDemoCamera(0); + } + else if (ev->data1 == gamecontrolbis[gc_freecam][0] || ev->data1 == gamecontrolbis[gc_freecam][1]) + { + P_ToggleDemoCamera(1); + } + else if (ev->data1 == gamecontrol3[gc_freecam][0] || ev->data1 == gamecontrol3[gc_freecam][1]) + { + P_ToggleDemoCamera(2); + } + else if (ev->data1 == gamecontrol4[gc_freecam][0] || ev->data1 == gamecontrol4[gc_freecam][1]) + { + P_ToggleDemoCamera(3); } return true; @@ -1740,13 +1752,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) viewnum = playersviewable; splitscreen = viewnum-1; - /* Prepare extra views for G_FindView to pass. */ - for (viewd = splits+1; viewd < viewnum; ++viewd) - { - displayplayerp = (&displayplayers[viewd-1]); - (*displayplayerp) = INT32_MAX; - } - R_ExecuteSetViewSize(); } @@ -5769,9 +5774,6 @@ void G_ConfirmRewind(tic_t rewindtime) COM_BufInsertText("renderview on\n"); - if (demo.freecam) - return; // don't touch from there - splitscreen = oldss; displayplayers[0] = olddp1; displayplayers[1] = olddp2; @@ -7154,15 +7156,14 @@ void G_DoPlayDemo(char *defdemoname) //LUA_HookInt(gamemap, HOOK(MapChange)); - displayplayers[0] = consoleplayer = 0; + consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); + memset(displayplayers,0,sizeof(displayplayers)); + memset(camera,0,sizeof(camera)); // reset freecam // Load players that were in-game when the map started p = READUINT8(demo_p); - for (i = 1; i < MAXSPLITSCREENPLAYERS; i++) - displayplayers[i] = INT32_MAX; - while (p != 0xFF) { spectator = false; @@ -7856,13 +7857,11 @@ void G_StopDemo(void) demo.timing = false; singletics = false; - demo.freecam = false; - // reset democam shit too: - democam.cam = NULL; - democam.localangle = 0; - democam.localaiming = 0; - democam.turnheld = false; - democam.keyboardlook = false; + UINT8 i; + for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) + { + camera[i].freecam = false; + } CV_SetValue(&cv_playbackspeed, 1); demo.rewinding = false; diff --git a/src/k_kart.c b/src/k_kart.c index a6aa76e4d..7a9f43f55 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1233,7 +1233,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) dontforcespb = true; // This makes the roulette produce the random noises. - if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player) && !demo.freecam) + if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player)) { #define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)) for (i = 0; i <= splitscreen; i++) @@ -1267,7 +1267,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) //player->kartstuff[k_itemblinkmode] = 1; player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_roulettetype] = 0; - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, sfx_itrole); return; } @@ -1280,7 +1280,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) player->kartstuff[k_itemblinkmode] = 2; player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_roulettetype] = 0; - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, sfx_dbgsal); return; } @@ -1312,7 +1312,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) player->kartstuff[k_itemamount] = 1; } - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, ((player->kartstuff[k_roulettetype] == 1) ? sfx_itrolk : (mashed ? sfx_itrolm : sfx_itrolf))); player->kartstuff[k_itemblink] = TICRATE; @@ -9311,7 +9311,7 @@ static void K_drawDriftGauge(void) 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (demo.playback && demo.freecam) + if (demo.playback && camera[R_GetViewNumber()].freecam) return; if (P_MobjWasRemoved(stplyr->mo) || (!splitscreen && !camera->chase)) @@ -10419,22 +10419,19 @@ void K_drawKartHUD(void) { boolean isfreeplay = false; boolean battlefullscreen = false; - boolean freecam = demo.freecam; //disable some hud elements w/ freecam - UINT8 i; + UINT8 viewnum = R_GetViewNumber(); + boolean freecam = camera[viewnum].freecam; //disable some hud elements w/ freecam // Define the X and Y for each drawn object // This is handled by console/menu values K_initKartHUD(); // Draw that fun first person HUD! Drawn ASAP so it looks more "real". - for (i = 0; i <= splitscreen; i++) - { - if (stplyr == &players[displayplayers[i]] && !camera[i].chase && !freecam) - K_drawKartFirstPerson(); - } + if (!camera[viewnum].chase && !freecam) + K_drawKartFirstPerson(); // Draw full screen stuff that turns off the rest of the HUD - if (mapreset && stplyr == &players[displayplayers[0]]) + if (mapreset && R_GetViewNumber() == 0) { K_drawChallengerScreen(); return; @@ -10527,7 +10524,7 @@ void K_drawKartHUD(void) } } - if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode + if (!stplyr->spectator && !freecam) // Bottom of the screen elements, don't need in spectate mode { if (!(splitscreen || demo.title)) { diff --git a/src/m_menu.c b/src/m_menu.c index ac6fc90db..0bfacba82 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7722,7 +7722,11 @@ static void M_PlaybackToggleFreecam(INT32 choice) splitscreen = 0; R_ExecuteSetViewSize(); - P_ToggleDemoCamera(); + UINT8 i; + for (i = 0; i <= splitscreen; ++i) + { + P_ToggleDemoCamera(i); + } } diff --git a/src/p_local.h b/src/p_local.h index 63dbed216..368779983 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -79,12 +79,16 @@ void P_UnlinkThinker(thinker_t *thinker); typedef struct camera_s { boolean chase; + boolean freecam; + angle_t aiming; + // Freecam: A button was held since entering from menu, so don't move camera + UINT8 button_a_held; + // Freecam: aiming needs to be reset after switching from chasecam boolean reset_aiming; - // Things used by FS cameras. fixed_t viewheight; angle_t startangle; @@ -116,20 +120,6 @@ typedef struct camera_s fixed_t pan; } camera_t; -// demo freecam or something before i commit die -struct demofreecam_s { - camera_t *cam; // this is useful when the game is paused, notably - - 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 - boolean keyboardlook; // keyboard look - - UINT8 button_a_held; // A button was held since entering from menu, so don't move camera -}; - -extern struct demofreecam_s democam; - extern camera_t camera[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS]; @@ -154,10 +144,10 @@ void P_AddPlayerScore(player_t *player, UINT32 amount); void P_ResetCamera(player_t *player, camera_t *thiscam); boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam); void P_SlideCameraMove(camera_t *thiscam); -void P_DemoCameraMovement(camera_t *cam); +void P_DemoCameraMovement(camera_t *cam, UINT8 num); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); -void P_ToggleDemoCamera(void); +void P_ToggleDemoCamera(UINT8 viewnum); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index d68cf9dcc..bdf6b1a93 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10760,9 +10760,12 @@ void P_SpawnPlayer(INT32 playernum) // Spectators can switch to freecam. This should be // disabled when they enter the race, or when the level // changes. - if (playernum == consoleplayer && !demo.playback) + if (!demo.playback) { - demo.freecam = false; + if (!p->spectator) + { + camera[playernum].freecam = false; + } } } diff --git a/src/p_user.c b/src/p_user.c index 54f67eec8..b562ca33c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1056,17 +1056,17 @@ boolean P_IsDisplayPlayer(const player_t *player) { UINT8 i; - // Freecam still techically has a player in - // displayplayers. But since the camera is detached, it - // would be weird if sounds were heard from that player's - // perspective. - if (demo.freecam) - { - return false; - } - for (i = 0; i <= splitscreen; i++) // DON'T skip P1 { + if (camera[i].freecam) + { + // Freecam still techically has a player in + // displayplayers. But since the camera is + // detached, it would be weird if sounds were + // heard from that player's perspective. + continue; + } + if (player == &players[displayplayers[i]]) return true; } @@ -3130,232 +3130,69 @@ 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) -// Heavily simplified version of G_BuildTicCmd that only takes the local first player's control input and converts it to readable ticcmd_t -// we then throw that ticcmd garbage in the camera and make it move - -// redefine this -static fixed_t forwardmove[2] = {25<>16, 50<>16}; -static fixed_t sidemove[2] = {2<>16, 4<>16}; -static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn - -struct demofreecam_s democam; - -// called by m_menu to reinit cam input every time it's toggled -static ticcmd_t *P_CameraCmd(camera_t *cam) +void P_ToggleDemoCamera(UINT8 viewnum) { - INT32 laim, th, tspeed, forward, side, axis; //i - const INT32 speed = 1; - // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming; - boolean invertmouse, lookaxis, usejoystick, kbl; - angle_t lang; - INT32 player_invert; - INT32 screen_invert; + camera_t *cam = &camera[viewnum]; - ticcmd_t *cmd = D_LocalTiccmd(0); - - (void)cam; - - //if (!demo.playback) - //return cmd; // empty cmd, no. - - lang = democam.localangle; - laim = democam.localaiming; - th = democam.turnheld; - kbl = democam.keyboardlook; - - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - - cmd->angleturn = (INT16)(lang >> 16); - cmd->aiming = G_ClipAimingPitch(&laim); - - mouseaiming = true; - invertmouse = cv_invertmouse.value; - lookaxis = cv_lookaxis[0].value; - - usejoystick = true; - turnright = InputDown(gc_turnright, 1); - turnleft = InputDown(gc_turnleft, 1); - - axis = JoyAxis(AXISTURN, 1); - - if (encoremode) + if (!cam->freecam) // toggle on { - turnright ^= turnleft; // swap these using three XORs - turnleft ^= turnright; - turnright ^= turnleft; - axis = -axis; - } - - if (axis != 0) - { - turnright = turnright || (axis > 0); - turnleft = turnleft || (axis < 0); - } - forward = side = 0; - - // use two stage accelerative turning - // on the keyboard and joystick - if (turnleft || turnright) - th += 1; - else - th = 0; - - if (th < SLOWTURNTICS) - tspeed = 2; // slow turn - else - tspeed = speed; - - // let movement keys cancel each other out - if (turnright && !(turnleft)) - { - cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); - side += sidemove[1]; - } - else if (turnleft && !(turnright)) - { - cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); - side -= sidemove[1]; - } - - cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); - - axis = JoyAxis(AXISMOVE, 1); - if (InputDown(gc_accelerate, 1) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ACCELERATE; - axis = JoyAxis(AXISBRAKE, 1); - if (InputDown(gc_brake, 1) || (usejoystick && axis > 0)) - cmd->buttons |= BT_BRAKE; - axis = JoyAxis(AXISAIM, 1); - if (InputDown(gc_aimforward, 1) || (usejoystick && axis < 0)) - forward += forwardmove[1]; - if (InputDown(gc_aimbackward, 1) || (usejoystick && axis > 0)) - forward -= forwardmove[1]; - - // fire with any button/key - axis = JoyAxis(AXISFIRE, 1); - if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ATTACK; - - // spectator aiming shit, ahhhh... - player_invert = invertmouse ? -1 : 1; - screen_invert = 1; // nope - - // mouse look stuff (mouse look is not the same as mouse aim) - kbl = false; - - // looking up/down - laim += (mlooky<<19)*player_invert*screen_invert; - - axis = JoyAxis(AXISLOOK, 1); - - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis && !mouseaiming) - laim = 0; - - if (InputDown(gc_lookup, 1) || (axis < 0)) - { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; - } - else if (InputDown(gc_lookdown, 1) || (axis > 0)) - { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; - } - - if (InputDown(gc_centerview, 1)) // No need to put a spectator limit on this one though :V - laim = 0; - - cmd->aiming = G_ClipAimingPitch(&laim); - - mousex = mousey = mlooky = 0; - - if (forward > MAXPLMOVE) - forward = MAXPLMOVE; - else if (forward < -MAXPLMOVE) - forward = -MAXPLMOVE; - - if (side > MAXPLMOVE) - side = MAXPLMOVE; - else if (side < -MAXPLMOVE) - side = -MAXPLMOVE; - - if (forward || side) - { - cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); - cmd->sidemove = (SINT8)(cmd->sidemove + side); - } - - lang += (cmd->angleturn<<16); - - democam.localangle = lang; - democam.localaiming = laim; - democam.turnheld = th; - democam.keyboardlook = kbl; - - return cmd; -} - -void P_ToggleDemoCamera(void) -{ - if (!demo.freecam) // toggle on - { - demo.freecam = true; - democam.button_a_held = 2; - camera[0].reset_aiming = true; - democam.cam = &camera[0]; // this is rather useful + cam->freecam = true; + cam->button_a_held = 2; + cam->reset_aiming = true; } else // toggle off { - demo.freecam = false; - // reset democam vars: - democam.cam = NULL; - democam.turnheld = false; - democam.keyboardlook = false; // reset only these. localangle / aiming gets set before the cam does anything anyway + cam->freecam = false; } } #define intsign(n) \ ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) -void P_DemoCameraMovement(camera_t *cam) +void P_DemoCameraMovement(camera_t *cam, UINT8 num) { ticcmd_t *cmd; angle_t thrustangle; player_t *lastp; - - // update democam stuff with what we got here: - democam.cam = cam; - democam.localangle = cam->angle; - democam.localaiming = cam->aiming; + angle_t turning; boolean moving = false; // first off we need to get button input - cmd = P_CameraCmd(cam); + cmd = D_LocalTiccmd(num); - cam->aiming = cmd->aiming<angle = cmd->angleturn<<16; + if (cmd->aiming != 0) + { + cam->aiming = cmd->aiming << FRACBITS; + + cam->reset_aiming = false; + } + + turning = cmd->angleturn << 16; + if (encoremode) + { + turning = -turning; + } + cam->angle = turning; // camera movement: - if (!democam.button_a_held) + if (!cam->button_a_held) { - if (cmd->buttons & BT_ACCELERATE || PLAYER1INPUTDOWN(gc_camfloat)) + if (InputDown(gc_camfloat, num+1)) { cam->z += 32*mapobjectscale; moving = true; } - else if (cmd->buttons & BT_BRAKE || PLAYER1INPUTDOWN(gc_camsink)) + else if (InputDown(gc_camsink, num+1)) { cam->z -= 32*mapobjectscale; moving = true; } } - if (!(cmd->buttons & (BT_ACCELERATE | BT_DRIFT)) && democam.button_a_held) + if (!(InputDown(gc_camfloat, num+1) || InputDown(gc_camsink, num+1)) && cam->button_a_held) { - democam.button_a_held--; + cam->button_a_held--; } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") @@ -3379,7 +3216,7 @@ void P_DemoCameraMovement(camera_t *cam) // forward/back will have a slope. So, as long as democam // controls haven't been used to alter the vertical angle, // slowly reset it to flat. - if ((cam->reset_aiming && moving) || ((cmd->buttons & BT_DRIFT) && !democam.button_a_held)) + if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, num+1)) && !cam->button_a_held)) { INT32 aiming = cam->aiming; INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); @@ -3395,7 +3232,23 @@ void P_DemoCameraMovement(camera_t *cam) } } - G_ClipAimingPitch((INT32 *)&cam->aiming); + if (rendermode == render_soft +#ifdef HWRENDER + || (rendermode == render_opengl && (cv_glshearing.value == 1)) +#endif + ) + { + // Extra restriction on this so it's not possible to + // distort the view too much. + if ((INT32)cam->aiming > ANGLE_45) + cam->aiming = ANGLE_45; + else if ((INT32)cam->aiming < -ANGLE_45) + cam->aiming = -ANGLE_45; + } + else + { + G_ClipAimingPitch((INT32 *)&cam->aiming); + } cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) @@ -3427,7 +3280,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) tic_t tries = 0; fixed_t x, y, z; - if (demo.freecam) + if (thiscam->freecam) return; // do not reset the camera there. if (!player->mo) @@ -3468,7 +3321,6 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->reset_aiming = true; - while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE); } @@ -3498,16 +3350,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; - if (demo.freecam || player->spectator) - { - P_DemoCameraMovement(thiscam); - return true; - } - - if (paused || P_AutoPause()) - return true; - - if (thiscam == &camera[1]) // Camera 2 { num = 1; @@ -3525,6 +3367,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } + if (thiscam->freecam || player->spectator) + { + P_DemoCameraMovement(thiscam, num); + return true; + } + + if (paused || P_AutoPause()) + return true; + if (player == &players[consoleplayer]) { plyrnum = 0; diff --git a/src/r_fps.h b/src/r_fps.h index 5ac6cfe90..563989fa6 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -37,6 +37,10 @@ enum viewcontext_e VIEWCONTEXT_SKY4 }; +extern enum viewcontext_e viewcontext; + +#define R_GetViewNumber() ((viewcontext - VIEWCONTEXT_PLAYER1) & 3) + typedef struct { fixed_t x; fixed_t y; diff --git a/src/r_main.c b/src/r_main.c index 7bd9f8630..79950a458 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -841,6 +841,7 @@ static inline int intsign(int n) { angle_t R_ViewRollAngle(const player_t *player) { angle_t roll = 0; + const UINT8 viewnum = R_GetViewNumber(); if (gamestate != GS_LEVEL) { @@ -859,7 +860,7 @@ angle_t R_ViewRollAngle(const player_t *player) if (cv_tilting.value) { - if (!player->spectator && !demo.freecam) + if (!player->spectator && !camera[viewnum].freecam) roll += player->tilt; if (cv_actionmovie.value) diff --git a/src/s_sound.c b/src/s_sound.c index fa56ab8ad..9a7dd5542 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -500,7 +500,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) listenmobj[i] = player->mo; } - if (origin && origin == listenmobj[i] && !demo.freecam) + if (origin && origin == listenmobj[i] && !camera[i].freecam) { itsUs = true; } @@ -833,15 +833,15 @@ void S_UpdateSounds(void) { boolean itsUs = false; - if (!demo.freecam) + for (i = splitscreen; i >= 0; i--) { - for (i = splitscreen; i >= 0; i--) - { - if (c->origin != listenmobj[i]) - continue; + if (camera[i].freecam) + continue; - itsUs = true; - } + if (c->origin != listenmobj[i]) + continue; + + itsUs = true; } if (itsUs == false) diff --git a/src/st_stuff.c b/src/st_stuff.c index 30b8b5cf7..398dc7dbe 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -657,6 +657,8 @@ static void ST_drawLevelTitle(void) // static void ST_overlayDrawer(void) { + const UINT8 viewnum = R_GetViewNumber(); + //hu_showscores = auto hide score/time/rings when tab rankings are shown if (!(hu_showscores && (netgame || multiplayer))) { @@ -665,7 +667,7 @@ static void ST_overlayDrawer(void) if (!hu_showscores) // hide the following if TAB is held { - if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !demo.freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) + if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !camera[viewnum].freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) { char directortext[20] = {0}; From 2c769f804341960feff6663d37758e9da2de44ec Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 01:41:49 +0100 Subject: [PATCH 07/76] changable freecam speed --- src/p_local.h | 2 ++ src/p_user.c | 17 ++++++++++++----- src/r_main.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 368779983..b45cebdc2 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -128,6 +128,8 @@ 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_freecam_speed; + extern consvar_t cv_tilting; extern consvar_t cv_quaketilt; extern consvar_t cv_tiltsmoothing; diff --git a/src/p_user.c b/src/p_user.c index b562ca33c..9484197ef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3117,6 +3117,9 @@ consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS] = { {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; +static CV_PossibleValue_t freecam_speed_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; +consvar_t cv_freecam_speed = {"freecam_speed", "1", CV_SAVE, freecam_speed_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}; consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3178,14 +3181,16 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num) // camera movement: if (!cam->button_a_held) { + fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; + if (InputDown(gc_camfloat, num+1)) { - cam->z += 32*mapobjectscale; + cam->z += spd; moving = true; } else if (InputDown(gc_camsink, num+1)) { - cam->z -= 32*mapobjectscale; + cam->z -= spd; moving = true; } } @@ -3253,14 +3258,16 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) { + fixed_t spd = cmd->forwardmove*mapobjectscale*cv_freecam_speed.value; + thrustangle = cam->angle >> ANGLETOFINESHIFT; - cam->x += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle)); - cam->y += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle)); + cam->x += FixedMul(spd, FINECOSINE(thrustangle)); + cam->y += FixedMul(spd, FINESINE(thrustangle)); if (!cam->reset_aiming) { - cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming)); + cam->z += FixedMul(spd, AIMINGTOSLOPE(cam->aiming)); } // momentums are useless here, directly add to the coordinates diff --git a/src/r_main.c b/src/r_main.c index 79950a458..b863d8141 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1537,6 +1537,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam_rotspeed[i]); } + CV_RegisterVar(&cv_freecam_speed); + CV_RegisterVar(&cv_tilting); CV_RegisterVar(&cv_quaketilt); CV_RegisterVar(&cv_tiltsmoothing); From 2639f94dfff0301a53e4a3512babca15dfd24872 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 03:44:21 +0100 Subject: [PATCH 08/76] fix freecam not being steerable when not in spec ugh this is godawful its literally almost a complete copy of --- src/g_game.c | 4 ++ src/p_local.h | 7 +- src/p_user.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 187 insertions(+), 15 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 1be80c944..79e94a24b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -886,6 +886,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) thiscam = (player->bot == 2 ? &camera[0] : &camera[forplayer]); else thiscam = &camera[forplayer]; + lang = localangle[forplayer]; laim = localaiming[forplayer]; th = turnheld[forplayer]; @@ -7861,6 +7862,9 @@ void G_StopDemo(void) for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) { camera[i].freecam = false; + camera[i].localangle = 0; + camera[i].localaiming = 0; + camera[i].keyboardlook = false; } CV_SetValue(&cv_playbackspeed, 1); diff --git a/src/p_local.h b/src/p_local.h index b45cebdc2..13219c429 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -81,6 +81,11 @@ typedef struct camera_s boolean chase; boolean freecam; + angle_t localangle; + INT32 localaiming; + + boolean keyboardlook; // keyboard look + angle_t aiming; // Freecam: A button was held since entering from menu, so don't move camera @@ -146,7 +151,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount); void P_ResetCamera(player_t *player, camera_t *thiscam); boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam); void P_SlideCameraMove(camera_t *thiscam); -void P_DemoCameraMovement(camera_t *cam, UINT8 num); +//void P_DemoCameraMovement(camera_t *cam, UINT8 num); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); void P_ToggleDemoCamera(UINT8 viewnum); diff --git a/src/p_user.c b/src/p_user.c index 9484197ef..8b0f15cf3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3133,10 +3133,18 @@ 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) +static fixed_t forwardmove[2] = {25<>16, 50<>16}; +static fixed_t sidemove[2] = {2<>16, 4<>16}; +static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn + +static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; + void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; + memset(&cameracmd[viewnum], 0, sizeof(ticcmd_t)); + if (!cam->freecam) // toggle on { cam->freecam = true; @@ -3149,20 +3157,180 @@ void P_ToggleDemoCamera(UINT8 viewnum) } } +static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) +{ + INT32 laim, forward, side, axis; //i + // these ones used for multiple conditions + boolean turnleft, turnright; + boolean usejoystick, kbl; + angle_t lang; + INT32 screen_invert; + const UINT8 forplayer = num+1; + + ticcmd_t *cmd = &cameracmd[num]; + + lang = cam->localangle; + laim = cam->localaiming; + kbl = cam->keyboardlook; + + if (!cam->freecam) + return cmd; // empty cmd, no. + + switch (num) + { + case 1: + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + break; + case 2: + G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + break; + case 3: + G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + break; + case 0: + default: + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + break; + } + + cmd->angleturn = (INT16)(lang >> 16); + cmd->aiming = G_ClipAimingPitch(&laim); + + const boolean lookaxis = cv_lookaxis[num].value; + const boolean analogjoystickmove = cv_usejoystick[num].value && !Joystick[num].bGamepadStyle; + const boolean gamepadjoystickmove = cv_usejoystick[num].value && Joystick[num].bGamepadStyle; + + usejoystick = (analogjoystickmove || gamepadjoystickmove); + + turnright = InputDown(gc_turnright, forplayer); + turnleft = InputDown(gc_turnleft, forplayer); + + axis = JoyAxis(AXISTURN, forplayer); + + if (encoremode) + { + turnright ^= turnleft; // swap these using three XORs + turnleft ^= turnright; + turnright ^= turnleft; + axis = -axis; + } + + if (gamepadjoystickmove && axis != 0) + { + turnright = turnright || (axis > 0); + turnleft = turnleft || (axis < 0); + } + forward = side = 0; + + // let movement keys cancel each other out + if (turnright && !(turnleft)) + { + cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); + side += sidemove[1]; + } + else if (turnleft && !(turnright)) + { + cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); + side -= sidemove[1]; + } + + if (analogjoystickmove && axis != 0) + { + // JOYAXISRANGE should be 1023 (divide by 1024) + cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG! + side += ((axis * sidemove[0]) >> 10); + } + + cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); + + axis = JoyAxis(AXISAIM, forplayer); + if (InputDown(gc_aimforward, forplayer) || (usejoystick && axis < 0)) + forward += forwardmove[1]; + if (InputDown(gc_aimbackward, forplayer) || (usejoystick && axis > 0)) + forward -= forwardmove[1]; + + // fire with any button/key + axis = JoyAxis(AXISFIRE, forplayer); + if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ATTACK; + + // spectator aiming shit, ahhhh... + screen_invert = 1; // nope + + // mouse look stuff (mouse look is not the same as mouse aim) + kbl = false; + + // looking up/down + laim += (mlooky<<19)*screen_invert; + + axis = JoyAxis(AXISLOOK, forplayer); + + if (analogjoystickmove && axis != 0 && lookaxis) + laim += (axis<<16) * screen_invert; + + // spring back if not using keyboard neither mouselookin' + if (!kbl && !lookaxis) + laim = 0; + + if (InputDown(gc_lookup, forplayer) || (gamepadjoystickmove && axis < 0)) + { + laim += KB_LOOKSPEED * screen_invert; + kbl = true; + } + else if (InputDown(gc_lookdown, forplayer) || (gamepadjoystickmove && axis > 0)) + { + laim -= KB_LOOKSPEED * screen_invert; + kbl = true; + } + + if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V + laim = 0; + + cmd->aiming = G_ClipAimingPitch(&laim); + + mousex = mousey = mlooky = 0; + + if (forward > MAXPLMOVE) + forward = MAXPLMOVE; + else if (forward < -MAXPLMOVE) + forward = -MAXPLMOVE; + + if (side > MAXPLMOVE) + side = MAXPLMOVE; + else if (side < -MAXPLMOVE) + side = -MAXPLMOVE; + + if (forward || side) + { + cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); + cmd->sidemove = (SINT8)(cmd->sidemove + side); + } + + lang += (cmd->angleturn<<16); + + cam->localangle = lang; + cam->localaiming = laim; + cam->keyboardlook = kbl; + + return cmd; +} + #define intsign(n) \ ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) -void P_DemoCameraMovement(camera_t *cam, UINT8 num) +static void P_DemoCameraMovement(camera_t *cam, UINT8 num) { ticcmd_t *cmd; angle_t thrustangle; player_t *lastp; - angle_t turning; - + const UINT8 forplayer = num+1; boolean moving = false; + cam->localangle = cam->angle; + cam->localaiming = cam->aiming; + // first off we need to get button input - cmd = D_LocalTiccmd(num); + cmd = P_CameraCmd(cam, num); if (cmd->aiming != 0) { @@ -3171,31 +3339,26 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->reset_aiming = false; } - turning = cmd->angleturn << 16; - if (encoremode) - { - turning = -turning; - } - cam->angle = turning; + cam->angle = cmd->angleturn << 16; // camera movement: if (!cam->button_a_held) { fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; - if (InputDown(gc_camfloat, num+1)) + if (InputDown(gc_camfloat, forplayer)) { cam->z += spd; moving = true; } - else if (InputDown(gc_camsink, num+1)) + else if (InputDown(gc_camsink, forplayer)) { cam->z -= spd; moving = true; } } - if (!(InputDown(gc_camfloat, num+1) || InputDown(gc_camsink, num+1)) && cam->button_a_held) + if (!(InputDown(gc_camfloat, forplayer) || InputDown(gc_camsink, forplayer)) && cam->button_a_held) { cam->button_a_held--; } @@ -3221,7 +3384,7 @@ void P_DemoCameraMovement(camera_t *cam, UINT8 num) // forward/back will have a slope. So, as long as democam // controls haven't been used to alter the vertical angle, // slowly reset it to flat. - if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, num+1)) && !cam->button_a_held)) + if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, forplayer)) && !cam->button_a_held)) { INT32 aiming = cam->aiming; INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); From a19cb5f2bcf0c4790cfda772d6a3131e40c24499 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 04:00:56 +0100 Subject: [PATCH 09/76] fix speccam again --- src/p_user.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 8b0f15cf3..37a5ee0df 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3137,14 +3137,10 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn -static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; - void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; - memset(&cameracmd[viewnum], 0, sizeof(ticcmd_t)); - if (!cam->freecam) // toggle on { cam->freecam = true; @@ -3167,15 +3163,15 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) INT32 screen_invert; const UINT8 forplayer = num+1; - ticcmd_t *cmd = &cameracmd[num]; + ticcmd_t *cmd = D_LocalTiccmd(num); + + if (!cam->freecam) + return cmd; // empty cmd, no. lang = cam->localangle; laim = cam->localaiming; kbl = cam->keyboardlook; - if (!cam->freecam) - return cmd; // empty cmd, no. - switch (num) { case 1: From 3156851554096001904be635e6528e5b4ba85a77 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 04:01:09 +0100 Subject: [PATCH 10/76] fix cam interp during pause again --- src/r_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index b863d8141..2a97136be 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1066,6 +1066,8 @@ R_SetupCommonFrame ( player_t * player, subsector_t * subsector) { + const UINT8 viewnum = R_GetViewNumber(); + newview->player = player; newview->x += quake.x; @@ -1079,7 +1081,7 @@ R_SetupCommonFrame else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? (demo.freecam ? rendertimefrac_unpaused : rendertimefrac) : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? (camera[viewnum].freecam ? rendertimefrac_unpaused : rendertimefrac) : FRACUNIT, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) From da9c19bba430891d382e2cb7722aa79f7b446b86 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 28 Dec 2024 18:48:58 +0300 Subject: [PATCH 11/76] Update replayfreecam lua global to use camera.freecam for currently viewed player --- src/dehacked.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index e4b4028ef..54ea4e510 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8542,6 +8542,16 @@ static int lua_enumlib_mariomode_get(lua_State *L) return 1; } +static int lua_enumlib_replayfreecam_get(lua_State *L) +{ + if (dedicated) // huh? + lua_pushboolean(L, false); + else + lua_pushboolean(L, camera[R_GetViewNumber()].freecam); + + return 1; +} + static int lua_enumlib_twodlevel_get(lua_State *L) { lua_pushboolean(L, twodlevel); @@ -9219,7 +9229,7 @@ int LUA_EnumLib(lua_State *L) lua_pushcfunction(L, lua_glib_new_getter); lua_pushliteral(L, "replayfreecam"); - lua_glib_push_bool_getter(L, &demo.freecam); + lua_pushcfunction(L, lua_enumlib_replayfreecam_get); lua_call(L, 2, 0); if (!mathlib) From f355b2269c8a5b27c34d9296f126ac11e2c3f319 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 05:00:41 +0100 Subject: [PATCH 12/76] toggle off freecam when f12ing --- src/g_game.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 79e94a24b..2c3e2fa02 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1773,7 +1773,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) G_FixCamera(viewd); } - if (viewnum == 1 && demo.playback) + if (demo.playback && viewnum == 1) consoleplayer = displayplayers[0]; } @@ -1787,6 +1787,10 @@ void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) INT32 *displayplayerp, oldview; displayplayerp = &displayplayers[viewnum-1]; oldview = (*displayplayerp); + + // turn off the freecam + camera[viewnum].freecam = false; + G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); // If no other view could be found, go back to what we had. From 3d39f5038805d3f1e3796a7449e94bdbef8cb4f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:03:10 +0100 Subject: [PATCH 13/76] make function to return button names to use with new rebindable cam controls --- src/st_stuff.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 398dc7dbe..da5628827 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -652,6 +652,20 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } +static const char *ST_GetButtonName(INT32 control, const char *inputtext) +{ + static char buttname[32] = {0}; // Static buffer + const char *item1 = gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL; + const char *item2 = gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL; + + if (item1 != NULL && item2 != NULL) + snprintf(buttname, 32, "%s/%s - %s", item1, item2, inputtext); + else + snprintf(buttname, 32, "%s - %s", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound", inputtext); + + return buttname; +} + // Draw the status bar overlay, customisable: the user chooses which // kind of information to overlay // @@ -780,19 +794,9 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); - - char directortoggle[32] = {0}; - const char *item1 = gamecontrol[gc_director][0] != 0 ? G_KeynumToString(gamecontrol[gc_director][0]) : NULL; - const char *item2 = gamecontrol[gc_director][1] != 0 ? G_KeynumToString(gamecontrol[gc_director][1]) : NULL; - - if (item1 != NULL && item2 != NULL) - snprintf(directortoggle, 32, "%s/%s - Toggle Director", item1, item2); - else - snprintf(directortoggle, 32, "%s - Toggle Director", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound"); - - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, directortoggle); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director")); directortextactive = true; } @@ -800,8 +804,8 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); } } } From 6b9900ad4ed25237bffa1f1f7187d0e76ce741c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:27:18 +0100 Subject: [PATCH 14/76] clean up cam stuff for good --- src/g_game.c | 1 - src/p_local.h | 2 -- src/p_user.c | 78 +++++++++++++++++++++------------------------------ 3 files changed, 32 insertions(+), 49 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2c3e2fa02..f612b813d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -7868,7 +7868,6 @@ void G_StopDemo(void) camera[i].freecam = false; camera[i].localangle = 0; camera[i].localaiming = 0; - camera[i].keyboardlook = false; } CV_SetValue(&cv_playbackspeed, 1); diff --git a/src/p_local.h b/src/p_local.h index 13219c429..c2a2ee017 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -84,8 +84,6 @@ typedef struct camera_s angle_t localangle; INT32 localaiming; - boolean keyboardlook; // keyboard look - angle_t aiming; // Freecam: A button was held since entering from menu, so don't move camera diff --git a/src/p_user.c b/src/p_user.c index 37a5ee0df..1456f1cbf 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3155,12 +3155,12 @@ void P_ToggleDemoCamera(UINT8 viewnum) static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { - INT32 laim, forward, side, axis; //i + INT32 laim, th, tspeed, forward, side, axis; + // these ones used for multiple conditions boolean turnleft, turnright; - boolean usejoystick, kbl; + boolean usejoystick; angle_t lang; - INT32 screen_invert; const UINT8 forplayer = num+1; ticcmd_t *cmd = D_LocalTiccmd(num); @@ -3170,24 +3170,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang = cam->localangle; laim = cam->localaiming; - kbl = cam->keyboardlook; - - switch (num) - { - case 1: - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - break; - case 2: - G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); - break; - case 3: - G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); - break; - case 0: - default: - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - break; - } cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); @@ -3218,15 +3200,27 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) } forward = side = 0; + // use two stage accelerative turning + // on the keyboard and joystick + if (turnleft || turnright) + th += 1; + else + th = 0; + + if (th < SLOWTURNTICS) + tspeed = 2; // slow turn + else + tspeed = 1; + // let movement keys cancel each other out if (turnright && !(turnleft)) { - cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); + cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); side += sidemove[1]; } else if (turnleft && !(turnright)) { - cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); + cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); side -= sidemove[1]; } @@ -3251,32 +3245,22 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) cmd->buttons |= BT_ATTACK; // spectator aiming shit, ahhhh... - screen_invert = 1; // nope - - // mouse look stuff (mouse look is not the same as mouse aim) - kbl = false; // looking up/down - laim += (mlooky<<19)*screen_invert; + laim += (mlooky<<19); axis = JoyAxis(AXISLOOK, forplayer); if (analogjoystickmove && axis != 0 && lookaxis) - laim += (axis<<16) * screen_invert; - - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis) - laim = 0; + laim += (axis<<16); if (InputDown(gc_lookup, forplayer) || (gamepadjoystickmove && axis < 0)) { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; + laim += KB_LOOKSPEED; } else if (InputDown(gc_lookdown, forplayer) || (gamepadjoystickmove && axis > 0)) { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; + laim -= KB_LOOKSPEED; } if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V @@ -3306,7 +3290,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) cam->localangle = lang; cam->localaiming = laim; - cam->keyboardlook = kbl; return cmd; } @@ -3341,16 +3324,19 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (!cam->button_a_held) { fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; + int dir = ((InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((InputDown(gc_camsink, forplayer)) ? -1 : 0); - if (InputDown(gc_camfloat, forplayer)) + switch (dir) { - cam->z += spd; - moving = true; - } - else if (InputDown(gc_camsink, forplayer)) - { - cam->z -= spd; - moving = true; + case 1: + cam->z += spd; + moving = true; + break; + + case -1: + cam->z -= spd; + moving = true; + break; } } From 4110130ca7dc96980df6ad6b437cc393ce741057 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:36:36 +0100 Subject: [PATCH 15/76] block freecam toggling when player is in spec --- src/p_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 1456f1cbf..31f2820bb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3141,13 +3141,17 @@ void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; + // dont let freecam be toggled when in spec lel + if (players[displayplayers[viewnum]].spectator) + return; + if (!cam->freecam) // toggle on { cam->freecam = true; cam->button_a_held = 2; cam->reset_aiming = true; } - else // toggle off + else // toggle off { cam->freecam = false; } From 11546cd9060622bd858fb7b2ea750c399aa157da Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:37:10 +0100 Subject: [PATCH 16/76] fix centerview --- src/p_user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 31f2820bb..22ea6454c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3315,6 +3315,10 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // first off we need to get button input cmd = P_CameraCmd(cam, num); + // let centerview work proper + if (InputDown(gc_centerview, forplayer)) + cam->aiming = 0; + if (cmd->aiming != 0) { cam->aiming = cmd->aiming << FRACBITS; From ca09a5dd465267d68c6a01b8982ac0c380dc6037 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 06:40:13 +0100 Subject: [PATCH 17/76] dont need to do this twice --- src/p_user.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 22ea6454c..7a9e1f67c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3390,24 +3390,6 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } } - if (rendermode == render_soft -#ifdef HWRENDER - || (rendermode == render_opengl && (cv_glshearing.value == 1)) -#endif - ) - { - // Extra restriction on this so it's not possible to - // distort the view too much. - if ((INT32)cam->aiming > ANGLE_45) - cam->aiming = ANGLE_45; - else if ((INT32)cam->aiming < -ANGLE_45) - cam->aiming = -ANGLE_45; - } - else - { - G_ClipAimingPitch((INT32 *)&cam->aiming); - } - cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) { From 267e2be69b6a34f42e2b741d86f9642d699c7ada Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 15:39:39 +0100 Subject: [PATCH 18/76] fix offbyone issue --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 961dfbf8f..6732e8c70 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1786,7 +1786,7 @@ void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) oldview = (*displayplayerp); // turn off the freecam - camera[viewnum].freecam = false; + camera[viewnum-1].freecam = false; G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); From b23020435f58636fb54957c7dea8509d7323cc28 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 16:43:09 +0100 Subject: [PATCH 19/76] replace all this crap with either stplyrnum or R_GetViewNumber --- src/hardware/hw_main.c | 6 ++--- src/k_kart.c | 59 +++++++++++++++++------------------------- src/lua_hudlib.c | 2 +- src/r_bsp.c | 16 +++--------- src/st_stuff.c | 8 +++--- 5 files changed, 34 insertions(+), 57 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5eefc9c7e..638b450a2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3232,11 +3232,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) angle_t shadowdir; // Set direction - if (splitscreen && stplyr == &players[displayplayers[1]]) + if (splitscreen && R_GetViewNumber() == 1) shadowdir = localangle[1] + FixedAngle(cv_cam_rotate[1].value); - else if (splitscreen > 1 && stplyr == &players[displayplayers[2]]) + else if (splitscreen > 1 && R_GetViewNumber() == 2) shadowdir = localangle[2] + FixedAngle(cv_cam_rotate[2].value); - else if (splitscreen > 2 && stplyr == &players[displayplayers[3]]) + else if (splitscreen > 2 && R_GetViewNumber() == 3) shadowdir = localangle[3] + FixedAngle(cv_cam_rotate[3].value); else shadowdir = localangle[0] + FixedAngle(cv_cam_rotate[0].value); diff --git a/src/k_kart.c b/src/k_kart.c index 7a9f43f55..f386b5ad9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7618,17 +7618,17 @@ INT32 K_calcSplitFlags(INT32 snapflags) if (splitscreen == 0) return snapflags; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) { - if (splitscreen == 1 && stplyr == &players[displayplayers[1]]) + if (splitscreen == 1 && stplyrnum == 1) { splitflags |= V_SPLITSCREEN; } else if (splitscreen > 1) { - if (stplyr == &players[displayplayers[2]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]])) + if (stplyrnum == 2 || (splitscreen == 3 && stplyrnum == 3)) splitflags |= V_SPLITSCREEN; - if (stplyr == &players[displayplayers[1]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]])) + if (stplyrnum == 1 || (splitscreen == 3 && stplyrnum == 3)) splitflags |= V_HORZSCREEN; } } @@ -7748,7 +7748,7 @@ static void K_drawKartStats(void) for (; splitnum < MAXSPLITSCREENPLAYERS; ++splitnum) { - if (stplyr == &players[displayplayers[splitnum]]) + if (stplyrnum == splitnum) break; } @@ -8334,7 +8334,7 @@ static void K_DrawKartPositionNum(INT32 num) else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different. { fx = POSI_X; - if (stplyr == &players[displayplayers[0]]) // for player 1: display this at the top right, above the minimap. + if (stplyrnum == 0) // for player 1: display this at the top right, above the minimap. { fy = 30 + cv_posi_yoffset.value; fflags = V_SNAPTOTOP|V_SNAPTORIGHT; @@ -8349,11 +8349,11 @@ static void K_DrawKartPositionNum(INT32 num) } else { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... + if (!(stplyrnum & 1)) // If we are P1 or P3... { fx = POSI_X; fy = POSI_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + fflags = V_SNAPTOLEFT|((stplyrnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. flipdraw = true; if (num && num >= 10) fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen. @@ -8362,7 +8362,7 @@ static void K_DrawKartPositionNum(INT32 num) { fx = POSI2_X; fy = POSI2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + fflags = V_SNAPTORIGHT|((stplyrnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom } } @@ -9311,7 +9311,7 @@ static void K_drawDriftGauge(void) 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (demo.playback && camera[R_GetViewNumber()].freecam) + if (demo.playback && camera[stplyrnum].freecam) return; if (P_MobjWasRemoved(stplyr->mo) || (!splitscreen && !camera->chase)) @@ -9469,7 +9469,7 @@ static void K_drawKartWanted(void) UINT8 *colormap = NULL; INT32 basex = 0, basey = 0; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) return; for (i = 0; i < 4; i++) @@ -9666,7 +9666,7 @@ static void K_drawKartMinimap(void) if (gamestate != GS_LEVEL) return; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) return; if (minimapinfo.minimap_pic == NULL) @@ -9828,7 +9828,7 @@ static void K_drawKartFinish(void) xval = (SHORT(kp_racefinish[pnum]->width)<kartstuff[k_cardanimation])< x ? xval : x))/TICRATE; - if (splitscreen && stplyr == &players[displayplayers[1]]) + if (splitscreen && stplyrnum == 1) x = -x; V_DrawFixedPatch(x + (STCD_X<>1), @@ -9985,14 +9985,9 @@ static void K_drawKartFirstPerson(void) if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW)) return; - if (stplyr == &players[displayplayers[1]] && splitscreen) - { pn = pnum[1]; tn = turn[1]; dr = drift[1]; } - else if (stplyr == &players[displayplayers[2]] && splitscreen > 1) - { pn = pnum[2]; tn = turn[2]; dr = drift[2]; } - else if (stplyr == &players[displayplayers[3]] && splitscreen > 2) - { pn = pnum[3]; tn = turn[3]; dr = drift[3]; } - else - { pn = pnum[0]; tn = turn[0]; dr = drift[0]; } + pn = pnum[stplyrnum]; + tn = turn[stplyrnum]; + dr = drift[stplyrnum]; if (splitscreen) { @@ -10114,14 +10109,9 @@ static void K_drawKartFirstPerson(void) V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap); - if (stplyr == &players[displayplayers[1]] && splitscreen) - { pnum[1] = pn; turn[1] = tn; drift[1] = dr; } - else if (stplyr == &players[displayplayers[2]] && splitscreen > 1) - { pnum[2] = pn; turn[2] = tn; drift[2] = dr; } - else if (stplyr == &players[displayplayers[3]] && splitscreen > 2) - { pnum[3] = pn; turn[3] = tn; drift[3] = dr; } - else - { pnum[0] = pn; turn[0] = tn; drift[0] = dr; } + pnum[stplyrnum] = pn; + turn[stplyrnum] = tn; + drift[stplyrnum] = dr; } // doesn't need to ever support 4p @@ -10341,7 +10331,7 @@ static void K_drawDistributionDebugger(void) boolean dontforcespb = false; boolean spbrush = false; - if (stplyr != &players[displayplayers[0]]) // only for p1 + if (stplyrnum != 0) // only for p1 return; // The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice @@ -10405,7 +10395,7 @@ static void K_drawDistributionDebugger(void) static void K_drawCheckpointDebugger(void) { - if (stplyr != &players[displayplayers[0]]) // only for p1 + if (stplyrnum != 0) // only for p1 return; if (stplyr->starpostnum >= (numstarposts - (numstarposts/2))) @@ -10419,19 +10409,18 @@ void K_drawKartHUD(void) { boolean isfreeplay = false; boolean battlefullscreen = false; - UINT8 viewnum = R_GetViewNumber(); - boolean freecam = camera[viewnum].freecam; //disable some hud elements w/ freecam + boolean freecam = camera[stplyrnum].freecam; //disable some hud elements w/ freecam // Define the X and Y for each drawn object // This is handled by console/menu values K_initKartHUD(); // Draw that fun first person HUD! Drawn ASAP so it looks more "real". - if (!camera[viewnum].chase && !freecam) + if (!camera[stplyrnum].chase && !freecam) K_drawKartFirstPerson(); // Draw full screen stuff that turns off the rest of the HUD - if (mapreset && R_GetViewNumber() == 0) + if (mapreset && stplyrnum == 0) { K_drawChallengerScreen(); return; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index f3c01f4eb..708eb8740 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -649,7 +649,7 @@ static int libd_drawOnMinimap(lua_State *L) if (gamestate != GS_LEVEL) return 0; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) return 0; AutomapPic = minimapinfo.minimap_pic; diff --git a/src/r_bsp.c b/src/r_bsp.c index db6a4378d..dbb6fb4d3 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -263,21 +263,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, mobj_t *pviewmobj = viewplayer->mo; INT32 heightsec; boolean underwater; - UINT8 i; - - for (i = 0; i <= splitscreen; i++) - { - if (viewplayer != &players[displayplayers[i]]) - continue; - - if (!camera[i].chase) - continue; + UINT8 i = R_GetViewNumber(); + if (camera[i].chase) heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; - break; - } - - if (i > splitscreen && pviewmobj) + else if (i > splitscreen && viewmobj) heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec; else return sec; diff --git a/src/st_stuff.c b/src/st_stuff.c index da5628827..d5d438414 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -671,8 +671,6 @@ static const char *ST_GetButtonName(INT32 control, const char *inputtext) // static void ST_overlayDrawer(void) { - const UINT8 viewnum = R_GetViewNumber(); - //hu_showscores = auto hide score/time/rings when tab rankings are shown if (!(hu_showscores && (netgame || multiplayer))) { @@ -681,7 +679,7 @@ static void ST_overlayDrawer(void) if (!hu_showscores) // hide the following if TAB is held { - if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !camera[viewnum].freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) + if (cv_showdirectorhud.value && !splitscreen && ((demo.playback && !camera[stplyrnum].freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !K_DirectorIsPlayerAlone()) { char directortext[20] = {0}; @@ -721,7 +719,7 @@ static void ST_overlayDrawer(void) V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_SNAPTOBOTTOM|V_HUDTRANS|V_ALLOWLOWERCASE, player_names[stplyr-players]); } } - else if (!demo.title && !demo.freecam) + else if (!demo.title && !camera[stplyrnum].freecam) { if (!splitscreen) { @@ -732,7 +730,7 @@ static void ST_overlayDrawer(void) { char name[MAXPLAYERNAME+12]; - INT32 y = (stplyr == &players[displayplayers[0]]) ? 4 : BASEVIDHEIGHT/2-12; + INT32 y = (stplyrnum == 0) ? 4 : BASEVIDHEIGHT/2-12; sprintf(name, "VIEWPOINT: %s", player_names[stplyr-players]); V_DrawRightAlignedThinString(BASEVIDWIDTH-40, y, V_HUDTRANSHALF|V_ALLOWLOWERCASE|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOBOTTOM|V_SNAPTORIGHT), name); } From 26480882c847713ef32784ff8dc2fcd8df7a19b4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 16:43:34 +0100 Subject: [PATCH 20/76] remove the remainder or demo.freecam --- src/k_director.c | 2 +- src/m_menu.c | 19 +++++++++---------- src/p_setup.c | 6 +++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index dafea6072..1385754f0 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -69,7 +69,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) static boolean K_DirectorIsEnabled(void) { - return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !demo.freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); + return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !camera[0].freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone()); } void K_InitDirector(void) diff --git a/src/m_menu.c b/src/m_menu.c index 0bfacba82..3c7153d2c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4033,19 +4033,19 @@ boolean M_Responder(event_t *ev) // switch viewpoints: case '1': // viewpoint for p1 (also f12) // maximum laziness: - if (!demo.freecam) + if (!camera[0].freecam) G_AdjustView(1, 1, true); break; case '2': // viewpoint for p2 - if (!demo.freecam) + if (!camera[1].freecam) G_AdjustView(2, 1, true); break; case '3': // viewpoint for p3 - if (!demo.freecam) + if (!camera[2].freecam) G_AdjustView(3, 1, true); break; case '4': // viewpoint for p4 - if (!demo.freecam) + if (!camera[3].freecam) G_AdjustView(4, 1, true); break; @@ -4272,19 +4272,19 @@ boolean M_DemoResponder(event_t *ev) // switch viewpoints: case '1': // viewpoint for p1 (also f12) // maximum laziness: - if (!demo.freecam) + if (!camera[0].freecam) G_AdjustView(1, 1, true); break; case '2': // viewpoint for p2 - if (!demo.freecam) + if (!camera[1].freecam) G_AdjustView(2, 1, true); break; case '3': // viewpoint for p3 - if (!demo.freecam) + if (!camera[2].freecam) G_AdjustView(3, 1, true); break; case '4': // viewpoint for p4 - if (!demo.freecam) + if (!camera[3].freecam) G_AdjustView(4, 1, true); break; @@ -7691,8 +7691,7 @@ static void M_PlaybackAdvance(INT32 choice) static void M_PlaybackSetViews(INT32 choice) { - - if (demo.freecam) + if (camera[0].freecam || camera[1].freecam || camera[2].freecam || camera[3].freecam) return; // not here. if (choice > 0) diff --git a/src/p_setup.c b/src/p_setup.c index b87c6e843..bcfb20978 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2474,9 +2474,13 @@ static void P_InitCamera(void) if (!dedicated) { - if (!demo.freecam) for (i = 0; i <= splitscreen; i++) + { + if (camera[i].freecam) + continue; + 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 for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) From 27d6447a83393f0250b8a6d0d7caf79439300285 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 16:51:07 +0100 Subject: [PATCH 21/76] fix wrong cam default controls --- src/g_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 606f20770..b99874b8d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1143,8 +1143,8 @@ void G_Controldefault(UINT8 player) gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up - gamecontrol[gc_camfloat ][1] = 'a'; - gamecontrol[gc_camsink ][1] = 'd'; + gamecontrol[gc_camfloat ][0] = 'a'; + gamecontrol[gc_camsink ][0] = 'd'; gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B From 7d6cce5881770f3055abcfd54c3500436c6a0b7d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 19:21:23 +0100 Subject: [PATCH 22/76] readd cam cmd stuff cause it may break the cam in replays or smth a --- src/p_user.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 7a9e1f67c..a91bebd79 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3157,9 +3157,11 @@ void P_ToggleDemoCamera(UINT8 viewnum) } } +static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; + static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { - INT32 laim, th, tspeed, forward, side, axis; + INT32 laim, forward, side, axis; // these ones used for multiple conditions boolean turnleft, turnright; @@ -3167,14 +3169,30 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) angle_t lang; const UINT8 forplayer = num+1; - ticcmd_t *cmd = D_LocalTiccmd(num); + memset(&cameracmd[num], 0, sizeof(ticcmd_t)); // initialize cmd - if (!cam->freecam) - return cmd; // empty cmd, no. + ticcmd_t *cmd = &cameracmd[num]; lang = cam->localangle; laim = cam->localaiming; + switch (num) + { + case 1: + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + break; + case 2: + G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + break; + case 3: + G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + break; + case 0: + default: + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + break; + } + cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); @@ -3204,27 +3222,15 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) } forward = side = 0; - // use two stage accelerative turning - // on the keyboard and joystick - if (turnleft || turnright) - th += 1; - else - th = 0; - - if (th < SLOWTURNTICS) - tspeed = 2; // slow turn - else - tspeed = 1; - // let movement keys cancel each other out if (turnright && !(turnleft)) { - cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); + cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); side += sidemove[1]; } else if (turnleft && !(turnright)) { - cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); + cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); side -= sidemove[1]; } From 92a3e974b046e32a14f678ffb61950fe17d79064 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 19:21:40 +0100 Subject: [PATCH 23/76] fix driftgauge showing with freecam while ingame --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index f386b5ad9..ef73e4b2b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9311,7 +9311,7 @@ static void K_drawDriftGauge(void) 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (demo.playback && camera[stplyrnum].freecam) + if (camera[stplyrnum].freecam) return; if (P_MobjWasRemoved(stplyr->mo) || (!splitscreen && !camera->chase)) From f72c64d7d15974a86e8e694e6c2ed139a0f6a728 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 19:29:12 +0100 Subject: [PATCH 24/76] fix some potential issues with viewinterp now unpaused disabled interp on netlag also fixes screencoord stuff not being interpolated during pause --- src/d_main.c | 9 ++++++++- src/k_kart.c | 2 +- src/r_main.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 642870a86..a46ba11c0 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -825,7 +825,14 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - rendertimefrac_unpaused = g_time.timefrac; + if (!hu_stopped) + { + rendertimefrac_unpaused = g_time.timefrac; + } + else + { + rendertimefrac_unpaused = FRACUNIT; + } } else { diff --git a/src/k_kart.c b/src/k_kart.c index ef73e4b2b..ec8e5aa73 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7608,7 +7608,7 @@ static void K_initKartHUD(void) // K_GetScreenCoords needs the right view* variables R_SetViewContext(stplyrnum); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, !cv_uncappedhud.value); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, !cv_uncappedhud.value); } INT32 K_calcSplitFlags(INT32 snapflags) diff --git a/src/r_main.c b/src/r_main.c index 2a97136be..dbbd1ee54 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1081,7 +1081,7 @@ R_SetupCommonFrame else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? (camera[viewnum].freecam ? rendertimefrac_unpaused : rendertimefrac) : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) From 6d01ec4c553f687c11315a9642642a98dfb2702f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Dec 2024 19:46:14 +0100 Subject: [PATCH 25/76] dont need this anymore --- src/r_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index dbbd1ee54..cd38fab85 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1066,8 +1066,6 @@ R_SetupCommonFrame ( player_t * player, subsector_t * subsector) { - const UINT8 viewnum = R_GetViewNumber(); - newview->player = player; newview->x += quake.x; From 761df3f2cf6db55abe3b3e8a816a8384187fd225 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Dec 2024 11:29:49 +0100 Subject: [PATCH 26/76] hide director control stuff for others than player 1 --- src/m_menu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index ff4096244..d78e41274 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12098,6 +12098,7 @@ static void M_Setup1PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_CONTROL; // GIF OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu OP_AllControlsMenu[21].status = IT_CONTROL; // Console + OP_AllControlsMenu[35].status = IT_CONTROL; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12120,6 +12121,7 @@ static void M_Setup2PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12142,6 +12144,7 @@ static void M_Setup3PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12164,6 +12167,7 @@ static void M_Setup4PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } From b2823c81e46fdc077f38addc2b5b363cbd5ad51e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Dec 2024 04:09:43 +0100 Subject: [PATCH 27/76] fix jitter when toggling freecam off --- src/g_game.c | 4 +--- src/g_game.h | 2 ++ src/p_user.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 18c67e4f9..385b7b6cf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -358,8 +358,6 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); -static void G_FixCamera(UINT8 view); - // don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler. // chat timer thingy @@ -1701,7 +1699,7 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active) // Reset camera position, angle and interpolation on a view // after changing state. // -static void G_FixCamera(UINT8 view) +void G_FixCamera(UINT8 view) { player_t *player = &players[displayplayers[view - 1]]; diff --git a/src/g_game.h b/src/g_game.h index 3a957d00a..ba26cd507 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -444,4 +444,6 @@ INT16 G_TOLFlag(INT32 pgametype); INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon, INT16 *extbuffer); void G_AddMapToBuffer(INT16 map); +void G_FixCamera(UINT8 view); + #endif diff --git a/src/p_user.c b/src/p_user.c index a91bebd79..ce404866e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3154,6 +3154,7 @@ void P_ToggleDemoCamera(UINT8 viewnum) else // toggle off { cam->freecam = false; + G_FixCamera(viewnum+1); } } From 6fcfb9cf36d44ffd662738bde07bc4b5bd5e28de Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Dec 2024 22:21:26 +0100 Subject: [PATCH 28/76] readd this check lel --- src/r_bsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index dbb6fb4d3..66861c49a 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -265,7 +265,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, boolean underwater; UINT8 i = R_GetViewNumber(); - if (camera[i].chase) + if (viewplayer == &players[displayplayers[i]] && camera[i].chase) heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; else if (i > splitscreen && viewmobj) heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec; From 3910e66905bd928b62c824a5caa6ca490bbd758e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 30 Dec 2024 23:10:51 +0100 Subject: [PATCH 29/76] dont try to chase after your spec mobj lel --- src/p_user.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index ce404866e..652fd0fea 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3364,10 +3364,15 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (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); - cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. - cam->reset_aiming = false; + // dont chase after your spectator self + if (!lastp->spectator) + { + const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + cam->reset_aiming = false; + } } if (cmd->forwardmove != 0) From 487018f1467ac64fab0fb6b86ace257820840f47 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jan 2025 05:37:30 +0100 Subject: [PATCH 30/76] hack: only let freecam for spec move when youre actually able to move as spec cause kart weird, and we cant remove the spec movement due to synch reasons and letting the cam move instantly instead of waiting, may put you in a weird cam position --- src/p_user.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 652fd0fea..e160068ae 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -67,6 +67,8 @@ static boolean onground; +static boolean speccam = false; + // // P_Thrust // Moves the given origin along a given angle. @@ -2278,8 +2280,11 @@ static void P_MovePlayer(player_t *player) if (player->spectator) { P_SpectatorMovement(player); + speccam = true; return; } + else + speccam = false; ////////////////////// // MOVEMENT CODE // @@ -3521,7 +3526,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } - if (thiscam->freecam || player->spectator) + if (thiscam->freecam || (player->spectator && speccam == true)) { P_DemoCameraMovement(thiscam, num); return true; From f7ca8fb9436d6b37aa572491358c7bbe67e14ced Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 03:28:21 +0100 Subject: [PATCH 31/76] add speccam playerflag the other thing was weird and dumb lol --- src/d_player.h | 2 ++ src/p_mobj.c | 6 ++++++ src/p_user.c | 10 ++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 140a4a748..a34094572 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -538,6 +538,8 @@ typedef struct player_s INT32 awayviewtics; angle_t awayviewaiming; // Used for cut-away view + boolean speccam; + boolean spectator; UINT8 bot; diff --git a/src/p_mobj.c b/src/p_mobj.c index bdf6b1a93..35f0b9883 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10618,7 +10618,10 @@ void P_SpawnPlayer(INT32 playernum) if (multiplayer && demo.playback) ; // Don't mess with spectator values since the demo setup handles them already. else if (!G_GametypeHasSpectators()) + { p->spectator = false; + p->speccam = false; + } else if (netgame && p->jointime <= 1 && pcount) { p->spectator = true; @@ -10650,7 +10653,10 @@ void P_SpawnPlayer(INT32 playernum) SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } else // Otherwise, never spectator. + { p->spectator = false; + p->speccam = false; + } } if (G_GametypeHasTeams()) diff --git a/src/p_user.c b/src/p_user.c index e160068ae..168de782a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -67,8 +67,6 @@ static boolean onground; -static boolean speccam = false; - // // P_Thrust // Moves the given origin along a given angle. @@ -2279,12 +2277,10 @@ static void P_MovePlayer(player_t *player) if (player->spectator) { + player->speccam = true; P_SpectatorMovement(player); - speccam = true; return; } - else - speccam = false; ////////////////////// // MOVEMENT CODE // @@ -3526,7 +3522,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } - if (thiscam->freecam || (player->spectator && speccam == true)) + if (thiscam->freecam || (player->spectator && player->speccam == true)) { P_DemoCameraMovement(thiscam, num); return true; @@ -4098,6 +4094,7 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; + player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->ctfteam = changeto; @@ -4126,6 +4123,7 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; + player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; From 854cb7ee49dc6e1c0cf2b458fc8ec6879a43f7f4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 05:21:25 +0100 Subject: [PATCH 32/76] this doesent work for us --- src/p_user.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 168de782a..29eeb585a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3362,13 +3362,13 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") - if (cmd->buttons & BT_ATTACK) + // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player + if (demo.playback) { - lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. - - // dont chase after your spectator self - if (!lastp->spectator) + if (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. + const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. From a7a6e9edfca72029ada5d8b2d9b128014fc86388 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 17:07:41 +0100 Subject: [PATCH 33/76] move camera noclip stuff into its own function its not used in kart anyways and moving it makes crap more readable --- src/p_user.c | 406 ++++++++++++++++++++++++++------------------------- 1 file changed, 208 insertions(+), 198 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 29eeb585a..2bc50d2e0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3479,6 +3479,212 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE); } +#ifndef NOCLIPCAM // Disable all z-clipping for noclip cam +static boolean P_CheckNoclipCameraPosition(player_t *player, camera_t *thiscam, fixed_t x, fixed_t y, fixed_t z, boolean resetcalled) +{ + subsector_t *newsubsec; + boolean cameranoclip; + mobj_t *mo = player->mo; + + cameranoclip = ((player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) + || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)) // Noclipping player camera noclips too!! + || (leveltime < introtime)); // Kart intro cam + + // move camera down to move under lower ceilings + newsubsec = R_IsPointInSubsector(((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1), ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1)); + + if (!newsubsec) + newsubsec = thiscam->subsector; + + if (newsubsec) + { + fixed_t myfloorz, myceilingz; + fixed_t midz = thiscam->z + (thiscam->z - mo->z)/2; + fixed_t midx = ((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1); + fixed_t midy = ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1); + + // Cameras use the heightsec's heights rather then the actual sector heights. + // If you can see through it, why not move the camera through it too? + if (newsubsec->sector->camsec >= 0) + { + myfloorz = sectors[newsubsec->sector->camsec].floorheight; + myceilingz = sectors[newsubsec->sector->camsec].ceilingheight; + } + else if (newsubsec->sector->heightsec >= 0) + { + myfloorz = sectors[newsubsec->sector->heightsec].floorheight; + myceilingz = sectors[newsubsec->sector->heightsec].ceilingheight; + } + else + { + myfloorz = P_CameraGetFloorZ(thiscam, newsubsec->sector, midx, midy, NULL); + myceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, midx, midy, NULL); + } + + // Check list of fake floors and see if floorz/ceilingz need to be altered. + if (newsubsec->sector->ffloors) + { + ffloor_t *rover; + fixed_t delta1, delta2; + INT32 thingtop = midz + thiscam->height; + + for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) + continue; + + topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); + bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); + + delta1 = midz - (bottomheight + + ((topheight - bottomheight)/2)); + delta2 = thingtop - (bottomheight + + ((topheight - bottomheight)/2)); + if (topheight > myfloorz && abs(delta1) < abs(delta2)) + myfloorz = topheight; + if (bottomheight < myceilingz && abs(delta1) >= abs(delta2)) + myceilingz = bottomheight; + } + } + + // Check polyobjects and see if floorz/ceilingz need to be altered + { + INT32 xl, xh, yl, yh, bx, by; + validcount++; + + xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; + + BMBOUNDFIX(xl, xh, yl, yh); + + for (by = yl; by <= yh; by++) + { + for (bx = xl; bx <= xh; bx++) + { + INT32 offset; + polymaplink_t *plink; // haleyjd 02/22/06 + + if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) + continue; + + offset = by*bmapwidth + bx; + + // haleyjd 02/22/06: consider polyobject lines + plink = polyblocklinks[offset]; + + while (plink) + { + polyobj_t *po = plink->po; + + if (po->validcount != validcount) // if polyobj hasn't been checked + { + sector_t *polysec; + fixed_t delta1, delta2, thingtop; + fixed_t polytop, polybottom; + + po->validcount = validcount; + + if (!P_PointInsidePolyobj(po, x, y) || !(po->flags & POF_SOLID)) + { + plink = (polymaplink_t *)(plink->link.next); + continue; + } + + // We're inside it! Yess... + polysec = po->lines[0]->backsector; + + if (GETSECSPECIAL(polysec->special, 4) == 12) + { // Camera noclip polyobj. + plink = (polymaplink_t *)(plink->link.next); + continue; + } + + if (po->flags & POF_CLIPPLANES) + { + polytop = polysec->ceilingheight; + polybottom = polysec->floorheight; + } + else + { + polytop = INT32_MAX; + polybottom = INT32_MIN; + } + + thingtop = midz + thiscam->height; + delta1 = midz - (polybottom + ((polytop - polybottom)/2)); + delta2 = thingtop - (polybottom + ((polytop - polybottom)/2)); + + if (polytop > myfloorz && abs(delta1) < abs(delta2)) + myfloorz = polytop; + + if (polybottom < myceilingz && abs(delta1) >= abs(delta2)) + myceilingz = polybottom; + } + plink = (polymaplink_t *)(plink->link.next); + } + } + } + } + + // crushed camera + if (myceilingz <= myfloorz + thiscam->height && !resetcalled && !cameranoclip) + { + P_ResetCamera(player, thiscam); + return true; + } + + // camera fit? + if (myceilingz != myfloorz + && myceilingz - thiscam->height < z) + { + z = myceilingz - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); + // is the camera fit is there own sector + } + + // Make the camera a tad smarter with 3d floors + if (newsubsec->sector->ffloors && !cameranoclip) + { + ffloor_t *rover; + + for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + if ((rover->flags & FF_BLOCKOTHERS) && (rover->flags & FF_RENDERALL) && (rover->flags & FF_EXISTS) && GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) + { + topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); + bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); + + if (bottomheight - thiscam->height < z + && midz < bottomheight) + z = bottomheight - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); + + else if (topheight + thiscam->height > z + && midz > topheight) + z = topheight; + + if ((mo->z >= topheight && midz < bottomheight) + || ((mo->z < bottomheight && mo->z+mo->height < topheight) && midz >= topheight)) + { + // Can't see + if (!resetcalled) + P_ResetCamera(player, thiscam); + return true; + } + } + } + } + } + + if (thiscam->z < thiscam->floorz && !cameranoclip) + thiscam->z = thiscam->floorz; + + return false; +} +#endif + boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled) { static boolean lookbackactive[MAXSPLITSCREENPLAYERS]; @@ -3492,10 +3698,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall UINT8 timeover; mobj_t *mo; fixed_t f1, f2; -#ifndef NOCLIPCAM - boolean cameranoclip; - subsector_t *newsubsec; -#endif // We probably shouldn't move the camera if there is no player or player mobj somehow if (!player || !player->mo) @@ -3554,12 +3756,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall mo = player->mo; -#ifndef NOCLIPCAM - cameranoclip = ((player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) - || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)) // Noclipping player camera noclips too!! - || (leveltime < introtime)); // Kart intro cam -#endif - if (player->pflags & PF_TIMEOVER) // 1 for momentum keep, 2 for turnaround timeover = (player->kartstuff[k_timeovercam] > 2*TICRATE ? 2 : 1); else @@ -3745,194 +3941,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall z = mo->z + pviewheight + camheight; #ifndef NOCLIPCAM // Disable all z-clipping for noclip cam - // move camera down to move under lower ceilings - newsubsec = R_IsPointInSubsector(((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1), ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1)); - - if (!newsubsec) - newsubsec = thiscam->subsector; - - if (newsubsec) - { - fixed_t myfloorz, myceilingz; - fixed_t midz = thiscam->z + (thiscam->z - mo->z)/2; - fixed_t midx = ((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1); - fixed_t midy = ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1); - - // Cameras use the heightsec's heights rather then the actual sector heights. - // If you can see through it, why not move the camera through it too? - if (newsubsec->sector->camsec >= 0) - { - myfloorz = sectors[newsubsec->sector->camsec].floorheight; - myceilingz = sectors[newsubsec->sector->camsec].ceilingheight; - } - else if (newsubsec->sector->heightsec >= 0) - { - myfloorz = sectors[newsubsec->sector->heightsec].floorheight; - myceilingz = sectors[newsubsec->sector->heightsec].ceilingheight; - } - else - { - myfloorz = P_CameraGetFloorZ(thiscam, newsubsec->sector, midx, midy, NULL); - myceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, midx, midy, NULL); - } - - // Check list of fake floors and see if floorz/ceilingz need to be altered. - if (newsubsec->sector->ffloors) - { - ffloor_t *rover; - fixed_t delta1, delta2; - INT32 thingtop = midz + thiscam->height; - - for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - continue; - - topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); - bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); - - delta1 = midz - (bottomheight - + ((topheight - bottomheight)/2)); - delta2 = thingtop - (bottomheight - + ((topheight - bottomheight)/2)); - if (topheight > myfloorz && abs(delta1) < abs(delta2)) - myfloorz = topheight; - if (bottomheight < myceilingz && abs(delta1) >= abs(delta2)) - myceilingz = bottomheight; - } - } - - // Check polyobjects and see if floorz/ceilingz need to be altered - { - INT32 xl, xh, yl, yh, bx, by; - validcount++; - - xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - INT32 offset; - polymaplink_t *plink; // haleyjd 02/22/06 - - if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) - continue; - - offset = by*bmapwidth + bx; - - // haleyjd 02/22/06: consider polyobject lines - plink = polyblocklinks[offset]; - - while (plink) - { - polyobj_t *po = plink->po; - - if (po->validcount != validcount) // if polyobj hasn't been checked - { - sector_t *polysec; - fixed_t delta1, delta2, thingtop; - fixed_t polytop, polybottom; - - po->validcount = validcount; - - if (!P_PointInsidePolyobj(po, x, y) || !(po->flags & POF_SOLID)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - if (GETSECSPECIAL(polysec->special, 4) == 12) - { // Camera noclip polyobj. - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - if (po->flags & POF_CLIPPLANES) - { - polytop = polysec->ceilingheight; - polybottom = polysec->floorheight; - } - else - { - polytop = INT32_MAX; - polybottom = INT32_MIN; - } - - thingtop = midz + thiscam->height; - delta1 = midz - (polybottom + ((polytop - polybottom)/2)); - delta2 = thingtop - (polybottom + ((polytop - polybottom)/2)); - - if (polytop > myfloorz && abs(delta1) < abs(delta2)) - myfloorz = polytop; - - if (polybottom < myceilingz && abs(delta1) >= abs(delta2)) - myceilingz = polybottom; - } - plink = (polymaplink_t *)(plink->link.next); - } - } - } - - // crushed camera - if (myceilingz <= myfloorz + thiscam->height && !resetcalled && !cameranoclip) - { - P_ResetCamera(player, thiscam); - return true; - } - - // camera fit? - if (myceilingz != myfloorz - && myceilingz - thiscam->height < z) - { - z = myceilingz - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); - // is the camera fit is there own sector - } - - // Make the camera a tad smarter with 3d floors - if (newsubsec->sector->ffloors && !cameranoclip) - { - ffloor_t *rover; - - for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if ((rover->flags & FF_BLOCKOTHERS) && (rover->flags & FF_RENDERALL) && (rover->flags & FF_EXISTS) && GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - { - topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); - bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, midx, midy, NULL); - - if (bottomheight - thiscam->height < z - && midz < bottomheight) - z = bottomheight - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); - - else if (topheight + thiscam->height > z - && midz > topheight) - z = topheight; - - if ((mo->z >= topheight && midz < bottomheight) - || ((mo->z < bottomheight && mo->z+mo->height < topheight) && midz >= topheight)) - { - // Can't see - if (!resetcalled) - P_ResetCamera(player, thiscam); - return true; - } - } - } - } - } - - if (thiscam->z < thiscam->floorz && !cameranoclip) - thiscam->z = thiscam->floorz; + if (P_CheckNoclipCameraPosition(player, thiscam, x, y, z, resetcalled)) + return true; #endif // NOCLIPCAM // point viewed by the camera From 3388d35fe0ac9801a2f3835d403e142d87a5c70a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 16:40:43 +0100 Subject: [PATCH 34/76] fix encore mirroring not applyingg to freecam/democam --- src/p_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 2bc50d2e0..1919cc007 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3317,6 +3317,9 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) const UINT8 forplayer = num+1; boolean moving = false; + if (encoremode) + players[displayplayers[num]].postimgflags |= POSTIMG_MIRROR; + cam->localangle = cam->angle; cam->localaiming = cam->aiming; From 01b942e1fcecedc1f671abf78197e1bac678bdaf Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 06:47:04 +0100 Subject: [PATCH 35/76] giga shizo spec synch "fix" ok so, for whatever dumb reason, spectatormovement will desynch at random, even on localhost. with this we just literally fucking ignore almost every button input locally and just wont move our spectator player at all. but since we are indeed still runiing specatotr movement code, and this is localcmd shit, the server just thinks we dont want to move and thus is "synchsave". sadly this does not fix desynchs from vanilla players the only code we keep is for button inputs that do certain actions like "item" so we can still join from spec with it and other crap --- src/g_game.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/p_user.c | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 385b7b6cf..59ff420cd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -905,6 +905,46 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) break; } + if (player->spectator) + { + axis = JoyAxis(AXISMOVE, ssplayer); + if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ACCELERATE; + axis = JoyAxis(AXISBRAKE, ssplayer); + if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_BRAKE; + axis = JoyAxis(AXISFIRE, ssplayer); + if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ATTACK; + + // drift with any button/key + axis = JoyAxis(AXISDRIFT, ssplayer); + if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_DRIFT; + + // Lua scriptable buttons + axis = JoyAxis(AXISCUSTOM1, ssplayer); + if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM1; + axis = JoyAxis(AXISCUSTOM2, ssplayer); + if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM2; + axis = JoyAxis(AXISCUSTOM3, ssplayer); + if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM3; + + // Reset camera + if (InputDown(gc_camreset, ssplayer)) + { + if (thiscam->chase && !rd) + P_ResetCamera(player, thiscam); + rd = true; + } + else + rd = false; + return; + } + // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions diff --git a/src/p_user.c b/src/p_user.c index 1919cc007..19a25513b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2109,7 +2109,7 @@ static void P_SpectatorMovement(player_t *player) { ticcmd_t *cmd = &player->cmd; - player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); + player->mo->angle = (angle_t)(cmd->angleturn<<16 /* not FRACBITS */); ticruned++; if (!(cmd->angleturn & TICCMD_RECEIVED)) From 7de32c74e6befb1df1b5efc6262336380e65c7f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 16:44:30 +0100 Subject: [PATCH 36/76] move spectator hack after pause/desynch code this should take priority over everything --- src/g_game.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 59ff420cd..51ce128e8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -905,6 +905,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) break; } + // why build a ticcmd if we're paused? + // Or, for that matter, if we're being reborn. + // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions + if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) + { + cmd->angleturn = (INT16)(lang >> 16); + cmd->aiming = G_ClipAimingPitch(&laim); + return; + } + + // lmfao this is beyond hellish if (player->spectator) { axis = JoyAxis(AXISMOVE, ssplayer); @@ -942,16 +953,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } else rd = false; - return; - } - // why build a ticcmd if we're paused? - // Or, for that matter, if we're being reborn. - // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions - if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) - { - cmd->angleturn = (INT16)(lang >> 16); - cmd->aiming = G_ClipAimingPitch(&laim); return; } From 45237c9298da97046a4e29b313055e645e7fdd93 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 16:54:54 +0100 Subject: [PATCH 37/76] fix unitialised use of controller stuff --- src/g_game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 51ce128e8..5c033e74e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -918,6 +918,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // lmfao this is beyond hellish if (player->spectator) { + usejoystick = (analogjoystickmove || gamepadjoystickmove); + axis = JoyAxis(AXISMOVE, ssplayer); if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ACCELERATE; From 575e46c3db9047b70ed19498b3e1ef2558afd41f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 16:55:20 +0100 Subject: [PATCH 38/76] let playercmd lua hook run during "spectator" input crap lmao --- src/g_game.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 5c033e74e..bfa265030 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -956,6 +956,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else rd = false; + if (gamestate == GS_LEVEL) + LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); + return; } From ba4329e623c2774ba07f3ffe3c049662c53a0b34 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 01:18:30 +0100 Subject: [PATCH 39/76] add another local ticcmd builder so it can guess if we "moved" and put us into freecam state and shit --- src/d_player.h | 2 - src/g_game.c | 108 ++++++++++++++++++++++++++++++++----------------- src/p_mobj.c | 2 - src/p_user.c | 21 ++++------ 4 files changed, 79 insertions(+), 54 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index a34094572..140a4a748 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -538,8 +538,6 @@ typedef struct player_s INT32 awayviewtics; angle_t awayviewaiming; // Used for cut-away view - boolean speccam; - boolean spectator; UINT8 bot; diff --git a/src/g_game.c b/src/g_game.c index bfa265030..7968e1f5f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -850,6 +850,76 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn +// this is absolutely awful +// but we need this if we dont want spectators to move but be able to go to freecam from watching someone +static void G_BuildLocalTiccmd(UINT8 ssplayer) +{ + const UINT8 forplayer = ssplayer-1; + boolean forward, side, axis; //i + boolean usejoystick; + boolean turnleft, turnright; + + ticcmd_t *cmd = D_LocalTiccmd(forplayer); + + const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; + const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; + + usejoystick = (analogjoystickmove || gamepadjoystickmove); + + turnright = InputDown(gc_turnright, ssplayer); + turnleft = InputDown(gc_turnleft, ssplayer); + + axis = JoyAxis(AXISTURN, ssplayer); + + if (gamepadjoystickmove && axis != 0) + { + turnright = turnright || (axis > 0); + turnleft = turnleft || (axis < 0); + } + side = (turnright || turnleft || (analogjoystickmove && axis != 0)); + + forward = false; + axis = JoyAxis(AXISAIM, ssplayer); + if (InputDown(gc_aimforward, ssplayer) || (usejoystick && axis < 0)) + forward = true; + if (InputDown(gc_aimbackward, ssplayer) || (usejoystick && axis > 0)) + forward = true; + + axis = JoyAxis(AXISMOVE, ssplayer); + if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ACCELERATE; + axis = JoyAxis(AXISBRAKE, ssplayer); + if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_BRAKE; + axis = JoyAxis(AXISFIRE, ssplayer); + if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ATTACK; + + // drift with any button/key + axis = JoyAxis(AXISDRIFT, ssplayer); + if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_DRIFT; + + // Lua scriptable buttons + axis = JoyAxis(AXISCUSTOM1, ssplayer); + if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM1; + axis = JoyAxis(AXISCUSTOM2, ssplayer); + if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM2; + axis = JoyAxis(AXISCUSTOM3, ssplayer); + if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_CUSTOM3; + + //Reset away view if a command is given. + if ((forward || side || cmd->buttons) + && displayplayers[0] != consoleplayer && ssplayer == 1) + { + displayplayers[0] = consoleplayer; + G_FixCamera(1); + } +} + void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { const UINT8 forplayer = ssplayer-1; @@ -918,43 +988,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // lmfao this is beyond hellish if (player->spectator) { - usejoystick = (analogjoystickmove || gamepadjoystickmove); - - axis = JoyAxis(AXISMOVE, ssplayer); - if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ACCELERATE; - axis = JoyAxis(AXISBRAKE, ssplayer); - if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_BRAKE; - axis = JoyAxis(AXISFIRE, ssplayer); - if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ATTACK; - - // drift with any button/key - axis = JoyAxis(AXISDRIFT, ssplayer); - if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_DRIFT; - - // Lua scriptable buttons - axis = JoyAxis(AXISCUSTOM1, ssplayer); - if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM1; - axis = JoyAxis(AXISCUSTOM2, ssplayer); - if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM2; - axis = JoyAxis(AXISCUSTOM3, ssplayer); - if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM3; - - // Reset camera - if (InputDown(gc_camreset, ssplayer)) - { - if (thiscam->chase && !rd) - P_ResetCamera(player, thiscam); - rd = true; - } - else - rd = false; + G_BuildLocalTiccmd(ssplayer); if (gamestate == GS_LEVEL) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); diff --git a/src/p_mobj.c b/src/p_mobj.c index 35f0b9883..b46c542a0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10620,7 +10620,6 @@ void P_SpawnPlayer(INT32 playernum) else if (!G_GametypeHasSpectators()) { p->spectator = false; - p->speccam = false; } else if (netgame && p->jointime <= 1 && pcount) { @@ -10655,7 +10654,6 @@ void P_SpawnPlayer(INT32 playernum) else // Otherwise, never spectator. { p->spectator = false; - p->speccam = false; } } diff --git a/src/p_user.c b/src/p_user.c index 19a25513b..6f4b2c471 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2275,9 +2275,9 @@ static void P_MovePlayer(player_t *player) } } + // have to keep this crap for synch reasons if (player->spectator) { - player->speccam = true; P_SpectatorMovement(player); return; } @@ -3366,17 +3366,14 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player - if (demo.playback) + if (cmd->buttons & BT_ATTACK) { - if (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. + lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. - const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); - cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); - cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. - cam->reset_aiming = false; - } + const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + cam->reset_aiming = false; } if (cmd->forwardmove != 0) @@ -3727,7 +3724,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall num = 0; } - if (thiscam->freecam || (player->spectator && player->speccam == true)) + if (thiscam->freecam || player->spectator) { P_DemoCameraMovement(thiscam, num); return true; @@ -4107,7 +4104,6 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; - player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->ctfteam = changeto; @@ -4136,7 +4132,6 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; - player->speccam = false; player->pflags &= ~PF_WANTSTOJOIN; player->kartstuff[k_spectatewait] = 0; player->playerstate = PST_REBORN; From caa09cbcfbcafc539609e69e457bff3a1c04d68e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 07:01:04 +0100 Subject: [PATCH 40/76] try and clean up this mess + fix cam angle being wrong when you switch to freecam from viewing someone --- src/g_game.c | 94 ++++++++++++++++++---------------------------------- 1 file changed, 33 insertions(+), 61 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 7968e1f5f..207513fd7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -834,14 +834,6 @@ boolean InputDown(INT32 gc, UINT8 p) } } -// -// G_BuildTiccmd -// Builds a ticcmd from all of the available inputs -// or reads it from the demo buffer. -// If recording a demo, write it out -// -// set secondaryplayer true to build player 2's ticcmd in splitscreen mode -// INT32 localaiming[MAXSPLITSCREENPLAYERS]; angle_t localangle[MAXSPLITSCREENPLAYERS]; boolean camspin[MAXSPLITSCREENPLAYERS]; @@ -852,79 +844,59 @@ static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // this is absolutely awful // but we need this if we dont want spectators to move but be able to go to freecam from watching someone -static void G_BuildLocalTiccmd(UINT8 ssplayer) +static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) { - const UINT8 forplayer = ssplayer-1; - boolean forward, side, axis; //i - boolean usejoystick; - boolean turnleft, turnright; - - ticcmd_t *cmd = D_LocalTiccmd(forplayer); - - const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; - const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; - - usejoystick = (analogjoystickmove || gamepadjoystickmove); - - turnright = InputDown(gc_turnright, ssplayer); - turnleft = InputDown(gc_turnleft, ssplayer); + boolean forward = false; + INT32 axis = 0; + const UINT8 forplayer = (ssplayer-1); + const boolean usejoystick = (cv_usejoystick[forplayer].value); + boolean turn = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer)); axis = JoyAxis(AXISTURN, ssplayer); + boolean side = (turn || (usejoystick && axis != 0)); - if (gamepadjoystickmove && axis != 0) - { - turnright = turnright || (axis > 0); - turnleft = turnleft || (axis < 0); - } - side = (turnright || turnleft || (analogjoystickmove && axis != 0)); - - forward = false; axis = JoyAxis(AXISAIM, ssplayer); if (InputDown(gc_aimforward, ssplayer) || (usejoystick && axis < 0)) forward = true; if (InputDown(gc_aimbackward, ssplayer) || (usejoystick && axis > 0)) forward = true; - axis = JoyAxis(AXISMOVE, ssplayer); - if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ACCELERATE; - axis = JoyAxis(AXISBRAKE, ssplayer); - if (InputDown(gc_brake, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_BRAKE; - axis = JoyAxis(AXISFIRE, ssplayer); - if (InputDown(gc_fire, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ATTACK; + // check for inputs and return button commands + // for stuff like joining with item button, etc. +#define CHECKINPUT(button, AXIS, buttflag) \ + axis = JoyAxis(AXIS, ssplayer); \ + if (InputDown(button, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= buttflag; - // drift with any button/key - axis = JoyAxis(AXISDRIFT, ssplayer); - if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_DRIFT; + CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); + CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); + CHECKINPUT(gc_fire, AXISFIRE, BT_ATTACK); + CHECKINPUT(gc_drift, AXISDRIFT, BT_DRIFT); + CHECKINPUT(gc_custom1, AXISCUSTOM1, BT_CUSTOM1); + CHECKINPUT(gc_custom2, AXISCUSTOM2, BT_CUSTOM2); + CHECKINPUT(gc_custom3, AXISCUSTOM3, BT_CUSTOM3); - // Lua scriptable buttons - axis = JoyAxis(AXISCUSTOM1, ssplayer); - if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM1; - axis = JoyAxis(AXISCUSTOM2, ssplayer); - if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM2; - axis = JoyAxis(AXISCUSTOM3, ssplayer); - if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) - cmd->buttons |= BT_CUSTOM3; +#undef CHECKINPUT - //Reset away view if a command is given. + // Reset to our spec player if we watch someone else. if ((forward || side || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) { displayplayers[0] = consoleplayer; - G_FixCamera(1); + R_ResetViewInterpolation(0); } } +// +// G_BuildTiccmd +// Builds a ticcmd from all of the available inputs +// or reads it from the demo buffer. +// If recording a demo, write it out +// void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { - const UINT8 forplayer = ssplayer-1; - INT32 laim, th, tspeed, forward, side, axis; //i - const INT32 speed = 1; + const UINT8 forplayer = (ssplayer-1); + INT32 laim, th, tspeed, forward, side, axis; + // these ones used for multiple conditions boolean turnleft, turnright, mouseaiming; boolean invertmouse, usejoystick, kbl, rd; @@ -988,7 +960,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // lmfao this is beyond hellish if (player->spectator) { - G_BuildLocalTiccmd(ssplayer); + G_BuildLocalTiccmd(cmd, ssplayer); if (gamestate == GS_LEVEL) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); @@ -1048,7 +1020,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (th < SLOWTURNTICS) tspeed = cv_turnsmooth.value == 2 ? 2 : 0; // slow turn else - tspeed = speed; + tspeed = 1; cmd->driftturn = 0; From 64a2fe141060f29eb40e85470a684dece9802277 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 07:33:28 +0100 Subject: [PATCH 41/76] clean shit up even more + fix cam aiming reset dont really care about which input anyways. --- src/g_game.c | 17 ++++++----------- src/p_user.c | 9 ++++++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 207513fd7..ad14a83f6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -846,20 +846,14 @@ static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // but we need this if we dont want spectators to move but be able to go to freecam from watching someone static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) { - boolean forward = false; + boolean moveinput = false; INT32 axis = 0; const UINT8 forplayer = (ssplayer-1); const boolean usejoystick = (cv_usejoystick[forplayer].value); - boolean turn = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer)); - axis = JoyAxis(AXISTURN, ssplayer); - boolean side = (turn || (usejoystick && axis != 0)); - - axis = JoyAxis(AXISAIM, ssplayer); - if (InputDown(gc_aimforward, ssplayer) || (usejoystick && axis < 0)) - forward = true; - if (InputDown(gc_aimbackward, ssplayer) || (usejoystick && axis > 0)) - forward = true; + moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) + || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || + (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); // check for inputs and return button commands // for stuff like joining with item button, etc. @@ -878,11 +872,12 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) #undef CHECKINPUT // Reset to our spec player if we watch someone else. - if ((forward || side || cmd->buttons) + if ((moveinput || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) { displayplayers[0] = consoleplayer; R_ResetViewInterpolation(0); + camera[0].reset_aiming = true; } } diff --git a/src/p_user.c b/src/p_user.c index 6f4b2c471..9182001c6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3144,7 +3144,9 @@ void P_ToggleDemoCamera(UINT8 viewnum) // dont let freecam be toggled when in spec lel if (players[displayplayers[viewnum]].spectator) + { return; + } if (!cam->freecam) // toggle on { @@ -3328,13 +3330,14 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // let centerview work proper if (InputDown(gc_centerview, forplayer)) + { cam->aiming = 0; + cam->reset_aiming = false; + } if (cmd->aiming != 0) { cam->aiming = cmd->aiming << FRACBITS; - - cam->reset_aiming = false; } cam->angle = cmd->angleturn << 16; @@ -3366,7 +3369,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player - if (cmd->buttons & BT_ATTACK) + if (cam->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. From 2e1120dc5010f674b39eed9a1b0fe3ae69f094c4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 18:18:20 +0100 Subject: [PATCH 42/76] move postimg flags to camera struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - also dont let water and heat be applied on top of each other since it does not look good (water postimg takes priority over heat) - also save a little time in opengl splitscreen since it does not support heat or wöter effects --- src/d_main.c | 2 +- src/d_player.h | 2 - src/hardware/hw_main.c | 23 ++++-- src/hardware/hw_main.h | 2 +- src/hardware/hw_portal.c | 4 +- src/p_local.h | 3 + src/p_mobj.c | 36 ++++----- src/p_user.c | 158 +++++++++++++++++++++------------------ src/v_video.c | 45 +++++------ src/v_video.h | 2 +- 10 files changed, 151 insertions(+), 126 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index a46ba11c0..dc464b0d6 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -517,7 +517,7 @@ static boolean D_Display(void) for (i = 0; i <= splitscreen; i++) { - V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]); + V_DoPostProcessor(i, postimgparam[i]); } } diff --git a/src/d_player.h b/src/d_player.h index 140a4a748..6ddca1622 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -412,8 +412,6 @@ typedef struct player_s // See pflags_t, above. pflags_t pflags; - UINT16 postimgflags; - // playing animation. panim_t panim; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 638b450a2..7bbad95b3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5133,8 +5133,11 @@ static void HWR_SetTransformAiming(FTransform *trans) trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); } -void HWR_SetTransform(float fpov, player_t *player) +void HWR_SetTransform(float fpov) { + UINT8 viewnum = R_GetViewNumber(); + camera_t *thiscam = &camera[viewnum]; + gl_viewx = FIXED_TO_FLOAT(viewx); gl_viewy = FIXED_TO_FLOAT(viewy); gl_viewz = FIXED_TO_FLOAT(viewz); @@ -5164,15 +5167,15 @@ void HWR_SetTransform(float fpov, player_t *player) atransform.splitscreen = splitscreen; atransform.flip = false; - if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) + if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) atransform.flip = true; atransform.mirror = false; - if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) + if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) atransform.mirror = true; atransform.mirrorflip = false; - if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR)) + if ((thiscam->postimg & POSTIMG_FLIP) && (thiscam->postimg & POSTIMG_MIRROR)) atransform.mirrorflip = true; // Set transform. @@ -5239,7 +5242,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearSprites(); HWR_ClearClipper(); @@ -5296,7 +5299,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_DrawSkyBackground(); HWR_SetStencilState(HWR_STENCIL_NORMAL, 0); GL_ClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer - HWR_SetTransform(fpov, player);// restore transform + HWR_SetTransform(fpov);// restore transform } gl_collect_skywalls = false; @@ -5745,8 +5748,12 @@ static void HWR_DoPostProcessor(player_t *player) if (splitscreen) // Not supported in splitscreen - someone want to add support? return; + //UINT8 viewnum = R_GetViewNumber(); // see above + //camera_t *thiscam = &camera[viewnum]; + camera_t *thiscam = &camera[0]; + // Drunken vision! WooOOooo~ - if (player->postimgflags & POSTIMG_WATER || player->postimgflags & POSTIMG_HEAT) + if (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT) { // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; @@ -5758,7 +5765,7 @@ static void HWR_DoPostProcessor(player_t *player) INT32 FREQUENCY; // Modifies the wave. - if (player->postimgflags & POSTIMG_WATER) + if (thiscam->postimg & POSTIMG_WATER) { WAVELENGTH = 5; AMPLITUDE = 20; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 52616b7e4..07c77ba98 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -108,7 +108,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl void HWR_ClearSkyDome(void); void HWR_BuildSkyDome(void); -void HWR_SetTransform(float fpov, player_t *player); +void HWR_SetTransform(float fpov); void HWR_ClearClipper(void); void HWR_SetStencilState(int state, int level); diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index f26e71331..2109fb851 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -160,7 +160,7 @@ static void HWR_RenderPortalSeg(gl_portal_t* portal, SINT8 state) void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float fpov, player_t *player, int stencil_level) { // draw portal seg to stencil buffer with increment - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearClipper(); HWR_SetStencilState(HWR_STENCIL_BEGIN, stencil_level); @@ -180,7 +180,7 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float } // remove portal seg from stencil buffer - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearClipper(); HWR_SetStencilState(HWR_STENCIL_REVERSE, stencil_level); diff --git a/src/p_local.h b/src/p_local.h index c2a2ee017..452b92dff 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -121,6 +121,9 @@ typedef struct camera_s // SRB2Kart: camera pans while drifting fixed_t pan; + + // postproccess effects + UINT16 postimg; } camera_t; extern camera_t camera[MAXSPLITSCREENPLAYERS]; diff --git a/src/p_mobj.c b/src/p_mobj.c index b46c542a0..5860d2137 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3235,13 +3235,20 @@ void P_DestroyRobots(void) static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); - UINT16 postimgflags = 0; - UINT8 i; + UINT16 postimgtype = 0; if (encoremode) - postimgflags |= POSTIMG_MIRROR; + postimgtype |= POSTIMG_MIRROR; if (flipcam) - postimgflags |= POSTIMG_FLIP; + postimgtype |= POSTIMG_FLIP; + +#ifdef HWRENDER + if (rendermode == render_opengl && splitscreen) + { + thiscam->postimg = postimgtype; + return; + } +#endif if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { @@ -3256,27 +3263,20 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) // Are we in water? if (P_CameraCheckWater(&dummycam)) - postimgflags |= POSTIMG_WATER; - if (P_CameraCheckHeat(&dummycam)) - postimgflags |= POSTIMG_HEAT; + postimgtype |= POSTIMG_WATER; + else if (P_CameraCheckHeat(&dummycam)) + postimgtype |= POSTIMG_HEAT; } else { // Are we in water? if (P_CameraCheckWater(thiscam)) - postimgflags |= POSTIMG_WATER; - if (P_CameraCheckHeat(thiscam)) - postimgflags |= POSTIMG_HEAT; + postimgtype |= POSTIMG_WATER; + else if (P_CameraCheckHeat(thiscam)) + postimgtype |= POSTIMG_HEAT; } - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; - - players[displayplayers[i]].postimgflags = postimgflags; - break; - } + thiscam->postimg = postimgtype; } // P_CameraThinker diff --git a/src/p_user.c b/src/p_user.c index 9182001c6..c6fac5c8d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3320,7 +3320,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) boolean moving = false; if (encoremode) - players[displayplayers[num]].postimgflags |= POSTIMG_MIRROR; + cam->postimg |= POSTIMG_MIRROR; cam->localangle = cam->angle; cam->localaiming = cam->aiming; @@ -4152,26 +4152,66 @@ boolean P_SpectatorJoinGame(player_t *player) return false; } -// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam -static void P_CalcPostImg(player_t *player) +static boolean P_CameraCheckHeatFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight) { - sector_t *sector = player->mo->subsector->sector; - INT16 typeflag = 0; - //INT32 *param; - fixed_t pviewheight; - UINT8 i; + if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) + return true; - if (player->mo->eflags & MFE_VERTICALFLIP) - pviewheight = player->mo->z + player->mo->height - player->viewheight; - else - pviewheight = player->mo->z + player->viewheight; - - if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) + if (sector->ffloors) { - sector = player->awayviewmobj->subsector->sector; - pviewheight = player->awayviewmobj->z + 20*FRACUNIT; + ffloor_t *rover; + + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) + return true; + } } + return false; +} + +static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight) +{ + if (sector->ffloors) + { + ffloor_t *rover; + + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER) + continue; + + if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y)) + continue; + + return true; + } + } + + return false; +} + +// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam +static void P_CalcPostImg(player_t *player, camera_t *thiscam) +{ + sector_t *sector = NULL; + INT16 postimgtype = 0; + //INT32 *param; + fixed_t pviewheight = 0; + /*for (i = 0; i <= splitscreen; i++) { if (player == &players[displayplayers[i]]) @@ -4181,79 +4221,55 @@ static void P_CalcPostImg(player_t *player) } }*/ - // see if we are in heat (no, not THAT kind of heat...) + if (encoremode) // srb2kart + postimgtype |= POSTIMG_MIRROR; - if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) - typeflag |= POSTIMG_HEAT; - else if (sector->ffloors) + if (player->mo->eflags & MFE_VERTICALFLIP) + postimgtype |= POSTIMG_FLIP; + +#ifdef HWRENDER + if (rendermode == render_opengl && splitscreen) { - ffloor_t *rover; - fixed_t topheight; - fixed_t bottomheight; + thiscam->postimg = postimgtype; + return; + } +#endif - for (rover = sector->ffloors; rover; rover = rover->next) + sector = player->mo->subsector->sector; + + if (sector->ffloors) + { + if (player->mo->eflags & MFE_VERTICALFLIP) + pviewheight = player->mo->z + player->mo->height - player->viewheight; + else + pviewheight = player->mo->z + player->viewheight; + + if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) { - if (!(rover->flags & FF_EXISTS)) - continue; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - if (pviewheight >= topheight || pviewheight <= bottomheight) - continue; - - if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) - typeflag |= POSTIMG_HEAT; + sector = player->awayviewmobj->subsector->sector; + pviewheight = player->awayviewmobj->z + 20*FRACUNIT; } } // see if we are in water (water trumps heat) - if (sector->ffloors) - { - ffloor_t *rover; - fixed_t topheight; - fixed_t bottomheight; - - for (rover = sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER) - continue; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - if (pviewheight >= topheight || pviewheight <= bottomheight) - continue; - - typeflag |= POSTIMG_WATER; - } - } - - if (encoremode) // srb2kart - typeflag |= POSTIMG_MIRROR; - - if (player->mo->eflags & MFE_VERTICALFLIP) - typeflag |= POSTIMG_FLIP; + if (P_CameraCheckWaterFirstperson(player, sector, pviewheight)) + postimgtype |= POSTIMG_WATER; + // see if we are in heat (no, not THAT kind of heat...) + else if (P_CameraCheckHeatFirstperson(player, sector, pviewheight)) + postimgtype |= POSTIMG_HEAT; // Motion blur // unused /*if (player->speed > (35<speed - 32)/4; if (*param > 5) *param = 5; }*/ - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; - - players[displayplayers[i]].postimgflags = typeflag; - break; - } + thiscam->postimg = postimgtype; } void P_DoTimeOver(player_t *player) @@ -5038,7 +5054,7 @@ void P_PlayerAfterThink(player_t *player) if (!thiscam->chase) // bob view only if looking through the player's eyes { P_CalcHeight(player); - P_CalcPostImg(player); + P_CalcPostImg(player, thiscam); } else { diff --git a/src/v_video.c b/src/v_video.c index 987a40a03..da2b0677a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3175,7 +3175,7 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; // Perform a particular image postprocessing function. // -void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) +void V_DoPostProcessor(INT32 view, INT32 param) { #if NUMSCREENS < 5 // do not enable image post processing for ARM, SH and MIPS CPUs @@ -3194,7 +3194,9 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) if (view < 0 || view > 3 || view > splitscreen) return; - if (!player->postimgflags) + camera_t *thiscam = &camera[view]; + + if (!thiscam->postimg) return; if ((view == 1 && splitscreen == 1) || view >= 2) @@ -3210,7 +3212,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) UINT8 *tmpscr = screens[4]; UINT8 *srcscr = screens[0]; - if (player->postimgflags & POSTIMG_WATER) + if (thiscam->postimg & POSTIMG_WATER) { INT32 y; // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic @@ -3269,22 +3271,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - - /*if (player->postimgflags & POSTIMG_MOTION) // Motion Blur! - { - INT32 x, y; - - // TODO: Add a postimg_param so that we can pick the translucency level... - UINT8 *transme = transtables + ((param-1)<postimgflags & POSTIMG_HEAT) // Heat wave + else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave { INT32 y; @@ -3331,7 +3318,21 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) srcscr = tmp; } - if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) // Flip the screen upside-down + /*if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! + { + INT32 x, y; + + // TODO: Add a postimg_param so that we can pick the translucency level... + UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down { INT32 y, y2; @@ -3342,7 +3343,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - else if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) // Flip the screen on the x axis + else if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) // Flip the screen on the x axis { INT32 y, x, x2; @@ -3354,7 +3355,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - else if ((player->postimgflags & POSTIMG_MIRROR) && (player->postimgflags & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis + else if ((thiscam->postimg & POSTIMG_MIRROR) && (thiscam->postimg & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis { INT32 y, x; diff --git a/src/v_video.h b/src/v_video.h index dfab7dfde..2513825c2 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -256,7 +256,7 @@ char V_GetSkincolorChar(INT32 color); typedef struct player_s player_t; -void V_DoPostProcessor(INT32 view, player_t *player, INT32 param); +void V_DoPostProcessor(INT32 view, INT32 param); void V_DrawPatchFill(patch_t *pat); From 7d47834e55d6295056415537556721dc9ec6a953 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 18:29:21 +0100 Subject: [PATCH 43/76] oops smol error --- src/p_user.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index c6fac5c8d..e7f8ea009 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4237,18 +4237,15 @@ static void P_CalcPostImg(player_t *player, camera_t *thiscam) sector = player->mo->subsector->sector; - if (sector->ffloors) - { - if (player->mo->eflags & MFE_VERTICALFLIP) - pviewheight = player->mo->z + player->mo->height - player->viewheight; - else - pviewheight = player->mo->z + player->viewheight; + if (player->mo->eflags & MFE_VERTICALFLIP) + pviewheight = player->mo->z + player->mo->height - player->viewheight; + else + pviewheight = player->mo->z + player->viewheight; - if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) - { - sector = player->awayviewmobj->subsector->sector; - pviewheight = player->awayviewmobj->z + 20*FRACUNIT; - } + if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) + { + sector = player->awayviewmobj->subsector->sector; + pviewheight = player->awayviewmobj->z + 20*FRACUNIT; } // see if we are in water (water trumps heat) From f9b107153964876844702aa9281109c1533be5f6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jan 2025 19:35:29 +0100 Subject: [PATCH 44/76] simplify this --- src/g_game.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ad14a83f6..2dae7dfbf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -848,8 +848,7 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) { boolean moveinput = false; INT32 axis = 0; - const UINT8 forplayer = (ssplayer-1); - const boolean usejoystick = (cv_usejoystick[forplayer].value); + const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value); moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || @@ -914,8 +913,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else player = &players[displayplayers[forplayer]]; - if (ssplayer == 2) - thiscam = (player->bot == 2 ? &camera[0] : &camera[forplayer]); + if ((ssplayer == 2) && (player->bot == 2)) + thiscam = &camera[0]; else thiscam = &camera[forplayer]; From 8cb7396f33cff00000e0236f10f136096ea22f4d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 01:53:44 +0100 Subject: [PATCH 45/76] check for consoleplayer since displayplayer is who youre watching --- src/p_user.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index e7f8ea009..03cf054d9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3142,9 +3142,11 @@ void P_ToggleDemoCamera(UINT8 viewnum) { camera_t *cam = &camera[viewnum]; - // dont let freecam be toggled when in spec lel - if (players[displayplayers[viewnum]].spectator) + // dont toggle freecam when in spec + // special case since only non splitscreen can change viewpoints + if ((!splitscreen && players[consoleplayer].spectator) || players[displayplayers[viewnum]].spectator) { + cam->freecam = false; return; } From 338bcf0d2d8e38c21d68c650be6ac065a1bc17f3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 01:54:32 +0100 Subject: [PATCH 46/76] forgor about lookback ig --- src/g_game.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 2dae7dfbf..cd96729fc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -870,6 +870,9 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) #undef CHECKINPUT + axis = JoyAxis(AXISLOOKBACK, ssplayer); + camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); + // Reset to our spec player if we watch someone else. if ((moveinput || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) From f512a080513669e15e36dc5c00122f87a102e643 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 19:33:43 +0100 Subject: [PATCH 47/76] dont do this while not in replay this is kinda awkward tbh, but its useful for replay stuff --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 03cf054d9..e5c1c86b2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3370,8 +3370,8 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") - // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player - if (cam->freecam && cmd->buttons & BT_ATTACK) + // this feels kinda pointless for ingame freecam so keep it for replays only + if (demo.playback && 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. From 2f4a113685bea06fbe512bd4dd0a757f15e7715b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 19:37:52 +0100 Subject: [PATCH 48/76] more hAx: dont move player during freecam state besides hop and honk useful if you wanna take pics and dont feel like driving away --- src/g_game.c | 38 +++++++++++++++++++++++++------------- src/p_user.c | 11 +++++++---- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index cd96729fc..861c09497 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -842,34 +842,45 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn -// this is absolutely awful -// but we need this if we dont want spectators to move but be able to go to freecam from watching someone -static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) +// +// G_BuildLocalTiccmd +// extremely basic cut down ticcmd builder +// for spectator and freecam +// this does not make the player move at all but keeps important things working +// +static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) { boolean moveinput = false; INT32 axis = 0; const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value); - moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) - || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || - (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); - // check for inputs and return button commands - // for stuff like joining with item button, etc. + // for stuff like joining with item button, saltyhop, honking, etc. #define CHECKINPUT(button, AXIS, buttflag) \ axis = JoyAxis(AXIS, ssplayer); \ if (InputDown(button, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= buttflag; - CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); - CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); CHECKINPUT(gc_fire, AXISFIRE, BT_ATTACK); CHECKINPUT(gc_drift, AXISDRIFT, BT_DRIFT); CHECKINPUT(gc_custom1, AXISCUSTOM1, BT_CUSTOM1); CHECKINPUT(gc_custom2, AXISCUSTOM2, BT_CUSTOM2); CHECKINPUT(gc_custom3, AXISCUSTOM3, BT_CUSTOM3); + // we dont need the rest of this if were in freecam state + if (freecam) + { + return; + } + + CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); + CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); + #undef CHECKINPUT + moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) + || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || + (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); + axis = JoyAxis(AXISLOOKBACK, ssplayer); camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); @@ -954,11 +965,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - // lmfao this is beyond hellish - if (player->spectator) + // dumbass thing so we can use a few buttons but dont accidentally drive away + if (player->spectator || camera[forplayer].freecam) { - G_BuildLocalTiccmd(cmd, ssplayer); + G_BuildLocalTiccmd(cmd, ssplayer, !player->spectator); + // let lua override everything if (gamestate == GS_LEVEL) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); diff --git a/src/p_user.c b/src/p_user.c index e5c1c86b2..ca2616461 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3155,6 +3155,12 @@ void P_ToggleDemoCamera(UINT8 viewnum) cam->freecam = true; cam->button_a_held = 2; cam->reset_aiming = true; + + // get rid of some hud elements + if (displayplayers[0] != consoleplayer) + { + displayplayers[0] = consoleplayer; + } } else // toggle off { @@ -3255,13 +3261,10 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_aimbackward, forplayer) || (usejoystick && axis > 0)) forward -= forwardmove[1]; - // fire with any button/key axis = JoyAxis(AXISFIRE, forplayer); - if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) + if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; - // spectator aiming shit, ahhhh... - // looking up/down laim += (mlooky<<19); From 5c8b318a937c2cc1f2c74a2b8278a1d3ba3bbaa7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 21:03:22 +0100 Subject: [PATCH 49/76] make float and sink use accel and brake again but also keep rebindable controls keeps intended behaviour since we now dont need to worry about player controls anymore but keeps the rebindable buttons incase someone wants to do a crazy control setup for some reason --- src/g_input.c | 6 ------ src/p_user.c | 10 +++++++++- src/st_stuff.c | 26 ++++++++++++++------------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index b99874b8d..c948ed751 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1142,12 +1142,6 @@ void G_Controldefault(UINT8 player) //gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up - - gamecontrol[gc_camfloat ][0] = 'a'; - gamecontrol[gc_camsink ][0] = 'd'; - - gamecontrol[gc_camfloat ][1] = KEY_JOY1+0; // A - gamecontrol[gc_camsink ][1] = KEY_JOY1+1; // B } if (player == 0 || player == 2) diff --git a/src/p_user.c b/src/p_user.c index 45889d327..a2b6b01c8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3261,6 +3261,14 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; + // float and sink + axis = JoyAxis(AXISMOVE, forplayer); + if (InputDown(gc_accelerate, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ACCELERATE; + axis = JoyAxis(AXISBRAKE, forplayer); + if (InputDown(gc_brake, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_BRAKE; + // looking up/down laim += (mlooky<<19); @@ -3347,7 +3355,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (!cam->button_a_held) { fixed_t spd = 32*mapobjectscale*cv_freecam_speed.value; - int dir = ((InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((InputDown(gc_camsink, forplayer)) ? -1 : 0); + int dir = ((cmd->buttons & BT_ACCELERATE || InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((cmd->buttons & BT_BRAKE || InputDown(gc_camsink, forplayer)) ? -1 : 0); switch (dir) { diff --git a/src/st_stuff.c b/src/st_stuff.c index 6f0777919..527d7af76 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -651,16 +651,18 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } -static const char *ST_GetButtonName(INT32 control, const char *inputtext) +// returns the actual button name for any gamecontrol +// if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol +static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound) { - static char buttname[32] = {0}; // Static buffer - const char *item1 = gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL; - const char *item2 = gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL; + static char buttname[32] = {0}; + const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); + const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind - if (item1 != NULL && item2 != NULL) - snprintf(buttname, 32, "%s/%s - %s", item1, item2, inputtext); + if (butt1 != NULL && butt2 != NULL) + snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); else - snprintf(buttname, 32, "%s - %s", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound", inputtext); + snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : unbound ? "Unbound" : ""), inputtext); return buttname; } @@ -789,16 +791,16 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director")); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true)); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camfloat, "Float")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_camsink, "Sink")); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); } } } From e53c6bb4da0507a324ba367df41dd814c3878a83 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 21:54:45 +0100 Subject: [PATCH 50/76] reduce ternary hell a little lel --- src/st_stuff.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 527d7af76..523bbc44a 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -655,14 +655,16 @@ static void ST_drawLevelTitle(void) // if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound) { - static char buttname[32] = {0}; + static char buttname[32] = ""; const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind - if (butt1 != NULL && butt2 != NULL) + if (butt1 == NULL && butt2 == NULL) // not bound to a button + snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (unbound ? "Unbound" : ""), inputtext); + else if (butt1 != NULL && butt2 != NULL) // bound to two buttons snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); - else - snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : unbound ? "Unbound" : ""), inputtext); + else // bound to only one + snprintf(buttname, 32, "- %s - %s", (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); return buttname; } From 077076532f3f701562d91a97dfcc84817749b299 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 14:17:44 +0100 Subject: [PATCH 51/76] slight cleanup buildticcmd --- src/g_game.c | 64 ++++------ src/p_maputl.c | 335 ++++++++++++++++++++++++++----------------------- 2 files changed, 201 insertions(+), 198 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index e76d0ef5f..00d3f861b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -898,36 +898,30 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) // void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { - const UINT8 forplayer = (ssplayer-1); INT32 laim, th, tspeed, forward, side, axis; // these ones used for multiple conditions boolean turnleft, turnright, mouseaiming; boolean invertmouse, usejoystick, kbl, rd; - player_t *player; - camera_t *thiscam; angle_t lang; static INT32 turnheld[MAXSPLITSCREENPLAYERS]; // for accelerative turning static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame + if (demo.playback) + return; + + const UINT8 forplayer = (ssplayer-1); + player_t *player = ((ssplayer == 1) ? &players[consoleplayer] : &players[displayplayers[forplayer]]); + + camera_t *thiscam = &camera[forplayer]; + const boolean freecam = camera[forplayer].freecam; + const boolean lookaxis = cv_lookaxis[forplayer].value; const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; - if (demo.playback) return; - - if (ssplayer == 1) - player = &players[consoleplayer]; - else - player = &players[displayplayers[forplayer]]; - - if ((ssplayer == 2) && (player->bot == 2)) - thiscam = &camera[0]; - else - thiscam = &camera[forplayer]; - lang = localangle[forplayer]; laim = localaiming[forplayer]; th = turnheld[forplayer]; @@ -938,16 +932,23 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { case 2: G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + mouseaiming = player->spectator; + invertmouse = cv_invertmouse2.value; break; case 3: G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + mouseaiming = false; + invertmouse = false; break; case 4: G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + mouseaiming = false; + invertmouse = false; break; case 1: - default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + mouseaiming = player->spectator; + invertmouse = cv_invertmouse.value; break; } @@ -962,9 +963,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } // dumbass thing so we can use a few buttons but dont accidentally drive away - if (player->spectator || camera[forplayer].freecam) + if (player->spectator || freecam) { - G_BuildLocalTiccmd(cmd, ssplayer, !player->spectator); + G_BuildLocalTiccmd(cmd, ssplayer, freecam); // let lua override everything if (gamestate == GS_LEVEL) @@ -973,27 +974,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - switch (ssplayer) - { - case 2: - mouseaiming = player->spectator; //(PLAYER2INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook2.value; - invertmouse = cv_invertmouse2.value; - break; - case 3: - mouseaiming = false; - invertmouse = false; - break; - case 4: - mouseaiming = false; - invertmouse = false; - break; - case 1: - default: - mouseaiming = player->spectator; //(PLAYER1INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook.value; - invertmouse = cv_invertmouse.value; - break; - } - usejoystick = (analogjoystickmove || gamepadjoystickmove); turnright = InputDown(gc_turnright, ssplayer); turnleft = InputDown(gc_turnleft, ssplayer); @@ -1145,7 +1125,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) INT32 player_invert = invertmouse ? -1 : 1; INT32 screen_invert = (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!thiscam->chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted + && (!thiscam->chase || player->pflags & PF_FLIPCAM)) // because chasecam's not inverted ? -1 : 1; // set to -1 or 1 to multiply // mouse look stuff (mouse look is not the same as mouse aim) @@ -1260,8 +1240,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); //Reset away view if a command is given. - if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && displayplayers[0] != consoleplayer && ssplayer == 1) + if (displayplayers[0] != consoleplayer && ssplayer == 1 + && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { displayplayers[0] = consoleplayer; G_FixCamera(1); diff --git a/src/p_maputl.c b/src/p_maputl.c index 3c91dc922..13dd85592 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -296,7 +296,7 @@ void P_CameraLineOpening(line_t *linedef) { frontfloor = sectors[front->camsec].floorheight; frontceiling = sectors[front->camsec].ceilingheight; - if (sectors[front->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[front->camsec].f_slope) frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera[0].x, camera[0].y); if (sectors[front->camsec].c_slope) frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera[0].x, camera[0].y); @@ -306,7 +306,7 @@ void P_CameraLineOpening(line_t *linedef) { frontfloor = sectors[front->heightsec].floorheight; frontceiling = sectors[front->heightsec].ceilingheight; - if (sectors[front->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[front->heightsec].f_slope) frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera[0].x, camera[0].y); if (sectors[front->heightsec].c_slope) frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera[0].x, camera[0].y); @@ -316,11 +316,12 @@ void P_CameraLineOpening(line_t *linedef) frontfloor = P_CameraGetFloorZ(mapcampointer, front, tmx, tmy, linedef); frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tmx, tmy, linedef); } + if (back->camsec >= 0) { backfloor = sectors[back->camsec].floorheight; backceiling = sectors[back->camsec].ceilingheight; - if (sectors[back->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[back->camsec].f_slope) frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera[0].x, camera[0].y); if (sectors[back->camsec].c_slope) frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera[0].x, camera[0].y); @@ -329,7 +330,7 @@ void P_CameraLineOpening(line_t *linedef) { backfloor = sectors[back->heightsec].floorheight; backceiling = sectors[back->heightsec].ceilingheight; - if (sectors[back->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + if (sectors[back->heightsec].f_slope) frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera[0].x, camera[0].y); if (sectors[back->heightsec].c_slope) frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera[0].x, camera[0].y); @@ -340,104 +341,111 @@ void P_CameraLineOpening(line_t *linedef) backceiling = P_CameraGetCeilingZ(mapcampointer, back, tmx, tmy, linedef); } + fixed_t thingtop = mapcampointer->z + mapcampointer->height; + + if (frontceiling < backceiling) { - fixed_t thingtop = mapcampointer->z + mapcampointer->height; - - if (frontceiling < backceiling) - { - opentop = frontceiling; - highceiling = backceiling; - } - else - { - opentop = backceiling; - highceiling = frontceiling; - } - - if (frontfloor > backfloor) - { - openbottom = frontfloor; - lowfloor = backfloor; - } - else - { - openbottom = backfloor; - lowfloor = frontfloor; - } - - // Check for fake floors in the sector. - if (front->ffloors || back->ffloors) - { - ffloor_t *rover; - fixed_t highestceiling = highceiling; - fixed_t lowestceiling = opentop; - fixed_t highestfloor = openbottom; - fixed_t lowestfloor = lowfloor; - fixed_t delta1, delta2; - - // Check for frontsector's fake floors - if (front->ffloors) - for (rover = front->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; - - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; - } - - // Check for backsectors fake floors - if (back->ffloors) - for (rover = back->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; - - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; - } - - if (highestceiling < highceiling) - highceiling = highestceiling; - - if (highestfloor > openbottom) - openbottom = highestfloor; - - if (lowestceiling < opentop) - opentop = lowestceiling; - - if (lowestfloor > lowfloor) - lowfloor = lowestfloor; - } - openrange = opentop - openbottom; - return; + opentop = frontceiling; + highceiling = backceiling; } + else + { + opentop = backceiling; + highceiling = frontceiling; + } + + if (frontfloor > backfloor) + { + openbottom = frontfloor; + lowfloor = backfloor; + } + else + { + openbottom = backfloor; + lowfloor = frontfloor; + } + + // Check for fake floors in the sector. + if (front->ffloors || back->ffloors) + { + ffloor_t *rover; + fixed_t highestceiling = highceiling; + fixed_t lowestceiling = opentop; + fixed_t highestfloor = openbottom; + fixed_t lowestfloor = lowfloor; + fixed_t delta1, delta2; + + // Check for frontsector's fake floors + if (front->ffloors) + { + for (rover = front->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + + if (bottomheight < lowestceiling && delta1 >= delta2) + lowestceiling = bottomheight; + else if (bottomheight < highestceiling && delta1 >= delta2) + highestceiling = bottomheight; + + if (topheight > highestfloor && delta1 < delta2) + highestfloor = topheight; + else if (topheight > lowestfloor && delta1 < delta2) + lowestfloor = topheight; + } + } + + // Check for backsectors fake floors + if (back->ffloors) + { + for (rover = back->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + + if (bottomheight < lowestceiling && delta1 >= delta2) + lowestceiling = bottomheight; + else if (bottomheight < highestceiling && delta1 >= delta2) + highestceiling = bottomheight; + + if (topheight > highestfloor && delta1 < delta2) + highestfloor = topheight; + else if (topheight > lowestfloor && delta1 < delta2) + lowestfloor = topheight; + } + } + + if (highestceiling < highceiling) + highceiling = highestceiling; + + if (highestfloor > openbottom) + openbottom = highestfloor; + + if (lowestceiling < opentop) + opentop = lowestceiling; + + if (lowestfloor > lowfloor) + lowfloor = lowestfloor; + } + + openrange = opentop - openbottom; + return; } void P_LineOpening(line_t *linedef, mobj_t *mobj) @@ -466,40 +474,39 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(front != NULL); I_Assert(back != NULL); - { // Set open and high/low values here - fixed_t frontheight, backheight; + // Set open and high/low values here + fixed_t frontheight, backheight; - frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - if (frontheight < backheight) - { - opentop = frontheight; - highceiling = backheight; - opentopslope = front->c_slope; - } - else - { - opentop = backheight; - highceiling = frontheight; - opentopslope = back->c_slope; - } + if (frontheight < backheight) + { + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; + } - frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - if (frontheight > backheight) - { - openbottom = frontheight; - lowfloor = backheight; - openbottomslope = front->f_slope; - } - else - { - openbottom = backheight; - lowfloor = frontheight; - openbottomslope = back->f_slope; - } + if (frontheight > backheight) + { + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; + } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; } if (mobj) @@ -508,29 +515,33 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Check for collision with front side's midtexture if Effect 4 is set if (linedef->flags & ML_EFFECT4 - && !linedef->polyobj // don't do anything for polyobjects! ...for now - ) { + && !linedef->polyobj) // don't do anything for polyobjects! ...for now + { side_t *side = &sides[linedef->sidenum[0]]; fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - if (texnum) { + if (texnum) + { // Get the midtexture's height texheight = textures[texnum]->height << FRACBITS; // Set texbottom and textop to the Z coordinates of the texture's boundaries + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) // "infinite" repeat { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } + texbottom = openbottom + side->rowoffset; + textop = opentop + side->rowoffset; + } + else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + { + texbottom = openbottom + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } + else + { + textop = opentop + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); } texmid = texbottom+(textop-texbottom)/2; @@ -538,10 +549,13 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - texmid); delta2 = abs(thingtop - texmid); - if (delta1 > delta2) { // Below + if (delta1 > delta2) // Below + { if (opentop > texbottom) opentop = texbottom; - } else { // Above + } + else // Above + { if (openbottom < textop) openbottom = textop; } @@ -549,9 +563,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) } // Check for fake floors in the sector. - if (front->ffloors || back->ffloors - || linedef->polyobj - ) + if (front->ffloors || back->ffloors || linedef->polyobj) { ffloor_t *rover; @@ -567,6 +579,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) for (rover = front->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) continue; @@ -584,7 +597,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { + if (bottomheight < lowestceiling) + { lowestceiling = bottomheight; ceilingslope = *rover->b_slope; } @@ -594,7 +608,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { + if (topheight > highestfloor) + { highestfloor = topheight; floorslope = *rover->t_slope; } @@ -624,7 +639,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { + if (bottomheight < lowestceiling) + { lowestceiling = bottomheight; ceilingslope = *rover->b_slope; } @@ -634,7 +650,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { + if (topheight > highestfloor) + { highestfloor = topheight; floorslope = *rover->t_slope; } @@ -650,29 +667,35 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - if (polysec->floorheight < lowestceiling && delta1 >= delta2) { + + if (polysec->floorheight < lowestceiling && delta1 >= delta2) + { lowestceiling = polysec->floorheight; ceilingslope = NULL; } else if (polysec->floorheight < highestceiling && delta1 >= delta2) highestceiling = polysec->floorheight; - if (polysec->ceilingheight > highestfloor && delta1 < delta2) { + if (polysec->ceilingheight > highestfloor && delta1 < delta2) + { highestfloor = polysec->ceilingheight; floorslope = NULL; } else if (polysec->ceilingheight > lowestfloor && delta1 < delta2) lowestfloor = polysec->ceilingheight; } + if (highestceiling < highceiling) highceiling = highestceiling; - if (highestfloor > openbottom) { + if (highestfloor > openbottom) + { openbottom = highestfloor; openbottomslope = floorslope; } - if (lowestceiling < opentop) { + if (lowestceiling < opentop) + { opentop = lowestceiling; opentopslope = ceilingslope; } From a90c51ec0fb182892edf5dbeff268de284f4ce2a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 14:51:32 +0100 Subject: [PATCH 52/76] no u may be used uninitialised --- src/g_game.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_game.c b/src/g_game.c index 00d3f861b..47b975b92 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -946,6 +946,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) invertmouse = false; break; case 1: + default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver mouseaiming = player->spectator; invertmouse = cv_invertmouse.value; From 1d8be20962a528966c641c8c87cea10adb2ef807 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 19:01:54 +0100 Subject: [PATCH 53/76] disable director while in replay freecam --- src/k_director.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index 611c64701..eca7903f5 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -73,7 +73,7 @@ boolean K_DirectorIsAvailable(void) { if ((demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && (demo.playback || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); + return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); } static boolean K_DirectorIsEnabled(void) From c4c995a9a35c8fba364c067d822a249b87f0d029 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 20:37:39 +0100 Subject: [PATCH 54/76] disable pause vhs effect when in freecam mode --- src/hu_stuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6cbb46148..7097e36a2 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -26,6 +26,7 @@ #include "i_video.h" #include "i_system.h" +#include "r_fps.h" #include "st_stuff.h" // ST_HEIGHT #include "r_local.h" @@ -2231,7 +2232,7 @@ void HU_DrawSongCredits(void) // void HU_Drawer(void) { - if (cv_vhseffect.value && (paused || (demo.playback && cv_playbackspeed.value > 1))) + if (cv_vhseffect.value && ((paused && !camera[R_GetViewNumber()].freecam) || (demo.playback && cv_playbackspeed.value > 1))) V_DrawVhsEffect(demo.rewinding); #ifndef NONET From 03259aeca0876c392875a2c780ea56bdb8717620 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 22:02:34 +0100 Subject: [PATCH 55/76] let postimg stuff also apply to freecam --- src/p_local.h | 1 + src/p_mobj.c | 2 +- src/p_user.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_local.h b/src/p_local.h index 452b92dff..d330c8c34 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -156,6 +156,7 @@ void P_SlideCameraMove(camera_t *thiscam); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); void P_ToggleDemoCamera(UINT8 viewnum); +void P_CalcChasePostImg(player_t *player, camera_t *thiscam); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index e69e9192b..46fb35f65 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3232,7 +3232,7 @@ void P_DestroyRobots(void) } // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person -static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) +void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); UINT16 postimgtype = 0; diff --git a/src/p_user.c b/src/p_user.c index a2b6b01c8..13750c594 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3739,6 +3739,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->freecam || player->spectator) { P_DemoCameraMovement(thiscam, num); + P_CalcChasePostImg(player, thiscam); return true; } From eff6b31ee8a40d03cae83f15784960545b75e7d8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 22:40:36 +0100 Subject: [PATCH 56/76] change director toggling handling - now not changable over console anymore, bind only! - it doesent save anymore so its always disabled at game start - moving while in spec state will disable director when active so stand still - disable it in splitscreen completely - only adjust view when toggling it on --- src/d_netcmd.c | 3 ++- src/g_game.c | 17 +++++------------ src/g_game.h | 2 -- src/k_director.c | 5 ++--- src/st_stuff.c | 3 +++ src/st_stuff.h | 2 ++ 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5156ed0c5..9b293aef6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -572,7 +572,8 @@ static CV_PossibleValue_t ps_descriptor_cons_t[] = { {1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}}; consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +// only there to better keep track of it globally +consvar_t cv_director = {"director", "Off", CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showdirectorhud = {"showdirectorhud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/g_game.c b/src/g_game.c index 47b975b92..1bcd9778c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -334,11 +334,6 @@ boolean precache = true; // if true, load all graphics at start INT16 prevmap, nextmap; -// save if director is enabled -// so demos can disable it by default and restore it after -static int directorstate = 0; -tic_t directortoggletimer = 0; - static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -884,6 +879,9 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) if ((moveinput || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) { + if (cv_director.value) + CV_SetValue(&cv_director, 0); + displayplayers[0] = consoleplayer; R_ResetViewInterpolation(0); camera[0].reset_aiming = true; @@ -7359,8 +7357,8 @@ post_compat: players[i].kartweight = kartweight[i]; } - directorstate = cv_director.value; - CV_SetValue(&cv_director, 0); + if (cv_director.value) + CV_SetValue(&cv_director, 0); demo.deferstart = true; } @@ -7925,11 +7923,6 @@ void G_StopDemo(void) { Z_Free(demobuf.buffer); demobuf.buffer = NULL; - if (demo.playback) - { - CV_SetValue(&cv_director, directorstate); - directorstate = 0; - } demo.playback = false; if (demo.title) modeattacking = false; diff --git a/src/g_game.h b/src/g_game.h index ba26cd507..10c2a6156 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -229,8 +229,6 @@ extern angle_t localangle[MAXSPLITSCREENPLAYERS]; extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but signed extern boolean camspin[MAXSPLITSCREENPLAYERS]; // SRB2Kart -extern tic_t directortoggletimer; - // // GAME // diff --git a/src/k_director.c b/src/k_director.c index eca7903f5..402f5d039 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -71,7 +71,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) boolean K_DirectorIsAvailable(void) { - if ((demo.playback && demo.title) || modeattacking) + if (splitscreen || (demo.playback && demo.title) || modeattacking) return false; return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); } @@ -422,10 +422,9 @@ void K_ToggleDirector(void) if (!K_DirectorIsAvailable()) return; - G_AdjustView(1, 1, true); - if (!K_DirectorIsEnabled()) { + G_AdjustView(1, 1, true); directorinfo.cooldown = 0; // switch immediately } diff --git a/src/st_stuff.c b/src/st_stuff.c index 523bbc44a..64e244b78 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -53,6 +53,9 @@ UINT16 objectsdrawn = 0; +// dumb fade thing for director toggle +tic_t directortoggletimer = 0; + // // STATUS BAR DATA // diff --git a/src/st_stuff.h b/src/st_stuff.h index 250db1e7f..d289e64ce 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -23,6 +23,8 @@ // STATUS BAR // +extern tic_t directortoggletimer; + // Called by main loop. void ST_Ticker(void); From c8737bd43f35d7af2c5436d6afcaf9d3292043e3 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jan 2025 22:50:15 +0100 Subject: [PATCH 57/76] make this more complicated due to a "-" --- src/st_stuff.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 64e244b78..d189e2c23 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -656,18 +656,19 @@ static void ST_drawLevelTitle(void) // returns the actual button name for any gamecontrol // if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol -static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound) +// if gamectrl is set, it adds an extra "-" for cases where theres also a hardcoded button like accelerate +static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound, boolean gamectrl) { static char buttname[32] = ""; const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind if (butt1 == NULL && butt2 == NULL) // not bound to a button - snprintf(buttname, 32, (unbound ? "%s - %s" : "- %s - %s"), (unbound ? "Unbound" : ""), inputtext); + snprintf(buttname, 32, (unbound ? "%s - %s" : (gamectrl ? "-%s - %s" : "%s - %s")), (unbound ? "Unbound" : ""), inputtext); else if (butt1 != NULL && butt2 != NULL) // bound to two buttons snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); else // bound to only one - snprintf(buttname, 32, "- %s - %s", (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); + snprintf(buttname, 32, (gamectrl ? "-%s - %s" : "%s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); return buttname; } @@ -796,16 +797,16 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true)); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true, false)); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false))); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); } } } From 03e45f459008315749cecc8a04c0c83be10ae039 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 16:28:38 +0100 Subject: [PATCH 58/76] check for cam subsector since we can move it around and i added this to freecam mode, subsector may be null for reason so better be safe than sorry --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 46fb35f65..2b120b99c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3141,7 +3141,7 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) sector_t *sector; fixed_t halfheight; - if (!thiscam) + if (!thiscam || !thiscam->subsector) return false; halfheight = thiscam->z + (thiscam->height >> 1); @@ -3179,7 +3179,7 @@ static boolean P_CameraCheckWater(camera_t *thiscam) sector_t *sector; fixed_t halfheight; - if (!thiscam) + if (!thiscam || !thiscam->subsector) return false; halfheight = thiscam->z + (thiscam->height >> 1); From d41b6c185a1c0f296d45037eb26da165c3491d9c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jan 2025 18:47:12 +0100 Subject: [PATCH 59/76] fix freecam aim getting stuck and other issues - gamepads now aim like they used to and at same speed as keyboard - aim reset has been changed so it resets automatically, but also can be manually reset with centerview - aiming is locked during cam reset --- src/p_local.h | 2 + src/p_user.c | 126 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 82 insertions(+), 46 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index d330c8c34..d80223531 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -81,6 +81,8 @@ typedef struct camera_s boolean chase; boolean freecam; + boolean keyboardlook; + angle_t localangle; INT32 localaiming; diff --git a/src/p_user.c b/src/p_user.c index 13750c594..0675808b0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3167,15 +3167,20 @@ void P_ToggleDemoCamera(UINT8 viewnum) static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; +#define intsign(n) \ + ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) + static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { INT32 laim, forward, side, axis; // these ones used for multiple conditions - boolean turnleft, turnright; - boolean usejoystick; + boolean turnleft, turnright, mouseaiming; + boolean invertmouse, usejoystick, kbl; angle_t lang; + INT32 player_invert; const UINT8 forplayer = num+1; + player_t *player = ((forplayer == 1) ? &players[consoleplayer] : &players[displayplayers[forplayer]]); memset(&cameracmd[num], 0, sizeof(ticcmd_t)); // initialize cmd @@ -3183,21 +3188,30 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang = cam->localangle; laim = cam->localaiming; + kbl = cam->keyboardlook; - switch (num) + switch (forplayer) { - case 1: - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - break; case 2: - G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + mouseaiming = player->spectator; + invertmouse = cv_invertmouse2.value; break; case 3: - G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + mouseaiming = false; + invertmouse = false; break; - case 0: + case 4: + G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + mouseaiming = false; + invertmouse = false; + break; + case 1: default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + mouseaiming = player->spectator; + invertmouse = cv_invertmouse.value; break; } @@ -3223,7 +3237,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) axis = -axis; } - if (gamepadjoystickmove && axis != 0) + if (usejoystick && axis != 0) { turnright = turnright || (axis > 0); turnleft = turnleft || (axis < 0); @@ -3242,13 +3256,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) side -= sidemove[1]; } - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE should be 1023 (divide by 1024) - cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG! - side += ((axis * sidemove[0]) >> 10); - } - cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); axis = JoyAxis(AXISAIM, forplayer); @@ -3261,6 +3268,11 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; + // drift with any button/key + axis = JoyAxis(AXISDRIFT, forplayer); + if (InputDown(gc_drift, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_DRIFT; + // float and sink axis = JoyAxis(AXISMOVE, forplayer); if (InputDown(gc_accelerate, forplayer) || (usejoystick && axis > 0)) @@ -3269,27 +3281,59 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_brake, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_BRAKE; + // spectator aiming shit, ahhhh... + player_invert = invertmouse ? -1 : 1; + + // mouse look stuff (mouse look is not the same as mouse aim) + kbl = false; + // looking up/down - laim += (mlooky<<19); + laim += (mlooky<<19)*player_invert; axis = JoyAxis(AXISLOOK, forplayer); - if (analogjoystickmove && axis != 0 && lookaxis) - laim += (axis<<16); + // spring back if not using keyboard neither mouselookin' + if (!kbl && !lookaxis && !mouseaiming) + laim = 0; - if (InputDown(gc_lookup, forplayer) || (gamepadjoystickmove && axis < 0)) + if (InputDown(gc_lookup, forplayer) || (usejoystick && axis < 0)) { laim += KB_LOOKSPEED; + kbl = true; } - else if (InputDown(gc_lookdown, forplayer) || (gamepadjoystickmove && axis > 0)) + else if (InputDown(gc_lookdown, forplayer) || (usejoystick && axis > 0)) { laim -= KB_LOOKSPEED; + kbl = true; } if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V + { laim = 0; + cam->reset_aiming = false; + } - cmd->aiming = G_ClipAimingPitch(&laim); + //if (cam->reset_aiming || ((cmd->buttons & BT_DRIFT) && !cam->button_a_held)) + if (cam->reset_aiming) + { + INT32 aiming = laim; + INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(laim)); + + if (abs(smooth) < abs(aiming)) + { + laim -= (angle_t)(smooth * intsign(aiming)); + } + else + { + laim = 0; + cam->reset_aiming = false; // completely smoothed out + } + } + + if (!cam->reset_aiming) + { + cmd->aiming = G_ClipAimingPitch(&laim); + } mousex = mousey = mlooky = 0; @@ -3312,24 +3356,21 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang += (cmd->angleturn<<16); cam->localangle = lang; - cam->localaiming = laim; + if (!cam->reset_aiming) + { + cam->localaiming = laim; + } + cam->keyboardlook = kbl; return cmd; } -#define intsign(n) \ - ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) - static void P_DemoCameraMovement(camera_t *cam, UINT8 num) { ticcmd_t *cmd; angle_t thrustangle; player_t *lastp; const UINT8 forplayer = num+1; - boolean moving = false; - - if (encoremode) - cam->postimg |= POSTIMG_MIRROR; cam->localangle = cam->angle; cam->localaiming = cam->aiming; @@ -3337,14 +3378,8 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // first off we need to get button input cmd = P_CameraCmd(cam, num); - // let centerview work proper - if (InputDown(gc_centerview, forplayer)) - { - cam->aiming = 0; - cam->reset_aiming = false; - } - - if (cmd->aiming != 0) + // make sure we dont aim away during reset + if (!cam->reset_aiming) { cam->aiming = cmd->aiming << FRACBITS; } @@ -3361,17 +3396,15 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) { case 1: cam->z += spd; - moving = true; break; case -1: cam->z -= spd; - moving = true; break; } } - if (!(InputDown(gc_camfloat, forplayer) || InputDown(gc_camsink, forplayer)) && cam->button_a_held) + if (!(cmd->buttons & (BT_ACCELERATE | BT_DRIFT) || InputDown(gc_camfloat, forplayer)) && cam->button_a_held) { cam->button_a_held--; } @@ -3388,9 +3421,10 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->reset_aiming = false; } - if (cmd->forwardmove != 0) + if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V { - moving = true; + cam->aiming = 0; + cam->reset_aiming = false; } // After switching to democam, the vertical angle of @@ -3399,7 +3433,8 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // forward/back will have a slope. So, as long as democam // controls haven't been used to alter the vertical angle, // slowly reset it to flat. - if ((cam->reset_aiming && moving) || ((InputDown(gc_camsink, forplayer)) && !cam->button_a_held)) + //if (cam->reset_aiming || ((cmd->buttons & BT_DRIFT) && !cam->button_a_held)) + if (cam->reset_aiming) { INT32 aiming = cam->aiming; INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); @@ -3424,7 +3459,6 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->x += FixedMul(spd, FINECOSINE(thrustangle)); cam->y += FixedMul(spd, FINESINE(thrustangle)); - if (!cam->reset_aiming) { cam->z += FixedMul(spd, AIMINGTOSLOPE(cam->aiming)); From a11227b15a2ed5e8ef595271d07e678d52ff044d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jan 2025 18:23:25 +0100 Subject: [PATCH 60/76] fix postimg data types mismatch also remove the "postimgflag_t" typedef since its useless and use smoler type for everything we dont need much space lol --- src/doomtype.h | 9 --------- src/p_local.h | 13 ++++++++++++- src/p_mobj.c | 2 +- src/p_user.c | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 429eba77e..116d5cdfb 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -342,15 +342,6 @@ union FColorRGBA } ATTRPACK; typedef union FColorRGBA RGBA_t; -typedef enum -{ - POSTIMG_WATER = 1, // Underwater screen effect. - POSTIMG_MOTION = 1<<1, // Unused motion blur effect. - POSTIMG_FLIP = 1<<2, // Flipcam screen effect. - POSTIMG_HEAT = 1<<3, // Heatwave screen effect. - POSTIMG_MIRROR = 1<<4, // encore screen effect. -} postimgflag_t; - typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) #define LUMPERROR UINT32_MAX diff --git a/src/p_local.h b/src/p_local.h index d80223531..318f99f87 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -76,6 +76,7 @@ void P_UnlinkThinker(thinker_t *thinker); // // P_USER // + typedef struct camera_s { boolean chase; @@ -125,9 +126,19 @@ typedef struct camera_s fixed_t pan; // postproccess effects - UINT16 postimg; + UINT8 postimg; } camera_t; +// post process types +enum +{ + POSTIMG_WATER = 1, // Underwater screen effect. + POSTIMG_MOTION = 1<<1, // Unused motion blur effect. + POSTIMG_FLIP = 1<<2, // Flipcam screen effect. + POSTIMG_HEAT = 1<<3, // Heatwave screen effect. + POSTIMG_MIRROR = 1<<4, // encore screen effect. +}; + extern camera_t camera[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS]; diff --git a/src/p_mobj.c b/src/p_mobj.c index 2b120b99c..dd3f62169 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3235,7 +3235,7 @@ void P_DestroyRobots(void) void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); - UINT16 postimgtype = 0; + UINT8 postimgtype = 0; if (encoremode) postimgtype |= POSTIMG_MIRROR; diff --git a/src/p_user.c b/src/p_user.c index 0675808b0..52399e56f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4252,7 +4252,7 @@ static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, static void P_CalcPostImg(player_t *player, camera_t *thiscam) { sector_t *sector = NULL; - INT16 postimgtype = 0; + UINT8 postimgtype = 0; //INT32 *param; fixed_t pviewheight = 0; From 1a9865ebc45bff2d65835d4451b3bf85f42a4532 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jan 2025 17:25:50 +0100 Subject: [PATCH 61/76] this should also use unpaused rendertimefrac --- src/d_main.c | 2 +- src/r_things.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index d74950b65..5b24c5c00 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -334,7 +334,7 @@ static boolean D_Display(void) if (rendermode == render_soft && !splitscreen) { - R_InterpolateViewRollAngle(rendertimefrac); + R_InterpolateViewRollAngle(rendertimefrac_unpaused); R_CheckViewMorph(); } diff --git a/src/r_things.c b/src/r_things.c index 9bdb9ea67..8f4677bcf 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -584,7 +584,7 @@ void R_DrawMaskedColumn(column_t *column) basetexturemid = dc_texturemid; - if (!column || column == 0) + if (column == NULL) return; for (; column->topdelta != 0xff ;) From d39fd5bb5c4e4f4df16f2d234d9f2dfcf91dd30f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 18:31:40 +0100 Subject: [PATCH 62/76] strafe controls for speccam/freecam TODO: seperate cam turning axis from gameplay turn axis for gamepads --- src/d_netcmd.c | 1 + src/g_game.c | 10 ++ src/g_game.h | 2 + src/g_input.c | 2 + src/g_input.h | 2 + src/m_menu.c | 265 ++++++++++++++++++++++--------------------------- src/p_user.c | 51 +++++++++- 7 files changed, 185 insertions(+), 148 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9b293aef6..1f2a0e95a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1033,6 +1033,7 @@ void D_RegisterClientCommands(void) { CV_RegisterVar(&cv_turnaxis[i]); CV_RegisterVar(&cv_moveaxis[i]); + CV_RegisterVar(&cv_strafeaxis[i]); CV_RegisterVar(&cv_brakeaxis[i]); CV_RegisterVar(&cv_aimaxis[i]); CV_RegisterVar(&cv_lookaxis[i]); diff --git a/src/g_game.c b/src/g_game.c index 1bcd9778c..87fd1b1d5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -440,6 +440,13 @@ consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS] = { {"joyaxis4_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; +consvar_t cv_strafeaxis[MAXSPLITSCREENPLAYERS] = { + {"joyaxis_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis2_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis3_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis4_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS] = { {"joyaxis_brake", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"joyaxis2_brake", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -732,6 +739,9 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player) case AXISMOVE: axisval = cv_moveaxis[player-1].value; break; + case AXISSTRAFE: + axisval = cv_strafeaxis[player-1].value; + break; case AXISBRAKE: axisval = cv_brakeaxis[player-1].value; break; diff --git a/src/g_game.h b/src/g_game.h index 10c2a6156..9ca6dce09 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,6 +124,7 @@ extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mo extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_strafeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS]; @@ -192,6 +193,7 @@ typedef enum AXISNONE = 0, AXISTURN, AXISMOVE, + AXISSTRAFE, AXISBRAKE, AXISAIM, AXISLOOK, diff --git a/src/g_input.c b/src/g_input.c index c948ed751..e80bbacd1 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -905,6 +905,8 @@ static const char *gamecontrolname[num_gamecontrols] = "freecam", "camfloat", "camsink", + "strafeleft", + "straferight", }; #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) diff --git a/src/g_input.h b/src/g_input.h index 1dbbb937f..1475af582 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -103,6 +103,8 @@ typedef enum gc_freecam, // Toggle for freecam while ingame gc_camfloat, // alternative button for raising cam gc_camsink, // alternative button for sinking + gc_strafeleft, + gc_straferight, num_gamecontrols } gamecontrols_e; diff --git a/src/m_menu.c b/src/m_menu.c index 664f734e5..b899efa30 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -643,23 +643,23 @@ static menuitem_t MISC_ReplayOptionsMenu[] = static tic_t playback_last_menu_interaction_leveltime = 0; static menuitem_t PlaybackMenu[] = { - {IT_CALL | IT_STRING, "M_PHIDE", "Hide Menu (Esc)", M_SelectableClearMenus, 0}, + {IT_CALL | IT_STRING, "M_PHIDE", "Hide Menu (Esc)", M_SelectableClearMenus, 0}, - {IT_CALL | IT_STRING, "M_PREW", "Rewind ([)", M_PlaybackRewind, 20}, - {IT_CALL | IT_STRING, "M_PPAUSE", "Pause (\\)", M_PlaybackPause, 36}, - {IT_CALL | IT_STRING, "M_PFFWD", "Fast-Forward (])", M_PlaybackFastForward, 52}, - {IT_CALL | IT_STRING, "M_PSTEPB", "Backup Frame ([)", M_PlaybackRewind, 20}, - {IT_CALL | IT_STRING, "M_PRESUM", "Resume", M_PlaybackPause, 36}, - {IT_CALL | IT_STRING, "M_PFADV", "Advance Frame (])", M_PlaybackAdvance, 52}, + {IT_CALL | IT_STRING, "M_PREW", "Rewind ([)", M_PlaybackRewind, 20}, + {IT_CALL | IT_STRING, "M_PPAUSE", "Pause (\\)", M_PlaybackPause, 36}, + {IT_CALL | IT_STRING, "M_PFFWD", "Fast-Forward (])", M_PlaybackFastForward, 52}, + {IT_CALL | IT_STRING, "M_PSTEPB", "Backup Frame ([)", M_PlaybackRewind, 20}, + {IT_CALL | IT_STRING, "M_PRESUM", "Resume", M_PlaybackPause, 36}, + {IT_CALL | IT_STRING, "M_PFADV", "Advance Frame (])", M_PlaybackAdvance, 52}, - {IT_ARROWS | IT_STRING, "M_PVIEWS", "View Count (- and =)", M_PlaybackSetViews, 72}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint (1)", M_PlaybackAdjustView, 88}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 2 (2)", M_PlaybackAdjustView, 104}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 3 (3)", M_PlaybackAdjustView, 120}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 4 (4)", M_PlaybackAdjustView, 136}, + {IT_ARROWS | IT_STRING, "M_PVIEWS", "View Count (- and =)", M_PlaybackSetViews, 72}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint (1)", M_PlaybackAdjustView, 88}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 2 (2)", M_PlaybackAdjustView, 104}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 3 (3)", M_PlaybackAdjustView, 120}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 4 (4)", M_PlaybackAdjustView, 136}, {IT_CALL | IT_STRING, "M_PVIEWS", "Toggle Free Camera (')", M_PlaybackToggleFreecam, 156}, - {IT_CALL | IT_STRING, "M_PEXIT", "Stop Playback", M_PlaybackQuit, 172}, + {IT_CALL | IT_STRING, "M_PEXIT", "Stop Playback", M_PlaybackQuit, 172}, }; typedef enum { @@ -702,8 +702,8 @@ typedef enum // --------------------- static menuitem_t MPauseMenu[] = { - {IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8}, - {IT_STRING | IT_CALL, NULL, "Add local skins...", M_LocalSkins, 16}, + {IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8}, + {IT_STRING | IT_CALL, NULL, "Add local skins...", M_LocalSkins, 16}, {IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 24}, {IT_STRING | IT_CALL, NULL, "Switch Map..." , M_MapChange, 32}, @@ -766,7 +766,7 @@ static menuitem_t SPauseMenu[] = // Pandora's Box will be shifted up if both options are available {IT_CALL | IT_STRING, NULL, "Pandora's Box...", M_PandorasBox, 16}, {IT_CALL | IT_STRING, NULL, "Medal Hints...", M_EmblemHints, 24}, - //{IT_CALL | IT_STRING, NULL, "Level Select...", M_LoadGameLevelSelect, 32}, + //{IT_CALL | IT_STRING, NULL, "Level Select...", M_LoadGameLevelSelect, 32}, {IT_CALL | IT_STRING, NULL, "Continue", M_SelectableClearMenus,48}, {IT_CALL | IT_STRING, NULL, "Retry", M_Retry, 56}, @@ -1034,13 +1034,13 @@ menuitem_t PlayerMenu[MAXSKINS]; static menuitem_t MP_MainMenu[] = { {IT_HEADER, NULL, "Players", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Number of local players", &cv_splitplayers, 10}, + {IT_STRING|IT_CVAR, NULL, "Number of local players", &cv_splitplayers, 10}, - {IT_STRING|IT_KEYHANDLER,NULL, "Player setup...", M_SetupMultiHandler,18}, + {IT_STRING|IT_KEYHANDLER,NULL, "Player setup...", M_SetupMultiHandler, 18}, {IT_HEADER, NULL, "Host a game", NULL, 100-24}, #ifndef NONET - {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_PreStartServerMenu, 110-24}, + {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_PreStartServerMenu, 110-24}, #else {IT_GRAYEDOUT, NULL, "Internet/LAN...", NULL, 110-24}, #endif @@ -1049,11 +1049,11 @@ static menuitem_t MP_MainMenu[] = {IT_HEADER, NULL, "Join a game", NULL, 132-24}, #ifndef NONET #ifndef MASTERSERVER - {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, + {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, #else - {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_PreConnectMenu, 142-24}, + {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_PreConnectMenu, 142-24}, #endif - {IT_STRING|IT_CALL, NULL, "Join last server", M_ConnectLastServer, 150-24}, + {IT_STRING|IT_CALL, NULL, "Join last server", M_ConnectLastServer, 150-24}, {IT_STRING|IT_KEYHANDLER, NULL, "Specify IPv4 address:", M_HandleConnectIP, 158-24}, #else {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, @@ -1149,7 +1149,7 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 155}, }; @@ -1158,13 +1158,13 @@ static menuitem_t OP_ControlsMenu[] = {IT_CALL | IT_STRING, NULL, "Player 1 Controls...", M_Setup1PControlsMenu, 10}, {IT_CALL | IT_STRING, NULL, "Player 2 Controls...", M_Setup2PControlsMenu, 20}, - {IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30}, - {IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40}, + {IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30}, + {IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40}, - {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60}, + {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60}, - {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90}, + {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80}, + {IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90}, }; static const char* OP_ControlsTooltips[] = @@ -1217,6 +1217,8 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Sink", M_ChangeControl, gc_camsink }, {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, + {IT_CONTROL, NULL, "Strafe Left", M_ChangeControl, gc_strafeleft }, + {IT_CONTROL, NULL, "Strafe Right", M_ChangeControl, gc_straferight}, //{IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, {IT_HEADER, NULL, "Spectator Controls", NULL, 0}, @@ -1233,90 +1235,94 @@ static menuitem_t OP_AllControlsMenu[] = static menuitem_t OP_Joystick1Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu, 10}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu , 10}, {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[0] , 20}, {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[0] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[0] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 80}, + {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[0] , 30}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 35}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 40}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 45}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 50}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 55}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[0] , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 70}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 75}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 80}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 100}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 95}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 100}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 105}, }; static menuitem_t OP_Joystick2Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[1] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu , 10}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 25}, + {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[1] , 30}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 35}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 40}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 45}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 50}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 55}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[1] , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 70}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 75}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 80}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 100}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 95}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 100}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 105}, }; static menuitem_t OP_Joystick3Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[2] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu , 10}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 25}, + {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[2] , 30}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 35}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 40}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 45}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 50}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 55}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[2] , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 70}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 75}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 80}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 100}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 95}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 100}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 105}, }; static menuitem_t OP_Joystick4Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[3] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu , 10}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 25}, + {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[3] , 30}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 35}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 40}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 45}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 50}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 55}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[3] , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 70}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 75}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 80}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 100}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 95}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 100}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 105}, }; static menuitem_t OP_JoystickSetMenu[] = @@ -12063,7 +12069,7 @@ static void M_Setup1PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_CONTROL; // GIF OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu OP_AllControlsMenu[21].status = IT_CONTROL; // Console - OP_AllControlsMenu[35].status = IT_CONTROL; // Director + OP_AllControlsMenu[37].status = IT_CONTROL; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12086,7 +12092,7 @@ static void M_Setup2PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console - OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12109,7 +12115,7 @@ static void M_Setup3PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console - OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12132,7 +12138,7 @@ static void M_Setup4PControlsMenu(INT32 choice) OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console - OP_AllControlsMenu[35].status = IT_GRAYEDOUT2; // Director + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12388,53 +12394,24 @@ static void M_ResetControlsResponse(INT32 ch) G_Controldefault(setupcontrolplayer); // Setup gamepad option defaults (yucky) - switch (setupcontrolplayer) + for (UINT8 j = 0; j < MAXSPLITSCREENPLAYERS; j++) { - case 4: - CV_StealthSet(&cv_usejoystick[3], cv_usejoystick[3].defaultvalue); - CV_StealthSet(&cv_turnaxis[3], cv_turnaxis[3].defaultvalue); - CV_StealthSet(&cv_moveaxis[3], cv_moveaxis[3].defaultvalue); - CV_StealthSet(&cv_brakeaxis[3], cv_brakeaxis[3].defaultvalue); - CV_StealthSet(&cv_aimaxis[3], cv_aimaxis[3].defaultvalue); - CV_StealthSet(&cv_lookaxis[3], cv_lookaxis[3].defaultvalue); - CV_StealthSet(&cv_fireaxis[3], cv_fireaxis[3].defaultvalue); - CV_StealthSet(&cv_driftaxis[3], cv_driftaxis[3].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[3], cv_lookbackaxis[3].defaultvalue); - break; - case 3: - CV_StealthSet(&cv_usejoystick[2], cv_usejoystick[2].defaultvalue); - CV_StealthSet(&cv_turnaxis[2], cv_turnaxis[2].defaultvalue); - CV_StealthSet(&cv_moveaxis[2], cv_moveaxis[2].defaultvalue); - CV_StealthSet(&cv_brakeaxis[2], cv_brakeaxis[2].defaultvalue); - CV_StealthSet(&cv_aimaxis[2], cv_aimaxis[2].defaultvalue); - CV_StealthSet(&cv_lookaxis[2], cv_lookaxis[2].defaultvalue); - CV_StealthSet(&cv_fireaxis[2], cv_fireaxis[2].defaultvalue); - CV_StealthSet(&cv_driftaxis[2], cv_driftaxis[2].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[2], cv_lookbackaxis[2].defaultvalue); - break; - case 2: - CV_StealthSet(&cv_usejoystick[1], cv_usejoystick[1].defaultvalue); - CV_StealthSet(&cv_turnaxis[1], cv_turnaxis[1].defaultvalue); - CV_StealthSet(&cv_moveaxis[1], cv_moveaxis[1].defaultvalue); - CV_StealthSet(&cv_brakeaxis[1], cv_brakeaxis[1].defaultvalue); - CV_StealthSet(&cv_aimaxis[1], cv_aimaxis[1].defaultvalue); - CV_StealthSet(&cv_lookaxis[1], cv_lookaxis[1].defaultvalue); - CV_StealthSet(&cv_fireaxis[1], cv_fireaxis[1].defaultvalue); - CV_StealthSet(&cv_driftaxis[1], cv_driftaxis[1].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[1], cv_lookbackaxis[1].defaultvalue); - break; - case 1: - default: - CV_StealthSet(&cv_usejoystick[0], cv_usejoystick[0].defaultvalue); - CV_StealthSet(&cv_turnaxis[0], cv_turnaxis[0].defaultvalue); - CV_StealthSet(&cv_moveaxis[0], cv_moveaxis[0].defaultvalue); - CV_StealthSet(&cv_brakeaxis[0], cv_brakeaxis[0].defaultvalue); - CV_StealthSet(&cv_aimaxis[0], cv_aimaxis[0].defaultvalue); - CV_StealthSet(&cv_lookaxis[0], cv_lookaxis[0].defaultvalue); - CV_StealthSet(&cv_fireaxis[0], cv_fireaxis[0].defaultvalue); - CV_StealthSet(&cv_driftaxis[0], cv_driftaxis[0].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[0], cv_lookbackaxis[0].defaultvalue); - break; + if (setupcontrolplayer != j) + continue; + + CV_StealthSet(&cv_usejoystick[j], cv_usejoystick[j].defaultvalue); + CV_StealthSet(&cv_turnaxis[j], cv_turnaxis[j].defaultvalue); + CV_StealthSet(&cv_strafeaxis[j], cv_strafeaxis[j].defaultvalue); + CV_StealthSet(&cv_moveaxis[j], cv_moveaxis[j].defaultvalue); + CV_StealthSet(&cv_brakeaxis[j], cv_brakeaxis[j].defaultvalue); + CV_StealthSet(&cv_aimaxis[j], cv_aimaxis[j].defaultvalue); + CV_StealthSet(&cv_lookaxis[j], cv_lookaxis[j].defaultvalue); + CV_StealthSet(&cv_fireaxis[j], cv_fireaxis[j].defaultvalue); + CV_StealthSet(&cv_driftaxis[j], cv_driftaxis[j].defaultvalue); + CV_StealthSet(&cv_lookbackaxis[j], cv_lookbackaxis[j].defaultvalue); + CV_StealthSet(&cv_custom1axis[j], cv_custom1axis[j].defaultvalue); + CV_StealthSet(&cv_custom2axis[j], cv_custom2axis[j].defaultvalue); + CV_StealthSet(&cv_custom3axis[j], cv_custom3axis[j].defaultvalue); } S_StartSound(NULL, sfx_s224); diff --git a/src/p_user.c b/src/p_user.c index 52399e56f..6dfe4d0af 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3131,8 +3131,9 @@ 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) static fixed_t forwardmove[2] = {25<>16, 50<>16}; -static fixed_t sidemove[2] = {2<>16, 4<>16}; +//static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn +static fixed_t strafemove[2] = {25<>16, 50<>16}; // faster! void P_ToggleDemoCamera(UINT8 viewnum) { @@ -3176,6 +3177,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) // these ones used for multiple conditions boolean turnleft, turnright, mouseaiming; + boolean strafeleft, straferight; boolean invertmouse, usejoystick, kbl; angle_t lang; INT32 player_invert; @@ -3242,18 +3244,48 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) turnright = turnright || (axis > 0); turnleft = turnleft || (axis < 0); } - forward = side = 0; + forward = 0; // let movement keys cancel each other out if (turnright && !(turnleft)) { cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); - side += sidemove[1]; + //side += sidemove[1]; } else if (turnleft && !(turnright)) { cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); - side -= sidemove[1]; + //side -= sidemove[1]; + } + + straferight = InputDown(gc_straferight, forplayer); + strafeleft = InputDown(gc_strafeleft, forplayer); + + axis = JoyAxis(AXISSTRAFE, forplayer); + + if (encoremode) + { + straferight ^= strafeleft; // swap these using three XORs + strafeleft ^= straferight; + straferight ^= strafeleft; + axis = -axis; + } + + if (usejoystick && axis != 0) + { + straferight = straferight || (axis > 0); + strafeleft = strafeleft || (axis < 0); + } + side = 0; + + // let strafe keys cancel each other out + if (straferight && !(strafeleft)) + { + side += strafemove[1]; + } + else if (strafeleft && !(straferight)) + { + side -= strafemove[1]; } cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); @@ -3470,6 +3502,17 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) // besides freecam going inside walls sounds pretty cool on paper. } + // cmd->strafemove -- cant really add stuff to ticcmd struct so im reusing this + if (cmd->sidemove != 0) // was disabled in practice anyways, since sidemove was suppressed + { + //False I fixed this shit - Nep + fixed_t spd = cmd->sidemove*mapobjectscale; + + thrustangle = (cam->angle-ANGLE_90) >> ANGLETOFINESHIFT; + cam->x += FixedMul(spd, FINECOSINE(thrustangle)); + cam->y += FixedMul(spd, FINESINE(thrustangle)); + } + // update subsector to avoid crashes; cam->subsector = R_PointInSubsector(cam->x, cam->y); } From 50d2bf5d8da6604f8c141f613c44ecdd26a82953 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 10 Jan 2025 22:23:28 +0100 Subject: [PATCH 63/76] seperate game turn axis from cam turn axis both are bound to the same value by default, so vanilla controls remain intact theres no other good way to have gamepad controls for this sadly --- src/d_netcmd.c | 3 +- src/g_game.c | 24 +++++-- src/g_game.h | 6 +- src/m_menu.c | 176 +++++++++++++++++++++++++++++-------------------- src/p_user.c | 4 +- 5 files changed, 129 insertions(+), 84 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1f2a0e95a..13d7bd679 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1033,7 +1033,8 @@ void D_RegisterClientCommands(void) { CV_RegisterVar(&cv_turnaxis[i]); CV_RegisterVar(&cv_moveaxis[i]); - CV_RegisterVar(&cv_strafeaxis[i]); + CV_RegisterVar(&cv_camturnaxis[i]); + CV_RegisterVar(&cv_camstrafeaxis[i]); CV_RegisterVar(&cv_brakeaxis[i]); CV_RegisterVar(&cv_aimaxis[i]); CV_RegisterVar(&cv_lookaxis[i]); diff --git a/src/g_game.c b/src/g_game.c index 87fd1b1d5..60dca3870 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -440,11 +440,18 @@ consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS] = { {"joyaxis4_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; -consvar_t cv_strafeaxis[MAXSPLITSCREENPLAYERS] = { - {"joyaxis_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"joyaxis2_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"joyaxis3_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"joyaxis4_strafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +consvar_t cv_camstrafeaxis[MAXSPLITSCREENPLAYERS] = { + {"joyaxis_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis2_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis3_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis4_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + +consvar_t cv_camturnaxis[MAXSPLITSCREENPLAYERS] = { + {"joyaxis_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis2_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis3_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis4_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS] = { @@ -739,8 +746,11 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player) case AXISMOVE: axisval = cv_moveaxis[player-1].value; break; - case AXISSTRAFE: - axisval = cv_strafeaxis[player-1].value; + case AXISCAMTURN: + axisval = cv_camturnaxis[player-1].value; + break; + case AXISCAMSTRAFE: + axisval = cv_camstrafeaxis[player-1].value; break; case AXISBRAKE: axisval = cv_brakeaxis[player-1].value; diff --git a/src/g_game.h b/src/g_game.h index 9ca6dce09..53da464a5 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,7 +124,8 @@ extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mo extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS]; -extern consvar_t cv_strafeaxis[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_camturnaxis[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_camstrafeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS]; @@ -193,7 +194,8 @@ typedef enum AXISNONE = 0, AXISTURN, AXISMOVE, - AXISSTRAFE, + AXISCAMTURN, + AXISCAMSTRAFE, AXISBRAKE, AXISAIM, AXISLOOK, diff --git a/src/m_menu.c b/src/m_menu.c index b899efa30..41bae3132 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1196,7 +1196,7 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Aim Backward", M_ChangeControl, gc_aimbackward}, {IT_CONTROL, NULL, "Look Backward", M_ChangeControl, gc_lookback }, - {IT_HEADER, NULL, "Miscelleanous Controls", NULL, 0}, + {IT_HEADER, NULL, "Miscellaneous Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Chat", M_ChangeControl, gc_talkkey }, //{IT_CONTROL, NULL, "Team Chat", M_ChangeControl, gc_teamkey }, @@ -1235,94 +1235,126 @@ static menuitem_t OP_AllControlsMenu[] = static menuitem_t OP_Joystick1Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[0] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[0] , 25}, - {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[0] , 30}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 35}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 40}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 45}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 50}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 55}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[0] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 70}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 75}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 80}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 85}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu , 0}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 95}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 100}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 105}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[0] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[0] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[0] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[0] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[0] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 130}, }; static menuitem_t OP_Joystick2Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 25}, - {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[1] , 30}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 35}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 40}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 45}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 50}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 55}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[1] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 70}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 75}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 80}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 95}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 100}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 105}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[1] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[1] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[1] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 130}, }; static menuitem_t OP_Joystick3Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 25}, - {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[2] , 30}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 35}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 40}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 45}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 50}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 55}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[2] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 70}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 75}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 80}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 95}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 100}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 105}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[2] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[2] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[2] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 130}, }; static menuitem_t OP_Joystick4Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 25}, - {IT_STRING | IT_CVAR, NULL, "Cam Strafe Left/Right", &cv_strafeaxis[3] , 30}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 35}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 40}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 45}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 50}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 55}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[3] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 70}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 75}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 80}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 85}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 95}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 100}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 105}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[3] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[3] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[3] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 130}, }; static menuitem_t OP_JoystickSetMenu[] = @@ -12401,7 +12433,8 @@ static void M_ResetControlsResponse(INT32 ch) CV_StealthSet(&cv_usejoystick[j], cv_usejoystick[j].defaultvalue); CV_StealthSet(&cv_turnaxis[j], cv_turnaxis[j].defaultvalue); - CV_StealthSet(&cv_strafeaxis[j], cv_strafeaxis[j].defaultvalue); + CV_StealthSet(&cv_camturnaxis[j], cv_camturnaxis[j].defaultvalue); + CV_StealthSet(&cv_camstrafeaxis[j], cv_camstrafeaxis[j].defaultvalue); CV_StealthSet(&cv_moveaxis[j], cv_moveaxis[j].defaultvalue); CV_StealthSet(&cv_brakeaxis[j], cv_brakeaxis[j].defaultvalue); CV_StealthSet(&cv_aimaxis[j], cv_aimaxis[j].defaultvalue); @@ -12413,7 +12446,6 @@ static void M_ResetControlsResponse(INT32 ch) CV_StealthSet(&cv_custom2axis[j], cv_custom2axis[j].defaultvalue); CV_StealthSet(&cv_custom3axis[j], cv_custom3axis[j].defaultvalue); } - S_StartSound(NULL, sfx_s224); } diff --git a/src/p_user.c b/src/p_user.c index 6dfe4d0af..48287b187 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3229,7 +3229,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) turnright = InputDown(gc_turnright, forplayer); turnleft = InputDown(gc_turnleft, forplayer); - axis = JoyAxis(AXISTURN, forplayer); + axis = JoyAxis(AXISCAMTURN, forplayer); if (encoremode) { @@ -3261,7 +3261,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) straferight = InputDown(gc_straferight, forplayer); strafeleft = InputDown(gc_strafeleft, forplayer); - axis = JoyAxis(AXISSTRAFE, forplayer); + axis = JoyAxis(AXISCAMSTRAFE, forplayer); if (encoremode) { From 67aa31439b0d4d27fe4e0029efdd54d65ca6010a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Jan 2025 17:24:50 +0100 Subject: [PATCH 64/76] dont rumble in freecam state --- src/p_tick.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8f5454ed6..ba1c8fa91 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -386,7 +386,12 @@ static void P_DeviceRumbleTick(void) continue; } - if (player->mo == NULL) + if (camera[i].freecam) + { + continue; + } + + if (P_MobjWasRemoved(player->mo)) { continue; } @@ -619,10 +624,7 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_thinkframe_time); } - // Run shield positioning - //P_RunShields(); P_RunOverlays(); - P_RunShadows(); P_UpdateSpecials(); From 6f7a52a6a6f62229afc88f58568707e6feb6469b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Jan 2025 12:57:35 +0100 Subject: [PATCH 65/76] make freecam strafe be affected by freecamspeed cvar --- 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 d0cbc9670..698401129 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3511,7 +3511,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (cmd->sidemove != 0) // was disabled in practice anyways, since sidemove was suppressed { //False I fixed this shit - Nep - fixed_t spd = cmd->sidemove*mapobjectscale; + fixed_t spd = cmd->forwardmove*mapobjectscale*cv_freecam_speed.value; thrustangle = (cam->angle-ANGLE_90) >> ANGLETOFINESHIFT; cam->x += FixedMul(spd, FINECOSINE(thrustangle)); From 1db9bcd6c97e62160d27f97dc79488d4ef2c1a0f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Jan 2025 12:59:00 +0100 Subject: [PATCH 66/76] oops --- 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 698401129..3068e7b67 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3511,7 +3511,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (cmd->sidemove != 0) // was disabled in practice anyways, since sidemove was suppressed { //False I fixed this shit - Nep - fixed_t spd = cmd->forwardmove*mapobjectscale*cv_freecam_speed.value; + fixed_t spd = cmd->sidemove*mapobjectscale*cv_freecam_speed.value; thrustangle = (cam->angle-ANGLE_90) >> ANGLETOFINESHIFT; cam->x += FixedMul(spd, FINECOSINE(thrustangle)); From aa0bf396e73a9937ede2ed19a28d07b1a2d5c9d9 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 15 Jan 2025 21:17:56 +0300 Subject: [PATCH 67/76] Fix spectator control text overlapping when showdirectorhud is off --- src/st_stuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index d189e2c23..f99c19fd3 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -805,8 +805,8 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); } } } From cccf6449f9a1ee0a06a727b80712e259bdc43d9c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 18:04:05 +0100 Subject: [PATCH 68/76] fix freecam vertical look for the 500th thousand time truly amazing code --- src/p_local.h | 2 -- src/p_user.c | 40 ++++++++-------------------------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 8ce9568f2..4f670bc74 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -84,8 +84,6 @@ typedef struct camera_s boolean chase; boolean freecam; - boolean keyboardlook; - angle_t localangle; INT32 localaiming; diff --git a/src/p_user.c b/src/p_user.c index 3068e7b67..13c98f81e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3136,7 +3136,7 @@ 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) static fixed_t forwardmove[2] = {25<>16, 50<>16}; -//static fixed_t sidemove[2] = {2<>16, 4<>16}; +static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn static fixed_t strafemove[2] = {25<>16, 50<>16}; // faster! @@ -3181,13 +3181,13 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) INT32 laim, forward, side, axis; // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming; + boolean turnleft, turnright; boolean strafeleft, straferight; - boolean invertmouse, usejoystick, kbl; + boolean usejoystick; angle_t lang; - INT32 player_invert; const UINT8 forplayer = num+1; - player_t *player = ((forplayer == 1) ? &players[consoleplayer] : &players[displayplayers[forplayer]]); + + SINT8 player_invert = cv_invertmouse.value ? -1 : 1; // who tf uses two mice? memset(&cameracmd[num], 0, sizeof(ticcmd_t)); // initialize cmd @@ -3195,37 +3195,27 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) lang = cam->localangle; laim = cam->localaiming; - kbl = cam->keyboardlook; switch (forplayer) { case 2: G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - mouseaiming = player->spectator; - invertmouse = cv_invertmouse2.value; break; case 3: G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); - mouseaiming = false; - invertmouse = false; break; case 4: G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); - mouseaiming = false; - invertmouse = false; break; case 1: default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - mouseaiming = player->spectator; - invertmouse = cv_invertmouse.value; break; } cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); - const boolean lookaxis = cv_lookaxis[num].value; const boolean analogjoystickmove = cv_usejoystick[num].value && !Joystick[num].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[num].value && Joystick[num].bGamepadStyle; @@ -3255,12 +3245,12 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (turnright && !(turnleft)) { cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); - //side += sidemove[1]; + side += sidemove[1]; } else if (turnleft && !(turnright)) { cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); - //side -= sidemove[1]; + side -= sidemove[1]; } straferight = InputDown(gc_straferight, forplayer); @@ -3318,30 +3308,17 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_brake, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_BRAKE; - // spectator aiming shit, ahhhh... - player_invert = invertmouse ? -1 : 1; - - // mouse look stuff (mouse look is not the same as mouse aim) - kbl = false; - - // looking up/down - laim += (mlooky<<19)*player_invert; - axis = JoyAxis(AXISLOOK, forplayer); - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis && !mouseaiming) - laim = 0; + laim += (mlooky<<19)*player_invert; if (InputDown(gc_lookup, forplayer) || (usejoystick && axis < 0)) { laim += KB_LOOKSPEED; - kbl = true; } else if (InputDown(gc_lookdown, forplayer) || (usejoystick && axis > 0)) { laim -= KB_LOOKSPEED; - kbl = true; } if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V @@ -3397,7 +3374,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { cam->localaiming = laim; } - cam->keyboardlook = kbl; return cmd; } From 8cdb920f5471e11aab9187ee021e8ae7a6b07fcb Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 19:00:10 +0100 Subject: [PATCH 69/76] dont turn 90 degrees when switching to freecam --- src/g_game.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 642449bbc..4692f84c2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -964,6 +964,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // dumbass thing so we can use a few buttons but dont accidentally drive away if (player->spectator || freecam) { + cmd->angleturn = (INT16)(lang >> 16); G_BuildLocalTiccmd(cmd, ssplayer, freecam); // let lua override everything @@ -1030,7 +1031,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) side += ((axis * sidemove[0]) >> 10); } - if (player->spectator || cv_mouseturn.value) + if (cv_mouseturn.value) { //THIS WORKS WTF???????? cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); From 24ca9fdafa3c60eb9cc1b0d719cd12317073e877 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 19:17:41 +0100 Subject: [PATCH 70/76] oops didnt init this --- 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 13c98f81e..722cf78a0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3239,7 +3239,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) turnright = turnright || (axis > 0); turnleft = turnleft || (axis < 0); } - forward = 0; + forward = side = 0; // let movement keys cancel each other out if (turnright && !(turnleft)) From ebfafd7b6e8d0fc234033a659db551d867385ea6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 19:21:33 +0100 Subject: [PATCH 71/76] a --- src/p_user.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 722cf78a0..bdab2b92d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3271,7 +3271,6 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) straferight = straferight || (axis > 0); strafeleft = strafeleft || (axis < 0); } - side = 0; // let strafe keys cancel each other out if (straferight && !(strafeleft)) From 5dc76d07ec7df933098b1a624c4eb53ac5ee7ef9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 19:33:47 +0100 Subject: [PATCH 72/76] Hold up/down for 2 seconds while not moving to pan the camera vertically from RR --- src/doomtype.h | 3 +++ src/p_local.h | 3 +++ src/p_tick.c | 15 ++++++++++++++- src/p_user.c | 11 +++++------ src/r_main.c | 4 ---- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 116d5cdfb..174bba5b1 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -380,6 +380,9 @@ unset_bit_array (bitarray_t * const array, const int value) array[value >> 3] &= ~(1<<(value & 7)); } +#define intsign(n) \ + ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) + typedef UINT64 precise_t; #endif //__DOOMTYPE__ diff --git a/src/p_local.h b/src/p_local.h index 4f670bc74..fb2f31485 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -95,6 +95,9 @@ typedef struct camera_s // Freecam: aiming needs to be reset after switching from chasecam boolean reset_aiming; + // Hold up/down to pan the camera vertically + SINT8 dpad_y_held; + // Things used by FS cameras. fixed_t viewheight; angle_t startangle; diff --git a/src/p_tick.c b/src/p_tick.c index 898be3efa..25934a0f1 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -469,7 +469,20 @@ void P_RunChaseCameras(void) for (i = 0; i <= splitscreen; i++) { if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); + { + player_t *p = &players[displayplayers[i]]; + camera_t *cam = &camera[i]; + + if (p->mo && p->kartstuff[k_throwdir] != 0) + { + if (p->speed < 6 * p->mo->scale && abs(cam->dpad_y_held) < 2*TICRATE) + cam->dpad_y_held += intsign(p->kartstuff[k_throwdir]); + } + else + cam->dpad_y_held = 0; + + P_MoveChaseCamera(p, cam, false); + } } } diff --git a/src/p_user.c b/src/p_user.c index bdab2b92d..f31190343 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3172,10 +3172,6 @@ void P_ToggleDemoCamera(UINT8 viewnum) } static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; - -#define intsign(n) \ - ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) - static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { INT32 laim, forward, side, axis; @@ -3497,8 +3493,6 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->subsector = R_PointInSubsector(cam->x, cam->y); } -#undef intsign - void P_ResetCamera(player_t *player, camera_t *thiscam) { tic_t tries = 0; @@ -3886,6 +3880,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusaiming = player->aiming; } + if (abs(thiscam->dpad_y_held) >= 2*TICRATE) + { + focusaiming += ANGLE_45 * intsign(thiscam->dpad_y_held) * P_MobjFlip(mo); + } + if (P_CameraThinker(player, thiscam, resetcalled)) return true; diff --git a/src/r_main.c b/src/r_main.c index 1b575dd11..20461b4a6 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -839,10 +839,6 @@ void R_ApplyViewMorph(void) vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); } -static inline int intsign(int n) { - return n < 0 ? -1 : n > 0 ? 1 : 0; -} - angle_t R_ViewRollAngle(const player_t *player) { angle_t roll = 0; From 2b09e74dcf76ab49e80f1d7149f944206913158d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 18:53:26 +0100 Subject: [PATCH 73/76] kill aiming stuff in BuildTiccmd --- src/g_game.c | 67 ++++------------------------------------------------ 1 file changed, 4 insertions(+), 63 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 4692f84c2..3c511ee6d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -899,12 +899,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) INT32 laim, th, tspeed, forward, side, axis; // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming; - boolean invertmouse, usejoystick, kbl, rd; + boolean turnleft, turnright; + boolean usejoystick, rd; angle_t lang; static INT32 turnheld[MAXSPLITSCREENPLAYERS]; // for accelerative turning - static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame if (demo.playback) @@ -916,38 +915,28 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) camera_t *thiscam = &camera[forplayer]; const boolean freecam = camera[forplayer].freecam; - const boolean lookaxis = cv_lookaxis[forplayer].value; const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; lang = localangle[forplayer]; laim = localaiming[forplayer]; th = turnheld[forplayer]; - kbl = keyboard_look[forplayer]; rd = resetdown[forplayer]; switch (ssplayer) { case 2: G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); - mouseaiming = player->spectator; - invertmouse = cv_invertmouse2.value; break; case 3: G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); - mouseaiming = false; - invertmouse = false; break; case 4: G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); - mouseaiming = false; - invertmouse = false; break; case 1: default: G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver - mouseaiming = player->spectator; - invertmouse = cv_invertmouse.value; break; } @@ -957,7 +946,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) { cmd->angleturn = (INT16)(lang >> 16); - cmd->aiming = G_ClipAimingPitch(&laim); + cmd->aiming = 0; return; } @@ -1120,54 +1109,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else rd = false; - // spectator aiming shit, ahhhh... - { - INT32 player_invert = invertmouse ? -1 : 1; - INT32 screen_invert = - (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!thiscam->chase || player->pflags & PF_FLIPCAM)) // because chasecam's not inverted - ? -1 : 1; // set to -1 or 1 to multiply - - // mouse look stuff (mouse look is not the same as mouse aim) - if (mouseaiming && player->spectator) - { - kbl = false; - - // looking up/down - laim += (mlooky<<19)*player_invert*screen_invert; - } - - axis = JoyAxis(AXISLOOK, ssplayer); - if (analogjoystickmove && axis != 0 && lookaxis && player->spectator) - laim += (axis<<16) * screen_invert; - - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis && !mouseaiming) - laim = 0; - - if (player->spectator) - { - if (InputDown(gc_lookup, ssplayer) || (gamepadjoystickmove && axis < 0)) - { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; - } - else if (InputDown(gc_lookdown, ssplayer) || (gamepadjoystickmove && axis > 0)) - { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; - } - } - - if (InputDown(gc_centerview, ssplayer)) // No need to put a spectator limit on this one though :V - laim = 0; - - // accept no mlook for network games - if (!cv_allowmlook.value) - laim = 0; - - cmd->aiming = G_ClipAimingPitch(&laim); - } + cmd->aiming = 0; mousex = mousey = mlooky = 0; @@ -1219,7 +1161,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { localangle[forplayer] = lang; localaiming[forplayer] = laim; - keyboard_look[forplayer] = kbl; turnheld[forplayer] = th; resetdown[forplayer] = rd; axis = JoyAxis(AXISLOOKBACK, ssplayer); From 3bbdd1ea720f99d0bb64d40ed803d79bbbcc0a3c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jan 2025 22:26:07 +0100 Subject: [PATCH 74/76] e better play it safe --- src/g_game.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 3c511ee6d..b527009db 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -946,7 +946,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) { cmd->angleturn = (INT16)(lang >> 16); - cmd->aiming = 0; + cmd->aiming = G_ClipAimingPitch(&laim); return; } @@ -1109,7 +1109,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else rd = false; - cmd->aiming = 0; + cmd->aiming = G_ClipAimingPitch(&laim); mousex = mousey = mlooky = 0; From 6d94ff8d1f513133e9bf45f00b4949bff8bac948 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 22 Jan 2025 19:42:01 +0100 Subject: [PATCH 75/76] fix freecam not resetting online idk local player handling is fucking awful in kart --- src/p_mobj.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index cd3054b59..abb82c5f4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10774,7 +10774,19 @@ void P_SpawnPlayer(INT32 playernum) { if (!p->spectator) { - camera[playernum].freecam = false; + if (playernum == consoleplayer) + camera[0].freecam = false; + else if (splitscreen) + { + for (i = 1; i <= splitscreen; i++) + { + if (playernum == displayplayers[i]) + { + camera[i].freecam = false; + break; + } + } + } } } } From 97a5c15c360d23cb509dbf6ff6b57e769788da44 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Jan 2025 15:50:45 +0100 Subject: [PATCH 76/76] just use D_NumPlayers --- src/k_director.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index 402f5d039..70fd66bbf 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -40,25 +40,6 @@ struct directorinfo INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? } directorinfo; -static boolean K_DirectorIsPlayerAlone(void) -{ - UINT8 pingame = 0; - - // Gotta check how many players are active at this moment. - for (UINT8 i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - pingame++; - - if (pingame >= 2) // we dont need to check further - break; - } - - return (pingame <= 1); -} - static inline boolean race_rules(void) { return gametype == GT_RACE; @@ -73,7 +54,7 @@ boolean K_DirectorIsAvailable(void) { if (splitscreen || (demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); + return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && (D_NumPlayers() > 1)))); } static boolean K_DirectorIsEnabled(void)