- floatified friction.

This commit is contained in:
Christoph Oelckers 2016-03-24 22:50:03 +01:00
commit 7a26318bf0
15 changed files with 84 additions and 94 deletions

View file

@ -1212,7 +1212,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers)
case dFriction_Low:
sector->friction = FRICTION_LOW;
sector->movefactor = 0x269;
sector->movefactor = 0x269/65536.;
sector->Flags |= SECF_FRICTION;
break;
@ -2049,7 +2049,7 @@ static void P_SpawnFriction(void)
}
else
{
length = P_AproxDistance(l->dx,l->dy)>>FRACBITS;
length = int(l->Delta().Length());
}
P_SetSectorFriction (l->args[0], length, false);
@ -2061,14 +2061,14 @@ static void P_SpawnFriction(void)
void P_SetSectorFriction (int tag, int amount, bool alterFlag)
{
int s;
fixed_t friction, movefactor;
double friction, movefactor;
// An amount of 100 should result in a friction of
// ORIG_FRICTION (0xE800)
friction = (0x1EB8*amount)/0x80 + 0xD001;
friction = ((0x1EB8 * amount) / 0x80 + 0xD001) / 65536.;
// killough 8/28/98: prevent odd situations
friction = clamp(friction, 0, FRACUNIT);
friction = clamp(friction, 0., 1.);
// The following check might seem odd. At the time of movement,
// the move distance is multiplied by 'friction/0x10000', so a
@ -2106,6 +2106,26 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag)
}
}
double FrictionToMoveFactor(double friction)
{
double movefactor;
// [RH] Twiddled these values so that velocity on ice (with
// friction 0xf900) is the same as in Heretic/Hexen.
if (friction >= ORIG_FRICTION) // ice
//movefactor = ((0x10092 - friction)*(0x70))/0x158;
movefactor = (((0x10092 - friction * 65536) * 1024) / 4352 + 568) / 65536.;
else
movefactor = (((friction*65536. - 0xDB34)*(0xA)) / 0x80) / 65536.;
// killough 8/28/98: prevent odd situations
if (movefactor < 1 / 2048.)
movefactor = 1 / 2048.;
return movefactor;
}
//
// phares 3/12/98: End of friction effects
//