mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 12:21:19 +00:00
fix rewind, fix sound local sound playing in freecam
This commit is contained in:
parent
45b62aa8a4
commit
18c8f47f9a
7 changed files with 55 additions and 53 deletions
|
@ -6002,9 +6002,6 @@ void G_PreviewRewind(tic_t previewtime)
|
|||
players[i].kartstuff[j] = info->playerinfo[i].player.kartstuff[j];
|
||||
}
|
||||
|
||||
if (demo.freecam)
|
||||
return; // nope
|
||||
|
||||
for (i = splitscreen; i >= 0; i--)
|
||||
P_ResetCamera(&players[displayplayers[i]], &camera[i]);
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@ struct demovars_s {
|
|||
DSM_WILLSAVE,
|
||||
DSM_SAVED
|
||||
} savemode;
|
||||
|
||||
|
||||
boolean freecam;
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern struct demovars_s demo;
|
||||
|
|
|
@ -1062,7 +1062,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
|
|||
}
|
||||
|
||||
// This makes the roulette produce the random noises.
|
||||
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player))
|
||||
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player) && !demo.freecam)
|
||||
{
|
||||
#define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8))
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
|
@ -1096,7 +1096,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))
|
||||
if (P_IsDisplayPlayer(player) && !demo.freecam)
|
||||
S_StartSound(NULL, sfx_itrole);
|
||||
return;
|
||||
}
|
||||
|
@ -1109,7 +1109,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))
|
||||
if (P_IsDisplayPlayer(player) && !demo.freecam)
|
||||
S_StartSound(NULL, sfx_dbgsal);
|
||||
return;
|
||||
}
|
||||
|
@ -1141,7 +1141,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
|
|||
player->kartstuff[k_itemamount] = 1;
|
||||
}
|
||||
|
||||
if (P_IsDisplayPlayer(player))
|
||||
if (P_IsDisplayPlayer(player) && !demo.freecam)
|
||||
S_StartSound(NULL, ((player->kartstuff[k_roulettetype] == 1) ? sfx_itrolk : (mashed ? sfx_itrolm : sfx_itrolf)));
|
||||
|
||||
player->kartstuff[k_itemblink] = TICRATE;
|
||||
|
|
|
@ -113,11 +113,8 @@ typedef struct camera_s
|
|||
struct demofreecam_s {
|
||||
|
||||
camera_t *cam; // this is useful when the game is paused, notably
|
||||
|
||||
fixed_t rewindx;
|
||||
fixed_t rewindy;
|
||||
fixed_t rewindz; // when rewinding, this is used to make sure the cam doesn't reset
|
||||
|
||||
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
|
||||
|
|
|
@ -3201,8 +3201,9 @@ boolean P_SetupLevel(boolean skipprecip)
|
|||
|
||||
if (!dedicated)
|
||||
{
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
P_SetupCamera(displayplayers[i], &camera[i]);
|
||||
if (!demo.freecam)
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
P_SetupCamera(displayplayers[i], &camera[i]);
|
||||
|
||||
// Salt: CV_ClearChangedFlags() messes with your settings :(
|
||||
/*if (!cv_cam_height.changed)
|
||||
|
|
77
src/p_user.c
77
src/p_user.c
|
@ -7217,11 +7217,11 @@ static ticcmd_t cameracmd;
|
|||
|
||||
struct demofreecam_s democam;
|
||||
|
||||
// called by m_menu to reinit cam input every time it's toggled
|
||||
// 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)
|
||||
{
|
||||
|
@ -7231,17 +7231,17 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
|
|||
boolean turnleft, turnright, mouseaiming;
|
||||
boolean invertmouse, lookaxis, usejoystick, kbl;
|
||||
angle_t lang;
|
||||
|
||||
|
||||
ticcmd_t *cmd = &cameracmd;
|
||||
|
||||
|
||||
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);
|
||||
|
@ -7295,7 +7295,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
|
|||
cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed]));
|
||||
side -= sidemove[1];
|
||||
}
|
||||
|
||||
|
||||
cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8)));
|
||||
|
||||
axis = JoyAxis(AXISMOVE, 1);
|
||||
|
@ -7342,7 +7342,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
|
|||
laim = 0;
|
||||
|
||||
cmd->aiming = G_ClipAimingPitch(&laim);
|
||||
|
||||
|
||||
mousex = mousey = mlooky = 0;
|
||||
|
||||
if (forward > MAXPLMOVE)
|
||||
|
@ -7362,35 +7362,32 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
|
|||
}
|
||||
|
||||
lang += (cmd->angleturn<<16);
|
||||
|
||||
|
||||
democam.localangle = lang;
|
||||
democam.localaiming = laim;
|
||||
democam.turnheld = th;
|
||||
democam.keyboardlook = kbl;
|
||||
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
void P_DemoCameraMovement(camera_t *cam)
|
||||
{
|
||||
ticcmd_t *cmd;
|
||||
ticcmd_t *cmd;
|
||||
angle_t thrustangle;
|
||||
|
||||
mobj_t *awayviewmobj_hack;
|
||||
|
||||
// update democam stuff with what we got here:
|
||||
democam.cam = cam;
|
||||
democam.localangle = cam->angle;
|
||||
democam.localaiming = cam->aiming;
|
||||
|
||||
democam.rewindx = cam->x;
|
||||
democam.rewindy = cam->y;
|
||||
democam.rewindz = cam->z;
|
||||
|
||||
|
||||
// first off we need to get button input
|
||||
cmd = P_CameraCmd(cam);
|
||||
|
||||
|
||||
cam->aiming = cmd->aiming<<FRACBITS;
|
||||
cam->angle = cmd->angleturn<<16;
|
||||
|
||||
|
||||
// camera movement:
|
||||
|
||||
if (cmd->buttons & BT_ACCELERATE)
|
||||
|
@ -7398,29 +7395,37 @@ void P_DemoCameraMovement(camera_t *cam)
|
|||
else if (cmd->buttons & BT_BRAKE)
|
||||
cam->z -= 32*mapobjectscale;
|
||||
|
||||
|
||||
|
||||
cam->momx = cam->momy = cam->momz = 0;
|
||||
if (cmd->forwardmove != 0)
|
||||
{
|
||||
|
||||
|
||||
thrustangle = cam->angle >> ANGLETOFINESHIFT;
|
||||
|
||||
cam->momx += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle));
|
||||
cam->momy += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle));
|
||||
cam->momz += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming));
|
||||
|
||||
//funny thing cameras aren't mobjs so we gotta handle this ourselves;
|
||||
cam->x += cam->momx;
|
||||
cam->y += cam->momy;
|
||||
cam->z += cam->momz;
|
||||
|
||||
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));
|
||||
// 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;
|
||||
}
|
||||
|
||||
void P_ResetCamera(player_t *player, camera_t *thiscam)
|
||||
{
|
||||
|
||||
if (demo.freecam)
|
||||
return; // do not reset the camera there.
|
||||
|
||||
tic_t tries = 0;
|
||||
fixed_t x, y, z;
|
||||
|
||||
|
@ -7477,13 +7482,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
boolean cameranoclip;
|
||||
subsector_t *newsubsec;
|
||||
#endif
|
||||
|
||||
|
||||
democam.soundmobj = NULL; // reset this each frame, we don't want the game crashing for stupid reasons now do we
|
||||
|
||||
if (demo.freecam)
|
||||
{
|
||||
{
|
||||
P_DemoCameraMovement(thiscam);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// We probably shouldn't move the camera if there is no player or player mobj somehow
|
||||
if (!player || !player->mo)
|
||||
return true;
|
||||
|
|
|
@ -442,7 +442,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
|
|||
listener_t listener3 = {0,0,0,0};
|
||||
listener_t listener4 = {0,0,0,0};
|
||||
|
||||
mobj_t *listenmobj = players[displayplayers[0]].mo;
|
||||
mobj_t *listenmobj = democam.soundmobj ? : players[displayplayers[0]].mo;
|
||||
mobj_t *listenmobj2 = NULL;
|
||||
mobj_t *listenmobj3 = NULL;
|
||||
mobj_t *listenmobj4 = NULL;
|
||||
|
@ -903,7 +903,7 @@ void S_UpdateSounds(void)
|
|||
listener_t listener3;
|
||||
listener_t listener4;
|
||||
|
||||
mobj_t *listenmobj = players[displayplayers[0]].mo;
|
||||
mobj_t *listenmobj = democam.soundmobj ? : players[displayplayers[0]].mo;
|
||||
mobj_t *listenmobj2 = NULL;
|
||||
mobj_t *listenmobj3 = NULL;
|
||||
mobj_t *listenmobj4 = NULL;
|
||||
|
|
Loading…
Reference in a new issue