Skip to content

Commit

Permalink
Fixed: Clientside mobjs on moving planes
Browse files Browse the repository at this point in the history
The server will now tell clients when a mobj is
on the floor so that it knows when it can rely on
its local plane Z heights for placing the objects.

Fixes Z coord flickering for remote mobjs on
moving planes.
  • Loading branch information
skyjake committed Jul 12, 2011
1 parent 1dfcf37 commit 6951b18
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/sv_pool.h
Expand Up @@ -89,6 +89,7 @@ typedef enum {
#define MDFC_TRANSLUCENCY 0x040000 // Mobj has translucency.
#define MDFC_FADETARGET 0x080000 // Mobj is fading to/from visible/invisible
#define MDFC_TYPE 0x100000 // Mobj type specified in delta.
#define MDFC_ON_FLOOR 0x200000 // Mobj Z is floorZ.

// Extra flags for the Extra Flags byte.
#define MDFE_FAST_MOM 0x01 // Momentum has 10.6 bits (+/- 512)
Expand Down
29 changes: 23 additions & 6 deletions doomsday/engine/portable/src/cl_mobj.c
Expand Up @@ -749,19 +749,33 @@ void ClMobj_ReadDelta2(boolean skip)
}
if(df & MDF_POS_Z)
{
d->pos[VZ] = FIX2FLT((Msg_ReadShort() << FRACBITS) | (Msg_ReadByte() << 8));
if(info)
if(!(moreFlags & MDFE_Z_FLOOR))
{
info->flags |= CLMF_KNOWN_Z;
d->pos[VZ] = FIX2FLT((Msg_ReadShort() << FRACBITS) | (Msg_ReadByte() << 8));
if(info)
{
info->flags |= CLMF_KNOWN_Z;

// The mobj won't stick if an explicit coordinate is supplied.
info->flags &= ~(CLMF_STICK_FLOOR | CLMF_STICK_CEILING);
}
d->floorZ = Msg_ReadFloat();
}
else
{
// Ignore these.
Msg_ReadShort();
Msg_ReadByte();
Msg_ReadFloat();

// The mobj won't stick if an explicit coordinate is supplied.
info->flags &= ~(CLMF_STICK_FLOOR | CLMF_STICK_CEILING);
info->flags |= CLMF_KNOWN_Z;
d->pos[VZ] = d->floorZ;
}

d->floorZ = Msg_ReadFloat();
d->ceilingZ = Msg_ReadFloat();
}

/*
// When these flags are set, the normal Z coord is not included.
if(moreFlags & MDFE_Z_FLOOR)
{
Expand All @@ -775,6 +789,7 @@ void ClMobj_ReadDelta2(boolean skip)
if(info)
info->flags |= CLMF_KNOWN_Z;
}
*/

// Momentum using 8.8 fixed point.
if(df & MDF_MOM_X)
Expand Down Expand Up @@ -872,12 +887,14 @@ void ClMobj_ReadDelta2(boolean skip)
}
}

/*
if(df & (MDF_POS_X | MDF_POS_Y | MDF_POS_Z) ||
moreFlags & (MDFE_Z_FLOOR | MDFE_Z_CEILING))
{
// This'll update floorz and ceilingz.
ClMobj_CheckPlanes(mo, justCreated);
}
*/

// If the clmobj is Hidden (or Nulled), it will not be linked back to
// the world until it's officially Created. (Otherwise, partially updated
Expand Down
9 changes: 9 additions & 0 deletions doomsday/engine/portable/src/sv_frame.c
Expand Up @@ -228,6 +228,13 @@ void Sv_WriteMobjDelta(const void* deltaPtr)
moreFlags |= MDFE_FADETARGET;
}

// On the floor?
if(df & MDFC_ON_FLOOR)
{
df |= MDF_MORE_FLAGS;
moreFlags |= MDFE_Z_FLOOR;
}

// Mobj type?
if(df & MDFC_TYPE)
{
Expand All @@ -239,6 +246,7 @@ void Sv_WriteMobjDelta(const void* deltaPtr)
if(d->selector & ~DDMOBJ_SELECTOR_MASK)
df |= MDF_SELSPEC;

/*
// Floor/ceiling z?
if(df & MDF_POS_Z)
{
Expand All @@ -249,6 +257,7 @@ void Sv_WriteMobjDelta(const void* deltaPtr)
moreFlags |= (d->pos[VZ] == DDMINFLOAT ? MDFE_Z_FLOOR : MDFE_Z_CEILING);
}
}
*/

#ifdef _DEBUG
if(df & MDFC_NULL)
Expand Down
8 changes: 8 additions & 0 deletions doomsday/engine/portable/src/sv_pool.c
Expand Up @@ -580,7 +580,15 @@ boolean Sv_RegisterCompareMobj(cregister_t* reg, const mobj_t* s,
if(r->pos[VY] != s->pos[VY])
df |= MDF_POS_Y;
if(r->pos[VZ] != Sv_GetMaxedMobjZ(s) || r->floorZ != s->floorZ || r->ceilingZ != s->ceilingZ)
{
df |= MDF_POS_Z;
if(!(df & MDFC_CREATE) && s->pos[VZ] <= s->floorZ)
{
// It is currently on the floor. The client will place it on its
// clientside floor and disregard the Z coordinate.
df |= MDFC_ON_FLOOR;
}
}

if(r->mom[MX] != s->mom[MX])
df |= MDF_MOM_X;
Expand Down

0 comments on commit 6951b18

Please sign in to comment.