mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 13:21:10 +00:00
Improve replay resyncing code
Notably, it should no longer cause immediate desync warnings if a track starts on a slope.
This commit is contained in:
parent
dd75c1621c
commit
1fa32a4b9d
1 changed files with 16 additions and 12 deletions
28
src/g_game.c
28
src/g_game.c
|
@ -5073,7 +5073,8 @@ void G_WriteGhostTic(mobj_t *ghost)
|
|||
// GZT_XYZ is only useful if you've moved 256 FRACUNITS or more in a single tic.
|
||||
if (abs(ghost->x-oldghost.x) > MAXMOM
|
||||
|| abs(ghost->y-oldghost.y) > MAXMOM
|
||||
|| abs(ghost->z-oldghost.z) > MAXMOM)
|
||||
|| abs(ghost->z-oldghost.z) > MAXMOM
|
||||
|| leveltime & 255 == 1) // Hack to enable slightly nicer resyncing
|
||||
{
|
||||
oldghost.x = ghost->x;
|
||||
oldghost.y = ghost->y;
|
||||
|
@ -5087,8 +5088,8 @@ void G_WriteGhostTic(mobj_t *ghost)
|
|||
{
|
||||
// For moving normally:
|
||||
// Store one full byte of movement, plus one byte of fractional movement.
|
||||
INT16 momx = (INT16)((ghost->x-oldghost.x)>>8);
|
||||
INT16 momy = (INT16)((ghost->y-oldghost.y)>>8);
|
||||
INT16 momx = (INT16)((ghost->x-oldghost.x + (1<<4))>>8);
|
||||
INT16 momy = (INT16)((ghost->y-oldghost.y + (1<<4))>>8);
|
||||
if (momx != oldghost.momx
|
||||
|| momy != oldghost.momy)
|
||||
{
|
||||
|
@ -5098,7 +5099,7 @@ void G_WriteGhostTic(mobj_t *ghost)
|
|||
WRITEINT16(demo_p,momx);
|
||||
WRITEINT16(demo_p,momy);
|
||||
}
|
||||
momx = (INT16)((ghost->z-oldghost.z)>>8);
|
||||
momx = (INT16)((ghost->z-oldghost.z + (1<<4))>>8);
|
||||
if (momx != oldghost.momz)
|
||||
{
|
||||
oldghost.momz = momx;
|
||||
|
@ -5202,8 +5203,9 @@ void G_WriteGhostTic(mobj_t *ghost)
|
|||
void G_ConsGhostTic(void)
|
||||
{
|
||||
UINT8 ziptic;
|
||||
UINT16 px,py,pz,gx,gy,gz;
|
||||
UINT32 px,py,pz,gx,gy,gz;
|
||||
mobj_t *testmo;
|
||||
UINT32 syncleeway;
|
||||
boolean nightsfail = false;
|
||||
|
||||
if (!demo_p || !demo_start)
|
||||
|
@ -5220,6 +5222,7 @@ void G_ConsGhostTic(void)
|
|||
oldghost.x = READFIXED(demo_p);
|
||||
oldghost.y = READFIXED(demo_p);
|
||||
oldghost.z = READFIXED(demo_p);
|
||||
syncleeway = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5233,6 +5236,7 @@ void G_ConsGhostTic(void)
|
|||
oldghost.x += oldghost.momx;
|
||||
oldghost.y += oldghost.momy;
|
||||
oldghost.z += oldghost.momz;
|
||||
syncleeway = FRACUNIT;
|
||||
}
|
||||
if (ziptic & GZT_ANGLE)
|
||||
demo_p++;
|
||||
|
@ -5298,14 +5302,14 @@ void G_ConsGhostTic(void)
|
|||
}
|
||||
|
||||
// Re-synchronise
|
||||
px = testmo->x>>FRACBITS;
|
||||
py = testmo->y>>FRACBITS;
|
||||
pz = testmo->z>>FRACBITS;
|
||||
gx = oldghost.x>>FRACBITS;
|
||||
gy = oldghost.y>>FRACBITS;
|
||||
gz = oldghost.z>>FRACBITS;
|
||||
px = testmo->x;
|
||||
py = testmo->y;
|
||||
pz = testmo->z;
|
||||
gx = oldghost.x;
|
||||
gy = oldghost.y;
|
||||
gz = oldghost.z;
|
||||
|
||||
if (nightsfail || px != gx || py != gy || pz != gz)
|
||||
if (nightsfail || abs(px-gx) > syncleeway || abs(py-gy) > syncleeway || abs(pz-gz) > syncleeway)
|
||||
{
|
||||
if (demosynced)
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n"));
|
||||
|
|
Loading…
Reference in a new issue