mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
P_DemoCameraMovement: use locally built ticcmd from G_BuildTiccmd
This commit is contained in:
parent
dbca307ad4
commit
fec0f13419
6 changed files with 30 additions and 144 deletions
|
|
@ -561,6 +561,11 @@ void D_ResetTiccmds(void)
|
|||
D_Clearticcmd(textcmds[i]->tic);
|
||||
}
|
||||
|
||||
ticcmd_t *D_LocalTiccmd(UINT8 ss)
|
||||
{
|
||||
return &localcmds[ss][0];
|
||||
}
|
||||
|
||||
void SendKick(UINT8 playernum, UINT8 msg)
|
||||
{
|
||||
UINT8 buf[2];
|
||||
|
|
|
|||
|
|
@ -615,7 +615,9 @@ extern UINT8 playerconsole[MAXPLAYERS];
|
|||
|
||||
INT32 D_NumPlayers(void);
|
||||
boolean D_IsPlayerHumanAndGaming(INT32 player_number);
|
||||
|
||||
void D_ResetTiccmds(void);
|
||||
ticcmd_t *D_LocalTiccmd(UINT8 ss);
|
||||
|
||||
tic_t GetLag(INT32 node);
|
||||
UINT8 GetFreeXCmdSize(UINT8 playerid);
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ class TiccmdBuilder
|
|||
|
||||
bool spectator_analog_input()
|
||||
{
|
||||
if (!player()->spectator && !objectplacing)
|
||||
if (!player()->spectator && !objectplacing && !demo.freecam)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -361,6 +361,26 @@ public:
|
|||
explicit TiccmdBuilder(ticcmd_t* cmd_, INT32 realtics_, UINT8 ssplayer_) :
|
||||
cmd(cmd_), realtics(realtics_), ssplayer(ssplayer_), viewnum(G_PartyPosition(g_localplayers[forplayer()]))
|
||||
{
|
||||
auto regular_input = [this]
|
||||
{
|
||||
analog_input();
|
||||
common_button_input();
|
||||
};
|
||||
|
||||
if (demo.freecam)
|
||||
{
|
||||
// freecam is controllable even while paused
|
||||
|
||||
*cmd = {};
|
||||
|
||||
if (!typing_input())
|
||||
{
|
||||
regular_input();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (paused || P_AutoPause())
|
||||
{
|
||||
return;
|
||||
|
|
@ -391,8 +411,7 @@ public:
|
|||
|
||||
if (!overlay)
|
||||
{
|
||||
analog_input();
|
||||
common_button_input();
|
||||
regular_input();
|
||||
}
|
||||
|
||||
cmd->angle = localangle[viewnum] >> TICCMD_REDUCE;
|
||||
|
|
|
|||
|
|
@ -236,7 +236,6 @@ void M_PlaybackToggleFreecam(INT32 choice)
|
|||
splitscreen = 0;
|
||||
R_ExecuteSetViewSize();
|
||||
|
||||
P_InitCameraCmd(); // init camera controls
|
||||
if (!demo.freecam) // toggle on
|
||||
{
|
||||
demo.freecam = true;
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam);
|
|||
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_InitCameraCmd(void);
|
||||
|
||||
boolean P_PlayerInPain(player_t *player);
|
||||
void P_ResetPlayer(player_t *player);
|
||||
|
|
|
|||
140
src/p_user.c
140
src/p_user.c
|
|
@ -2979,146 +2979,8 @@ fixed_t t_cam_dist[MAXSPLITSCREENPLAYERS] = {-42,-42,-42,-42};
|
|||
fixed_t t_cam_height[MAXSPLITSCREENPLAYERS] = {-42,-42,-42,-42};
|
||||
fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42,-42,-42,-42};
|
||||
|
||||
// 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
|
||||
// TODO: please just use the normal ticcmd function somehow
|
||||
|
||||
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 forward, axis; //i
|
||||
// these ones used for multiple conditions
|
||||
boolean turnleft, turnright, mouseaiming;
|
||||
boolean invertmouse, lookaxis, usejoystick, kbl;
|
||||
INT32 player_invert;
|
||||
INT32 screen_invert;
|
||||
*/
|
||||
ticcmd_t *cmd = &cameracmd;
|
||||
|
||||
(void)cam;
|
||||
|
||||
if (!demo.playback)
|
||||
return cmd; // empty cmd, no.
|
||||
|
||||
/*
|
||||
kbl = democam.keyboardlook;
|
||||
|
||||
G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver
|
||||
|
||||
mouseaiming = true;
|
||||
invertmouse = cv_invertmouse.value;
|
||||
lookaxis = cv_lookaxis[0].value;
|
||||
|
||||
usejoystick = true;
|
||||
turnright = PlayerInputDown(1, gc_turnright);
|
||||
turnleft = PlayerInputDown(1, gc_turnleft);
|
||||
|
||||
axis = PlayerJoyAxis(1, AXISTURN);
|
||||
|
||||
if (encoremode)
|
||||
{
|
||||
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 = 0;
|
||||
|
||||
cmd->turning = 0;
|
||||
|
||||
// let movement keys cancel each other out
|
||||
if (turnright && !(turnleft))
|
||||
{
|
||||
cmd->turning -= KART_FULLTURN;
|
||||
}
|
||||
else if (turnleft && !(turnright))
|
||||
{
|
||||
cmd->turning += KART_FULLTURN;
|
||||
}
|
||||
|
||||
cmd->turning -= (mousex * 8) * (encoremode ? -1 : 1);
|
||||
|
||||
axis = PlayerJoyAxis(1, AXISMOVE);
|
||||
if (PlayerInputDown(1, gc_a) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
axis = PlayerJoyAxis(1, AXISBRAKE);
|
||||
if (PlayerInputDown(1, gc_brake) || (usejoystick && axis > 0))
|
||||
cmd->buttons |= BT_BRAKE;
|
||||
axis = PlayerJoyAxis(1, AXISAIM);
|
||||
if (PlayerInputDown(1, gc_aimforward) || (usejoystick && axis < 0))
|
||||
forward += MAXPLMOVE;
|
||||
if (PlayerInputDown(1, gc_aimbackward) || (usejoystick && axis > 0))
|
||||
forward -= MAXPLMOVE;
|
||||
|
||||
// fire with any button/key
|
||||
axis = PlayerJoyAxis(1, AXISFIRE);
|
||||
if (PlayerInputDown(1, gc_fire) || (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
|
||||
cmd->aiming += (mlooky<<19)*player_invert*screen_invert;
|
||||
|
||||
axis = PlayerJoyAxis(1, AXISLOOK);
|
||||
|
||||
// spring back if not using keyboard neither mouselookin'
|
||||
if (!kbl && !lookaxis && !mouseaiming)
|
||||
cmd->aiming = 0;
|
||||
|
||||
if (PlayerInputDown(1, gc_lookup) || (axis < 0))
|
||||
{
|
||||
cmd->aiming += KB_LOOKSPEED * screen_invert;
|
||||
kbl = true;
|
||||
}
|
||||
else if (PlayerInputDown(1, gc_lookdown) || (axis > 0))
|
||||
{
|
||||
cmd->aiming -= KB_LOOKSPEED * screen_invert;
|
||||
kbl = true;
|
||||
}
|
||||
|
||||
if (PlayerInputDown(1, gc_centerview)) // No need to put a spectator limit on this one though :V
|
||||
cmd->aiming = 0;
|
||||
|
||||
cmd->forwardmove += (SINT8)forward;
|
||||
|
||||
if (cmd->forwardmove > MAXPLMOVE)
|
||||
cmd->forwardmove = MAXPLMOVE;
|
||||
else if (cmd->forwardmove < -MAXPLMOVE)
|
||||
cmd->forwardmove = -MAXPLMOVE;
|
||||
|
||||
if (cmd->turning > KART_FULLTURN)
|
||||
cmd->turning = KART_FULLTURN;
|
||||
else if (cmd->turning < -KART_FULLTURN)
|
||||
cmd->turning = -KART_FULLTURN;
|
||||
|
||||
democam.keyboardlook = kbl;
|
||||
*/
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
void P_DemoCameraMovement(camera_t *cam)
|
||||
{
|
||||
ticcmd_t *cmd;
|
||||
|
|
@ -3131,7 +2993,7 @@ void P_DemoCameraMovement(camera_t *cam)
|
|||
democam.localaiming = cam->aiming;
|
||||
|
||||
// first off we need to get button input
|
||||
cmd = P_CameraCmd(cam);
|
||||
cmd = D_LocalTiccmd(0);
|
||||
|
||||
cam->aiming += cmd->aiming << TICCMD_REDUCE;
|
||||
cam->angle += cmd->turning << TICCMD_REDUCE;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue