From 077076532f3f701562d91a97dfcc84817749b299 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jan 2025 14:17:44 +0100 Subject: [PATCH 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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);