Fix sound handling in demo freecam

- Object sounds are audible from the location of the
  camera
- Certain HUD sounds should no longer be audible
  - For instance, lap complete sfx
This commit is contained in:
James R 2023-08-14 01:16:35 -07:00 committed by NepDisk
parent 10e4fb183d
commit 6531cc065e
4 changed files with 17 additions and 28 deletions

View file

@ -3993,7 +3993,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.keyboardlook = false;

View file

@ -137,7 +137,6 @@ struct camera_t
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

View file

@ -1137,6 +1137,15 @@ boolean P_IsDisplayPlayer(player_t *player)
return false;
}
// 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 <= r_splitscreen; i++) // DON'T skip P1
{
if (player == &players[displayplayers[i]])
@ -2685,7 +2694,6 @@ void P_DemoCameraMovement(camera_t *cam)
{
ticcmd_t *cmd = &cameracmd;;
angle_t thrustangle;
mobj_t *awayviewmobj_hack;
player_t *lastp;
// update democam stuff with what we got here:
@ -2734,14 +2742,6 @@ void P_DemoCameraMovement(camera_t *cam)
// 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->renderflags |= RF_DONTDRAW;
democam.soundmobj = awayviewmobj_hack;
// update subsector to avoid crashes;
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y);
}
@ -2812,8 +2812,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->old_angle = thiscam->angle;
thiscam->old_aiming = thiscam->aiming;
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;

View file

@ -545,11 +545,6 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
continue;
}
if (i == 0 && democam.soundmobj)
{
continue;
}
if (player->awayviewtics)
{
listenmobj[i] = player->awayviewmobj;
@ -559,7 +554,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;
}
@ -810,11 +805,6 @@ void S_UpdateSounds(void)
continue;
}
if (i == 0 && democam.soundmobj)
{
continue;
}
if (player->awayviewtics)
{
listenmobj[i] = player->awayviewmobj;
@ -881,12 +871,15 @@ void S_UpdateSounds(void)
{
boolean itsUs = false;
for (i = r_splitscreen; i >= 0; i--)
if (!demo.freecam)
{
if (c->origin != listenmobj[i])
continue;
for (i = r_splitscreen; i >= 0; i--)
{
if (c->origin != listenmobj[i])
continue;
itsUs = true;
itsUs = true;
}
}
if (itsUs == false)