mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-17 19:11:30 +00:00
WIP: Turn towards local camera (midgame join broken right now)
This commit is contained in:
parent
d76a10f2fa
commit
7c08634f7e
5 changed files with 94 additions and 34 deletions
|
|
@ -359,10 +359,10 @@ struct doomdata_t
|
|||
UINT8 reserved; // Padding
|
||||
union
|
||||
{
|
||||
clientcmd_pak clientpak; // 145 bytes
|
||||
client2cmd_pak client2pak; // 202 bytes
|
||||
client3cmd_pak client3pak; // 258 bytes(?)
|
||||
client4cmd_pak client4pak; // 316 bytes(?)
|
||||
clientcmd_pak clientpak; // 147 bytes
|
||||
client2cmd_pak client2pak; // 206 bytes
|
||||
client3cmd_pak client3pak; // 264 bytes(?)
|
||||
client4cmd_pak client4pak; // 324 bytes(?)
|
||||
servertics_pak serverpak; // 132495 bytes (more around 360, no?)
|
||||
serverconfig_pak servercfg; // 773 bytes
|
||||
UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...)
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ struct ticcmd_t
|
|||
{
|
||||
SINT8 forwardmove; // -MAXPLMOVE to MAXPLMOVE (50)
|
||||
INT16 turning; // Turn speed
|
||||
INT16 angle; // Predicted angle, use me if you can!
|
||||
INT16 throwdir; // Aiming direction
|
||||
INT16 aiming; // vertical aiming, see G_BuildTicCmd
|
||||
UINT16 buttons;
|
||||
|
|
|
|||
37
src/g_demo.c
37
src/g_demo.c
|
|
@ -136,14 +136,15 @@ demoghost *ghosts = NULL;
|
|||
#define DEMO_BOT 0x08
|
||||
|
||||
// For demos
|
||||
#define ZT_FWD 0x01
|
||||
#define ZT_SIDE 0x02
|
||||
#define ZT_TURNING 0x04
|
||||
#define ZT_THROWDIR 0x08
|
||||
#define ZT_BUTTONS 0x10
|
||||
#define ZT_AIMING 0x20
|
||||
#define ZT_LATENCY 0x40
|
||||
#define ZT_FLAGS 0x80
|
||||
#define ZT_FWD 1
|
||||
#define ZT_SIDE 2
|
||||
#define ZT_TURNING 4
|
||||
#define ZT_ANGLE 8
|
||||
#define ZT_THROWDIR 16
|
||||
#define ZT_BUTTONS 32
|
||||
#define ZT_AIMING 64
|
||||
#define ZT_LATENCY 128
|
||||
#define ZT_FLAGS 256
|
||||
// OUT OF ZIPTICS...
|
||||
|
||||
#define DEMOMARKER 0x80 // demobuf.end
|
||||
|
|
@ -530,17 +531,19 @@ void G_WriteDemoExtraData(void)
|
|||
|
||||
void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum)
|
||||
{
|
||||
UINT8 ziptic;
|
||||
UINT16 ziptic;
|
||||
|
||||
if (!demobuf.p || !demo.deferstart)
|
||||
return;
|
||||
|
||||
ziptic = READUINT8(demobuf.p);
|
||||
ziptic = READUINT16(demobuf.p);
|
||||
|
||||
if (ziptic & ZT_FWD)
|
||||
oldcmd[playernum].forwardmove = READSINT8(demobuf.p);
|
||||
if (ziptic & ZT_TURNING)
|
||||
oldcmd[playernum].turning = READINT16(demobuf.p);
|
||||
if (ziptic & ZT_ANGLE)
|
||||
oldcmd[playernum].angle = READINT16(demobuf.p);
|
||||
if (ziptic & ZT_THROWDIR)
|
||||
oldcmd[playernum].throwdir = READINT16(demobuf.p);
|
||||
if (ziptic & ZT_BUTTONS)
|
||||
|
|
@ -564,13 +567,14 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum)
|
|||
|
||||
void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum)
|
||||
{
|
||||
char ziptic = 0;
|
||||
UINT16 ziptic = 0;
|
||||
UINT8 *ziptic_p;
|
||||
(void)playernum;
|
||||
|
||||
if (!demobuf.p)
|
||||
return;
|
||||
ziptic_p = demobuf.p++; // the ziptic, written at the end of this function
|
||||
ziptic_p = demobuf.p; // the ziptic, written at the end of this function
|
||||
demobuf.p += 2;
|
||||
|
||||
if (cmd->forwardmove != oldcmd[playernum].forwardmove)
|
||||
{
|
||||
|
|
@ -586,6 +590,13 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum)
|
|||
ziptic |= ZT_TURNING;
|
||||
}
|
||||
|
||||
if (cmd->angle != oldcmd[playernum].angle)
|
||||
{
|
||||
WRITEINT16(demobuf.p,cmd->angle);
|
||||
oldcmd[playernum].turning = cmd->angle;
|
||||
ziptic |= ZT_ANGLE;
|
||||
}
|
||||
|
||||
if (cmd->throwdir != oldcmd[playernum].throwdir)
|
||||
{
|
||||
WRITEINT16(demobuf.p,cmd->throwdir);
|
||||
|
|
@ -621,7 +632,7 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum)
|
|||
ziptic |= ZT_FLAGS;
|
||||
}
|
||||
|
||||
*ziptic_p = ziptic;
|
||||
WRITEUINT16(ziptic_p, ziptic);
|
||||
|
||||
// attention here for the ticcmd size!
|
||||
// latest demos with mouse aiming byte in ticcmd
|
||||
|
|
|
|||
37
src/g_game.c
37
src/g_game.c
|
|
@ -1080,6 +1080,8 @@ INT32 localaiming[MAXSPLITSCREENPLAYERS];
|
|||
angle_t localangle[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
INT32 localsteering[MAXSPLITSCREENPLAYERS];
|
||||
INT32 localdrift[MAXSPLITSCREENPLAYERS];
|
||||
INT32 localdriftend[MAXSPLITSCREENPLAYERS];
|
||||
INT32 localdelta[MAXSPLITSCREENPLAYERS];
|
||||
INT32 localstoredeltas[MAXSPLITSCREENPLAYERS][TICCMD_LATENCYMASK + 1];
|
||||
UINT8 locallatency[MAXSPLITSCREENPLAYERS][TICRATE];
|
||||
|
|
@ -1113,25 +1115,21 @@ static void G_DoAnglePrediction(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer, p
|
|||
|
||||
localtic = cmd->latency;
|
||||
|
||||
if (player->pflags & PF_DRIFTEND)
|
||||
while (realtics > 0)
|
||||
{
|
||||
// Otherwise, your angle slingshots off to the side violently...
|
||||
G_ResetAnglePrediction(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (realtics > 0)
|
||||
{
|
||||
localsteering[ssplayer - 1] = K_UpdateSteeringValue(localsteering[ssplayer - 1], cmd->turning);
|
||||
angleChange = K_GetKartTurnValue(player, localsteering[ssplayer - 1]) << TICCMD_REDUCE;
|
||||
pflags_t oldflags = player->pflags;
|
||||
|
||||
// Store the angle we applied to this tic, so we can revert it later.
|
||||
// If we trust the camera to do all of the work, then it can get out of sync fast.
|
||||
localstoredeltas[ssplayer - 1][cmd->latency] += angleChange;
|
||||
localdelta[ssplayer - 1] += angleChange;
|
||||
localsteering[ssplayer - 1] = K_UpdateSteeringValue(localsteering[ssplayer - 1], cmd->turning);
|
||||
angleChange = K_GetKartTurnValue(player, localsteering[ssplayer - 1]) << TICCMD_REDUCE;
|
||||
|
||||
realtics--;
|
||||
}
|
||||
player->pflags = oldflags;
|
||||
|
||||
// Store the angle we applied to this tic, so we can revert it later.
|
||||
// If we trust the camera to do all of the work, then it can get out of sync fast.
|
||||
localstoredeltas[ssplayer - 1][cmd->latency] += angleChange;
|
||||
localdelta[ssplayer - 1] += angleChange;
|
||||
|
||||
realtics--;
|
||||
}
|
||||
|
||||
// We COULD set it to destAngle directly...
|
||||
|
|
@ -1141,6 +1139,7 @@ static void G_DoAnglePrediction(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer, p
|
|||
|
||||
diff = destAngle - localangle[ssplayer - 1];
|
||||
|
||||
/*
|
||||
if (diff > ANGLE_180)
|
||||
{
|
||||
diff = InvAngle(InvAngle(diff) / 2);
|
||||
|
|
@ -1151,9 +1150,10 @@ static void G_DoAnglePrediction(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer, p
|
|||
}
|
||||
|
||||
localangle[ssplayer - 1] += diff;
|
||||
*/
|
||||
|
||||
// In case of angle debugging, break glass
|
||||
// localangle[ssplayer - 1] = destAngle;
|
||||
localangle[ssplayer - 1] = destAngle;
|
||||
}
|
||||
|
||||
void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
|
|
@ -1292,6 +1292,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
cmd->throwdir -= (joystickvector.yaxis * KART_FULLTURN) / JOYAXISRANGE;
|
||||
}
|
||||
}
|
||||
|
||||
cmd->angle = localangle[forplayer] >> TICCMD_REDUCE;
|
||||
|
||||
// drift
|
||||
if (G_PlayerInputDown(forplayer, gc_drift, 0))
|
||||
|
|
@ -1422,6 +1424,7 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n)
|
|||
{
|
||||
dest[i].forwardmove = src[i].forwardmove;
|
||||
dest[i].turning = (INT16)SHORT(src[i].turning);
|
||||
dest[i].angle = (INT16)SHORT(src[i].angle);
|
||||
dest[i].throwdir = (INT16)SHORT(src[i].throwdir);
|
||||
dest[i].aiming = (INT16)SHORT(src[i].aiming);
|
||||
dest[i].buttons = (UINT16)SHORT(src[i].buttons);
|
||||
|
|
|
|||
45
src/p_user.c
45
src/p_user.c
|
|
@ -2136,6 +2136,42 @@ static void P_UpdatePlayerAngle(player_t *player)
|
|||
player->steering = K_UpdateSteeringValue(player->steering, player->cmd.turning);
|
||||
angleChange = K_GetKartTurnValue(player, player->steering) << TICCMD_REDUCE;
|
||||
|
||||
INT16 steeringRight = K_UpdateSteeringValue(player->steering, KART_FULLTURN);
|
||||
angle_t maxTurnRight = K_GetKartTurnValue(player, steeringRight) << TICCMD_REDUCE;
|
||||
INT16 steeringLeft = K_UpdateSteeringValue(player->steering, -1 * KART_FULLTURN);
|
||||
angle_t maxTurnLeft = K_GetKartTurnValue(player, steeringLeft) << TICCMD_REDUCE;
|
||||
|
||||
angle_t targetAngle = (player->cmd.angle) << TICCMD_REDUCE;
|
||||
|
||||
angle_t targetDelta = targetAngle - (player->mo->angle);
|
||||
|
||||
//CONS_Printf("%u, steering by %u but we want %u, MTL %d %u, MTR %d %u\n", targetAngle, angleChange, targetDelta, steeringLeft, maxTurnLeft, steeringRight, maxTurnRight);
|
||||
|
||||
if (targetDelta == angleChange)
|
||||
{
|
||||
//CONS_Printf("Facing correct, thank god\n");
|
||||
}
|
||||
else if (targetDelta >= ANGLE_180 && maxTurnLeft >= targetDelta)
|
||||
{
|
||||
//CONS_Printf("undershoot left\n");
|
||||
angleChange = targetDelta;
|
||||
}
|
||||
else if (targetDelta <= ANGLE_180 && maxTurnRight <= targetDelta)
|
||||
{
|
||||
//CONS_Printf("undershoot right\n");
|
||||
angleChange = targetDelta;
|
||||
}
|
||||
else if (targetDelta >= ANGLE_180 && maxTurnLeft < targetDelta)
|
||||
{
|
||||
//CONS_Printf("overshoot left\n");
|
||||
angleChange = maxTurnLeft;
|
||||
}
|
||||
else if (targetDelta <= ANGLE_180 && maxTurnRight < targetDelta)
|
||||
{
|
||||
//CONS_Printf("overshoot right\n");
|
||||
angleChange = maxTurnRight;
|
||||
}
|
||||
|
||||
if (p == UINT8_MAX)
|
||||
{
|
||||
// When F12ing players, set local angle directly.
|
||||
|
|
@ -2144,6 +2180,8 @@ static void P_UpdatePlayerAngle(player_t *player)
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
// During standard play, our latency can vary by up to 1 tic in either direction, even on a stable connection.
|
||||
// This probably comes from differences in ticcmd dispatch vs consumption rate. Probably.
|
||||
// Uncorrected, this 2-tic "wobble" causes camera corrections to sometimes be skipped or batched.
|
||||
|
|
@ -2157,10 +2195,16 @@ static void P_UpdatePlayerAngle(player_t *player)
|
|||
|
||||
UINT8 lateTic = ((leveltime - maxlatency) & TICCMD_LATENCYMASK);
|
||||
UINT8 clearTic = ((localtic + 1) & TICCMD_LATENCYMASK);
|
||||
*/
|
||||
|
||||
/*
|
||||
player->angleturn += angleChange;
|
||||
player->mo->angle = player->angleturn;
|
||||
*/
|
||||
|
||||
player->mo->angle += angleChange;
|
||||
|
||||
/*
|
||||
// Undo the ticcmd's old emulated angle,
|
||||
// now that we added the actual game logic angle.
|
||||
|
||||
|
|
@ -2171,6 +2215,7 @@ static void P_UpdatePlayerAngle(player_t *player)
|
|||
|
||||
lateTic = (lateTic - 1) & TICCMD_LATENCYMASK;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (!cv_allowmlook.value || player->spectator == false)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue