mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-25 13:55:36 -04:00
Restore Boom friction code for demo compatibility (#127)
* Restore Boom friction code for demo compatibility * clean up * fix original indentation * try to fix indent again * more indent fixes
This commit is contained in:
parent
1eea0b91b9
commit
8cb43b66a6
@ -170,6 +170,49 @@ int P_GetMoveFactor(const mobj_t *mo, int *frictionp)
|
|||||||
{
|
{
|
||||||
int movefactor, friction;
|
int movefactor, friction;
|
||||||
|
|
||||||
|
// Restore original Boom friction code for
|
||||||
|
// demo compatibility
|
||||||
|
if (demo_version < 203)
|
||||||
|
{
|
||||||
|
int momentum;
|
||||||
|
|
||||||
|
movefactor = ORIG_FRICTION_FACTOR;
|
||||||
|
|
||||||
|
if (!compatibility && variable_friction &&
|
||||||
|
!(mo->flags & (MF_NOGRAVITY | MF_NOCLIP)))
|
||||||
|
{
|
||||||
|
friction = mo->friction;
|
||||||
|
if (friction == ORIG_FRICTION) // normal floor
|
||||||
|
;
|
||||||
|
else if (friction > ORIG_FRICTION) // ice
|
||||||
|
{
|
||||||
|
movefactor = mo->movefactor;
|
||||||
|
((mobj_t*)mo)->movefactor = ORIG_FRICTION_FACTOR; // reset
|
||||||
|
}
|
||||||
|
else // sludge
|
||||||
|
{
|
||||||
|
|
||||||
|
// phares 3/11/98: you start off slowly, then increase as
|
||||||
|
// you get better footing
|
||||||
|
|
||||||
|
momentum = (P_AproxDistance(mo->momx,mo->momy));
|
||||||
|
movefactor = mo->movefactor;
|
||||||
|
if (momentum > MORE_FRICTION_MOMENTUM<<2)
|
||||||
|
movefactor <<= 3;
|
||||||
|
|
||||||
|
else if (momentum > MORE_FRICTION_MOMENTUM<<1)
|
||||||
|
movefactor <<= 2;
|
||||||
|
|
||||||
|
else if (momentum > MORE_FRICTION_MOMENTUM)
|
||||||
|
movefactor <<= 1;
|
||||||
|
|
||||||
|
((mobj_t*)mo)->movefactor = ORIG_FRICTION_FACTOR; // reset
|
||||||
|
}
|
||||||
|
} // ^
|
||||||
|
|
||||||
|
return(movefactor); // |
|
||||||
|
}
|
||||||
|
|
||||||
// If the floor is icy or muddy, it's harder to get moving. This is where
|
// If the floor is icy or muddy, it's harder to get moving. This is where
|
||||||
// the different friction factors are applied to 'trying to move'. In
|
// the different friction factors are applied to 'trying to move'. In
|
||||||
// p_mobj.c, the friction factors are applied as you coast and slow down.
|
// p_mobj.c, the friction factors are applied as you coast and slow down.
|
||||||
@ -1021,12 +1064,24 @@ static void P_HitSlideLine(line_t *ld)
|
|||||||
// Check for the special cases of horz or vert walls.
|
// Check for the special cases of horz or vert walls.
|
||||||
|
|
||||||
// killough 10/98: only bounce if hit hard (prevents wobbling)
|
// killough 10/98: only bounce if hit hard (prevents wobbling)
|
||||||
|
|
||||||
|
if (demo_version >= 203)
|
||||||
|
{
|
||||||
icyfloor =
|
icyfloor =
|
||||||
(demo_version >= 203 ?
|
P_AproxDistance(tmxmove, tmymove) > 4*FRACUNIT &&
|
||||||
P_AproxDistance(tmxmove, tmymove) > 4*FRACUNIT : !compatibility) &&
|
|
||||||
variable_friction && // killough 8/28/98: calc friction on demand
|
variable_friction && // killough 8/28/98: calc friction on demand
|
||||||
slidemo->z <= slidemo->floorz &&
|
slidemo->z <= slidemo->floorz &&
|
||||||
P_GetFriction(slidemo, NULL) > ORIG_FRICTION;
|
P_GetFriction(slidemo, NULL) > ORIG_FRICTION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extern boolean onground;
|
||||||
|
icyfloor = !compatibility &&
|
||||||
|
variable_friction &&
|
||||||
|
slidemo->player &&
|
||||||
|
onground &&
|
||||||
|
slidemo->friction > ORIG_FRICTION;
|
||||||
|
}
|
||||||
|
|
||||||
if (ld->slopetype == ST_HORIZONTAL)
|
if (ld->slopetype == ST_HORIZONTAL)
|
||||||
{
|
{
|
||||||
|
@ -134,6 +134,8 @@ void P_XYMovement (mobj_t* mo)
|
|||||||
player_t *player;
|
player_t *player;
|
||||||
fixed_t xmove, ymove;
|
fixed_t xmove, ymove;
|
||||||
|
|
||||||
|
fixed_t oldx,oldy; // phares 9/10/98: reducing bobbing/momentum on ice
|
||||||
|
|
||||||
if (!(mo->momx | mo->momy)) // Any momentum?
|
if (!(mo->momx | mo->momy)) // Any momentum?
|
||||||
{
|
{
|
||||||
if (mo->flags & MF_SKULLFLY)
|
if (mo->flags & MF_SKULLFLY)
|
||||||
@ -165,6 +167,10 @@ void P_XYMovement (mobj_t* mo)
|
|||||||
xmove = mo->momx;
|
xmove = mo->momx;
|
||||||
ymove = mo->momy;
|
ymove = mo->momy;
|
||||||
|
|
||||||
|
oldx = mo->x; // phares 9/10/98: new code to reduce bobbing/momentum
|
||||||
|
oldy = mo->y; // when on ice & up against wall. These will be compared
|
||||||
|
// to your x,y values later to see if you were able to move
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
fixed_t ptryx, ptryy;
|
fixed_t ptryx, ptryy;
|
||||||
@ -326,6 +332,26 @@ void P_XYMovement (mobj_t* mo)
|
|||||||
// Reducing player momentum is no longer needed to reduce
|
// Reducing player momentum is no longer needed to reduce
|
||||||
// bobbing, so ice works much better now.
|
// bobbing, so ice works much better now.
|
||||||
|
|
||||||
|
if (demo_version < 203)
|
||||||
|
{
|
||||||
|
// phares 9/10/98: reduce bobbing/momentum when on ice & up against wall
|
||||||
|
|
||||||
|
if ((oldx == mo->x) && (oldy == mo->y)) // Did you go anywhere?
|
||||||
|
{ // No. Use original friction. This allows you to not bob so much
|
||||||
|
// if you're on ice, but keeps enough momentum around to break free
|
||||||
|
// when you're mildly stuck in a wall.
|
||||||
|
mo->momx = FixedMul(mo->momx,ORIG_FRICTION);
|
||||||
|
mo->momy = FixedMul(mo->momy,ORIG_FRICTION);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Yes. Use stored friction.
|
||||||
|
mo->momx = FixedMul(mo->momx,mo->friction);
|
||||||
|
mo->momy = FixedMul(mo->momy,mo->friction);
|
||||||
|
}
|
||||||
|
mo->friction = ORIG_FRICTION; // reset to normal for next tic
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
fixed_t friction = P_GetFriction(mo, NULL);
|
fixed_t friction = P_GetFriction(mo, NULL);
|
||||||
|
|
||||||
mo->momx = FixedMul(mo->momx, friction);
|
mo->momx = FixedMul(mo->momx, friction);
|
||||||
@ -340,6 +366,7 @@ void P_XYMovement (mobj_t* mo)
|
|||||||
player->momx = FixedMul(player->momx, ORIG_FRICTION);
|
player->momx = FixedMul(player->momx, ORIG_FRICTION);
|
||||||
player->momy = FixedMul(player->momy, ORIG_FRICTION);
|
player->momy = FixedMul(player->momy, ORIG_FRICTION);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,6 +796,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
|||||||
mobj->thinker.function = P_MobjThinker;
|
mobj->thinker.function = P_MobjThinker;
|
||||||
mobj->above_thing = mobj->below_thing = 0; // phares
|
mobj->above_thing = mobj->below_thing = 0; // phares
|
||||||
|
|
||||||
|
// for Boom friction code
|
||||||
|
mobj->friction = ORIG_FRICTION; // phares 3/17/98
|
||||||
|
|
||||||
P_AddThinker(&mobj->thinker);
|
P_AddThinker(&mobj->thinker);
|
||||||
|
|
||||||
return mobj;
|
return mobj;
|
||||||
|
@ -336,6 +336,10 @@ typedef struct mobj_s
|
|||||||
|
|
||||||
// killough 8/2/98: friction properties part of sectors,
|
// killough 8/2/98: friction properties part of sectors,
|
||||||
// not objects -- removed friction properties from here
|
// not objects -- removed friction properties from here
|
||||||
|
// e6y: restored friction properties here
|
||||||
|
// Friction values for the sector the object is in
|
||||||
|
int friction; // phares 3/17/98
|
||||||
|
int movefactor;
|
||||||
|
|
||||||
// a linked list of sectors where this object appears
|
// a linked list of sectors where this object appears
|
||||||
struct msecnode_s* touching_sectorlist; // phares 3/14/98
|
struct msecnode_s* touching_sectorlist; // phares 3/14/98
|
||||||
|
@ -2691,6 +2691,79 @@ static void P_SpawnScrollers(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restored Boom's friction code
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
//
|
||||||
|
// Add a friction thinker to the thinker list
|
||||||
|
//
|
||||||
|
// Add_Friction adds a new friction thinker to the list of active thinkers.
|
||||||
|
//
|
||||||
|
|
||||||
|
static void Add_Friction(int friction, int movefactor, int affectee)
|
||||||
|
{
|
||||||
|
friction_t *f = Z_Malloc(sizeof *f, PU_LEVSPEC, 0);
|
||||||
|
|
||||||
|
f->thinker.function/*.acp1*/ = /*(actionf_p1) */T_Friction;
|
||||||
|
f->friction = friction;
|
||||||
|
f->movefactor = movefactor;
|
||||||
|
f->affectee = affectee;
|
||||||
|
P_AddThinker(&f->thinker);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
//
|
||||||
|
// This is where abnormal friction is applied to objects in the sectors.
|
||||||
|
// A friction thinker has been spawned for each sector where less or
|
||||||
|
// more friction should be applied. The amount applied is proportional to
|
||||||
|
// the length of the controlling linedef.
|
||||||
|
|
||||||
|
void T_Friction(friction_t *f)
|
||||||
|
{
|
||||||
|
sector_t *sec;
|
||||||
|
mobj_t *thing;
|
||||||
|
msecnode_t* node;
|
||||||
|
|
||||||
|
if (compatibility || !variable_friction)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sec = sectors + f->affectee;
|
||||||
|
|
||||||
|
// Be sure the special sector type is still turned on. If so, proceed.
|
||||||
|
// Else, bail out; the sector type has been changed on us.
|
||||||
|
|
||||||
|
if (!(sec->special & FRICTION_MASK))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Assign the friction value to players on the floor, non-floating,
|
||||||
|
// and clipped. Normally the object's friction value is kept at
|
||||||
|
// ORIG_FRICTION and this thinker changes it for icy or muddy floors.
|
||||||
|
|
||||||
|
// In Phase II, you can apply friction to Things other than players.
|
||||||
|
|
||||||
|
// When the object is straddling sectors with the same
|
||||||
|
// floorheight that have different frictions, use the lowest
|
||||||
|
// friction value (muddy has precedence over icy).
|
||||||
|
|
||||||
|
node = sec->touching_thinglist; // things touching this sector
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
thing = node->m_thing;
|
||||||
|
if (thing->player &&
|
||||||
|
!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) &&
|
||||||
|
thing->z <= sec->floorheight)
|
||||||
|
{
|
||||||
|
if ((thing->friction == ORIG_FRICTION) || // normal friction?
|
||||||
|
(f->friction < thing->friction))
|
||||||
|
{
|
||||||
|
thing->friction = f->friction;
|
||||||
|
thing->movefactor = f->movefactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node = node->m_snext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// killough 3/7/98 -- end generalized scroll effects
|
// killough 3/7/98 -- end generalized scroll effects
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -2792,6 +2865,10 @@ static void P_SpawnFriction(void)
|
|||||||
// drag on CPU. New code adjusts friction of sector only once
|
// drag on CPU. New code adjusts friction of sector only once
|
||||||
// at level startup, and then uses this friction value.
|
// at level startup, and then uses this friction value.
|
||||||
|
|
||||||
|
// Boom's friction code for demo compatibility
|
||||||
|
if (!demo_compatibility && demo_version < 203)
|
||||||
|
Add_Friction(friction,movefactor,s);
|
||||||
|
|
||||||
sectors[s].friction = friction;
|
sectors[s].friction = friction;
|
||||||
sectors[s].movefactor = movefactor;
|
sectors[s].movefactor = movefactor;
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,9 @@ void P_Thrust(player_t* player,angle_t angle,fixed_t move)
|
|||||||
|
|
||||||
void P_Bob(player_t *player, angle_t angle, fixed_t move)
|
void P_Bob(player_t *player, angle_t angle, fixed_t move)
|
||||||
{
|
{
|
||||||
|
if (demo_version < 203)
|
||||||
|
return;
|
||||||
|
|
||||||
player->momx += FixedMul(move,finecosine[angle >>= ANGLETOFINESHIFT]);
|
player->momx += FixedMul(move,finecosine[angle >>= ANGLETOFINESHIFT]);
|
||||||
player->momy += FixedMul(move,finesine[angle]);
|
player->momy += FixedMul(move,finesine[angle]);
|
||||||
}
|
}
|
||||||
@ -102,14 +105,24 @@ void P_CalcHeight (player_t* player)
|
|||||||
|
|
||||||
// [FG] MBF player bobbing rewrite causes demo sync problems
|
// [FG] MBF player bobbing rewrite causes demo sync problems
|
||||||
// http://prboom.sourceforge.net/mbf-bugs.html
|
// http://prboom.sourceforge.net/mbf-bugs.html
|
||||||
player->bob = demo_compatibility ?
|
player->bob = (demo_compatibility || player_bobbing) ?
|
||||||
(FixedMul (player->mo->momx, player->mo->momx)
|
(FixedMul (player->mo->momx, player->mo->momx)
|
||||||
+ FixedMul (player->mo->momy,player->mo->momy))>>2 :
|
+ FixedMul (player->mo->momy,player->mo->momy))>>2 :
|
||||||
player_bobbing ? (FixedMul(player->momx,player->momx) +
|
(demo_version >= 203 && player_bobbing) ? (FixedMul(player->momx,player->momx) +
|
||||||
FixedMul(player->momy,player->momy))>>2 : 0;
|
FixedMul(player->momy,player->momy))>>2 : 0;
|
||||||
|
|
||||||
if (player->bob > MAXBOB)
|
if ((demo_version == 202 ||
|
||||||
|
demo_version == 203) &&
|
||||||
|
player->mo->friction > ORIG_FRICTION) // ice?
|
||||||
|
{
|
||||||
|
if (player->bob > (MAXBOB>>2))
|
||||||
|
player->bob = MAXBOB>>2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (player->bob > MAXBOB)
|
||||||
player->bob = MAXBOB;
|
player->bob = MAXBOB;
|
||||||
|
}
|
||||||
|
|
||||||
if (!onground || player->cheats & CF_NOMOMENTUM)
|
if (!onground || player->cheats & CF_NOMOMENTUM)
|
||||||
{
|
{
|
||||||
@ -186,7 +199,7 @@ void P_MovePlayer (player_t* player)
|
|||||||
// ice, because the player still "works just as hard" to move, while the
|
// ice, because the player still "works just as hard" to move, while the
|
||||||
// thrust applied to the movement varies with 'movefactor'.
|
// thrust applied to the movement varies with 'movefactor'.
|
||||||
|
|
||||||
if (cmd->forwardmove | cmd->sidemove) // killough 10/98
|
if ((!demo_compatibility && demo_version < 203) || cmd->forwardmove | cmd->sidemove) // killough 10/98
|
||||||
{
|
{
|
||||||
if (onground || mo->flags & MF_BOUNCES) // killough 8/9/98
|
if (onground || mo->flags & MF_BOUNCES) // killough 8/9/98
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user