- Major cleanup of Q16.16 utilisation within games and engine.

* Remove fix16.h/cpp and utilise library from m_fixed.h.
* Extend m_fixed.h with two inline functions for int to/from float operations.
* Replace fix16_floor operations with those from xs_Float.h
* Replace multiple Q16.16 conversions from 0 to just be 0.
* Replaced all found in-game bit-shifts and multiplications/divisions with inline functions from m_fixed.h
* Replaced many casts of FRACUNIT as double in SW's panel.cpp as it is converted to double by way of type promotion.
* Fixed missed precision fixes in SW's panel.cpp where some types weren't declared correctly.
* Replaced 100+ `Cos()/Sin() >> 16` operations for Blood with inline functions `CosScale16()/SinScale16()`.
This commit is contained in:
Mitchell Richters 2020-09-01 23:00:35 +10:00
parent d40e53eb53
commit 1354d52c05
104 changed files with 906 additions and 1579 deletions

View file

@ -764,7 +764,6 @@ set (PCH_SOURCES
glbackend/gl_texture.cpp
thirdparty/src/base64.cpp
thirdparty/src/fix16.cpp
thirdparty/src/md4.cpp
# Todo: Split out the license-safe code from this.

View file

@ -4142,7 +4142,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite)
if (mass1 > mass2) {
actKickObject(pSprite, pSprite2);
sfxPlay3DSound(pSprite, 357, -1, 1);
int dmg = (mass1 - mass2) + abs(xvel[pSprite->index] >> 16);
int dmg = (mass1 - mass2) + abs(FixedToInt(xvel[pSprite->index]));
if (dmg > 0)
actDamageSprite(nSprite, pSprite2, (Chance(0x2000)) ? DAMAGE_TYPE_0 : DAMAGE_TYPE_2, dmg);
}
@ -5848,8 +5848,8 @@ void actProcessSprites(void)
x += (dx/2)>>12;
y += (dy/2)>>12;
}
dy = Sin(pSprite->ang)>>16;
dx = Cos(pSprite->ang)>>16;
dy = SinScale16(pSprite->ang);
dx = CosScale16(pSprite->ang);
gVectorData[VECTOR_TYPE_20].maxDist = pXSprite->data1<<9;
actFireVector(pSprite, 0, 0, dx, dy, Random2(0x8888), VECTOR_TYPE_20);
}

View file

@ -122,7 +122,7 @@ bool CanMove(spritetype *pSprite, int a2, int nAngle, int nRange)
int x = pSprite->x;
int y = pSprite->y;
int z = pSprite->z;
HitScan(pSprite, z, Cos(nAngle)>>16, Sin(nAngle)>>16, 0, CLIPMASK0, nRange);
HitScan(pSprite, z, CosScale16(nAngle), SinScale16(nAngle), 0, CLIPMASK0, nRange);
int nDist = approxDist(x-gHitInfo.hitx, y-gHitInfo.hity);
if (nDist - (pSprite->clipdist << 2) < nRange)
{

View file

@ -78,8 +78,8 @@ static void BiteSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
spritetype *pSprite = &sprite[pXSprite->reference];
spritetype *pTarget = &sprite[pXSprite->target];
int dx = Cos(pSprite->ang) >> 16;
int dy = Sin(pSprite->ang) >> 16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
dassert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);

View file

@ -85,8 +85,8 @@ static void SlashSeqCallback(int, int nXSprite)
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
spritetype *pTarget = &sprite[pXSprite->target];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
// Correct ?
int dz = pSprite->z-pTarget->z;
dx += Random3(4000-700*gGameOptions.nDifficulty);
@ -103,8 +103,8 @@ static void StompSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int x = pSprite->x;
int y = pSprite->y;
int z = pSprite->z;

View file

@ -79,8 +79,8 @@ static void BiteSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
spritetype *pSprite = &sprite[pXSprite->reference];
spritetype *pTarget = &sprite[pXSprite->target];
int dx = Cos(pSprite->ang) >> 16;
int dy = Sin(pSprite->ang) >> 16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
dassert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);

View file

@ -76,8 +76,8 @@ static void SeqAttackCallback(int, int nXSprite)
{
int nSprite = xsprite[nXSprite].reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = gDudeSlope[nXSprite];
dx += Random2(1500);
dy += Random2(1500);

View file

@ -78,8 +78,8 @@ static void BiteSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
///dassert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
consoleSysMsg("pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
@ -114,8 +114,8 @@ static void BurnSeqCallback(int, int nXSprite)
int z = height; // ???
TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
Aim aim;
aim.dx = Cos(pSprite->ang)>>16;
aim.dy = Sin(pSprite->ang)>>16;
aim.dx = CosScale16(pSprite->ang);
aim.dy = SinScale16(pSprite->ang);
aim.dz = gDudeSlope[nXSprite];
int nClosest = 0x7fffffff;
for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2])
@ -158,8 +158,8 @@ static void BurnSeqCallback(int, int nXSprite)
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
aim.dx = Cos(nAngle)>>16;
aim.dy = Sin(nAngle)>>16;
aim.dx = CosScale16(nAngle);
aim.dy = SinScale16(nAngle);
aim.dz = divscale(tz, nDist, 10);
}
else
@ -197,8 +197,8 @@ static void BurnSeqCallback2(int, int nXSprite)
TARGETTRACK tt1 = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
Aim aim;
int ax, ay, az;
aim.dx = ax = Cos(pSprite->ang)>>16;
aim.dy = ay = Sin(pSprite->ang)>>16;
aim.dx = ax = CosScale16(pSprite->ang);
aim.dy = ay = SinScale16(pSprite->ang);
aim.dz = gDudeSlope[nXSprite];
az = 0;
int nClosest = 0x7fffffff;
@ -244,8 +244,8 @@ static void BurnSeqCallback2(int, int nXSprite)
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
aim.dx = Cos(nAngle)>>16;
aim.dy = Sin(nAngle)>>16;
aim.dx = CosScale16(nAngle);
aim.dy = SinScale16(nAngle);
aim.dz = divscale(tz, nDist, 10);
}
else

View file

@ -104,8 +104,8 @@ static void TommySeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang) >> 16;
int dy = Sin(pSprite->ang) >> 16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = gDudeSlope[nXSprite];
dx += Random3((5-gGameOptions.nDifficulty)*1000);
dy += Random3((5-gGameOptions.nDifficulty)*1000);
@ -121,8 +121,8 @@ static void TeslaSeqCallback(int, int nXSprite)
spritetype *pSprite = &sprite[nSprite];
if (Chance(dword_138BB0[gGameOptions.nDifficulty]))
{
int dx = Cos(pSprite->ang) >> 16;
int dy = Sin(pSprite->ang) >> 16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = gDudeSlope[nXSprite];
dx += Random3((5-gGameOptions.nDifficulty)*1000);
dy += Random3((5-gGameOptions.nDifficulty)*1000);
@ -137,8 +137,8 @@ static void ShotSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang) >> 16;
int dy = Sin(pSprite->ang) >> 16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = gDudeSlope[nXSprite];
dx += Random2((5-gGameOptions.nDifficulty)*1000-500);
dy += Random2((5-gGameOptions.nDifficulty)*1000-500);

View file

@ -110,8 +110,8 @@ static void SlashFSeqCallback(int, int nXSprite)
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
int dz = height-height2;
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
actFireVector(pSprite, 0, 0, dx, dy, dz, VECTOR_TYPE_13);
int r1 = Random(50);
int r2 = Random(50);
@ -143,8 +143,8 @@ static void BlastSSeqCallback(int, int nXSprite)
int z = height;
TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
Aim aim;
aim.dx = Cos(pSprite->ang)>>16;
aim.dy = Sin(pSprite->ang)>>16;
aim.dx = CosScale16(pSprite->ang);
aim.dy = SinScale16(pSprite->ang);
aim.dz = gDudeSlope[nXSprite];
int nClosest = 0x7fffffff;
for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2])
@ -187,8 +187,8 @@ static void BlastSSeqCallback(int, int nXSprite)
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
aim.dx = Cos(nAngle)>>16;
aim.dy = Sin(nAngle)>>16;
aim.dx = CosScale16(nAngle);
aim.dy = SinScale16(nAngle);
aim.dz = divscale(tz, nDist, 10);
if (tz > -0x333)
aim.dz = divscale(tz, nDist, 10);

View file

@ -92,8 +92,8 @@ static void SlashSeqCallback(int, int nXSprite)
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
int dz = height-height2;
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
sfxPlay3DSound(pSprite, 1406, 0, 0);
actFireVector(pSprite, 0, 0, dx, dy, dz, VECTOR_TYPE_12);
int r1 = Random(50);
@ -126,8 +126,8 @@ static void BlastSeqCallback(int, int nXSprite)
int z = height;
TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa };
Aim aim;
aim.dx = Cos(pSprite->ang)>>16;
aim.dy = Sin(pSprite->ang)>>16;
aim.dx = CosScale16(pSprite->ang);
aim.dy = SinScale16(pSprite->ang);
aim.dz = gDudeSlope[nXSprite];
int nClosest = 0x7fffffff;
for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2])
@ -170,8 +170,8 @@ static void BlastSeqCallback(int, int nXSprite)
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
aim.dx = Cos(nAngle)>>16;
aim.dy = Sin(nAngle)>>16;
aim.dx = CosScale16(nAngle);
aim.dy = SinScale16(nAngle);
aim.dz = divscale(tz, nDist, 10);
if (tz > -0x333)
aim.dz = divscale(tz, nDist, 10);

View file

@ -78,8 +78,8 @@ static void GillBiteSeqCallback(int, int nXSprite)
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
spritetype *pTarget = &sprite[pXSprite->target];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = pSprite->z-pTarget->z;
dx += Random3(2000);
dy += Random3(2000);

View file

@ -67,8 +67,8 @@ static void BiteSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
///dassert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
consoleSysMsg("pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
@ -95,7 +95,7 @@ static void BurnSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
actFireMissile(pSprite, 0, 0, Cos(pSprite->ang)>>16, Sin(pSprite->ang)>>16, 0, kMissileFlameHound);
actFireMissile(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), 0, kMissileFlameHound);
}
static void thinkSearch(spritetype *pSprite, XSPRITE *pXSprite)

View file

@ -62,8 +62,8 @@ static void BiteSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
dassert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
dassert(pXSprite->target >= 0 && pXSprite->target < kMaxSprites);
spritetype *pTarget = &sprite[pXSprite->target];

View file

@ -90,8 +90,8 @@ static void SpidBiteSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
dx += Random2(2000);
dy += Random2(2000);
int dz = Random2(2000);
@ -140,8 +140,8 @@ static void SpidJumpSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
dx += Random2(200);
dy += Random2(200);
int dz = Random2(200);
@ -154,9 +154,9 @@ static void SpidJumpSeqCallback(int, int nXSprite)
case kDudeSpiderBrown:
case kDudeSpiderRed:
case kDudeSpiderBlack:
xvel[nSprite] = dx << 16;
yvel[nSprite] = dy << 16;
zvel[nSprite] = dz << 16;
xvel[nSprite] = IntToFixed(dx);
yvel[nSprite] = IntToFixed(dy);
zvel[nSprite] = IntToFixed(dz);
break;
}
}

View file

@ -98,8 +98,8 @@ static void sub_71BD4(int, int nXSprite)
int z = height;
TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x100000 };
Aim aim;
aim.dx = Cos(pSprite->ang)>>16;
aim.dy = Sin(pSprite->ang)>>16;
aim.dx = CosScale16(pSprite->ang);
aim.dy = SinScale16(pSprite->ang);
aim.dz = gDudeSlope[nXSprite];
int nClosest = 0x7fffffff;
for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2])
@ -142,8 +142,8 @@ static void sub_71BD4(int, int nXSprite)
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
aim.dx = Cos(nAngle)>>16;
aim.dy = Sin(nAngle)>>16;
aim.dx = CosScale16(nAngle);
aim.dy = SinScale16(nAngle);
aim.dz = divscale(tz, nDist, 10);
}
else
@ -168,8 +168,8 @@ static void sub_720AC(int, int nXSprite)
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int height = pSprite->yrepeat*pDudeInfo->eyeHeight;
int ax, ay, az;
ax = Cos(pSprite->ang)>>16;
ay = Sin(pSprite->ang)>>16;
ax = CosScale16(pSprite->ang);
ay = SinScale16(pSprite->ang);
int x = pSprite->x;
int y = pSprite->y;
int z = height;
@ -220,8 +220,8 @@ static void sub_720AC(int, int nXSprite)
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
{
nClosest = nDist2;
aim.dx = Cos(nAngle)>>16;
aim.dy = Sin(nAngle)>>16;
aim.dx = CosScale16(nAngle);
aim.dy = SinScale16(nAngle);
aim.dz = divscale(tz, nDist, 10);
}
else

View file

@ -150,7 +150,7 @@ bool genDudeAdjustSlope(spritetype* pSprite, XSPRITE* pXSprite, int dist, int we
int fStart = 0; int fEnd = 0; GENDUDEEXTRA* pExtra = genDudeExtra(pSprite);
unsigned int clipMask = (weaponType == kGenDudeWeaponMissile) ? CLIPMASK0 : CLIPMASK1;
for (int i = -8191; i < 8192; i += by) {
HitScan(pSprite, pSprite->z, Cos(pSprite->ang) >> 16, Sin(pSprite->ang) >> 16, i, clipMask, dist);
HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), i, clipMask, dist);
if (!fStart && pXSprite->target == gHitInfo.hitsprite) fStart = i;
else if (fStart && pXSprite->target != gHitInfo.hitsprite) { fEnd = i; break; }
}
@ -197,8 +197,8 @@ static void punchCallback(int, int nXIndex) {
if(IsDudeSprite(pTarget))
nZOffset2 = getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat << 2;
int dx = Cos(pSprite->ang) >> 16;
int dy = Sin(pSprite->ang) >> 16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int dz = nZOffset1 - nZOffset2;
if (!playGenDudeSound(pSprite, kGenDudeSndAttackMelee))
@ -231,7 +231,7 @@ static void genDudeAttack1(int, int nXIndex) {
if (pExtra->weaponType == kGenDudeWeaponHitscan) {
dx = Cos(pSprite->ang) >> 16; dy = Sin(pSprite->ang) >> 16; dz = gDudeSlope[nXIndex];
dx = CosScale16(pSprite->ang); dy = SinScale16(pSprite->ang); dz = gDudeSlope[nXIndex];
// dispersal modifiers here in case if non-melee enemy
if (!dudeIsMelee(pXSprite)) {
dx += Random3(dispersion); dy += Random3(dispersion); dz += Random3(dispersion);
@ -263,7 +263,7 @@ static void genDudeAttack1(int, int nXIndex) {
} else if (pExtra->weaponType == kGenDudeWeaponMissile) {
dx = Cos(pSprite->ang) >> 16; dy = Sin(pSprite->ang) >> 16; dz = gDudeSlope[nXIndex];
dx = CosScale16(pSprite->ang); dy = SinScale16(pSprite->ang); dz = gDudeSlope[nXIndex];
// dispersal modifiers here
dx += Random3(dispersion); dy += Random3(dispersion); dz += Random3(dispersion >> 1);
@ -669,9 +669,9 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) {
if (pExtra->canWalk) {
int objDist = -1; int targetDist = -1; int hit = -1;
if (weaponType == kGenDudeWeaponHitscan)
hit = HitScan(pSprite, pSprite->z, Cos(pSprite->ang) >> 16, Sin(pSprite->ang) >> 16, gDudeSlope[pSprite->extra], CLIPMASK1, dist);
hit = HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), gDudeSlope[pSprite->extra], CLIPMASK1, dist);
else if (weaponType == kGenDudeWeaponMissile)
hit = HitScan(pSprite, pSprite->z, Cos(pSprite->ang) >> 16, Sin(pSprite->ang) >> 16, gDudeSlope[pSprite->extra], CLIPMASK0, dist);
hit = HitScan(pSprite, pSprite->z, CosScale16(pSprite->ang), SinScale16(pSprite->ang), gDudeSlope[pSprite->extra], CLIPMASK0, dist);
if (hit >= 0) {
targetDist = dist - (pTarget->clipdist << 2);
@ -766,7 +766,7 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) {
break;
} else if (weaponType == kGenDudeWeaponHitscan && hscn) {
if (genDudeAdjustSlope(pSprite, pXSprite, dist, weaponType)) break;
VectorScan(pSprite, 0, 0, Cos(pSprite->ang) >> 16, Sin(pSprite->ang) >> 16, gDudeSlope[pSprite->extra], dist, 1);
VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), gDudeSlope[pSprite->extra], dist, 1);
if (pXSprite->target == gHitInfo.hitsprite) break;
bool immune = nnExtIsImmune(pHSprite, gVectorData[curWeapon].dmgType);
@ -818,7 +818,7 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) {
case 4:
if (hit == 4 && weaponType == kGenDudeWeaponHitscan && hscn) {
bool masked = (pHWall->cstat & CSTAT_WALL_MASKED);
if (masked) VectorScan(pSprite, 0, 0, Cos(pSprite->ang) >> 16, Sin(pSprite->ang) >> 16, gDudeSlope[pSprite->extra], dist, 1);
if (masked) VectorScan(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), gDudeSlope[pSprite->extra], dist, 1);
//viewSetSystemMessage("WALL VHIT: %d", gHitInfo.hitwall);
if ((pXSprite->target != gHitInfo.hitsprite) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked)) {
@ -1556,8 +1556,8 @@ void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT event)
y += (yvel[nTarget] * t) >> 12;
int angBak = pSprite->ang;
pSprite->ang = getangle(x - pSprite->x, y - pSprite->y);
int dx = Cos(pSprite->ang) >> 16;
int dy = Sin(pSprite->ang) >> 16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int tz = pTarget->z - (pTarget->yrepeat * pDudeInfo->aimHeight) * 4;
int dz = divscale(tz - top - 256, nDist, 10);
int nMissileType = kMissileLifeLeechAltNormal + (pXSprite->data3 ? 1 : 0);

View file

@ -90,8 +90,8 @@ static void HackSeqCallback(int, int nXSprite)
int height = (pSprite->yrepeat*pDudeInfo->eyeHeight)<<2;
int height2 = (pTarget->yrepeat*pDudeInfoT->eyeHeight)<<2;
int dz = height-height2;
int dx = Cos(nAngle)>>16;
int dy = Sin(nAngle)>>16;
int dx = CosScale16(nAngle);
int dy = SinScale16(nAngle);
sfxPlay3DSound(pSprite, 1101, 1, 0);
actFireVector(pSprite, 0, 0, dx, dy, dz, VECTOR_TYPE_10);
}

View file

@ -80,7 +80,7 @@ static void HackSeqCallback(int, int nXSprite)
int height = (pDudeInfo->eyeHeight*pSprite->yrepeat);
DUDEINFO *pDudeInfoT = getDudeInfo(pTarget->type);
int height2 = (pDudeInfoT->eyeHeight*pTarget->yrepeat);
actFireVector(pSprite, 0, 0, Cos(pSprite->ang)>>16, Sin(pSprite->ang)>>16, height-height2, VECTOR_TYPE_11);
actFireVector(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), height-height2, VECTOR_TYPE_11);
}
static void PukeSeqCallback(int, int nXSprite)
@ -96,8 +96,8 @@ static void PukeSeqCallback(int, int nXSprite)
int tx = pXSprite->targetX-pSprite->x;
int ty = pXSprite->targetY-pSprite->y;
int nAngle = getangle(tx, ty);
int dx = Cos(nAngle)>>16;
int dy = Sin(nAngle)>>16;
int dx = CosScale16(nAngle);
int dy = SinScale16(nAngle);
sfxPlay3DSound(pSprite, 1203, 1, 0);
actFireMissile(pSprite, 0, -(height-height2), dx, dy, 0, kMissilePukeGreen);
}
@ -107,7 +107,7 @@ static void ThrowSeqCallback(int, int nXSprite)
XSPRITE *pXSprite = &xsprite[nXSprite];
int nSprite = pXSprite->reference;
spritetype *pSprite = &sprite[nSprite];
actFireMissile(pSprite, 0, -getDudeInfo(pSprite->type)->eyeHeight, Cos(pSprite->ang)>>16, Sin(pSprite->ang)>>16, 0, kMissileButcherKnife);
actFireMissile(pSprite, 0, -getDudeInfo(pSprite->type)->eyeHeight, CosScale16(pSprite->ang), SinScale16(pSprite->ang), 0, kMissileButcherKnife);
}
static void thinkSearch(spritetype *pSprite, XSPRITE *pXSprite)

View file

@ -49,7 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
static fix16_t gCameraAng;
static fixed_t gCameraAng;
int dword_172CE0[16][3];
static void RotateYZ(int *, int *pY, int *pZ, int ang)

View file

@ -583,7 +583,7 @@ inline int interpolateang(int a, int b, int c)
return a+mulscale16(((b-a+1024)&2047)-1024, c);
}
inline fix16_t interpolateangfix16(fix16_t a, fix16_t b, int c)
inline fixed_t interpolateangfix16(fixed_t a, fixed_t b, int c)
{
return a+mulscale16(((b-a+0x4000000)&0x7ffffff)-0x4000000, c);
}

View file

@ -59,7 +59,7 @@ int32_t GetTime(void)
return gameclock;
}
fix16_t gViewLook, gViewAngle;
fixed_t gViewLook, gViewAngle;
float gViewAngleAdjust;
float gViewLookAdjust;
int gViewLookRecenter;
@ -184,9 +184,9 @@ void ctrlGetInput(void)
turnHeldTime = 0;
if (turnLeft)
input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2)));
input.q16avel -= FloatToFixed(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2));
if (turnRight)
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2)));
input.q16avel += FloatToFixed(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2));
if (run && turnHeldTime > 24)
input.q16avel <<= 1;
@ -198,21 +198,21 @@ void ctrlGetInput(void)
}
else
{
input.q16avel = fix16_sadd(input.q16avel, fix16_from_float(info.mousex));
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
input.q16avel += FloatToFixed(info.mousex);
input.q16avel += FloatToFixed(scaleAdjustmentToInterval(info.dyaw));
}
input.svel -= scaleAdjustmentToInterval(info.dx * keyMove);
input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove);
if (mouseaim)
input.q16horz = fix16_sadd(input.q16horz, fix16_from_float(info.mousey / mlookScale));
input.q16horz += FloatToFixed(info.mousey / mlookScale);
else
input.fvel -= info.mousey * 64.f;
if (!in_mouseflip)
input.q16horz = -input.q16horz;
input.q16horz = fix16_ssub(input.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch / mlookScale)));
input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(info.dpitch / mlookScale));
if (!automapFollow && automapMode != am_off)
{
@ -225,27 +225,27 @@ void ctrlGetInput(void)
}
gInput.fvel = clamp(gInput.fvel + input.fvel, -2048, 2048);
gInput.svel = clamp(gInput.svel + input.svel, -2048, 2048);
gInput.q16avel = fix16_sadd(gInput.q16avel, input.q16avel);
gInput.q16horz = fix16_clamp(fix16_sadd(gInput.q16horz, input.q16horz), fix16_from_int(-127)>>2, fix16_from_int(127)>>2);
gInput.q16avel += input.q16avel;
gInput.q16horz = clamp(gInput.q16horz + input.q16horz, IntToFixed(-127)>>2, IntToFixed(127)>>2);
if (gMe && gMe->pXSprite->health != 0 && !paused)
{
int upAngle = 289;
int downAngle = -347;
double lookStepUp = 4.0*upAngle/60.0;
double lookStepDown = -4.0*downAngle/60.0;
gViewAngle = (gViewAngle + input.q16avel + fix16_from_dbl(scaleAdjustmentToInterval(gViewAngleAdjust))) & 0x7ffffff;
gViewAngle = (gViewAngle + input.q16avel + FloatToFixed(scaleAdjustmentToInterval(gViewAngleAdjust))) & 0x7ffffff;
if (gViewLookRecenter)
{
if (gViewLook < 0)
gViewLook = fix16_min(gViewLook+fix16_from_dbl(scaleAdjustmentToInterval(lookStepDown)), fix16_from_int(0));
gViewLook = min(gViewLook+FloatToFixed(scaleAdjustmentToInterval(lookStepDown)), 0);
if (gViewLook > 0)
gViewLook = fix16_max(gViewLook-fix16_from_dbl(scaleAdjustmentToInterval(lookStepUp)), fix16_from_int(0));
gViewLook = max(gViewLook-FloatToFixed(scaleAdjustmentToInterval(lookStepUp)), 0);
}
else
{
gViewLook = fix16_clamp(gViewLook+fix16_from_dbl(scaleAdjustmentToInterval(gViewLookAdjust)), fix16_from_int(downAngle), fix16_from_int(upAngle));
gViewLook = clamp(gViewLook+FloatToFixed(scaleAdjustmentToInterval(gViewLookAdjust)), IntToFixed(downAngle), IntToFixed(upAngle));
}
gViewLook = fix16_clamp(gViewLook+(input.q16horz << 3), fix16_from_int(downAngle), fix16_from_int(upAngle));
gViewLook = clamp(gViewLook+(input.q16horz << 3), IntToFixed(downAngle), IntToFixed(upAngle));
}
}

View file

@ -29,7 +29,7 @@ BEGIN_BLD_NS
extern InputPacket gInput, gNetInput;
extern bool bSilentAim;
extern fix16_t gViewLook, gViewAngle;
extern fixed_t gViewLook, gViewAngle;
extern float gViewAngleAdjust;
extern float gViewLookAdjust;
extern int gViewLookRecenter;

View file

@ -838,7 +838,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
pXSector->bobCeiling = bitReader.readUnsigned(1);
pXSector->bobRotate = bitReader.readUnsigned(1);
xsector[sector[i].extra].reference = i;
xsector[sector[i].extra].busy = xsector[sector[i].extra].state<<16;
xsector[sector[i].extra].busy = IntToFixed(xsector[sector[i].extra].state);
}
}
@ -911,7 +911,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
pXWall->unused3 = bitReader.readUnsigned(4);
pXWall->unused4 = bitReader.readUnsigned(32);
xwall[wall[i].extra].reference = i;
xwall[wall[i].extra].busy = xwall[wall[i].extra].state << 16;
xwall[wall[i].extra].busy = IntToFixed(xwall[wall[i].extra].state);
}
}
@ -1028,7 +1028,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
pXSprite->aiState = NULL;
bitReader.skipBits(32);
xsprite[sprite[i].extra].reference = i;
xsprite[sprite[i].extra].busy = xsprite[sprite[i].extra].state << 16;
xsprite[sprite[i].extra].busy = IntToFixed(xsprite[sprite[i].extra].state);
if (!byte_1A76C8) {
xsprite[sprite[i].extra].lT |= xsprite[sprite[i].extra].lB;
}

View file

@ -168,8 +168,8 @@ void hudDraw(PLAYER *gView, int nSectnum, int defaultHoriz, double bobx, double
viewingRange = viewingrange;
yxAspect = yxaspect;
renderSetAspect(65536, 54613);
r otatesprite(280 << 16, 35 << 16, 53248, 512, 4077, v10, v14, 512 + 6, gViewX0, gViewY0, gViewX1, gViewY1);
r otatesprite(280 << 16, 35 << 16, 53248, 0, 1683, v10, 0, 512 + 35, gViewX0, gViewY0, gViewX1, gViewY1);
r otatesprite(IntToFixed(280), IntToFixed(35), 53248, 512, 4077, v10, v14, 512 + 6, gViewX0, gViewY0, gViewX1, gViewY1);
r otatesprite(IntToFixed(280), IntToFixed(35), 53248, 0, 1683, v10, 0, 512 + 35, gViewX0, gViewY0, gViewX1, gViewY1);
renderSetAspect(viewingRange, yxAspect);
}
#endif

View file

@ -206,7 +206,7 @@ void CViewMap::sub_25DB0(spritetype *pSprite)
}
else
{
angle += fix16_to_int(turn)>>3;
angle += FixedToInt(turn)>>3;
x += mulscale24(forward>>8, Cos(angle));
y += mulscale24(forward>>8, Sin(angle));
x -= mulscale24(strafe>>8, Cos(angle+512));

View file

@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//-------------------------------------------------------------------------
#pragma once
#include "build.h"
#include "fix16.h"
BEGIN_BLD_NS
@ -32,7 +31,7 @@ public:
int x, y, nZoom;
short angle;
int forward, strafe;
fix16_t turn;
fixed_t turn;
void sub_25C38(int, int, int, short);
void sub_25C74(void);
void sub_25DB0(spritetype *pSprite);

View file

@ -298,7 +298,7 @@ void sub_557C4(int x, int y, int interpolation)
}
}
void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int viewPlayer)
void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int viewPlayer)
{
if (videoGetRenderMode() == REND_POLYMER)
return;
@ -345,7 +345,7 @@ void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int
yax_preparedrawrooms();
int32_t didmirror = renderDrawRoomsQ16(cx, cy, z, ca,horiz,mirrorsector|MAXSECTORS);
yax_drawrooms(viewProcessSprites, mirrorsector, didmirror, smooth);
viewProcessSprites(cx,cy,z,fix16_to_int(ca),smooth);
viewProcessSprites(cx,cy,z,FixedToInt(ca),smooth);
renderDrawMasks();
if (GetWallType(nWall) != kWallStack)
renderCompleteMirror();
@ -377,7 +377,7 @@ void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int
yax_preparedrawrooms();
renderDrawRoomsQ16(x+mirror[i].at8, y+mirror[i].atc, z+mirror[i].at10, a, horiz, nSector|MAXSECTORS);
yax_drawrooms(viewProcessSprites, nSector, 0, smooth);
viewProcessSprites(x+mirror[i].at8, y+mirror[i].atc, z+mirror[i].at10, fix16_to_int(a), smooth);
viewProcessSprites(x+mirror[i].at8, y+mirror[i].atc, z+mirror[i].at10, FixedToInt(a), smooth);
short fstat = sector[nSector].floorstat;
sector[nSector].floorstat |= 1;
renderDrawMasks();
@ -415,7 +415,7 @@ void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int
yax_preparedrawrooms();
renderDrawRoomsQ16(x+mirror[i].at8, y+mirror[i].atc, z+mirror[i].at10, a, horiz, nSector|MAXSECTORS);
yax_drawrooms(viewProcessSprites, nSector, 0, smooth);
viewProcessSprites(x+mirror[i].at8, y+mirror[i].atc, z+mirror[i].at10, fix16_to_int(a), smooth);
viewProcessSprites(x+mirror[i].at8, y+mirror[i].atc, z+mirror[i].at10, FixedToInt(a), smooth);
short cstat = sector[nSector].ceilingstat;
sector[nSector].ceilingstat |= 1;
renderDrawMasks();

View file

@ -84,7 +84,7 @@ int wRandSeed = 1;
int wrand(void)
{
wRandSeed = (wRandSeed*1103515245)+12345;
return (wRandSeed>>16)&0x7fff;
return FixedToInt(wRandSeed)&0x7fff;
}
void wsrand(int seed)

View file

@ -40,7 +40,7 @@ void UpdateNetworkMenus(void);
void InitMirrors(void);
void sub_5571C(char mode);
void sub_557C4(int x, int y, int interpolation);
void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int viewPlayer);
void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int viewPlayer);
int32_t registerosdcommands(void);
int qanimateoffs(int a1, int a2);
int32_t qgetpalookup(int32_t a1, int32_t a2);
@ -78,6 +78,8 @@ void RotateVector(int *dx, int *dy, int nAngle);
void RotatePoint(int *x, int *y, int nAngle, int ox, int oy);
void trigInit();
#include "m_fixed.h"
inline int Sin(int ang)
{
return costable[(ang - 512) & 2047];
@ -86,7 +88,17 @@ inline int Sin(int ang)
inline int Cos(int ang)
{
return costable[ang & 2047];
}
}
inline int SinScale16(int ang)
{
return FixedToInt(costable[(ang - 512) & 2047]);
}
inline int CosScale16(int ang)
{
return FixedToInt(costable[ang & 2047]);
}
enum SurfaceType {
kSurfNone = 0,

View file

@ -1491,8 +1491,8 @@ void trPlayerCtrlSetLookAngle(XSPRITE* pXSource, PLAYER* pPlayer) {
CONSTEXPR double lookStepDown = -4.0 * downAngle / 60.0;
int look = pXSource->data2 << 5;
if (look > 0) pPlayer->q16look = fix16_min(mulscale8(F16(lookStepUp), look), F16(upAngle));
else if (look < 0) pPlayer->q16look = -fix16_max(mulscale8(F16(lookStepDown), abs(look)), F16(downAngle));
if (look > 0) pPlayer->q16look = min(mulscale8(FloatToFixed(lookStepUp), look), FloatToFixed(upAngle));
else if (look < 0) pPlayer->q16look = -max(mulscale8(FloatToFixed(lookStepDown), abs(look)), FloatToFixed(downAngle));
else pPlayer->q16look = 0;
}
@ -2109,7 +2109,7 @@ void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) {
if (pXSource->data2 == 1) {
if (pPlayer) pPlayer->q16ang = fix16_from_int(pSource->ang);
if (pPlayer) pPlayer->q16ang = IntToFixed(pSource->ang);
else if (isDude) xsprite[pSprite->extra].goalAng = pSprite->ang = pSource->ang;
else pSprite->ang = pSource->ang;
}
@ -3066,9 +3066,9 @@ bool condCheckSprite(XSPRITE* pXCond, int cmpOp, bool PUSH) {
if ((pPlayer = getPlayerById(pSpr->type)) != NULL)
var = HitScan(pSpr, pPlayer->zWeapon - pSpr->z, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, arg1, arg3 << 1);
else if (IsDudeSprite(pSpr))
var = HitScan(pSpr, pSpr->z, Cos(pSpr->ang) >> 16, Sin(pSpr->ang) >> 16, gDudeSlope[pSpr->extra], arg1, arg3 << 1);
var = HitScan(pSpr, pSpr->z, CosScale16(pSpr->ang), SinScale16(pSpr->ang), gDudeSlope[pSpr->extra], arg1, arg3 << 1);
else
var = HitScan(pSpr, pSpr->z, Cos(pSpr->ang) >> 16, Sin(pSpr->ang) >> 16, 0, arg1, arg3 << 1);
var = HitScan(pSpr, pSpr->z, CosScale16(pSpr->ang), SinScale16(pSpr->ang), 0, arg1, arg3 << 1);
if (var >= 0) {
switch (cond) {
@ -3217,7 +3217,8 @@ char modernTypeSetSpriteState(int nSprite, XSPRITE* pXSprite, int nState) {
if ((pXSprite->busy & 0xffff) == 0 && pXSprite->state == nState)
return 0;
pXSprite->busy = nState << 16; pXSprite->state = nState;
pXSprite->busy = IntToFixed(nState);
pXSprite->state = nState;
evKill(nSprite, 3);
if (pXSprite->restState != nState && pXSprite->waitTime > 0)
@ -3960,8 +3961,8 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite
case 9: // 73 (set player's sprite angle, TO-DO: if tx > 0, take a look on TX ID sprite)
//data4 is reserved
if (pXSprite->data4 != 0) break;
else if (pSprite->flags & kModernTypeFlag1) pPlayer->q16ang = fix16_from_int(pSprite->ang);
else if (valueIsBetween(pXSprite->data2, -kAng360, kAng360)) pPlayer->q16ang = fix16_from_int(pXSprite->data2);
else if (pSprite->flags & kModernTypeFlag1) pPlayer->q16ang = IntToFixed(pSprite->ang);
else if (valueIsBetween(pXSprite->data2, -kAng360, kAng360)) pPlayer->q16ang = IntToFixed(pXSprite->data2);
break;
}
}
@ -4273,8 +4274,8 @@ void useUniMissileGen(int, int nXSprite) {
if (pSprite->cstat & 8) dz = 0x4000;
else dz = -0x4000;
} else {
dx = Cos(pSprite->ang) >> 16;
dy = Sin(pSprite->ang) >> 16;
dx = CosScale16(pSprite->ang);
dy = SinScale16(pSprite->ang);
dz = pXSprite->data3 << 6; // add slope controlling
if (dz > 0x10000) dz = 0x10000;
else if (dz < -0x10000) dz = -0x10000;

View file

@ -186,14 +186,14 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms >= 4)
{
pPlayer->q16ang = gView->q16ang = fix16_from_int(atoi(parm->parms[3]));
pPlayer->q16ang = gView->q16ang = IntToFixed(atoi(parm->parms[3]));
}
if (parm->numparms == 5)
{
// fix me, I'm broken.
pPlayer->q16horiz = gView->q16horiz = fix16_from_int(atoi(parm->parms[4]));
gViewAngle = fix16_from_dbl(atan2(atoi(parm->parms[4]), 100) * (1024. / pi::pi()));
pPlayer->q16horiz = gView->q16horiz = IntToFixed(atoi(parm->parms[4]));
gViewAngle = FloatToFixed(atan2(atoi(parm->parms[4]), 100) * (1024. / pi::pi()));
}
viewBackupView(pPlayer->nPlayer);

View file

@ -711,7 +711,7 @@ void playerStart(int nPlayer, int bNewLevel)
pSprite->z -= bottom - pSprite->z;
pSprite->pal = 11+(pPlayer->teamId&3);
pPlayer->angold = pSprite->ang = pStartZone->ang;
pPlayer->q16ang = fix16_from_int(pSprite->ang);
pPlayer->q16ang = IntToFixed(pSprite->ang);
pSprite->type = kDudePlayer1+nPlayer;
pSprite->clipdist = pDudeInfo->clipdist;
pSprite->flags = 15;
@ -1236,8 +1236,8 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3)
*a2 = 0;
*a3 = 0;
spritetype *pSprite = pPlayer->pSprite;
int x = Cos(pSprite->ang)>>16;
int y = Sin(pSprite->ang)>>16;
int x = CosScale16(pSprite->ang);
int y = SinScale16(pSprite->ang);
int z = pPlayer->slope;
int hit = HitScan(pSprite, pPlayer->zView, x, y, z, 0x10000040, 128);
int hitDist = approxDist(pSprite->x-gHitInfo.hitx, pSprite->y-gHitInfo.hity)>>4;
@ -1343,15 +1343,15 @@ void ProcessInput(PLAYER *pPlayer)
if (pPlayer->fraggerId != -1)
{
pPlayer->angold = pSprite->ang = getangle(sprite[pPlayer->fraggerId].x - pSprite->x, sprite[pPlayer->fraggerId].y - pSprite->y);
pPlayer->q16ang = fix16_from_int(pSprite->ang);
pPlayer->q16ang = IntToFixed(pSprite->ang);
}
pPlayer->deathTime += 4;
if (!bSeqStat)
{
if (bVanilla)
pPlayer->q16horiz = fix16_from_int(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime*8, 1024))>>15), 120));
pPlayer->q16horiz = IntToFixed(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime*8, 1024))>>15), 120));
else
pPlayer->q16horiz = mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime*8, 1024))>>15), fix16_from_int(120));
pPlayer->q16horiz = mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime*8, 1024))>>15), IntToFixed(120));
}
if (pPlayer->curWeapon)
pInput->setNewWeapon(pPlayer->curWeapon);
@ -1447,14 +1447,14 @@ void ProcessInput(PLAYER *pPlayer)
else
speed = 128;
pPlayer->spin = min(pPlayer->spin+speed, 0);
pPlayer->q16ang += fix16_from_int(speed);
pPlayer->q16ang += IntToFixed(speed);
if (pPlayer == gMe && numplayers == 1)
gViewAngleAdjust += float(speed);
}
if (pPlayer == gMe && numplayers == 1)
gViewAngleAdjust += float(pSprite->ang - pPlayer->angold);
pPlayer->q16ang = (pPlayer->q16ang+fix16_from_int(pSprite->ang-pPlayer->angold))&0x7ffffff;
pPlayer->angold = pSprite->ang = fix16_to_int(pPlayer->q16ang);
pPlayer->q16ang = (pPlayer->q16ang+IntToFixed(pSprite->ang-pPlayer->angold))&0x7ffffff;
pPlayer->angold = pSprite->ang = FixedToInt(pPlayer->q16ang);
if (!(pInput->actions & SB_JUMP))
pPlayer->cantJump = 0;
@ -1551,8 +1551,8 @@ void ProcessInput(PLAYER *pPlayer)
spritetype *pSprite2 = actSpawnDude(pPlayer->pSprite, kDudeHand, pPlayer->pSprite->clipdist<<1, 0);
pSprite2->ang = (pPlayer->pSprite->ang+1024)&2047;
int nSprite = pPlayer->pSprite->index;
int x = Cos(pPlayer->pSprite->ang)>>16;
int y = Sin(pPlayer->pSprite->ang)>>16;
int x = CosScale16(pPlayer->pSprite->ang);
int y = SinScale16(pPlayer->pSprite->ang);
xvel[pSprite2->index] = xvel[nSprite] + mulscale14(0x155555, x);
yvel[pSprite2->index] = yvel[nSprite] + mulscale14(0x155555, y);
zvel[pSprite2->index] = zvel[nSprite];
@ -1565,24 +1565,24 @@ void ProcessInput(PLAYER *pPlayer)
if ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
{
if (pPlayer->q16look < 0)
pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_int(4), fix16_from_int(0));
pPlayer->q16look = min(pPlayer->q16look+IntToFixed(4), 0);
if (pPlayer->q16look > 0)
pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_int(4), fix16_from_int(0));
pPlayer->q16look = max(pPlayer->q16look-IntToFixed(4), 0);
if (!pPlayer->q16look)
pInput->actions &= ~SB_CENTERVIEW;
}
else
{
if (pInput->actions & (SB_LOOK_UP|SB_AIM_UP))
pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_int(4), fix16_from_int(60));
pPlayer->q16look = min(pPlayer->q16look+IntToFixed(4), IntToFixed(60));
if (pInput->actions & (SB_LOOK_DOWN|SB_AIM_DOWN))
pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_int(4), fix16_from_int(-60));
pPlayer->q16look = max(pPlayer->q16look-IntToFixed(4), IntToFixed(-60));
}
pPlayer->q16look = fix16_clamp(pPlayer->q16look+pInput->q16horz, fix16_from_int(-60), fix16_from_int(60));
pPlayer->q16look = clamp(pPlayer->q16look+pInput->q16horz, IntToFixed(-60), IntToFixed(60));
if (pPlayer->q16look > 0)
pPlayer->q16horiz = fix16_from_int(mulscale30(120, Sin(fix16_to_int(pPlayer->q16look)<<3)));
pPlayer->q16horiz = IntToFixed(mulscale30(120, Sin(FixedToInt(pPlayer->q16look)<<3)));
else if (pPlayer->q16look < 0)
pPlayer->q16horiz = fix16_from_int(mulscale30(180, Sin(fix16_to_int(pPlayer->q16look)<<3)));
pPlayer->q16horiz = IntToFixed(mulscale30(180, Sin(FixedToInt(pPlayer->q16look)<<3)));
else
pPlayer->q16horiz = 0;
}
@ -1595,18 +1595,18 @@ void ProcessInput(PLAYER *pPlayer)
if ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
{
if (pPlayer->q16look < 0)
pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_dbl(lookStepDown), fix16_from_int(0));
pPlayer->q16look = min(pPlayer->q16look+FloatToFixed(lookStepDown), 0);
if (pPlayer->q16look > 0)
pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_dbl(lookStepUp), fix16_from_int(0));
pPlayer->q16look = max(pPlayer->q16look-FloatToFixed(lookStepUp), 0);
if (!pPlayer->q16look)
pInput->actions &= ~SB_CENTERVIEW;
}
else
{
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
pPlayer->q16look = fix16_min(pPlayer->q16look+fix16_from_dbl(lookStepUp), fix16_from_int(upAngle));
pPlayer->q16look = min(pPlayer->q16look+FloatToFixed(lookStepUp), IntToFixed(upAngle));
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
pPlayer->q16look = fix16_max(pPlayer->q16look-fix16_from_dbl(lookStepDown), fix16_from_int(downAngle));
pPlayer->q16look = max(pPlayer->q16look-FloatToFixed(lookStepDown), IntToFixed(downAngle));
}
if (pPlayer == gMe && numplayers == 1)
{
@ -1620,8 +1620,8 @@ void ProcessInput(PLAYER *pPlayer)
}
gViewLookRecenter = ((pInput->actions & SB_CENTERVIEW) && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)));
}
pPlayer->q16look = fix16_clamp(pPlayer->q16look+(pInput->q16horz<<3), fix16_from_int(downAngle), fix16_from_int(upAngle));
pPlayer->q16horiz = fix16_from_float(100.f*tanf(fix16_to_float(pPlayer->q16look)*fPI/1024.f));
pPlayer->q16look = clamp(pPlayer->q16look+(pInput->q16horz<<3), IntToFixed(downAngle), IntToFixed(upAngle));
pPlayer->q16horiz = FloatToFixed(100.f*tanf(FixedToFloat(pPlayer->q16look)*fPI/1024.f));
}
int nSector = pSprite->sectnum;
int florhit = gSpriteHit[pSprite->extra].florhit & 0xc000;
@ -1640,16 +1640,16 @@ void ProcessInput(PLAYER *pPlayer)
if (nSector2 == nSector)
{
int z2 = getflorzofslope(nSector2, x2, y2);
pPlayer->q16slopehoriz = interpolate(pPlayer->q16slopehoriz, fix16_from_int(z1-z2)>>3, 0x4000);
pPlayer->q16slopehoriz = interpolate(pPlayer->q16slopehoriz, IntToFixed(z1-z2)>>3, 0x4000);
}
}
else
{
pPlayer->q16slopehoriz = interpolate(pPlayer->q16slopehoriz, fix16_from_int(0), 0x4000);
pPlayer->q16slopehoriz = interpolate(pPlayer->q16slopehoriz, 0, 0x4000);
if (klabs(pPlayer->q16slopehoriz) < 4)
pPlayer->q16slopehoriz = 0;
}
pPlayer->slope = (-fix16_to_int(pPlayer->q16horiz))<<7;
pPlayer->slope = (-FixedToInt(pPlayer->q16horiz))<<7;
if (pInput->actions & SB_INVPREV)
{
pInput->actions&= ~SB_INVPREV;
@ -1748,7 +1748,7 @@ void playerProcess(PLAYER *pPlayer)
pPlayer->zWeaponVel += mulscale16(dz<<8, 0xc00);
pPlayer->zWeapon += pPlayer->zWeaponVel>>8;
pPlayer->bobPhase = ClipLow(pPlayer->bobPhase-4, 0);
nSpeed >>= 16;
nSpeed >>= FRACBITS;
if (pPlayer->posture == 1)
{
pPlayer->bobAmp = (pPlayer->bobAmp+17)&2047;
@ -2141,9 +2141,9 @@ void sub_41250(PLAYER *pPlayer)
for (int i = 0; i < 4; i++)
{
int ang1 = (pPlayer->voodooVar1+pPlayer->vodooVar2)&2047;
actFireVector(pPlayer->pSprite, 0, dz, Cos(ang1)>>16, Sin(ang1)>>16, v4, VECTOR_TYPE_21);
actFireVector(pPlayer->pSprite, 0, dz, CosScale16(ang1), SinScale16(ang1), v4, VECTOR_TYPE_21);
int ang2 = (pPlayer->voodooVar1+2048-pPlayer->vodooVar2)&2047;
actFireVector(pPlayer->pSprite, 0, dz, Cos(ang2)>>16, Sin(ang2)>>16, v4, VECTOR_TYPE_21);
actFireVector(pPlayer->pSprite, 0, dz, CosScale16(ang2), SinScale16(ang2), v4, VECTOR_TYPE_21);
}
pPlayer->voodooTargets = ClipLow(pPlayer->voodooTargets-1, 0);
}

View file

@ -30,7 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "controls.h"
#include "db.h"
#include "dude.h"
#include "fix16.h"
#include "levels.h"
#include "qav.h"
@ -110,7 +109,7 @@ struct PLAYER
int zViewVel;
int zWeapon;
int zWeaponVel;
fix16_t q16look;
fixed_t q16look;
int q16horiz; // horiz
int q16slopehoriz; // horizoff
int slope;
@ -182,7 +181,7 @@ struct PLAYER
int pickupEffect;
bool flashEffect; // if true, reduce pPlayer->visibility counter
int quakeEffect;
fix16_t q16ang;
fixed_t q16ang;
int angold;
int player_par;
int nWaterPal;

View file

@ -139,8 +139,8 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
predict.at71 = !!(gMe->input.actions & SB_JUMP);
if (predict.at48 == 1)
{
int x = Cos(fix16_to_int(predict.at30));
int y = Sin(fix16_to_int(predict.at30));
int x = Cos(FixedToInt(predict.at30));
int y = Sin(FixedToInt(predict.at30));
if (pInput->fvel)
{
int forward = pInput->fvel;
@ -164,8 +164,8 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
int speed = 0x10000;
if (predict.at6a > 0)
speed -= divscale16(predict.at6a, 0x100);
int x = Cos(fix16_to_int(predict.at30));
int y = Sin(fix16_to_int(predict.at30));
int x = Cos(FixedToInt(predict.at30));
int y = Sin(FixedToInt(predict.at30));
if (pInput->fvel)
{
int forward = pInput->fvel;
@ -202,7 +202,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
speed = 128;
predict.at4c = min(predict.at4c+speed, 0);
predict.at30 += fix16_from_int(speed);
predict.at30 += IntToFixed(speed);
if (numplayers > 1 && gPrediction)
gViewAngleAdjust += float(speed);
}
@ -236,25 +236,25 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
if (predict.at6e && !pInput->syncFlags.lookUp && !pInput->syncFlags.lookDown)
{
if (predict.at20 < 0)
predict.at20 = fix16_min(predict.at20+fix16_from_int(4), fix16_from_int(0));
predict.at20 = min(predict.at20+IntToFixed(4), 0);
if (predict.at20 > 0)
predict.at20 = fix16_max(predict.at20-fix16_from_int(4), fix16_from_int(0));
predict.at20 = max(predict.at20-IntToFixed(4), 0);
if (predict.at20 == 0)
predict.at6e = 0;
}
else
{
if (pInput->syncFlags.lookUp)
predict.at20 = fix16_min(predict.at20+fix16_from_int(4), fix16_from_int(60));
predict.at20 = min(predict.at20+IntToFixed(4), IntToFixed(60));
if (pInput->syncFlags.lookDown)
predict.at20 = fix16_max(predict.at20-fix16_from_int(4), fix16_from_int(-60));
predict.at20 = max(predict.at20-IntToFixed(4), IntToFixed(-60));
}
predict.at20 = fix16_clamp(predict.at20+pInput->q16mlook, fix16_from_int(-60), fix16_from_int(60));
predict.at20 = clamp(predict.at20+pInput->q16mlook, IntToFixed(-60), IntToFixed(60));
if (predict.at20 > 0)
predict.at24 = mulscale30(fix16_from_int(120), Sin(fix16_to_int(predict.at20<<3)));
predict.at24 = mulscale30(IntToFixed(120), Sin(FixedToInt(predict.at20<<3)));
else if (predict.at20 < 0)
predict.at24 = mulscale30(fix16_from_int(180), Sin(fix16_to_int(predict.at20<<3)));
predict.at24 = mulscale30(IntToFixed(180), Sin(FixedToInt(predict.at20<<3)));
else
predict.at24 = 0;
#endif
@ -265,18 +265,18 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
if (predict.at6e && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
{
if (predict.at20 < 0)
predict.at20 = fix16_min(predict.at20+fix16_from_dbl(lookStepDown), fix16_from_int(0));
predict.at20 = min(predict.at20+FloatToFixed(lookStepDown), 0);
if (predict.at20 > 0)
predict.at20 = fix16_max(predict.at20-fix16_from_dbl(lookStepUp), fix16_from_int(0));
predict.at20 = max(predict.at20-FloatToFixed(lookStepUp), 0);
if (predict.at20 == 0)
predict.at6e = 0;
}
else
{
if (pInput->actions & (SB_LOOK_UP | SB_AIM_UP))
predict.at20 = fix16_min(predict.at20+fix16_from_dbl(lookStepUp), fix16_from_int(upAngle));
predict.at20 = min(predict.at20+FloatToFixed(lookStepUp), IntToFixed(upAngle));
if (pInput->actions & (SB_LOOK_DOWN | SB_AIM_DOWN))
predict.at20 = fix16_max(predict.at20-fix16_from_dbl(lookStepDown), fix16_from_int(downAngle));
predict.at20 = max(predict.at20-FloatToFixed(lookStepDown), IntToFixed(downAngle));
}
if (numplayers > 1 && gPrediction)
{
@ -290,8 +290,8 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
}
gViewLookRecenter = predict.at6e && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN));
}
predict.at20 = fix16_clamp(predict.at20+(pInput->q16horz<<3), fix16_from_int(downAngle), fix16_from_int(upAngle));
predict.at24 = fix16_from_float(100.f*tanf(fix16_to_float(predict.at20)*fPI/1024.f));
predict.at20 = clamp(predict.at20+(pInput->q16horz<<3), IntToFixed(downAngle), IntToFixed(upAngle));
predict.at24 = FloatToFixed(100.f*tanf(FixedToFloat(predict.at20)*fPI/1024.f));
int nSector = predict.at68;
int florhit = predict.at75.florhit & 0xc000;
@ -303,14 +303,14 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
if (va && (sector[nSector].floorstat&2) != 0)
{
int z1 = getflorzofslope(nSector, predict.at50, predict.at54);
int x2 = predict.at50+mulscale30(64, Cos(fix16_to_int(predict.at30)));
int y2 = predict.at54+mulscale30(64, Sin(fix16_to_int(predict.at30)));
int x2 = predict.at50+mulscale30(64, Cos(FixedToInt(predict.at30)));
int y2 = predict.at54+mulscale30(64, Sin(FixedToInt(predict.at30)));
short nSector2 = nSector;
updatesector(x2, y2, &nSector2);
if (nSector2 == nSector)
{
int z2 = getflorzofslope(nSector2, x2, y2);
predict.at28 = interpolate(predict.at28, fix16_from_int(z1-z2)>>3, 0x4000);
predict.at28 = interpolate(predict.at28, IntToFixed(z1-z2)>>3, 0x4000);
}
}
else
@ -319,7 +319,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
if (klabs(predict.at28) < 4)
predict.at28 = 0;
}
predict.at2c = (-fix16_to_int(predict.at24))<<7;
predict.at2c = (-FixedToInt(predict.at24))<<7;
}
void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput)
@ -369,7 +369,7 @@ void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput)
predict.at0 = ClipLow(predict.at0-4, 0);
nSpeed >>= 16;
nSpeed >>= FRACBITS;
if (predict.at48 == 1)
{
predict.at4 = (predict.at4+17)&2047;

View file

@ -70,13 +70,13 @@ unsigned int GetWaveValue(unsigned int nPhase, int nType)
switch (nType)
{
case 0:
return 0x8000-(Cos((nPhase<<10)>>16)>>15);
return 0x8000-(Cos(FixedToInt(nPhase<<10))>>15);
case 1:
return nPhase;
case 2:
return 0x10000-(Cos((nPhase<<9)>>16)>>14);
return 0x10000-(Cos(FixedToInt(nPhase<<9))>>14);
case 3:
return Sin((nPhase<<9)>>16)>>14;
return Sin(FixedToInt(nPhase<<9))>>14;
}
return nPhase;
}
@ -85,7 +85,7 @@ char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState)
{
if ((pXSprite->busy & 0xffff) == 0 && pXSprite->state == nState)
return 0;
pXSprite->busy = nState << 16;
pXSprite->busy = IntToFixed(nState);
pXSprite->state = nState;
evKill(nSprite, 3);
if ((sprite[nSprite].flags & kHitagRespawn) != 0 && sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax)
@ -112,7 +112,7 @@ char SetWallState(int nWall, XWALL *pXWall, int nState)
{
if ((pXWall->busy&0xffff) == 0 && pXWall->state == nState)
return 0;
pXWall->busy = nState<<16;
pXWall->busy = IntToFixed(nState);
pXWall->state = nState;
evKill(nWall, 0);
if (pXWall->restState != nState && pXWall->waitTime > 0)
@ -131,7 +131,7 @@ char SetSectorState(int nSector, XSECTOR *pXSector, int nState)
{
if ((pXSector->busy&0xffff) == 0 && pXSector->state == nState)
return 0;
pXSector->busy = nState<<16;
pXSector->busy = IntToFixed(nState);
pXSector->state = nState;
evKill(nSector, 6);
if (nState == 1)
@ -293,8 +293,8 @@ void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event)
y += (yvel[nTarget]*t)>>12;
int angBak = pSprite->ang;
pSprite->ang = getangle(x-pSprite->x, y-pSprite->y);
int dx = Cos(pSprite->ang)>>16;
int dy = Sin(pSprite->ang)>>16;
int dx = CosScale16(pSprite->ang);
int dy = SinScale16(pSprite->ang);
int tz = pTarget->z - (pTarget->yrepeat * pDudeInfo->aimHeight) * 4;
int dz = divscale(tz - top - 256, nDist, 10);
int nMissileType = kMissileLifeLeechAltNormal + (pXSprite->data3 ? 1 : 0);
@ -1102,8 +1102,8 @@ int VCrushBusy(unsigned int nSector, unsigned int a2)
evSend(nSector, 6, pXSector->txID, kCmdLink);
if ((a2&0xffff) == 0)
{
SetSectorState(nSector, pXSector, a2>>16);
SectorEndSound(nSector, a2>>16);
SetSectorState(nSector, pXSector, FixedToInt(a2));
SectorEndSound(nSector, FixedToInt(a2));
return 3;
}
return 0;
@ -1151,8 +1151,8 @@ int VSpriteBusy(unsigned int nSector, unsigned int a2)
evSend(nSector, 6, pXSector->txID, kCmdLink);
if ((a2&0xffff) == 0)
{
SetSectorState(nSector, pXSector, a2>>16);
SectorEndSound(nSector, a2>>16);
SetSectorState(nSector, pXSector, FixedToInt(a2));
SectorEndSound(nSector, FixedToInt(a2));
return 3;
}
return 0;
@ -1250,8 +1250,8 @@ int VDoorBusy(unsigned int nSector, unsigned int a2)
evSend(nSector, 6, pXSector->txID, kCmdLink);
if ((a2&0xffff) == 0)
{
SetSectorState(nSector, pXSector, a2>>16);
SectorEndSound(nSector, a2>>16);
SetSectorState(nSector, pXSector, FixedToInt(a2));
SectorEndSound(nSector, FixedToInt(a2));
return 3;
}
return 0;
@ -1278,8 +1278,8 @@ int HDoorBusy(unsigned int nSector, unsigned int a2)
evSend(nSector, 6, pXSector->txID, kCmdLink);
if ((a2&0xffff) == 0)
{
SetSectorState(nSector, pXSector, a2>>16);
SectorEndSound(nSector, a2>>16);
SetSectorState(nSector, pXSector, FixedToInt(a2));
SectorEndSound(nSector, FixedToInt(a2));
return 3;
}
return 0;
@ -1305,8 +1305,8 @@ int RDoorBusy(unsigned int nSector, unsigned int a2)
evSend(nSector, 6, pXSector->txID, kCmdLink);
if ((a2&0xffff) == 0)
{
SetSectorState(nSector, pXSector, a2>>16);
SectorEndSound(nSector, a2>>16);
SetSectorState(nSector, pXSector, FixedToInt(a2));
SectorEndSound(nSector, FixedToInt(a2));
return 3;
}
return 0;
@ -1338,8 +1338,8 @@ int StepRotateBusy(unsigned int nSector, unsigned int a2)
evSend(nSector, 6, pXSector->txID, kCmdLink);
if ((a2&0xffff) == 0)
{
SetSectorState(nSector, pXSector, a2>>16);
SectorEndSound(nSector, a2>>16);
SetSectorState(nSector, pXSector, FixedToInt(a2));
SectorEndSound(nSector, FixedToInt(a2));
pXSector->data = vbp&2047;
return 3;
}
@ -1358,8 +1358,8 @@ int GenSectorBusy(unsigned int nSector, unsigned int a2)
evSend(nSector, 6, pXSector->txID, kCmdLink);
if ((a2&0xffff) == 0)
{
SetSectorState(nSector, pXSector, a2>>16);
SectorEndSound(nSector, a2>>16);
SetSectorState(nSector, pXSector, FixedToInt(a2));
SectorEndSound(nSector, FixedToInt(a2));
return 3;
}
return 0;
@ -1700,7 +1700,7 @@ void LinkSector(int nSector, XSECTOR *pXSector, EVENT event)
default:
pXSector->busy = nBusy;
if ((pXSector->busy&0xffff) == 0)
SetSectorState(nSector, pXSector, nBusy>>16);
SetSectorState(nSector, pXSector, FixedToInt(nBusy));
break;
}
}
@ -1729,7 +1729,7 @@ void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) {
{
pXSprite->busy = nBusy;
if ((pXSprite->busy & 0xffff) == 0)
SetSpriteState(nSprite, pXSprite, nBusy >> 16);
SetSpriteState(nSprite, pXSprite, FixedToInt(nBusy));
}
break;
}
@ -1740,7 +1740,7 @@ void LinkWall(int nWall, XWALL *pXWall, EVENT event)
int nBusy = GetSourceBusy(event);
pXWall->busy = nBusy;
if ((pXWall->busy & 0xffff) == 0)
SetWallState(nWall, pXWall, nBusy>>16);
SetWallState(nWall, pXWall, FixedToInt(nBusy));
}
void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command) {
@ -2257,7 +2257,7 @@ void FireballTrapSeqCallback(int, int nXSprite)
if (pSprite->cstat&32)
actFireMissile(pSprite, 0, 0, 0, 0, (pSprite->cstat&8) ? 0x4000 : -0x4000, kMissileFireball);
else
actFireMissile(pSprite, 0, 0, Cos(pSprite->ang)>>16, Sin(pSprite->ang)>>16, 0, kMissileFireball);
actFireMissile(pSprite, 0, 0, CosScale16(pSprite->ang), SinScale16(pSprite->ang), 0, kMissileFireball);
}
@ -2274,8 +2274,8 @@ void MGunFireSeqCallback(int, int nXSprite)
if (pXSprite->data2 == 0)
evPost(nSprite, 3, 1, kCmdOff);
}
int dx = (Cos(pSprite->ang)>>16)+Random2(1000);
int dy = (Sin(pSprite->ang)>>16)+Random2(1000);
int dx = CosScale16(pSprite->ang)+Random2(1000);
int dy = SinScale16(pSprite->ang)+Random2(1000);
int dz = Random2(1000);
actFireVector(pSprite, 0, 0, dx, dy, dz, VECTOR_TYPE_2);
sfxPlay3DSound(pSprite, 359, -1, 0);

View file

@ -354,11 +354,11 @@ int othercameradist = 1280;
int cameradist = -1;
int othercameraclock, cameraclock;
void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fix16_t zm)
void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fixed_t zm)
{
int vX = mulscale30(-Cos(nAng), 1280);
int vY = mulscale30(-Sin(nAng), 1280);
int vZ = fix16_to_int(mulscale(zm, 1280, 3))-(16<<8);
int vZ = FixedToInt(mulscale(zm, 1280, 3))-(16<<8);
int bakCstat = pSprite->cstat;
pSprite->cstat &= ~256;
dassert(*vsectnum >= 0 && *vsectnum < kMaxSectors);
@ -399,11 +399,11 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsec
pSprite->cstat = bakCstat;
}
void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fix16_t zm)
void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fixed_t zm)
{
int vX = mulscale30(-Cos(nAng), 1280);
int vY = mulscale30(-Sin(nAng), 1280);
int vZ = fix16_to_int(mulscale(zm, 1280, 3))-(16<<8);
int vZ = FixedToInt(mulscale(zm, 1280, 3))-(16<<8);
int bakCstat = pSprite->cstat;
pSprite->cstat &= ~256;
dassert(*vsectnum >= 0 && *vsectnum < kMaxSectors);
@ -574,7 +574,7 @@ void viewUpdateDelirium(void)
int timer = gFrameClock*4;
if (powerCount < 512)
{
int powerScale = (powerCount<<16) / 512;
int powerScale = IntToFixed(powerCount) / 512;
tilt1 = mulscale16(tilt1, powerScale);
tilt2 = mulscale16(tilt2, powerScale);
pitch = mulscale16(pitch, powerScale);
@ -698,9 +698,9 @@ void viewDrawScreen(bool sceneonly)
int cY = gView->pSprite->y;
int cZ = gView->zView;
double zDelta = gView->zWeapon - gView->zView - (12 << 8);
fix16_t cA = gView->q16ang;
fix16_t q16horiz = gView->q16horiz;
fix16_t q16slopehoriz = gView->q16slopehoriz;
fixed_t cA = gView->q16ang;
fixed_t q16horiz = gView->q16horiz;
fixed_t q16slopehoriz = gView->q16slopehoriz;
int v74 = gView->bobWidth;
int v8c = gView->bobHeight;
double v4c = gView->swayWidth;
@ -743,28 +743,28 @@ void viewDrawScreen(bool sceneonly)
{
int upAngle = 289;
int downAngle = -347;
fix16_t q16look;
fixed_t q16look;
cA = gViewAngle;
q16look = gViewLook;
q16horiz = fix16_from_float(100.f * tanf(fix16_to_float(q16look) * fPI / 1024.f));
q16horiz = FloatToFixed(100.f * tanf(FixedToFloat(q16look) * fPI / 1024.f));
}
viewUpdateShake();
q16horiz += fix16_from_int(shakeHoriz);
cA += fix16_from_int(shakeAngle);
q16horiz += IntToFixed(shakeHoriz);
cA += IntToFixed(shakeAngle);
cX += shakeX;
cY += shakeY;
cZ += shakeZ;
v4c += shakeBobX;
v48 += shakeBobY;
q16horiz += fix16_from_int(mulscale30(0x40000000 - Cos(gView->tiltEffect << 2), 30));
q16horiz += IntToFixed(mulscale30(0x40000000 - Cos(gView->tiltEffect << 2), 30));
if (gViewPos == 0)
{
if (cl_viewbob)
{
if (cl_viewhbob)
{
cX -= mulscale30(v74, Sin(fix16_to_int(cA))) >> 4;
cY += mulscale30(v74, Cos(fix16_to_int(cA))) >> 4;
cX -= mulscale30(v74, Sin(FixedToInt(cA))) >> 4;
cY += mulscale30(v74, Cos(FixedToInt(cA))) >> 4;
}
if (cl_viewvbob)
{
@ -775,13 +775,13 @@ void viewDrawScreen(bool sceneonly)
{
q16horiz += q16slopehoriz;
}
cZ += fix16_to_int(q16horiz * 10);
cZ += FixedToInt(q16horiz * 10);
cameradist = -1;
cameraclock = gameclock;
}
else
{
CalcPosition(gView->pSprite, (int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum, fix16_to_int(cA), q16horiz);
CalcPosition(gView->pSprite, (int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum, FixedToInt(cA), q16horiz);
}
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum);
int v78 = interpolateang(gScreenTiltO, gScreenTilt, gInterpolate);
@ -869,7 +869,7 @@ void viewDrawScreen(bool sceneonly)
for (int i = 0; i < 16; i++)
ror_status[i] = TestBitString(gotpic, 4080 + i);
yax_preparedrawrooms();
DrawMirrors(vd8, vd4, vd0, fix16_from_int(v50), fix16_from_int(v54 + defaultHoriz), gInterpolate, -1);
DrawMirrors(vd8, vd4, vd0, IntToFixed(v50), IntToFixed(v54 + defaultHoriz), gInterpolate, -1);
drawrooms(vd8, vd4, vd0, v50, v54 + defaultHoriz, vcc);
yax_drawrooms(viewProcessSprites, vcc, 0, gInterpolate);
bool do_ror_hack = false;
@ -927,7 +927,7 @@ void viewDrawScreen(bool sceneonly)
nSprite = nextspritestat[nSprite];
}
g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - unk, 0));
cA = (cA + interpolateangfix16(fix16_from_int(deliriumTurnO), fix16_from_int(deliriumTurn), gInterpolate)) & 0x7ffffff;
cA = (cA + interpolateangfix16(IntToFixed(deliriumTurnO), IntToFixed(deliriumTurn), gInterpolate)) & 0x7ffffff;
int vfc, vf8;
getzsofslope(nSectnum, cX, cY, &vfc, &vf8);
if (cZ >= vf8)
@ -938,13 +938,13 @@ void viewDrawScreen(bool sceneonly)
{
cZ = vfc + (gLowerLink[nSectnum] >= 0 ? 0 : (8 << 8));
}
q16horiz = ClipRange(q16horiz, fix16_from_int(-200), fix16_from_int(200));
q16horiz = ClipRange(q16horiz, IntToFixed(-200), IntToFixed(200));
RORHACK:
int ror_status[16];
for (int i = 0; i < 16; i++)
ror_status[i] = TestBitString(gotpic, 4080 + i);
fix16_t deliriumPitchI = interpolate(fix16_from_int(deliriumPitchO), fix16_from_int(deliriumPitch), gInterpolate);
DrawMirrors(cX, cY, cZ, cA, q16horiz + fix16_from_int(defaultHoriz) + deliriumPitchI, gInterpolate, gViewIndex);
fixed_t deliriumPitchI = interpolate(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate);
DrawMirrors(cX, cY, cZ, cA, q16horiz + IntToFixed(defaultHoriz) + deliriumPitchI, gInterpolate, gViewIndex);
int bakCstat = gView->pSprite->cstat;
if (gViewPos == 0)
{
@ -955,8 +955,8 @@ void viewDrawScreen(bool sceneonly)
gView->pSprite->cstat |= 514;
}
renderDrawRoomsQ16(cX, cY, cZ, cA, q16horiz + fix16_from_int(defaultHoriz) + deliriumPitchI, nSectnum);
viewProcessSprites(cX, cY, cZ, fix16_to_int(cA), gInterpolate);
renderDrawRoomsQ16(cX, cY, cZ, cA, q16horiz + IntToFixed(defaultHoriz) + deliriumPitchI, nSectnum);
viewProcessSprites(cX, cY, cZ, FixedToInt(cA), gInterpolate);
bool do_ror_hack = false;
for (int i = 0; i < 16; i++)
if (ror_status[i] != TestBitString(gotpic, 4080 + i))

View file

@ -40,11 +40,11 @@ struct VIEW {
int at14;
int at18; // bob sway y
int at1c; // bob sway x
fix16_t at20;
fix16_t at24; // horiz
fixed_t at20;
fixed_t at24; // horiz
int at28; // horizoff
int at2c;
fix16_t at30; // angle
fixed_t at30; // angle
int at34; // weapon z
int at38; // view z
int at3c;

View file

@ -315,8 +315,8 @@ void UpdateAimVector(PLAYER * pPlayer)
int y = pPSprite->y;
int z = pPlayer->zWeapon;
Aim aim;
aim.dx = Cos(pPSprite->ang)>>16;
aim.dy = Sin(pPSprite->ang)>>16;
aim.dx = CosScale16(pPSprite->ang);
aim.dy = SinScale16(pPSprite->ang);
aim.dz = pPlayer->slope;
WEAPONTRACK *pWeaponTrack = &gWeaponTrack[pPlayer->curWeapon];
int nTarget = -1;
@ -374,8 +374,8 @@ void UpdateAimVector(PLAYER * pPlayer)
if (cansee(x, y, z, pPSprite->sectnum, x2, y2, z2, pSprite->sectnum))
{
nClosest = nDist2;
aim.dx = Cos(angle)>>16;
aim.dy = Sin(angle)>>16;
aim.dx = CosScale16(angle);
aim.dy = SinScale16(angle);
aim.dz = divscale(dzCenter, nDist, 10);
nTarget = nSprite;
}
@ -421,8 +421,8 @@ void UpdateAimVector(PLAYER * pPlayer)
if (cansee(x, y, z, pPSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum))
{
nClosest = nDist2;
aim.dx = Cos(angle)>>16;
aim.dy = Sin(angle)>>16;
aim.dx = CosScale16(angle);
aim.dy = SinScale16(angle);
aim.dz = divscale(dz, nDist, 10);
nTarget = nSprite;
}
@ -1200,8 +1200,8 @@ void FireSpread(int nTrigger, PLAYER *pPlayer)
dassert(nTrigger > 0 && nTrigger <= kMaxSpread);
Aim *aim = &pPlayer->aim;
int angle = (getangle(aim->dx, aim->dy)+((112*(nTrigger-1))/14-56))&2047;
int dx = Cos(angle)>>16;
int dy = Sin(angle)>>16;
int dx = CosScale16(angle);
int dy = SinScale16(angle);
sfxPlay3DSound(pPlayer->pSprite, 431, -1, 0);
int r1, r2, r3;
r1 = Random3(300);
@ -1221,8 +1221,8 @@ void AltFireSpread(int nTrigger, PLAYER *pPlayer)
dassert(nTrigger > 0 && nTrigger <= kMaxSpread);
Aim *aim = &pPlayer->aim;
int angle = (getangle(aim->dx, aim->dy)+((112*(nTrigger-1))/14-56))&2047;
int dx = Cos(angle)>>16;
int dy = Sin(angle)>>16;
int dx = CosScale16(angle);
int dy = SinScale16(angle);
sfxPlay3DSound(pPlayer->pSprite, 431, -1, 0);
int r1, r2, r3;
r1 = Random3(300);
@ -1250,8 +1250,8 @@ void AltFireSpread2(int nTrigger, PLAYER *pPlayer)
dassert(nTrigger > 0 && nTrigger <= kMaxSpread);
Aim *aim = &pPlayer->aim;
int angle = (getangle(aim->dx, aim->dy)+((112*(nTrigger-1))/14-56))&2047;
int dx = Cos(angle)>>16;
int dy = Sin(angle)>>16;
int dx = CosScale16(angle);
int dy = SinScale16(angle);
sfxPlay3DSound(pPlayer->pSprite, 431, -1, 0);
if (powerupCheck(pPlayer, kPwUpTwoGuns) && sub_4B2C8(pPlayer, 3, 2))
{

View file

@ -126,8 +126,8 @@ enum rendmode_t {
# define yax_preparedrawrooms()
# define yax_drawrooms(SpriteAnimFunc, sectnum, didmirror, smoothr)
#define CLIPMASK0 (((1)<<16)+1)
#define CLIPMASK1 (((256)<<16)+64)
#define CLIPMASK0 (IntToFixed(1)+1)
#define CLIPMASK1 (IntToFixed(256)+64)
#define NEXTWALL(i) (wall[wall[i].nextwall])
#define POINT2(i) (wall[wall[i].point2])
@ -653,15 +653,15 @@ inline void renderFlushPerms(void) {}
void plotpixel(int32_t x, int32_t y, char col);
FCanvasTexture *renderSetTarget(int16_t tilenume);
void renderRestoreTarget();
void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz, int16_t dawall,
int32_t *tposx, int32_t *tposy, fix16_t *tang);
void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t dawall,
int32_t *tposx, int32_t *tposy, fixed_t *tang);
void renderCompleteMirror(void);
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fix16_t daang, fix16_t dahoriz, int16_t dacursectnum);
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, int16_t dacursectnum);
static FORCE_INLINE int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int16_t dahoriz, int16_t dacursectnum)
{
return renderDrawRoomsQ16(daposx, daposy, daposz, fix16_from_int(daang), fix16_from_int(dahoriz), dacursectnum);
return renderDrawRoomsQ16(daposx, daposy, daposz, IntToFixed(daang), IntToFixed(dahoriz), dacursectnum);
}
void renderDrawMasks(void);
@ -733,7 +733,7 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum);
static FORCE_INLINE int32_t krand(void)
{
randomseed = (randomseed * 1664525ul) + 221297ul;
return ((uint32_t) randomseed)>>16;
return FixedToInt(randomseed);
}
#else
int32_t krand(void);
@ -741,11 +741,11 @@ int32_t krand(void);
int32_t ksqrt(uint32_t num);
int32_t getangle(int32_t xvect, int32_t yvect);
fix16_t gethiq16angle(int32_t xvect, int32_t yvect);
fixed_t gethiq16angle(int32_t xvect, int32_t yvect);
static FORCE_INLINE fix16_t getq16angle(int32_t xvect, int32_t yvect)
static FORCE_INLINE fixed_t getq16angle(int32_t xvect, int32_t yvect)
{
return fix16_from_int(getangle(xvect, yvect));
return IntToFixed(getangle(xvect, yvect));
}
static FORCE_INLINE CONSTEXPR uint32_t uhypsq(int32_t const dx, int32_t const dy)

View file

@ -518,7 +518,7 @@ static FORCE_INLINE char *Bstrncpyz(char *dst, const char *src, bsize_t n)
////////// Inlined external libraries //////////
#include "fix16.h"
#include "m_fixed.h"
#include "vectors.h"
inline FVector3 GetSoundPos(const vec3_t *pos)

View file

@ -26,7 +26,7 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
void polymost_fillpolygon(int32_t npoints);
void polymost_initosdfuncs(void);
void polymost_drawrooms(void);
void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz, int16_t mirrorWall);
void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t mirrorWall);
void polymost_completeMirror();
int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall);

View file

@ -481,7 +481,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
int const initialsectnum = *sectnum;
int32_t const dawalclipmask = (cliptype & 65535); // CLIPMASK0 = 0x00010001
int32_t const dasprclipmask = (cliptype >> 16); // CLIPMASK1 = 0x01000040
int32_t const dasprclipmask = FixedToInt(cliptype); // CLIPMASK1 = 0x01000040
vec2_t const move = { xvect, yvect };
vec2_t goal = { pos->x + (xvect >> 14), pos->y + (yvect >> 14) };
@ -854,7 +854,7 @@ int pushmove(vec3_t *const vect, int16_t *const sectnum,
int bad;
const int32_t dawalclipmask = (cliptype&65535);
// const int32_t dasprclipmask = (cliptype>>16);
// const int32_t dasprclipmask = FixedToInt(cliptype);
if (*sectnum < 0)
return -1;
@ -1012,7 +1012,7 @@ void getzrange(const vec3_t *pos, int16_t sectnum,
const int32_t xmax = pos->x+extradist, ymax = pos->y+extradist;
const int32_t dawalclipmask = (cliptype&65535);
const int32_t dasprclipmask = (cliptype>>16);
const int32_t dasprclipmask = FixedToInt(cliptype);
vec2_t closest = pos->vec2;
if (enginecompatibility_mode == ENGINECOMPATIBILITY_NONE)
@ -1336,7 +1336,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
// tmp: { (int32_t)curidx, (spritetype *)curspr, (!=0 if outer sector) }
intptr_t *tmpptr=NULL;
const int32_t dawalclipmask = (cliptype&65535);
const int32_t dasprclipmask = (cliptype>>16);
const int32_t dasprclipmask = FixedToInt(cliptype);
hit->sect = -1; hit->wall = -1; hit->sprite = -1;
if (sectnum < 0)

View file

@ -103,7 +103,7 @@ int32_t showheightindicators=1;
int32_t circlewall=-1;
int16_t editstatus = 0;
static fix16_t global100horiz; // (-100..300)-scale horiz (the one passed to drawrooms)
static fixed_t global100horiz; // (-100..300)-scale horiz (the one passed to drawrooms)
static FString printcoords(void)
{
@ -117,7 +117,7 @@ static FString printcoords(void)
"horiz: %d\n",
globalposx, globalposy,
globalposz, globalang,
fix16_to_int(global100horiz)
FixedToInt(global100horiz)
);
return str;
@ -327,10 +327,10 @@ int32_t ydimen;
int32_t rxi[8], ryi[8];
int32_t globalposx, globalposy, globalposz, globalhoriz;
fix16_t qglobalhoriz;
fixed_t qglobalhoriz;
float fglobalposx, fglobalposy, fglobalposz;
int16_t globalang, globalcursectnum;
fix16_t qglobalang;
fixed_t qglobalang;
int32_t globalpal, cosglobalang, singlobalang;
int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
@ -577,11 +577,11 @@ static void dosetaspect(void)
oviewingrange = viewingrange;
xinc = mulscale32(viewingrange*2560,xdimenrecip);
x = (5120<<16)-mulscale1(xinc,xdimen);
x = IntToFixed(5120)-mulscale1(xinc,xdimen);
for (i=0; i<xdimen; i++)
{
j = (x&65535); k = (x>>16); x += xinc;
j = (x&65535); k = FixedToInt(x); x += xinc;
if (k < 0 || k >= (int32_t)ARRAY_SIZE(qradarang)-1)
{
@ -624,7 +624,7 @@ static int32_t engineLoadTables(void)
radarang[1279-i] = -radarang[i];
for (i=0; i<5120; i++)
qradarang[i] = fix16_from_float(atanf(((float)(5120-i)-0.5f) * (1.f/1280.f)) * (-64.f * (1.f/BANG2RAD)));
qradarang[i] = FloatToFixed(atanf(((float)(5120-i)-0.5f) * (1.f/1280.f)) * (-64.f * (1.f/BANG2RAD)));
for (i=0; i<5120; i++)
qradarang[10239-i] = -qradarang[i];
@ -921,7 +921,7 @@ int32_t lintersect(const int32_t originX, const int32_t originY, const int32_t o
//
// rintersect (internal)
//
// returns: -1 if didn't intersect, coefficient (x3--x4 fraction)<<16 else
// returns: -1 if didn't intersect, coefficient IntToFixed(x3--x4 fraction) else
int32_t rintersect_old(int32_t x1, int32_t y1, int32_t z1,
int32_t vx, int32_t vy, int32_t vz,
int32_t x3, int32_t y3, int32_t x4, int32_t y4,
@ -981,12 +981,12 @@ int32_t rintersect(int32_t x1, int32_t y1, int32_t z1,
else if (bot < 0 && (topt > 0 || topu > 0 || topu <= bot))
return -1;
int64_t t = (topt<<16) / bot;
*intx = x1 + ((vx*t)>>16);
*inty = y1 + ((vy*t)>>16);
*intz = z1 + ((vz*t)>>16);
int64_t t = IntToFixed(topt) / bot;
*intx = x1 + FixedToInt(vx*t);
*inty = y1 + FixedToInt(vy*t);
*intz = z1 + FixedToInt(vz*t);
t = (topu<<16) / bot;
t = IntToFixed(topu) / bot;
assert((unsigned)t < 65536);
@ -1238,12 +1238,12 @@ void initspritelists(void)
}
void set_globalang(fix16_t const ang)
void set_globalang(fixed_t const ang)
{
globalang = fix16_to_int(ang)&2047;
globalang = FixedToInt(ang)&2047;
qglobalang = ang & 0x7FFFFFF;
float const f_ang = fix16_to_float(ang);
float const f_ang = FixedToFloat(ang);
float const f_ang_radians = f_ang * M_PI * (1.f/1024.f);
float const fcosang = cosf(f_ang_radians) * 16384.f;
@ -1265,7 +1265,7 @@ void set_globalang(fix16_t const ang)
// drawrooms
//
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
fix16_t daang, fix16_t dahoriz, int16_t dacursectnum)
fixed_t daang, fixed_t dahoriz, int16_t dacursectnum)
{
int32_t i;
@ -1276,8 +1276,8 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
// xdimenscale is scale(xdimen,yxaspect,320);
// normalization by viewingrange so that center-of-aim doesn't depend on it
qglobalhoriz = mulscale16(dahoriz-F16(100), divscale16(xdimenscale, viewingrange))+fix16_from_int(ydimen>>1);
globalhoriz = fix16_to_int(qglobalhoriz);
qglobalhoriz = mulscale16(dahoriz-IntToFixed(100), divscale16(xdimenscale, viewingrange))+IntToFixed(ydimen>>1);
globalhoriz = FixedToInt(qglobalhoriz);
globalcursectnum = dacursectnum;
@ -2932,23 +2932,23 @@ int32_t getangle(int32_t xvect, int32_t yvect)
return rv;
}
fix16_t gethiq16angle(int32_t xvect, int32_t yvect)
fixed_t gethiq16angle(int32_t xvect, int32_t yvect)
{
fix16_t rv;
fixed_t rv;
if ((xvect | yvect) == 0)
rv = 0;
else if (xvect == 0)
rv = fix16_from_int(512 + ((yvect < 0) << 10));
rv = IntToFixed(512 + ((yvect < 0) << 10));
else if (yvect == 0)
rv = fix16_from_int(((xvect < 0) << 10));
rv = IntToFixed(((xvect < 0) << 10));
else if (xvect == yvect)
rv = fix16_from_int(256 + ((xvect < 0) << 10));
rv = IntToFixed(256 + ((xvect < 0) << 10));
else if (xvect == -yvect)
rv = fix16_from_int(768 + ((xvect > 0) << 10));
rv = IntToFixed(768 + ((xvect > 0) << 10));
else if (klabs(xvect) > klabs(yvect))
rv = ((qradarang[5120 + scale(1280, yvect, xvect)] >> 6) + fix16_from_int(((xvect < 0) << 10))) & 0x7FFFFFF;
else rv = ((qradarang[5120 - scale(1280, xvect, yvect)] >> 6) + fix16_from_int(512 + ((yvect < 0) << 10))) & 0x7FFFFFF;
rv = ((qradarang[5120 + scale(1280, yvect, xvect)] >> 6) + IntToFixed(((xvect < 0) << 10))) & 0x7FFFFFF;
else rv = ((qradarang[5120 - scale(1280, xvect, yvect)] >> 6) + IntToFixed(512 + ((yvect < 0) << 10))) & 0x7FFFFFF;
return rv;
}
@ -3819,8 +3819,8 @@ void renderRestoreTarget()
//
// preparemirror
//
void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz, int16_t dawall,
int32_t *tposx, int32_t *tposy, fix16_t *tang)
void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t dawall,
int32_t *tposx, int32_t *tposy, fixed_t *tang)
{
const int32_t x = wall[dawall].x, dx = wall[wall[dawall].point2].x-x;
const int32_t y = wall[dawall].y, dy = wall[wall[dawall].point2].y-y;
@ -3833,7 +3833,7 @@ void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang, f
*tposx = (x<<1) + scale(dx,i,j) - dax;
*tposy = (y<<1) + scale(dy,i,j) - day;
*tang = (fix16_from_int(getangle(dx, dy) << 1) - daang) & 0x7FFFFFF;
*tang = (IntToFixed(getangle(dx, dy) << 1) - daang) & 0x7FFFFFF;
inpreparemirror = 1;

View file

@ -88,7 +88,7 @@ extern tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1];
extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen;
extern float fxdimen;
extern int32_t globalposx, globalposy, globalposz, globalhoriz;
extern fix16_t qglobalhoriz, qglobalang;
extern fixed_t qglobalhoriz, qglobalang;
extern float fglobalposx, fglobalposy, fglobalposz;
extern int16_t globalang, globalcursectnum;
extern int32_t globalpal, cosglobalang, singlobalang;
@ -121,7 +121,7 @@ extern int32_t rxi[8], ryi[8];
// int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat);
int32_t wallfront(int32_t l1, int32_t l2);
void set_globalang(fix16_t const ang);
void set_globalang(fixed_t const ang);
int32_t animateoffs(int tilenum, int fakevar);

View file

@ -601,7 +601,7 @@ static void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal)
i = (mdtims - sprext->mdanimtims) * ((fps * 120) / 120);
j = (smooth->mdsmooth || !anim) ? 65536 : ((anim->endframe + 1 - anim->startframe) << 16);
j = (smooth->mdsmooth || !anim) ? 65536 : IntToFixed(anim->endframe + 1 - anim->startframe);
// XXX: Just in case you play the game for a VERY long time...
if (i < 0) { i = 0; sprext->mdanimtims = mdtims; }
@ -636,7 +636,7 @@ static void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal)
else
{
if (anim)
m->cframe = (i>>16)+anim->startframe;
m->cframe = FixedToInt(i)+anim->startframe;
m->nframe = m->cframe+1;

View file

@ -1299,7 +1299,7 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i
xys[i].y = v.y * r + ghalfy;
}
float const fglobalang = fix16_to_float(qglobalang);
float const fglobalang = FixedToFloat(qglobalang);
int32_t dapyscale, dapskybits, dapyoffs, daptileyscale;
int16_t const * dapskyoff = getpsky(globalpicnum, &dapyscale, &dapskybits, &dapyoffs, &daptileyscale);
@ -1482,7 +1482,7 @@ static void polymost_drawalls(int32_t const bunch)
int32_t const sectnum = thesector[bunchfirst[bunch]];
auto const sec = (usectorptr_t)&sector[sectnum];
float const fglobalang = fix16_to_float(qglobalang);
float const fglobalang = FixedToFloat(qglobalang);
polymost_outputGLDebugMessage(3, "polymost_drawalls(bunch:%d)", bunch);
@ -2483,8 +2483,8 @@ void polymost_drawrooms()
ghalfx = (float)(xdimen>>1);
ghalfy = (float)(ydimen>>1);
grhalfxdown10 = 1.f/(ghalfx*1024.f);
ghoriz = fix16_to_float(qglobalhoriz);
ghorizcorrect = fix16_to_float((100-polymostcenterhoriz)*divscale16(xdimenscale, viewingrange));
ghoriz = FixedToFloat(qglobalhoriz);
ghorizcorrect = FixedToFloat((100-polymostcenterhoriz)*divscale16(xdimenscale, viewingrange));
GLInterface.SetShadeInterpolate(hw_shadeinterpolate);
@ -2852,7 +2852,7 @@ void polymost_drawmaskwall(int32_t damaskwallcnt)
polymost_drawmaskwallinternal(thewall[z]);
}
void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz, int16_t mirrorWall)
void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t mirrorWall)
{
polymost_outputGLDebugMessage(3, "polymost_prepareMirror(%u)", mirrorWall);
@ -2871,8 +2871,8 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang
set_globalpos(dax, day, daz);
set_globalang(daang);
globalhoriz = mulscale16(fix16_to_int(dahoriz)-100,divscale16(xdimenscale,viewingrange))+(ydimen>>1);
qglobalhoriz = mulscale16(dahoriz-F16(100), divscale16(xdimenscale, viewingrange))+fix16_from_int(ydimen>>1);
globalhoriz = mulscale16(FixedToInt(dahoriz)-100,divscale16(xdimenscale,viewingrange))+(ydimen>>1);
qglobalhoriz = mulscale16(dahoriz-IntToFixed(100), divscale16(xdimenscale, viewingrange))+IntToFixed(ydimen>>1);
gyxscale = ((float)xdimenscale)*(1.0f/131072.f);
gxyaspect = ((double)xyaspect*fviewingrange)*(5.0/(65536.0*262144.0));
gviewxrange = fviewingrange * fxdimen * (1.f/(32768.f*1024.f));
@ -2883,8 +2883,8 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang
ghalfx = (float)(xdimen>>1);
ghalfy = (float)(ydimen>>1);
grhalfxdown10 = 1.f/(ghalfx*1024.f);
ghoriz = fix16_to_float(qglobalhoriz);
ghorizcorrect = fix16_to_float((100-polymostcenterhoriz)*divscale16(xdimenscale, viewingrange));
ghoriz = FixedToFloat(qglobalhoriz);
ghorizcorrect = FixedToFloat((100-polymostcenterhoriz)*divscale16(xdimenscale, viewingrange));
resizeglcheck();
if (r_yshearing)
{

View file

@ -53,11 +53,22 @@ inline fixed_t FloatToFixed(double f)
return xs_Fix<16>::ToFix(f);
}
inline fixed_t IntToFixed(int32_t f)
{
// Negative shifts are undefined, so multiply instead of shifting left.
return f * FRACUNIT;
}
inline double FixedToFloat(fixed_t f)
{
return f / 65536.;
}
inline int32_t FixedToInt(fixed_t f)
{
return xs_CRoundToInt(FixedToFloat(f));
}
inline unsigned FloatToAngle(double f)
{
return xs_CRoundToInt((f)* (0x40000000 / 90.));

View file

@ -90,7 +90,7 @@ public:
return binangle(value - other.value);
}
void interpolate(binangle a1, binangle a2, fix16_t smoothratio)
void interpolate(binangle a1, binangle a2, fixed_t smoothratio)
{
// Calculate in floating point to reduce the error caused by overflows which are to be expected here and then downconvert using a method that is safe to overflow.
// We do not want fixed point multiplications here to trash the result.
@ -115,7 +115,7 @@ public:
fixedhoriz(const fixedhoriz &other) = default;
// This class intentionally makes no allowances for implicit type conversions because those would render it ineffective.
short asbuild() const { return value >> 16; }
short asbuild() const { return FixedToInt(value); }
constexpr fixed_t asq16() const { return value; }
bool operator< (fixedhoriz other) const
@ -184,5 +184,5 @@ inline binangle radang(double v) { return binangle(xs_CRoundToUInt(v * (0x800000
inline binangle degang(double v) { return binangle(xs_CRoundToUInt(v * (0x40000000 / 90.))); }
inline constexpr fixedhoriz q16horiz(int v) { return fixedhoriz(v); }
inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(v << 16); }
inline constexpr fixedhoriz buildhoriz(int v) { return fixedhoriz(IntToFixed(v)); }

View file

@ -1,7 +1,7 @@
#pragma once
#include <stdint.h>
#include "fix16.h"
#include "m_fixed.h"
#include "tflags.h"
enum ESyncBits_ : uint32_t
@ -72,10 +72,10 @@ struct InputPacket
{
int16_t svel;
int16_t fvel;
fix16_t q16avel;
fix16_t q16horz;
fix16_t q16horiz; // only used by SW
fix16_t q16ang; // only used by SW
fixed_t q16avel;
fixed_t q16horz;
fixed_t q16horiz; // only used by SW
fixed_t q16ang; // only used by SW
ESyncBits actions;

View file

@ -190,7 +190,7 @@ void menu_DoPlasma()
for (int i = 0; i < 5; i++)
{
int logoWidth = tilesiz[nLogoTile].x;
plasma_C[i] = (nSmokeLeft + rand() % logoWidth) << 16;
plasma_C[i] = IntToFixed(nSmokeLeft + rand() % logoWidth);
plasma_B[i] = (rnd_plasma.GenRand32() % 327680) + 0x10000;
if (rnd_plasma.GenRand32()&1) {
@ -298,13 +298,13 @@ void menu_DoPlasma()
{
int pB = plasma_B[j];
int pC = plasma_C[j];
int badOffset = (pC >> 16) < nSmokeLeft || (pC >> 16) >= nSmokeRight;
int badOffset = FixedToInt(pC) < nSmokeLeft || FixedToInt(pC) >= nSmokeRight;
const uint8_t* ptr3 = (logopix + ((pC >> 16) - nSmokeLeft) * tilesiz[nLogoTile].y);
const uint8_t* ptr3 = (logopix + (FixedToInt(pC) - nSmokeLeft) * tilesiz[nLogoTile].y);
plasma_C[j] += plasma_B[j];
if ((pB > 0 && (plasma_C[j] >> 16) >= nSmokeRight) || (pB < 0 && (plasma_C[j] >> 16) <= nSmokeLeft))
if ((pB > 0 && FixedToInt(plasma_C[j]) >= nSmokeRight) || (pB < 0 && FixedToInt(plasma_C[j]) <= nSmokeLeft))
{
int esi = plasma_A[j];
plasma_B[j] = -plasma_B[j];
@ -349,7 +349,7 @@ void menu_DoPlasma()
}
}
uint8_t* v28 = plasmapix + (80 * (plasma_C[j] >> 16));
uint8_t* v28 = plasmapix + (80 * FixedToInt(plasma_C[j]));
v28[nSmokeOffset] = 175;
}

View file

@ -782,7 +782,7 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
pBullet->z = var_18 >> 3;
}
return nBulletSprite | (nBullet << 16);
return nBulletSprite | IntToFixed(nBullet);
}
void FuncBullet(int a, int, int nRun)

View file

@ -464,7 +464,7 @@ void GameTicker()
PlayerInterruptKeys(false);
nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.q16avel);
nPlayerDAng += localInput.q16avel;
inita &= kAngleMask;
for (int i = 0; i < 4; i++)
@ -550,8 +550,8 @@ void GameTicker()
{
bLockPan = false;
bPlayerPan = false;
//PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92);
nDestVertPan[nLocalPlayer] = fix16_from_int(92);
//PlayerList[nLocalPlayer].q16horiz = IntToFixed(92);
nDestVertPan[nLocalPlayer] = IntToFixed(92);
}
if (localInput.actions & SB_TURNAROUND)
{

View file

@ -739,7 +739,7 @@ loc_flag:
// loc_27266:
case kWeaponSword:
{
nHeight += (92 - fix16_to_int(sPlayerInput[nPlayer].horizon)) << 6;
nHeight += (92 - FixedToInt(sPlayerInput[nPlayer].horizon)) << 6;
theZ += nHeight;
@ -844,7 +844,7 @@ loc_flag:
}
case kWeaponPistol:
{
int var_50 = (fix16_to_int(sPlayerInput[nPlayer].horizon) - 92) << 2;
int var_50 = (FixedToInt(sPlayerInput[nPlayer].horizon) - 92) << 2;
nHeight -= var_50;
if (sPlayerInput[nPlayer].nTarget >= 0 && cl_autoaim)
@ -859,7 +859,7 @@ loc_flag:
case kWeaponGrenade:
{
ThrowGrenade(nPlayer, ebp, ebx, nHeight - 2560, fix16_to_int(sPlayerInput[nPlayer].horizon) - 92);
ThrowGrenade(nPlayer, ebp, ebx, nHeight - 2560, FixedToInt(sPlayerInput[nPlayer].horizon) - 92);
break;
}
case kWeaponStaff:

View file

@ -130,7 +130,7 @@ void PlayerInterruptKeys(bool after)
return;
InputPacket tempinput{};
fix16_t input_angle = 0;
fixed_t input_angle = 0;
if (PlayerList[nLocalPlayer].nHealth == 0)
{
@ -161,20 +161,19 @@ void PlayerInterruptKeys(bool after)
}
else
{
input_angle = fix16_sadd(input_angle, fix16_from_float(info.mousex));
input_angle = fix16_sadd(input_angle, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
input_angle += FloatToFixed(info.mousex + scaleAdjustmentToInterval(info.dyaw));
}
bool mouseaim = !(localInput.actions & SB_AIMMODE);
if (mouseaim)
tempinput.q16horz = fix16_sadd(tempinput.q16horz, fix16_from_float(info.mousey));
tempinput.q16horz += FloatToFixed(info.mousey);
else
tempinput.fvel -= info.mousey * 8.f;
if (!in_mouseflip) tempinput.q16horz = -tempinput.q16horz;
tempinput.q16horz = fix16_ssub(tempinput.q16horz, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch)));
tempinput.q16horz -= FloatToFixed(scaleAdjustmentToInterval(info.dpitch));
tempinput.svel -= info.dx * keyMove;
tempinput.fvel -= info.dz * keyMove;
@ -221,7 +220,7 @@ void PlayerInterruptKeys(bool after)
}
//if ((counter++) % 4 == 0) // what was this for???
input_angle = fix16_sadd(input_angle, fix16_from_dbl(scaleAdjustmentToInterval(turn * 2)));
input_angle += FloatToFixed(scaleAdjustmentToInterval(turn * 2));
}
@ -240,17 +239,17 @@ void PlayerInterruptKeys(bool after)
localInput.fvel = clamp(localInput.fvel + tempinput.fvel, -12, 12);
localInput.svel = clamp(localInput.svel + tempinput.svel, -12, 12);
localInput.q16avel = fix16_sadd(localInput.q16avel, input_angle);
localInput.q16avel += input_angle;
if (!nFreeze)
{
PlayerList[nLocalPlayer].q16angle = fix16_sadd(PlayerList[nLocalPlayer].q16angle, input_angle) & 0x7FFFFFF;
PlayerList[nLocalPlayer].q16angle = (PlayerList[nLocalPlayer].q16angle + input_angle) & 0x7FFFFFF;
// A horiz diff of 128 equal 45 degrees,
// so we convert horiz to 1024 angle units
float const horizAngle = clamp(atan2f(PlayerList[nLocalPlayer].q16horiz - fix16_from_int(92), fix16_from_int(128)) * (512.f / fPI) + fix16_to_float(tempinput.q16horz), -255.f, 255.f);
auto newq16horiz = fix16_from_int(92) + Blrintf(fix16_from_int(128) * tanf(horizAngle * (fPI / 512.f)));
float const horizAngle = clamp(atan2f(PlayerList[nLocalPlayer].q16horiz - IntToFixed(92), IntToFixed(128)) * (512.f / fPI) + FixedToFloat(tempinput.q16horz), -255.f, 255.f);
auto newq16horiz = IntToFixed(92) + Blrintf(IntToFixed(128) * tanf(horizAngle * (fPI / 512.f)));
if (PlayerList[nLocalPlayer].q16horiz != newq16horiz)
{
bLockPan = true;
@ -262,8 +261,8 @@ void PlayerInterruptKeys(bool after)
if (localInput.actions & (SB_LOOK_UP|SB_AIM_UP))
{
bLockPan |= (localInput.actions & SB_LOOK_UP);
if (PlayerList[nLocalPlayer].q16horiz < fix16_from_int(180)) {
PlayerList[nLocalPlayer].q16horiz = fix16_sadd(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4)));
if (PlayerList[nLocalPlayer].q16horiz < IntToFixed(180)) {
PlayerList[nLocalPlayer].q16horiz += FloatToFixed(scaleAdjustmentToInterval(4));
}
bPlayerPan = true;
@ -272,8 +271,8 @@ void PlayerInterruptKeys(bool after)
else if (localInput.actions & (SB_LOOK_DOWN|SB_AIM_DOWN))
{
bLockPan |= (localInput.actions & SB_LOOK_DOWN);
if (PlayerList[nLocalPlayer].q16horiz > fix16_from_int(4)) {
PlayerList[nLocalPlayer].q16horiz = fix16_ssub(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4)));
if (PlayerList[nLocalPlayer].q16horiz > IntToFixed(4)) {
PlayerList[nLocalPlayer].q16horiz -= FloatToFixed(scaleAdjustmentToInterval(4));
}
bPlayerPan = true;
@ -288,18 +287,18 @@ void PlayerInterruptKeys(bool after)
if (nFreeze) return;
// loc_1C05E
fix16_t dVertPan = nDestVertPan[nLocalPlayer] - PlayerList[nLocalPlayer].q16horiz;
fixed_t dVertPan = nDestVertPan[nLocalPlayer] - PlayerList[nLocalPlayer].q16horiz;
if (dVertPan != 0 && !bLockPan)
{
int val = dVertPan / 4;
if (abs(val) >= 4)
{
if (val >= 4)
PlayerList[nLocalPlayer].q16horiz += fix16_from_int(4);
PlayerList[nLocalPlayer].q16horiz += IntToFixed(4);
else if (val <= -4)
PlayerList[nLocalPlayer].q16horiz -= fix16_from_int(4);
PlayerList[nLocalPlayer].q16horiz -= IntToFixed(4);
}
else if (abs(dVertPan) >= fix16_one)
else if (abs(dVertPan) >= FRACUNIT)
PlayerList[nLocalPlayer].q16horiz += dVertPan / 2.0f;
else
{
@ -308,7 +307,7 @@ void PlayerInterruptKeys(bool after)
}
}
else bLockPan = mouseaim;
PlayerList[nLocalPlayer].q16horiz = fix16_clamp(PlayerList[nLocalPlayer].q16horiz, fix16_from_int(0), fix16_from_int(184));
PlayerList[nLocalPlayer].q16horiz = clamp(PlayerList[nLocalPlayer].q16horiz, 0, IntToFixed(184));
}

View file

@ -398,7 +398,7 @@ void FuncMummy(int a, int nDamage, int nRun)
{
// FIXME CHECKME - nBullet & 0xFFFF can be -1. Original code doesn't handle this??
SetBulletEnemy(nBullet >> 16, nTarget); // isolate the bullet number (shift off the sprite index)
SetBulletEnemy(FixedToInt(nBullet), nTarget); // isolate the bullet number (shift off the sprite index)
sprite[nBullet & 0xFFFF].pal = 5;
}
}

View file

@ -133,12 +133,12 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms >= 4)
{
nPlayer->q16angle = fix16_from_int(atoi(parm->parms[3]));
nPlayer->q16angle = IntToFixed(atoi(parm->parms[3]));
}
if (parm->numparms == 5)
{
nPlayer->q16horiz = fix16_from_int(atoi(parm->parms[4]));
nPlayer->q16horiz = IntToFixed(atoi(parm->parms[4]));
}
return CCMD_OK;

View file

@ -49,7 +49,7 @@ struct PlayerSave
int lPlayerXVel = 0;
int lPlayerYVel = 0;
fix16_t nPlayerDAng = 0;
fixed_t nPlayerDAng = 0;
short obobangle = 0, bobangle = 0;
short bPlayerPan = 0;
short bLockPan = 0;
@ -310,8 +310,8 @@ void RestartPlayer(short nPlayer)
sprite[nSprite].y = sprite[nNStartSprite].y;
sprite[nSprite].z = sprite[nNStartSprite].z;
mychangespritesect(nSprite, sprite[nNStartSprite].sectnum);
PlayerList[nPlayer].q16angle = fix16_from_int(sprite[nNStartSprite].ang&kAngleMask);
sprite[nSprite].ang = fix16_to_int(PlayerList[nPlayer].q16angle);
PlayerList[nPlayer].q16angle = IntToFixed(sprite[nNStartSprite].ang&kAngleMask);
sprite[nSprite].ang = FixedToInt(PlayerList[nPlayer].q16angle);
floorspr = insertsprite(sprite[nSprite].sectnum, 0);
assert(floorspr >= 0 && floorspr < kMaxSprites);
@ -329,8 +329,8 @@ void RestartPlayer(short nPlayer)
sprite[nSprite].x = sPlayerSave[nPlayer].x;
sprite[nSprite].y = sPlayerSave[nPlayer].y;
sprite[nSprite].z = sector[sPlayerSave[nPlayer].nSector].floorz;
PlayerList[nPlayer].q16angle = fix16_from_int(sPlayerSave[nPlayer].nAngle&kAngleMask);
sprite[nSprite].ang = fix16_to_int(PlayerList[nPlayer].q16angle);
PlayerList[nPlayer].q16angle = IntToFixed(sPlayerSave[nPlayer].nAngle&kAngleMask);
sprite[nSprite].ang = FixedToInt(PlayerList[nPlayer].q16angle);
floorspr = -1;
}
@ -435,8 +435,8 @@ void RestartPlayer(short nPlayer)
nYDamage[nPlayer] = 0;
nXDamage[nPlayer] = 0;
PlayerList[nPlayer].q16horiz = F16(92);
nDestVertPan[nPlayer] = F16(92);
PlayerList[nPlayer].q16horiz = IntToFixed(92);
nDestVertPan[nPlayer] = IntToFixed(92);
nBreathTimer[nPlayer] = 90;
nTauntTimer[nPlayer] = RandomSize(3) + 3;
@ -537,7 +537,7 @@ void StartDeathSeq(int nPlayer, int nVal)
StopFiringWeapon(nPlayer);
PlayerList[nPlayer].q16horiz = F16(92);
PlayerList[nPlayer].q16horiz = IntToFixed(92);
oeyelevel[nPlayer] = eyelevel[nPlayer] = -14080;
nPlayerInvisible[nPlayer] = 0;
dVertPan[nPlayer] = 15;
@ -935,7 +935,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
}
// loc_1A494:
sprite[nPlayerSprite].ang = fix16_to_int(PlayerList[nPlayer].q16angle);
sprite[nPlayerSprite].ang = FixedToInt(PlayerList[nPlayer].q16angle);
// sprite[nPlayerSprite].zvel is modified within Gravity()
short zVel = sprite[nPlayerSprite].zvel;
@ -1030,10 +1030,10 @@ void FuncPlayer(int a, int nDamage, int nRun)
{
if (nTotalPlayers <= 1)
{
PlayerList[nPlayer].q16angle = fix16_from_int(GetAngleToSprite(nPlayerSprite, nSpiritSprite) & kAngleMask);
sprite[nPlayerSprite].ang = fix16_to_int(PlayerList[nPlayer].q16angle);
PlayerList[nPlayer].q16angle = IntToFixed(GetAngleToSprite(nPlayerSprite, nSpiritSprite) & kAngleMask);
sprite[nPlayerSprite].ang = FixedToInt(PlayerList[nPlayer].q16angle);
PlayerList[nPlayer].q16horiz = F16(92);
PlayerList[nPlayer].q16horiz = IntToFixed(92);
lPlayerXVel = 0;
lPlayerYVel = 0;
@ -1051,15 +1051,15 @@ void FuncPlayer(int a, int nDamage, int nRun)
StopLocalSound();
InitSpiritHead();
nDestVertPan[nPlayer] = F16(92);
nDestVertPan[nPlayer] = IntToFixed(92);
if (currentLevel->levelNumber == 11)
{
nDestVertPan[nPlayer] += F16(46);
nDestVertPan[nPlayer] += IntToFixed(46);
}
else
{
nDestVertPan[nPlayer] += F16(11);
nDestVertPan[nPlayer] += IntToFixed(11);
}
}
}
@ -1088,7 +1088,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
}
if (zVelB > 512 && !bLockPan) {
nDestVertPan[nPlayer] = F16(92);
nDestVertPan[nPlayer] = IntToFixed(92);
}
}
@ -1189,14 +1189,14 @@ void FuncPlayer(int a, int nDamage, int nRun)
loc_1AB8E:
if (!bPlayerPan && !bLockPan)
{
fix16_t nPanVal = fix16_from_int(spr_z - sprite[nPlayerSprite].z) / 32 + F16(92);
fixed_t nPanVal = IntToFixed(spr_z - sprite[nPlayerSprite].z) / 32 + IntToFixed(92);
if (nPanVal < F16(0)) {
nPanVal = F16(0);
if (nPanVal < 0) {
nPanVal = 0;
}
else if (nPanVal > F16(183))
else if (nPanVal > IntToFixed(183))
{
nPanVal = F16(183);
nPanVal = IntToFixed(183);
}
nDestVertPan[nPlayer] = nPanVal;
@ -2823,19 +2823,19 @@ loc_1BD2E:
}
else
{
if (PlayerList[nPlayer].q16horiz < fix16_from_int(92))
if (PlayerList[nPlayer].q16horiz < IntToFixed(92))
{
PlayerList[nPlayer].q16horiz = fix16_from_int(91);
PlayerList[nPlayer].q16horiz = IntToFixed(91);
eyelevel[nPlayer] -= (dVertPan[nPlayer] << 8);
}
else
{
PlayerList[nPlayer].q16horiz = fix16_sadd(PlayerList[nPlayer].q16horiz, fix16_from_int(dVertPan[nPlayer]));
if (PlayerList[nPlayer].q16horiz >= fix16_from_int(200))
PlayerList[nPlayer].q16horiz += IntToFixed(dVertPan[nPlayer]);
if (PlayerList[nPlayer].q16horiz >= IntToFixed(200))
{
PlayerList[nPlayer].q16horiz = fix16_from_int(199);
PlayerList[nPlayer].q16horiz = IntToFixed(199);
}
else if (PlayerList[nPlayer].q16horiz <= fix16_from_int(92))
else if (PlayerList[nPlayer].q16horiz <= IntToFixed(92))
{
if (!(SectFlag[sprite[nPlayerSprite].sectnum] & kSectUnderwater))
{

View file

@ -44,7 +44,7 @@ extern int nLocalPlayer;
extern int lPlayerXVel;
extern int lPlayerYVel;
extern fix16_t nPlayerDAng;
extern fixed_t nPlayerDAng;
struct Player
{
@ -71,8 +71,8 @@ struct Player
short field_3C;
short nRun;
fix16_t q16angle;
fix16_t q16horiz;
fixed_t q16angle;
fixed_t q16horiz;
vec3_t opos;
};

View file

@ -38,7 +38,7 @@ struct PlayerInput
int yVel;
uint16_t buttons;
short nTarget;
fix16_t horizon;
fixed_t horizon;
int8_t nItem;
ESyncBits actions;

View file

@ -208,7 +208,7 @@ int DoSpiritHead()
{
static short word_964E6 = 0;
PlayerList[0].q16horiz = fix16_sadd(PlayerList[0].q16horiz, fix16_sdiv(fix16_ssub(nDestVertPan[0], PlayerList[0].q16horiz), fix16_from_int(4)));
PlayerList[0].q16horiz += (nDestVertPan[0] - PlayerList[0].q16horiz) / 4;
TileFiles.InvalidateTile(kTileRamsesWorkTile);

View file

@ -70,7 +70,7 @@ uint16_t RandomWord()
int RandomLong()
{
int randLong = RandomWord() << 16;
int randLong = IntToFixed(RandomWord());
randLong |= RandomWord();
return randLong;
}

View file

@ -376,7 +376,7 @@ void seq_DrawPilotLightSeq(double xOffset, double yOffset)
double x = ChunkXpos[nFrameBase] + (160 + xOffset);
double y = ChunkYpos[nFrameBase] + (100 + yOffset);
hud_drawsprite(x, y, 65536, fmod(-2 * (nPlayerDAng / (double)(FRACUNIT)), kAngleMask + 1), nTile, 0, 0, 1);
hud_drawsprite(x, y, 65536, fmod(-2 * FixedToFloat(nPlayerDAng), kAngleMask + 1), nTile, 0, 0, 1);
nFrameBase++;
}
}

View file

@ -563,7 +563,7 @@ void FuncSet(int a, int nDamage, int nRun)
{
// low 16 bits of returned var contains the sprite index, the high 16 the bullet number
int nBullet = BuildBullet(nSprite, 11, 0, 0, -1, sprite[nSprite].ang, nTarget + 10000, 1);
SetBulletEnemy(nBullet >> 16, nTarget); // isolate the bullet number (shift off the sprite index)
SetBulletEnemy(FixedToInt(nBullet), nTarget); // isolate the bullet number (shift off the sprite index)
SetList[nSet].field_E--;
if (SetList[nSet].field_E <= 0 || !RandomBit())

View file

@ -36,7 +36,7 @@ short bSubTitles = true;
int zbob;
fix16_t nDestVertPan[kMaxPlayers] = { 0 };
fixed_t nDestVertPan[kMaxPlayers] = { 0 };
short dVertPan[kMaxPlayers];
int nCamerax;
int nCameray;
@ -49,8 +49,8 @@ short nQuake[kMaxPlayers] = { 0 };
short nChunkTotal = 0;
fix16_t nCameraa;
fix16_t nCamerapan;
fixed_t nCameraa;
fixed_t nCamerapan;
short nViewTop;
short bCamera = false;
@ -241,8 +241,8 @@ void DrawView(double smoothRatio, bool sceneonly)
int playerY;
int playerZ;
short nSector;
fix16_t nAngle;
fix16_t pan;
fixed_t nAngle;
fixed_t pan;
zbob = Sin(2 * bobangle) >> 3;
@ -258,7 +258,7 @@ void DrawView(double smoothRatio, bool sceneonly)
playerY = sprite[nSprite].y;
playerZ = sprite[nSprite].z;
nSector = sprite[nSprite].sectnum;
nAngle = fix16_from_int(sprite[nSprite].ang);
nAngle = IntToFixed(sprite[nSprite].ang);
SetGreenPal();
@ -296,7 +296,7 @@ void DrawView(double smoothRatio, bool sceneonly)
{
if (nSnakeCam >= 0 && !sceneonly)
{
pan = F16(92);
pan = IntToFixed(92);
viewz = playerZ;
}
else
@ -309,7 +309,7 @@ void DrawView(double smoothRatio, bool sceneonly)
if (viewz > floorZ)
viewz = floorZ;
nCameraa += fix16_from_int((nQuake[nLocalPlayer] >> 7) % 31);
nCameraa += IntToFixed((nQuake[nLocalPlayer] >> 7) % 31);
nCameraa &= 0x7FFFFFF;
}
}
@ -320,7 +320,7 @@ void DrawView(double smoothRatio, bool sceneonly)
-2000 * Sin(inita),
4, 0, 0, CLIPMASK1);
pan = F16(92);
pan = IntToFixed(92);
viewz = playerZ;
}
@ -410,7 +410,7 @@ void DrawView(double smoothRatio, bool sceneonly)
sprite[nPlayerSprite].cstat |= 0x8000;
int ang2 = fix16_to_int(nCameraa) - sprite[nPlayerSprite].ang;
int ang2 = FixedToInt(nCameraa) - sprite[nPlayerSprite].ang;
if (ang2 < 0)
ang2 = -ang2;

View file

@ -40,7 +40,7 @@ void viewDoInterpolations(int smoothRatio);
void viewUpdateInterpolations(void);
void viewRestoreInterpolations(void);
extern fix16_t nDestVertPan[];
extern fixed_t nDestVertPan[];
extern short dVertPan[];
extern short nQuake[];
extern int nCamerax;

View file

@ -327,7 +327,7 @@ void animatesprites_d(int x,int y,int a,int smoothratio)
t->x = omyx + mulscale16((int)(myx - omyx), smoothratio);
t->y = omyy + mulscale16((int)(myy - omyy), smoothratio);
t->z = omyz + mulscale16((int)(myz - omyz), smoothratio) + (40 << 8);
t->ang = (oq16myang + mulscale16((int)(((q16myang + (1024 << FRACBITS) - oq16myang) & 0x7FFFFFF) - (1024 << FRACBITS)), smoothratio)) >> FRACBITS;
t->ang = FixedToInt(oq16myang + mulscale16((int)(((q16myang + IntToFixed(1024) - oq16myang) & 0x7FFFFFF) - IntToFixed(1024)), smoothratio));
t->sectnum = mycursectnum;
}
}

View file

@ -374,8 +374,8 @@ void animatesprites_r(int x,int y,int a,int smoothratio)
t->x = omyx + mulscale16((int)(myx - omyx), smoothratio);
t->y = omyy + mulscale16((int)(myy - omyy), smoothratio);
t->z = omyz + mulscale16((int)(myz - omyz), smoothratio) + (40 << 8);
int omyang = fix16_to_int(oq16myang);
int myang = fix16_to_int(q16myang);
int omyang = FixedToInt(oq16myang);
int myang = FixedToInt(q16myang);
t->ang = omyang + mulscale16((int)(((myang + 1024 - omyang) & 2047) - 1024), smoothratio);
t->sectnum = mycursectnum;
}

View file

@ -274,12 +274,12 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms >= 4)
{
p->oq16ang = p->q16ang = fix16_from_int(atoi(parm->parms[3]));
p->oq16ang = p->q16ang = IntToFixed(atoi(parm->parms[3]));
}
if (parm->numparms == 5)
{
p->oq16horiz = p->q16horiz = fix16_from_int(atoi(parm->parms[4]));
p->oq16horiz = p->q16horiz = IntToFixed(atoi(parm->parms[4]));
}
return CCMD_OK;

View file

@ -289,7 +289,7 @@ void drawoverlays(double smoothratio)
{
cposx = omyx + mulscale16(myx - omyx, smoothratio);
cposy = omyy + mulscale16(myy - omyy, smoothratio);
cang = (oq16myang + mulscale16(((q16myang + (1024 << FRACBITS) - oq16myang) & 0x7FFFFFF) - (1024 << FRACBITS), smoothratio)) >> FRACBITS;
cang = FixedToInt(oq16myang + mulscale16(((q16myang + IntToFixed(1024) - oq16myang) & 0x7FFFFFF) - IntToFixed(1024), smoothratio));
}
else
{

View file

@ -40,7 +40,7 @@ BEGIN_DUKE_NS
double getavel(int snum)
{
return PlayerInputAngVel(screenpeek) / (double)(FRACUNIT);
return FixedToFloat(PlayerInputAngVel(screenpeek));
}
//---------------------------------------------------------------------------

View file

@ -532,7 +532,7 @@ void hud_input(int snum)
OnEvent(EVENT_TURNAROUND, -1, snum, -1);
if (GetGameVarID(g_iReturnVarID, -1, snum) == 0)
{
p->one_eighty_count = -F16(1024);
p->one_eighty_count = -IntToFixed(1024);
}
}
}
@ -647,16 +647,16 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo &i
if (buttonMap.ButtonDown(gamefunc_Strafe))
input.svel -= info.mousex * 4.f + scaleFactor * info.dyaw * keymove;
else
input.q16avel += fix16_from_float(info.mousex + scaleFactor * info.dyaw);
input.q16avel += FloatToFixed(info.mousex + scaleFactor * info.dyaw);
if (mouseaim)
input.q16horz += fix16_from_float(info.mousey);
input.q16horz += FloatToFixed(info.mousey);
else
input.fvel -= info.mousey * 8.f;
if (!in_mouseflip) input.q16horz = -input.q16horz;
input.q16horz -= fix16_from_dbl(scaleFactor * (info.dpitch));
input.q16horz -= FloatToFixed(scaleFactor * (info.dpitch));
input.svel -= scaleFactor * (info.dx * keymove);
input.fvel -= scaleFactor * (info.dz * keymove);
@ -678,12 +678,12 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo &i
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
{
turnheldtime += tics;
input.q16avel -= fix16_from_dbl(2 * scaleFactor * (turnheldtime >= TURBOTURNTIME ? turnamount : PREAMBLETURN));
input.q16avel -= FloatToFixed(2 * scaleFactor * (turnheldtime >= TURBOTURNTIME ? turnamount : PREAMBLETURN));
}
else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
{
turnheldtime += tics;
input.q16avel += fix16_from_dbl(2 * scaleFactor * (turnheldtime >= TURBOTURNTIME ? turnamount : PREAMBLETURN));
input.q16avel += FloatToFixed(2 * scaleFactor * (turnheldtime >= TURBOTURNTIME ? turnamount : PREAMBLETURN));
}
else
{
@ -962,7 +962,7 @@ static void processVehicleInput(player_struct *p, ControlInfo& info, InputPacket
turnvel *= clamp(turnspeed * turnspeed, 0., 1.);
input.fvel = p->MotoSpeed;
input.q16avel = fix16_from_dbl(turnvel);
input.q16avel = FloatToFixed(turnvel);
}
//---------------------------------------------------------------------------
@ -981,7 +981,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
if (automapFollow && automapMode != am_off)
{
ud.folfvel = input.fvel;
ud.folavel = fix16_to_int(input.q16avel);
ud.folavel = FixedToInt(input.q16avel);
}
loc.fvel = loc.svel = 0;
@ -1008,7 +1008,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
if (p->on_crane < 0 && p->newowner == -1)
{
loc.q16avel = fix16_clamp(loc.q16avel + input.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL));
loc.q16avel = clamp(loc.q16avel + input.q16avel, IntToFixed(-MAXANGVEL), IntToFixed(MAXANGVEL));
if (!cl_syncinput && input.q16avel)
{
p->one_eighty_count = 0;
@ -1021,7 +1021,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
if (p->newowner == -1 && p->return_to_center <= 0)
{
loc.q16horz = fix16_clamp(loc.q16horz + input.q16horz, F16(-MAXHORIZVEL), F16(MAXHORIZVEL));
loc.q16horz = clamp(loc.q16horz + input.q16horz, IntToFixed(-MAXHORIZVEL), IntToFixed(MAXHORIZVEL));
}
else
{
@ -1105,7 +1105,7 @@ void GameInterface::GetInput(InputPacket* packet)
if (packet)
{
auto const pPlayer = &ps[myconnectindex];
auto const q16ang = fix16_to_int(pPlayer->q16ang);
auto const q16ang = FixedToInt(pPlayer->q16ang);
*packet = loc;
auto fvel = loc.fvel;

View file

@ -107,12 +107,12 @@ void calcviewpitch(player_struct *p, double factor)
}
if (p->q16horizoff > 0)
{
p->addhorizoff(-factor * fix16_to_dbl((p->q16horizoff >> 3) + FRACUNIT));
p->addhorizoff(-factor * FixedToFloat((p->q16horizoff >> 3) + FRACUNIT));
if (p->q16horizoff < 0) p->q16horizoff = 0;
}
else if (p->q16horizoff < 0)
{
p->addhorizoff(-factor * fix16_to_dbl((p->q16horizoff >> 3) + FRACUNIT));
p->addhorizoff(-factor * FixedToFloat((p->q16horizoff >> 3) + FRACUNIT));
if (p->q16horizoff > 0) p->q16horizoff = 0;
}
}
@ -793,10 +793,10 @@ void applylook(int snum, double factor, fixed_t adjustment)
if (p->dead_flag == 0)
{
p->addrotscrnang(factor * -0.5 * fix16_to_dbl(p->q16rotscrnang));
p->addrotscrnang(factor * -0.5 * FixedToFloat(p->q16rotscrnang));
if (abs(p->q16rotscrnang) < FRACUNIT) p->q16rotscrnang = 0;
p->addlookang(factor * -0.25 * fix16_to_dbl(p->q16look_ang));
p->addlookang(factor * -0.25 * FixedToFloat(p->q16look_ang));
if (abs(p->q16look_ang) < FRACUNIT) p->q16look_ang = 0;
if (p->lookLeft)
@ -813,7 +813,7 @@ void applylook(int snum, double factor, fixed_t adjustment)
if (p->one_eighty_count < 0 && p->on_crane < 0)
{
fixed_t add = fix16_from_dbl(factor * 128);
fixed_t add = FloatToFixed(factor * 128);
p->one_eighty_count += add;
if (p->one_eighty_count > 0)
{
@ -829,7 +829,7 @@ void applylook(int snum, double factor, fixed_t adjustment)
// Add angAdjust if input is unsynchronised.
if (!cl_syncinput)
{
p->q16ang += fix16_from_dbl(factor * p->angAdjust);
p->q16ang += FloatToFixed(factor * p->angAdjust);
}
// Taken from processinput() for use with applying look while cl_syncinput is 0.
@ -1007,7 +1007,7 @@ void sethorizon(int snum, ESyncBits actions, double factor, fixed_t adjustment)
auto p = &ps[snum];
// Calculate adjustment as true pitch (Fixed point math really sucks...)
double horizAngle = clamp2(atan2(p->q16horiz - F16(100), F16(128)) * (512. / pi::pi()) + (factor * p->pitchAdjust) + (adjustment / 65536.), -180, 180);
double horizAngle = clamp2(atan2(p->q16horiz - IntToFixed(100), IntToFixed(128)) * (512. / pi::pi()) + (factor * p->pitchAdjust) + (adjustment / 65536.), -180, 180);
if (p->return_to_center > 0 && (actions & (SB_LOOK_UP | SB_LOOK_DOWN)) == 0) // only snap back if no relevant button is pressed.
{
@ -1022,7 +1022,7 @@ void sethorizon(int snum, ESyncBits actions, double factor, fixed_t adjustment)
}
// Convert back to Build's horizon.
p->q16horiz = F16(100) + xs_CRoundToInt(F16(128) * tan(horizAngle * (pi::pi() / 512.)));
p->q16horiz = IntToFixed(100) + xs_CRoundToInt(IntToFixed(128) * tan(horizAngle * (pi::pi() / 512.)));
// Add horizAdjust if input is unsynchronised.
if (!cl_syncinput)
@ -1030,7 +1030,7 @@ void sethorizon(int snum, ESyncBits actions, double factor, fixed_t adjustment)
p->q16horiz += xs_CRoundToInt(factor * (p->horizAdjust * 65536.));
}
p->q16horiz = clamp(p->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
p->q16horiz = clamp(p->q16horiz, IntToFixed(HORIZ_MIN), IntToFixed(HORIZ_MAX));
}
//---------------------------------------------------------------------------

View file

@ -39,7 +39,7 @@ BEGIN_DUKE_NS
int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel;
short globalskillsound;
fix16_t q16myang, oq16myang, q16myhoriz, oq16myhoriz, q16myhorizoff, oq16myhorizoff;
fixed_t q16myang, oq16myang, q16myhoriz, oq16myhoriz, q16myhorizoff, oq16myhorizoff;
short mycursectnum, myjumpingcounter;
char myjumpingtoggle, myonground, myhardlanding,myreturntocenter;
int fakemovefifoplc;

View file

@ -5,7 +5,7 @@ BEGIN_DUKE_NS
extern int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel;
extern short globalskillsound;
extern short mycursectnum, myjumpingcounter;
extern fix16_t q16myang, oq16myang, q16myhoriz, oq16myhoriz, q16myhorizoff, oq16myhorizoff;
extern fixed_t q16myang, oq16myang, q16myhoriz, oq16myhoriz, q16myhorizoff, oq16myhorizoff;
extern char myjumpingtoggle, myonground, myhardlanding,myreturntocenter;
extern int fakemovefifoplc;
extern int myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ];

View file

@ -216,7 +216,7 @@ void renderMirror(int cposx, int cposy, int cposz, binangle cang, fixedhoriz cho
if (wall[mirrorwall[i]].overpicnum == TILE_MIRROR)
{
int tposx, tposy;
fix16_t tang;
fixed_t tang;
renderPrepareMirror(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), mirrorwall[i], &tposx, &tposy, &tang);
@ -518,7 +518,7 @@ void displayrooms(int snum, double smoothratio)
else
{
int i = divscale22(1, isRR() ? 64 : sprite[p->i].yrepeat + 28);
fixed_t dang = 1024 << FRACBITS;
fixed_t dang = IntToFixed(1024);
if (!isRRRA() || !p->DrugMode)
{
// Fixme: This should get the aspect ratio from the backend, not the current viewport size.
@ -531,9 +531,9 @@ void displayrooms(int snum, double smoothratio)
}
if (!cl_syncinput)
renderSetRollAngle(p->q16rotscrnang / (float)(FRACUNIT));
renderSetRollAngle(FixedToFloat(p->q16rotscrnang));
else
renderSetRollAngle((p->oq16rotscrnang + fmulscale16(((p->q16rotscrnang - p->oq16rotscrnang + dang) & 0x7FFFFFF) - dang, smoothratio)) / FRACUNIT);
renderSetRollAngle(FixedToFloat(p->oq16rotscrnang + fmulscale16(((p->q16rotscrnang - p->oq16rotscrnang + dang) & 0x7FFFFFF) - dang, smoothratio)));
if ((snum == myconnectindex) && (numplayers > 1))
{

View file

@ -437,7 +437,7 @@ void initshell(int j, int i, bool isshell)
a = ps[snum].getang() - (krand() & 63) + 8; //Fine tune
t[0] = krand() & 1;
sp->z = (3 << 8) + ps[snum].pyoff + ps[snum].posz - ((ps[snum].q16horizoff + ps[snum].q16horiz - (100 << FRACBITS)) >> (FRACBITS - 4)) + (!isshell ? (3 << 8) : 0);
sp->z = (3 << 8) + ps[snum].pyoff + ps[snum].posz - ((ps[snum].q16horizoff + ps[snum].q16horiz - IntToFixed(100)) >> 12) + (!isshell ? (3 << 8) : 0);
sp->zvel = -(krand() & 255);
}
else

View file

@ -215,25 +215,25 @@ struct player_struct
// Access helpers for the widened angle and horizon fields.
void setlookang(int b) { q16look_ang = b << FRACBITS; }
void addlookang(int b) { q16look_ang += b << FRACBITS; }
void addlookang(double b) { q16look_ang += xs_CRoundToInt(b * FRACUNIT); }
void setrotscrnang(int b) { q16rotscrnang = b << FRACBITS; }
void addrotscrnang(int b) { q16rotscrnang += b << FRACBITS; }
void addrotscrnang(double b) { q16rotscrnang += xs_CRoundToInt(b * FRACUNIT); }
int getang() { return q16ang >> FRACBITS; }
int getoang() { return oq16ang >> FRACBITS; }
void setang(int v) { q16ang = v << FRACBITS; }
void addang(int v) { q16ang = (q16ang + (v << FRACBITS)) & 0x7FFFFFF; }
void setoang(int v) { oq16ang = v << FRACBITS; }
void addhoriz(int v) { q16horiz += (v << FRACBITS); }
void addhorizoff(int v) { q16horiz += (v << FRACBITS); }
void addhorizoff(double v) { q16horiz += xs_CRoundToInt(v * FRACUNIT); }
void sethoriz(int v) { q16horiz = (v << FRACBITS); }
void sethorizoff(int v) { q16horizoff = (v << FRACBITS); }
int gethoriz() { return q16horiz >> FRACBITS; }
int gethorizof() { return q16horizoff >> FRACBITS; }
int gethorizsum() { return (q16horiz + q16horizoff) >> FRACBITS; }
void setlookang(int b) { q16look_ang = IntToFixed(b); }
void addlookang(int b) { q16look_ang += IntToFixed(b); }
void addlookang(double b) { q16look_ang += FloatToFixed(b); }
void setrotscrnang(int b) { q16rotscrnang = IntToFixed(b); }
void addrotscrnang(int b) { q16rotscrnang += IntToFixed(b); }
void addrotscrnang(double b) { q16rotscrnang += FloatToFixed(b); }
int getang() { return FixedToInt(q16ang); }
int getoang() { return FixedToInt(oq16ang); }
void setang(int v) { q16ang = IntToFixed(v); }
void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; }
void setoang(int v) { oq16ang = IntToFixed(v); }
void addhoriz(int v) { q16horiz += (IntToFixed(v)); }
void addhorizoff(int v) { q16horiz += (IntToFixed(v)); }
void addhorizoff(double v) { q16horiz += FloatToFixed(v); }
void sethoriz(int v) { q16horiz = IntToFixed(v); }
void sethorizoff(int v) { q16horizoff = IntToFixed(v); }
int gethoriz() { return FixedToInt(q16horiz); }
int gethorizof() { return FixedToInt(q16horizoff); }
int gethorizsum() { return FixedToInt(q16horiz + q16horizoff); }
};

View file

@ -378,11 +378,11 @@ DoMotionBlur(tspritetype const * const tsp)
if (TEST(tsp->extra, SPRX_PLAYER_OR_ENEMY))
{
z_amt_per_pixel = (((int)-tu->jump_speed * ACTORMOVETICS)<<16)/tsp->xvel;
z_amt_per_pixel = IntToFixed((int)-tu->jump_speed * ACTORMOVETICS)/tsp->xvel;
}
else
{
z_amt_per_pixel = (((int)-tsp->zvel)<<16)/tsp->xvel;
z_amt_per_pixel = IntToFixed((int)-tsp->zvel)/tsp->xvel;
}
switch (tu->motion_blur_dist)
@ -390,22 +390,22 @@ DoMotionBlur(tspritetype const * const tsp)
case 64:
dx = nx = MOVEx(64, ang);
dy = ny = MOVEy(64, ang);
nz = (z_amt_per_pixel * 64)>>16;
nz = FixedToInt(z_amt_per_pixel * 64);
break;
case 128:
dx = nx = MOVEx(128, ang);
dy = ny = MOVEy(128, ang);
nz = (z_amt_per_pixel * 128)>>16;
nz = FixedToInt(z_amt_per_pixel * 128);
break;
case 256:
dx = nx = MOVEx(256, ang);
dy = ny = MOVEy(256, ang);
nz = (z_amt_per_pixel * 256)>>16;
nz = FixedToInt(z_amt_per_pixel * 256);
break;
case 512:
dx = nx = MOVEx(512, ang);
dy = ny = MOVEy(512, ang);
nz = (z_amt_per_pixel * 512)>>16;
nz = FixedToInt(z_amt_per_pixel * 512);
break;
default:
dx = nx = MOVEx(tu->motion_blur_dist, ang);
@ -574,8 +574,8 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror)
ang = NORM_ANGLE(ang + 12);
smr4 = smoothratio + (((int) MoveSkip4) << 16);
smr2 = smoothratio + (((int) MoveSkip2) << 16);
smr4 = smoothratio + IntToFixed(MoveSkip4);
smr2 = smoothratio + IntToFixed(MoveSkip2);
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
{
@ -798,7 +798,7 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror)
tsp->x -= mulscale16(pp->posx - pp->oposx, 65536-smoothratio);
tsp->y -= mulscale16(pp->posy - pp->oposy, 65536-smoothratio);
tsp->z -= mulscale16(pp->posz - pp->oposz, 65536-smoothratio);
tsp->ang -= fix16_to_int(mulscale16(pp->q16ang - pp->oq16ang, 65536-smoothratio));
tsp->ang -= FixedToInt(mulscale16(pp->q16ang - pp->oq16ang, 65536-smoothratio));
}
}
@ -962,7 +962,7 @@ ResizeView(PLAYERp pp)
void
BackView(int *nx, int *ny, int *nz, short *vsect, fix16_t *nq16ang, short horiz)
BackView(int *nx, int *ny, int *nz, short *vsect, fixed_t *nq16ang, short horiz)
{
vec3_t n = { *nx, *ny, *nz };
SPRITEp sp;
@ -974,7 +974,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, fix16_t *nq16ang, short horiz)
ASSERT(*vsect >= 0 && *vsect < MAXSECTORS);
ang = fix16_to_int(*nq16ang) + pp->view_outside_dang;
ang = FixedToInt(*nq16ang) + pp->view_outside_dang;
// Calculate the vector (nx,ny,nz) to shoot backwards
vx = (sintable[NORM_ANGLE(ang + 1536)] >> 3);
@ -1055,9 +1055,9 @@ BackView(int *nx, int *ny, int *nz, short *vsect, fix16_t *nq16ang, short horiz)
}
if (klabs(vx) > klabs(vy))
i = (hx << 16) / vx;
i = IntToFixed(hx) / vx;
else
i = (hy << 16) / vy;
i = IntToFixed(hy) / vy;
if (i < pp->camera_dist)
pp->camera_dist = i;
@ -1077,7 +1077,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, fix16_t *nq16ang, short horiz)
// Make sure vsect is correct
updatesectorz(*nx, *ny, *nz, vsect);
*nq16ang = fix16_from_int(ang);
*nq16ang = IntToFixed(ang);
}
void
@ -1091,7 +1091,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, int *nq16ang, short horiz)
PLAYERp pp = &Player[screenpeek];
short ang;
ang = fix16_to_int(*nq16ang) + pp->circle_camera_ang;
ang = FixedToInt(*nq16ang) + pp->circle_camera_ang;
// Calculate the vector (nx,ny,nz) to shoot backwards
vx = (sintable[NORM_ANGLE(ang + 1536)] >> 4);
@ -1164,18 +1164,18 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, int *nq16ang, short horiz)
}
if (klabs(vx) > klabs(vy))
i = (hx << 16) / vx;
i = IntToFixed(hx) / vx;
else
i = (hy << 16) / vy;
i = IntToFixed(hy) / vy;
if (i < pp->circle_camera_dist)
pp->circle_camera_dist = i;
}
// Actually move you! (Camerdist is 65536 if nothing is in the way)
*nx = (*nx) + ((vx * pp->circle_camera_dist) >> 16);
*ny = (*ny) + ((vy * pp->circle_camera_dist) >> 16);
*nz = (*nz) + ((vz * pp->circle_camera_dist) >> 16);
*nx = (*nx) + FixedToInt(vx * pp->circle_camera_dist);
*ny = (*ny) + FixedToInt(vy * pp->circle_camera_dist);
*nz = (*nz) + FixedToInt(vz * pp->circle_camera_dist);
// Slowly increase pp->circle_camera_dist until it reaches 65536
// Synctics is a timer variable so it increases the same rate
@ -1186,7 +1186,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, int *nq16ang, short horiz)
// Make sure vsect is correct
updatesectorz(*nx, *ny, *nz, vsect);
*nq16ang = fix16_from_int(ang);
*nq16ang = IntToFixed(ang);
}
FString GameInterface::GetCoordString()
@ -1196,7 +1196,7 @@ FString GameInterface::GetCoordString()
out.AppendFormat("POSX:%d ", pp->posx);
out.AppendFormat("POSY:%d ", pp->posy);
out.AppendFormat("POSZ:%d ", pp->posz);
out.AppendFormat("ANG:%d\n", fix16_to_int(pp->camq16ang));
out.AppendFormat("ANG:%d\n", FixedToInt(pp->camq16ang));
return out;
}
@ -1292,7 +1292,7 @@ void DrawCrosshair(PLAYERp pp)
}
}
void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fix16_t *tq16ang, fix16_t *tq16horiz)
void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fixed_t *tq16ang, fixed_t *tq16horiz)
{
int i,nexti;
short ang;
@ -1359,14 +1359,14 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fix16_t
zvect = 0;
// new horiz to player
*tq16horiz = fix16_from_int(100 - (zvect/256));
*tq16horiz = fix16_max(*tq16horiz, fix16_from_int(PLAYER_HORIZ_MIN));
*tq16horiz = fix16_min(*tq16horiz, fix16_from_int(PLAYER_HORIZ_MAX));
*tq16horiz = IntToFixed(100 - (zvect/256));
*tq16horiz = max(*tq16horiz, IntToFixed(PLAYER_HORIZ_MIN));
*tq16horiz = min(*tq16horiz, IntToFixed(PLAYER_HORIZ_MAX));
//DSPRINTF(ds,"xvect %d,yvect %d,zvect %d,tq16horiz %d",xvect,yvect,zvect,*tq16horiz);
MONO_PRINT(ds);
*tq16ang = fix16_from_int(ang);
*tq16ang = IntToFixed(ang);
*tx = sp->x;
*ty = sp->y;
*tz = sp->z;
@ -1572,7 +1572,7 @@ void PreDrawStackedWater(void)
}
void FAF_DrawRooms(int x, int y, int z, fix16_t q16ang, fix16_t q16horiz, short sectnum)
void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short sectnum)
{
short i,nexti;
@ -1638,7 +1638,7 @@ drawscreen(PLAYERp pp, double smoothratio)
{
extern SWBOOL CameraTestMode;
int tx, ty, tz;
fix16_t tq16horiz, tq16ang;
fixed_t tq16horiz, tq16ang;
short tsectnum;
short i,j;
int bob_amt = 0;
@ -1681,12 +1681,12 @@ drawscreen(PLAYERp pp, double smoothratio)
if (PedanticMode || (pp != Player+myconnectindex) ||
(TEST(pp->Flags, PF_DEAD) && (loc.q16avel == 0)))
{
tq16ang = camerapp->oq16ang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) - fix16_from_int(1024), smoothratio));
tq16ang = camerapp->oq16ang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16ang + IntToFixed(1024) - camerapp->oq16ang) - IntToFixed(1024), smoothratio));
tq16horiz = camerapp->oq16horiz + xs_CRoundToInt(fmulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio));
}
else if (cl_sointerpolation && !CommEnabled)
{
tq16ang = camerapp->oq16ang + xs_CRoundToInt(fmulscale16(((pp->camq16ang + fix16_from_int(1024) - camerapp->oq16ang) & 0x7FFFFFF) - fix16_from_int(1024), smoothratio));
tq16ang = camerapp->oq16ang + xs_CRoundToInt(fmulscale16(((pp->camq16ang + IntToFixed(1024) - camerapp->oq16ang) & 0x7FFFFFF) - IntToFixed(1024), smoothratio));
tq16horiz = camerapp->oq16horiz + xs_CRoundToInt(fmulscale16(pp->camq16horiz - camerapp->oq16horiz, smoothratio));
}
else
@ -1724,27 +1724,27 @@ drawscreen(PLAYERp pp, double smoothratio)
pp->six = tx;
pp->siy = ty;
pp->siz = tz - pp->posz;
pp->siang = fix16_to_int(tq16ang);
pp->siang = FixedToInt(tq16ang);
QuakeViewChange(camerapp, &quake_z, &quake_x, &quake_y, &quake_ang);
VisViewChange(camerapp, &g_visibility);
tz = tz + quake_z;
tx = tx + quake_x;
ty = ty + quake_y;
//tq16horiz = tq16horiz + fix16_from_int(quake_x);
tq16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(tq16ang) + quake_ang));
//tq16horiz = tq16horiz + IntToFixed(quake_x);
tq16ang = IntToFixed(NORM_ANGLE(FixedToInt(tq16ang) + quake_ang));
if (pp->sop_remote)
{
if (TEST_BOOL1(pp->remote_sprite))
tq16ang = fix16_from_int(pp->remote_sprite->ang);
tq16ang = IntToFixed(pp->remote_sprite->ang);
else
tq16ang = GetQ16AngleFromVect(pp->sop_remote->xmid - tx, pp->sop_remote->ymid - ty);
}
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
{
BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, fix16_to_int(tq16horiz));
BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, FixedToInt(tq16horiz));
}
else
{
@ -1763,9 +1763,9 @@ drawscreen(PLAYERp pp, double smoothratio)
pp->obob_z + xs_CRoundToInt(fmulscale16(pp->bob_z - pp->obob_z, smoothratio));
// recoil only when not in camera
tq16horiz = tq16horiz + fix16_from_int(pp->recoil_horizoff);
tq16horiz = fix16_max(tq16horiz, fix16_from_int(PLAYER_HORIZ_MIN));
tq16horiz = fix16_min(tq16horiz, fix16_from_int(PLAYER_HORIZ_MAX));
tq16horiz = tq16horiz + IntToFixed(pp->recoil_horizoff);
tq16horiz = max(tq16horiz, IntToFixed(PLAYER_HORIZ_MIN));
tq16horiz = min(tq16horiz, IntToFixed(PLAYER_HORIZ_MAX));
}
if (automapMode != am_full)// && !ScreenSavePic)
@ -1860,11 +1860,11 @@ drawscreen(PLAYERp pp, double smoothratio)
{
// only clear the actual window.
twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000);
renderDrawMapView(tx, ty, zoom, fix16_to_int(tq16ang));
renderDrawMapView(tx, ty, zoom, FixedToInt(tq16ang));
}
// Draw the line map on top of texture 2d map or just stand alone
drawoverheadmap(tx, ty, zoom, fix16_to_int(tq16ang));
drawoverheadmap(tx, ty, zoom, FixedToInt(tq16ang));
}
for (j = 0; j < MAXSPRITES; j++)

View file

@ -375,7 +375,7 @@ void InitLevel(void)
currentLevel = maprec;
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
STAT_NewLevel(currentLevel->fileName);
Player[0].q16ang = fix16_from_int(ang);
Player[0].q16ang = IntToFixed(ang);
SetupPreCache();

View file

@ -191,8 +191,10 @@ extern SWBOOL MenuInputMode;
#define PK_ZOOM_OUT 17
#define PK_MESSAGE 18
#define MK_FIXED(msw,lsw) (((int32_t)(msw)<<16)|(lsw))
#define FIXED(msw,lsw) MK_FIXED(msw,lsw)
inline int32_t FIXED(int32_t msw, int32_t lsw)
{
return IntToFixed(msw) | lsw;
}
// Ouch...
#if B_BIG_ENDIAN == 0
@ -260,14 +262,14 @@ extern SWBOOL MenuInputMode;
#define ANGLE_2_PLAYER(pp,x,y) (NORM_ANGLE(getangle(pp->posx-(x), pp->posy-(y))))
#define NORM_Q16ANGLE(ang) ((ang) & 0x7FFFFFF)
static fix16_t FORCE_INLINE GetQ16AngleFromVect(int32_t xvect, int32_t yvect)
static fixed_t FORCE_INLINE GetQ16AngleFromVect(int32_t xvect, int32_t yvect)
{
return (PedanticMode ? getq16angle : gethiq16angle)(xvect, yvect);
}
static fix16_t FORCE_INLINE PedanticQ16AngleFloor(fix16_t ang)
static fixed_t FORCE_INLINE PedanticQ16AngleFloor(fixed_t ang)
{
return PedanticMode ? fix16_floor(ang) : ang;
return PedanticMode ? xs_FloorToInt(ang) : ang;
}
int StdRandomRange(int range);
@ -372,11 +374,11 @@ int StdRandomRange(int range);
#define KENFACING_PLAYER(pp,sp) (sintable[NORM_ANGLE(sp->ang+512)]*(pp->posy-sp->y) >= sintable[NORM_ANGLE(sp-ang)]*(pp->posx-sp->x))
#define FACING_PLAYER(pp,sp) (abs(GetDeltaAngle((sp)->ang, NORM_ANGLE(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y)))) < 512)
#define PLAYER_FACING(pp,sp) (abs(GetDeltaAngle(fix16_to_int((pp)->q16ang), NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < 320)
#define PLAYER_FACING(pp,sp) (abs(GetDeltaAngle(FixedToInt((pp)->q16ang), NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < 320)
#define FACING(sp1,sp2) (abs(GetDeltaAngle((sp2)->ang, NORM_ANGLE(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y)))) < 512)
#define FACING_PLAYER_RANGE(pp,sp,range) (abs(GetDeltaAngle((sp)->ang, NORM_ANGLE(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y)))) < (range))
#define PLAYER_FACING_RANGE(pp,sp,range) (abs(GetDeltaAngle(fix16_to_int((pp)->q16ang), NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < (range))
#define PLAYER_FACING_RANGE(pp,sp,range) (abs(GetDeltaAngle(FixedToInt((pp)->q16ang), NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < (range))
#define FACING_RANGE(sp1,sp2,range) (abs(GetDeltaAngle((sp2)->ang, NORM_ANGLE(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y)))) < (range))
// two vectors
@ -511,7 +513,7 @@ int StdRandomRange(int range);
// new define more readable defines
// Clip Sprite adjustment
#define CS(sprite_bit) ((sprite_bit)<<16)
#define CS(sprite_bit) IntToFixed(sprite_bit)
// for players to clip against walls
#define CLIPMASK_PLAYER (CS(CSTAT_SPRITE_BLOCK) | CSTAT_WALL_BLOCK)
@ -851,7 +853,7 @@ struct PLAYERstruct
// interpolation
int
oposx, oposy, oposz;
fix16_t oq16horiz, oq16ang;
fixed_t oq16horiz, oq16ang;
// holds last valid move position
short lv_sectnum;
@ -902,8 +904,8 @@ struct PLAYERstruct
// variables that do not fit into sprite structure
int hvel,tilt,tilt_dest;
bool centering;
fix16_t q16horiz, q16horizbase, q16horizoff, q16ang;
fix16_t camq16horiz, camq16ang;
fixed_t q16horiz, q16horizbase, q16horizoff, q16ang;
fixed_t camq16horiz, camq16ang;
short recoil_amt;
short recoil_speed;
short recoil_ndx;
@ -912,7 +914,7 @@ struct PLAYERstruct
int oldposx,oldposy,oldposz;
int RevolveX, RevolveY;
short RevolveDeltaAng;
fix16_t RevolveQ16Ang;
fixed_t RevolveQ16Ang;
// under vars are for wading and swimming
short PlayerSprite, PlayerUnderSprite;
@ -1873,7 +1875,7 @@ ANIMATOR NullAnimator;
int Distance(int x1, int y1, int x2, int y2);
short GetDeltaAngle(short, short);
fix16_t GetDeltaQ16Angle(fix16_t, fix16_t);
fixed_t GetDeltaQ16Angle(fixed_t, fixed_t);
int SetActorRotation(short SpriteNum,int,int);
int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]);
@ -2145,7 +2147,7 @@ void ScreenCaptureKeys(void); // draw.c
void computergetinput(int snum,InputPacket *syn); // jplayer.c
void DrawOverlapRoom(int tx,int ty,int tz,fix16_t tq16ang,fix16_t tq16horiz,short tsectnum); // rooms.c
void DrawOverlapRoom(int tx,int ty,int tz,fixed_t tq16ang,fixed_t tq16horiz,short tsectnum); // rooms.c
void SetupMirrorTiles(void); // rooms.c
SWBOOL FAF_Sector(short sectnum); // rooms.c
int GetZadjustment(short sectnum,short hitag); // rooms.c

View file

@ -37,8 +37,8 @@ BEGIN_SW_NS
double elapsedInputTicks;
double scaleAdjustmentToInterval(double x) { return x * (120 / synctics) / (1000.0 / elapsedInputTicks); }
void DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel);
void DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz);
void DoPlayerTurn(PLAYERp pp, fixed_t *pq16ang, fixed_t q16angvel);
void DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz);
void GameInterface::ResetFollowPos(bool)
@ -160,7 +160,7 @@ getinput(InputPacket *loc, SWBOOL tied)
keymove = 0;
int32_t svel = 0, vel = 0;
fix16_t q16horz = 0, q16angvel = 0;
fixed_t q16horz = 0, q16angvel = 0;
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{
@ -169,19 +169,18 @@ getinput(InputPacket *loc, SWBOOL tied)
}
else
{
q16angvel = fix16_sadd(q16angvel, fix16_from_float(info.mousex / angvelScale));
q16angvel = fix16_sadd(q16angvel, fix16_from_dbl(scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale)));
q16angvel += FloatToFixed((info.mousex / angvelScale) + scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale));
}
if (mouseaim)
q16horz = fix16_ssub(q16horz, fix16_from_float(info.mousey / aimvelScale));
q16horz -= FloatToFixed(info.mousey / aimvelScale);
else
vel -= (info.mousey * ticrateScale) * 8.f;
if (in_mouseflip)
q16horz = -q16horz;
q16horz -= fix16_from_dbl(scaleAdjustmentToInterval((info.dpitch * ticrateScale) / aimvelScale));
q16horz -= FloatToFixed(scaleAdjustmentToInterval((info.dpitch * ticrateScale) / aimvelScale));
svel -= info.dx * keymove;
vel -= info.dz * keymove;
@ -200,12 +199,12 @@ getinput(InputPacket *loc, SWBOOL tied)
if (PedanticMode)
{
if (turnheldtime >= TURBOTURNTIME)
q16angvel -= fix16_from_int(turnamount);
q16angvel -= IntToFixed(turnamount);
else
q16angvel -= fix16_from_int(PREAMBLETURN);
q16angvel -= IntToFixed(PREAMBLETURN);
}
else
q16angvel = fix16_ssub(q16angvel, fix16_from_float(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN)));
q16angvel -= FloatToFixed(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN));
}
else if (buttonMap.ButtonDown(gamefunc_Turn_Right) || (buttonMap.ButtonDown(gamefunc_Strafe_Right) && pp->sop))
{
@ -213,12 +212,12 @@ getinput(InputPacket *loc, SWBOOL tied)
if (PedanticMode)
{
if (turnheldtime >= TURBOTURNTIME)
q16angvel += fix16_from_int(turnamount);
q16angvel += IntToFixed(turnamount);
else
q16angvel += fix16_from_int(PREAMBLETURN);
q16angvel += IntToFixed(PREAMBLETURN);
}
else
q16angvel = fix16_sadd(q16angvel, fix16_from_float(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN)));
q16angvel += FloatToFixed(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN));
}
else
{
@ -240,18 +239,18 @@ getinput(InputPacket *loc, SWBOOL tied)
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
vel += -keymove;
q16angvel = fix16_clamp(q16angvel, -fix16_from_int(MAXANGVEL), fix16_from_int(MAXANGVEL));
q16horz = fix16_clamp(q16horz, -fix16_from_int(MAXHORIZVEL), fix16_from_int(MAXHORIZVEL));
q16angvel = clamp(q16angvel, -IntToFixed(MAXANGVEL), IntToFixed(MAXANGVEL));
q16horz = clamp(q16horz, -IntToFixed(MAXHORIZVEL), IntToFixed(MAXHORIZVEL));
void DoPlayerTeleportPause(PLAYERp pp);
if (PedanticMode)
{
q16angvel = fix16_floor(q16angvel);
q16horz = fix16_floor(q16horz);
q16angvel = xs_FloorToInt(q16angvel);
q16horz = xs_FloorToInt(q16horz);
}
else
{
fix16_t prevcamq16ang = pp->camq16ang, prevcamq16horiz = pp->camq16horiz;
fixed_t prevcamq16ang = pp->camq16ang, prevcamq16horiz = pp->camq16horiz;
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN))
DoPlayerTurn(pp, &pp->camq16ang, q16angvel);
@ -269,11 +268,11 @@ getinput(InputPacket *loc, SWBOOL tied)
vel = clamp(loc->fvel, -MAXVEL, MAXVEL);
svel = clamp(loc->svel, -MAXSVEL, MAXSVEL);
momx = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 512)]);
momy = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]);
momx = mulscale9(vel, sintable[NORM_ANGLE(FixedToInt(newpp->q16ang) + 512)]);
momy = mulscale9(vel, sintable[NORM_ANGLE(FixedToInt(newpp->q16ang))]);
momx += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]);
momy += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 1536)]);
momx += mulscale9(svel, sintable[NORM_ANGLE(FixedToInt(newpp->q16ang))]);
momy += mulscale9(svel, sintable[NORM_ANGLE(FixedToInt(newpp->q16ang) + 1536)]);
loc->fvel = momx;
loc->svel = momy;

View file

@ -72,13 +72,13 @@ extern PANEL_STATE ps_PanelEnvironSuit[];
INVENTORY_DATA InventoryData[MAX_INVENTORY+1] =
{
{"PORTABLE MEDKIT", UseInventoryMedkit, NULL, 0, 1, (1<<16), 0},
{"REPAIR KIT", NULL, NULL, 100, 1, (1<<16), INVF_AUTO_USE},
{"SMOKE BOMB", UseInventoryCloak, StopInventoryCloak, 4, 1, (1<<16), INVF_TIMED},
{"NIGHT VISION", UseInventoryNightVision, StopInventoryNightVision, 3, 1, (1<<16), INVF_TIMED},
{"GAS BOMB", UseInventoryChemBomb, NULL, 0, 1, (1<<16), INVF_COUNT},
{"FLASH BOMB", UseInventoryFlashBomb, NULL, 0, 2, (1<<16), INVF_COUNT},
{"CALTROPS", UseInventoryCaltrops, NULL, 0, 3, (1<<16), INVF_COUNT},
{"PORTABLE MEDKIT", UseInventoryMedkit, NULL, 0, 1, (FRACUNIT), 0},
{"REPAIR KIT", NULL, NULL, 100, 1, (FRACUNIT), INVF_AUTO_USE},
{"SMOKE BOMB", UseInventoryCloak, StopInventoryCloak, 4, 1, (FRACUNIT), INVF_TIMED},
{"NIGHT VISION", UseInventoryNightVision, StopInventoryNightVision, 3, 1, (FRACUNIT), INVF_TIMED},
{"GAS BOMB", UseInventoryChemBomb, NULL, 0, 1, (FRACUNIT), INVF_COUNT},
{"FLASH BOMB", UseInventoryFlashBomb, NULL, 0, 2, (FRACUNIT), INVF_COUNT},
{"CALTROPS", UseInventoryCaltrops, NULL, 0, 3, (FRACUNIT), INVF_COUNT},
{NULL, NULL, NULL, NULL, 0, 0, 0}
};

View file

@ -457,7 +457,7 @@ void JS_InitMirrors(void)
// Draw a 3d screen to a specific tile
/////////////////////////////////////////////////////
void drawroomstotile(int daposx, int daposy, int daposz,
fix16_t daq16ang, fix16_t daq16horiz, short dacursectnum, short tilenume)
fixed_t daq16ang, fixed_t daq16horiz, short dacursectnum, short tilenume)
{
TileFiles.MakeCanvas(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y);
@ -710,7 +710,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
}
else
{
drawroomstotile(sp->x, sp->y, sp->z, fix16_from_int(SP_TAG5(sp)), fix16_from_int(camhoriz), sp->sectnum, mirror[cnt].campic);
drawroomstotile(sp->x, sp->y, sp->z, IntToFixed(SP_TAG5(sp)), IntToFixed(camhoriz), sp->sectnum, mirror[cnt].campic);
}
}
}
@ -720,13 +720,13 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
}
}
void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq16horiz)
void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed_t tpq16horiz)
{
int j, cnt;
int dist;
int tposx, tposy; // Camera
int *longptr;
fix16_t tang;
fixed_t tang;
// int tx, ty, tz, tpang; // Interpolate so mirror doesn't
// drift!

View file

@ -71,7 +71,7 @@ extern short NormalVisibility;
void JAnalyzeSprites(tspriteptr_t tspr);
void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz);
void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,fix16_t tpq16ang,fix16_t tpq16horiz);
void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,fixed_t tpq16ang,fixed_t tpq16horiz);
void JS_InitMirrors(void);
void JS_InitLockouts(void);
void JS_ToggleLockouts(void);

View file

@ -1389,7 +1389,7 @@ PlayerInitChemBomb(PLAYERp pp)
// Spawn a shot
// Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, CHEMBOMB, s_ChemBomb, pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), CHEMBOMB_VELOCITY);
nx, ny, nz, FixedToInt(pp->q16ang), CHEMBOMB_VELOCITY);
wp = &sprite[w];
wu = User[w];
@ -1419,10 +1419,10 @@ PlayerInitChemBomb(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER);
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
// //DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",fix16_to_int(pp->q16horiz), fix16_to_int(pp->q16horizoff),
// fix16_to_int(pp->q16horizoff + pp->q16horiz));
// //DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",FixedToInt(pp->q16horiz), FixedToInt(pp->q16horizoff),
// FixedToInt(pp->q16horizoff + pp->q16horiz));
// MONO_PRINT(ds);
oclipdist = pp->SpriteP->clipdist;
@ -1833,7 +1833,7 @@ PlayerInitCaltrops(PLAYERp pp)
// Spawn a shot
// Inserting and setting up variables
w = SpawnSprite(STAT_DEAD_ACTOR, CALTROPS, s_Caltrops, pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), (CHEMBOMB_VELOCITY + RANDOM_RANGE(CHEMBOMB_VELOCITY)) / 2);
nx, ny, nz, FixedToInt(pp->q16ang), (CHEMBOMB_VELOCITY + RANDOM_RANGE(CHEMBOMB_VELOCITY)) / 2);
wp = &sprite[w];
wu = User[w];
@ -1861,9 +1861,9 @@ PlayerInitCaltrops(PLAYERp pp)
SET(wu->Flags, SPR_UNDERWATER);
// They go out at different angles
// wp->ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + (RANDOM_RANGE(50) - 25));
// wp->ang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(50) - 25));
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
oclipdist = pp->SpriteP->clipdist;
pp->SpriteP->clipdist = 0;
@ -2497,7 +2497,7 @@ InitShell(int16_t SpriteNum, int16_t ShellNum)
if (u->PlayerP)
{
wp->z += ((100 - fix16_to_int(u->PlayerP->q16horiz)) * (HORIZ_MULT/3));
wp->z += ((100 - FixedToInt(u->PlayerP->q16horiz)) * (HORIZ_MULT/3));
}
switch (wu->ID)

View file

@ -61,7 +61,7 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
{
// move the box to position instead of using offset- this prevents small rounding errors
// allowing you to move through wall
ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + sop->clipbox_ang[i]);
ang = NORM_ANGLE(FixedToInt(pp->q16ang) + sop->clipbox_ang[i]);
xs = pp->posx;
ys = pp->posy;

View file

@ -79,10 +79,10 @@ typedef struct
{
int32_t fvel;
int32_t svel;
fix16_t q16avel;
fix16_t q16horz;
fix16_t q16ang;
fix16_t q16horiz;
fixed_t q16avel;
fixed_t q16horz;
fixed_t q16ang;
fixed_t q16horiz;
ESyncBits actions;
} SW_AVERAGE_PACKET;
@ -222,8 +222,8 @@ UpdateInputs(void)
loc.fvel = AveragePacket.fvel / MovesPerPacket;
loc.svel = AveragePacket.svel / MovesPerPacket;
loc.q16avel = fix16_div(AveragePacket.q16avel, fix16_from_int(MovesPerPacket));
loc.q16horz = fix16_div(AveragePacket.q16horz, fix16_from_int(MovesPerPacket));
loc.q16avel = AveragePacket.q16avel / MovesPerPacket;
loc.q16horz = AveragePacket.q16horz / MovesPerPacket;
loc.q16ang = AveragePacket.q16ang;
loc.q16horiz = AveragePacket.q16horiz;
loc.actions = AveragePacket.actions;

View file

@ -2400,7 +2400,7 @@ InitPlayerSprite(PLAYERp pp)
COVER_SetReverb(0); // Turn off any echoing that may have been going before
pp->Reverb = 0;
sp_num = pp->PlayerSprite = SpawnSprite(STAT_PLAYER0 + pnum, NINJA_RUN_R0, NULL, pp->cursectnum, pp->posx,
pp->posy, pp->posz, fix16_to_int(pp->q16ang), 0);
pp->posy, pp->posz, FixedToInt(pp->q16ang), 0);
pp->SpriteP = sp = &sprite[sp_num];
pp->pnum = pnum;
@ -2475,7 +2475,7 @@ SpawnPlayerUnderSprite(PLAYERp pp)
int pnum = pp - Player, sp_num;
sp_num = pp->PlayerUnderSprite = SpawnSprite(STAT_PLAYER_UNDER0 + pnum,
NINJA_RUN_R0, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, fix16_to_int(pp->q16ang), 0);
NINJA_RUN_R0, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, FixedToInt(pp->q16ang), 0);
sp = &sprite[sp_num];
u = User[sp_num];

View file

@ -182,12 +182,12 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms >= 4)
{
Player->oq16ang = Player->q16ang = Player->camq16ang = fix16_from_int(atoi(parm->parms[3]));
Player->oq16ang = Player->q16ang = Player->camq16ang = IntToFixed(atoi(parm->parms[3]));
}
if (parm->numparms == 5)
{
Player->oq16horiz = Player->q16horiz = Player->camq16horiz = fix16_from_int(atoi(parm->parms[4]));
Player->oq16horiz = Player->q16horiz = Player->camq16horiz = IntToFixed(atoi(parm->parms[4]));
}
return CCMD_OK;

View file

@ -1015,8 +1015,8 @@ pSwordSlide(PANEL_SPRITEp psp)
double nx, ny;
short vel_adj;
nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
nx = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
ny = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
SpawnSwordBlur(psp);
vel_adj = 24;
@ -1028,9 +1028,9 @@ pSwordSlide(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(nx);
psp->x = nx / (double)(FRACUNIT);
psp->x = FixedToFloat(nx);
psp->yfract = LSW(ny);
psp->y = ny / (double)(FRACUNIT);
psp->y = FixedToFloat(ny);
psp->vel += vel_adj * synctics;
}
@ -1041,8 +1041,8 @@ pSwordSlideDown(PANEL_SPRITEp psp)
double nx, ny;
short vel, vel_adj;
nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
nx = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
ny = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
SpawnSwordBlur(psp);
vel_adj = 20;
@ -1055,9 +1055,9 @@ pSwordSlideDown(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(nx);
psp->x = nx / (double)(FRACUNIT);
psp->x = FixedToFloat(nx);
psp->yfract = LSW(ny);
psp->y = ny / (double)(FRACUNIT);
psp->y = FixedToFloat(ny);
psp->vel += vel_adj * synctics;
@ -1100,8 +1100,8 @@ pSwordSlideR(PANEL_SPRITEp psp)
double nx, ny;
short vel_adj;
nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
nx = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
ny = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
SpawnSwordBlur(psp);
vel_adj = 24;
@ -1113,9 +1113,9 @@ pSwordSlideR(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(nx);
psp->x = nx / (double)(FRACUNIT);
psp->x = FixedToFloat(nx);
psp->yfract = LSW(ny);
psp->y = ny / (double)(FRACUNIT);
psp->y = FixedToFloat(ny);
psp->vel += vel_adj * synctics;
}
@ -1126,8 +1126,8 @@ pSwordSlideDownR(PANEL_SPRITEp psp)
double nx, ny;
short vel, vel_adj;
nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
nx = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
ny = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
SpawnSwordBlur(psp);
vel_adj = 24;
@ -1140,9 +1140,9 @@ pSwordSlideDownR(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(nx);
psp->x = nx / (double)(FRACUNIT);
psp->x = FixedToFloat(nx);
psp->yfract = LSW(ny);
psp->y = ny / (double)(FRACUNIT);
psp->y = FixedToFloat(ny);
psp->vel += vel_adj * synctics;
@ -1858,12 +1858,12 @@ pUziReload(PANEL_SPRITEp nclip)
{
double nx, ny;
double x = xs_CRoundToInt(nclip->x * (double)(FRACUNIT)) | nclip->xfract;
double y = xs_CRoundToInt(nclip->y * (double)(FRACUNIT)) | nclip->yfract;
double x = xs_CRoundToInt(nclip->x * FRACUNIT) | nclip->xfract;
double y = xs_CRoundToInt(nclip->y * FRACUNIT) | nclip->yfract;
PANEL_SPRITEp gun = nclip->sibling;
double xgun = xs_CRoundToInt(gun->x * (double)(FRACUNIT)) | gun->xfract;
double ygun = xs_CRoundToInt(gun->y * (double)(FRACUNIT)) | gun->yfract;
double xgun = xs_CRoundToInt(gun->x * FRACUNIT) | gun->xfract;
double ygun = xs_CRoundToInt(gun->y * FRACUNIT) | gun->yfract;
nx = nclip->vel * synctics * calcSinTableValue(NORM_ANGLE(nclip->ang + 512)) / 64.;
ny = nclip->vel * synctics * -calcSinTableValue(nclip->ang) / 64.;
@ -1877,9 +1877,9 @@ pUziReload(PANEL_SPRITEp nclip)
nclip->oy = nclip->y;
nclip->xfract = LSW(x);
nclip->x = x / (double)(FRACUNIT);
nclip->x = x / FRACUNIT;
nclip->yfract = LSW(y);
nclip->y = y / (double)(FRACUNIT);
nclip->y = y / FRACUNIT;
nx = gun->vel * synctics * calcSinTableValue(NORM_ANGLE(gun->ang + 512)) / 64.;
ny = gun->vel * synctics * -calcSinTableValue(gun->ang) / 64.;
@ -1891,9 +1891,9 @@ pUziReload(PANEL_SPRITEp nclip)
gun->oy = gun->y;
gun->xfract = LSW(xgun);
gun->x = xgun / (double)(FRACUNIT);
gun->x = xgun / FRACUNIT;
gun->yfract = LSW(ygun);
gun->y = ygun / (double)(FRACUNIT);
gun->y = ygun / FRACUNIT;
if (TEST(nclip->flags, PANF_XFLIP))
{
@ -1930,12 +1930,12 @@ pUziReloadRetract(PANEL_SPRITEp nclip)
{
double nx, ny;
double x = xs_CRoundToInt(nclip->x * (double)(FRACUNIT)) | nclip->xfract;
double y = xs_CRoundToInt(nclip->y * (double)(FRACUNIT)) | nclip->yfract;
double x = xs_CRoundToInt(nclip->x * FRACUNIT) | nclip->xfract;
double y = xs_CRoundToInt(nclip->y * FRACUNIT) | nclip->yfract;
PANEL_SPRITEp gun = nclip->sibling;
double xgun = xs_CRoundToInt(gun->x * (double)(FRACUNIT)) | gun->xfract;
double ygun = xs_CRoundToInt(gun->y * (double)(FRACUNIT)) | gun->yfract;
double xgun = xs_CRoundToInt(gun->x * FRACUNIT) | gun->xfract;
double ygun = xs_CRoundToInt(gun->y * FRACUNIT) | gun->yfract;
nx = nclip->vel * synctics * calcSinTableValue(NORM_ANGLE(nclip->ang + 512)) / 64.;
ny = nclip->vel * synctics * -calcSinTableValue(nclip->ang) / 64.;
@ -1949,9 +1949,9 @@ pUziReloadRetract(PANEL_SPRITEp nclip)
nclip->oy = nclip->y;
nclip->xfract = LSW(x);
nclip->x = x / (double)(FRACUNIT);
nclip->x = x / FRACUNIT;
nclip->yfract = LSW(y);
nclip->y = y / (double)(FRACUNIT);
nclip->y = y / FRACUNIT;
xgun -= nx;
ygun -= ny;
@ -1960,9 +1960,9 @@ pUziReloadRetract(PANEL_SPRITEp nclip)
gun->oy = gun->y;
gun->xfract = LSW(xgun);
gun->x = xgun / (double)(FRACUNIT);
gun->x = xgun / FRACUNIT;
gun->yfract = LSW(ygun);
gun->y = ygun / (double)(FRACUNIT);
gun->y = ygun / FRACUNIT;
if (gun->y > UZI_RELOAD_YOFF + tilesiz[gun->picndx].y)
{
@ -2020,8 +2020,8 @@ void
pUziClip(PANEL_SPRITEp oclip)
{
double nx, ny, ox, oy;
double x = xs_CRoundToInt(oclip->x * (double)(FRACUNIT)) | oclip->xfract;
double y = xs_CRoundToInt(oclip->y * (double)(FRACUNIT)) | oclip->yfract;
double x = xs_CRoundToInt(oclip->x * FRACUNIT) | oclip->xfract;
double y = xs_CRoundToInt(oclip->y * FRACUNIT) | oclip->yfract;
ox = x;
oy = y;
@ -2038,9 +2038,9 @@ pUziClip(PANEL_SPRITEp oclip)
oclip->oy = oclip->y;
oclip->xfract = LSW(x);
oclip->x = x / (double)(FRACUNIT);
oclip->x = x / FRACUNIT;
oclip->yfract = LSW(y);
oclip->y = y / (double)(FRACUNIT);
oclip->y = y / FRACUNIT;
if (oclip->y > UZI_RELOAD_YOFF)
{
@ -2056,9 +2056,9 @@ pUziClip(PANEL_SPRITEp oclip)
}
oclip->xfract = LSW(x);
oclip->x = x / (double)(FRACUNIT);
oclip->x = x / FRACUNIT;
oclip->yfract = LSW(y);
oclip->y = y / (double)(FRACUNIT);
oclip->y = y / FRACUNIT;
oclip->ox = oclip->x;
oclip->oy = oclip->y = UZI_RELOAD_YOFF;
@ -2622,7 +2622,7 @@ SpawnShotgunShell(PANEL_SPRITEp psp)
void
pShotgunShell(PANEL_SPRITEp psp)
{
int x = FIXED(psp->x, psp->xfract);
double x = xs_CRoundToInt(psp->x * FRACUNIT) | psp->xfract;
if (TEST(psp->flags, PANF_JUMPING))
{
@ -2638,7 +2638,7 @@ pShotgunShell(PANEL_SPRITEp psp)
psp->ox = psp->x;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
if (psp->x > 320 || psp->x < 0 || psp->y > 200)
{
@ -2822,8 +2822,8 @@ pShotgunRecoilDown(PANEL_SPRITEp psp)
{
int targetvel;
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
if (psp->PlayerP->WpnShotgunType == 1)
targetvel = 890;
@ -2837,9 +2837,9 @@ pShotgunRecoilDown(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->vel -= 24 * synctics;
@ -2855,8 +2855,8 @@ pShotgunRecoilDown(PANEL_SPRITEp psp)
void
pShotgunRecoilUp(PANEL_SPRITEp psp)
{
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
@ -2865,9 +2865,9 @@ pShotgunRecoilUp(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->vel += 15 * synctics;
@ -3333,8 +3333,8 @@ pRailSetRecoil(PANEL_SPRITEp psp)
void
pRailRecoilDown(PANEL_SPRITEp psp)
{
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
@ -3343,9 +3343,9 @@ pRailRecoilDown(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->vel -= 24 * synctics;
@ -3361,8 +3361,8 @@ pRailRecoilDown(PANEL_SPRITEp psp)
void
pRailRecoilUp(PANEL_SPRITEp psp)
{
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
@ -3371,9 +3371,9 @@ pRailRecoilUp(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->vel += 15 * synctics;
@ -4227,8 +4227,8 @@ InitWeaponMicro(PLAYERp pp)
void
pMicroRecoilDown(PANEL_SPRITEp psp)
{
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
@ -4237,9 +4237,9 @@ pMicroRecoilDown(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->vel -= 24 * synctics;
@ -4255,8 +4255,8 @@ pMicroRecoilDown(PANEL_SPRITEp psp)
void
pMicroRecoilUp(PANEL_SPRITEp psp)
{
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
@ -4265,9 +4265,9 @@ pMicroRecoilUp(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->vel += 15 * synctics;
@ -4998,7 +4998,7 @@ SpawnSmallHeartBlood(PANEL_SPRITEp psp)
void
pHeartBlood(PANEL_SPRITEp psp)
{
int x = FIXED(psp->x, psp->xfract);
double x = xs_CRoundToInt(psp->x * FRACUNIT) | psp->xfract;
if (TEST(psp->flags, PANF_JUMPING))
{
@ -5014,7 +5014,7 @@ pHeartBlood(PANEL_SPRITEp psp)
psp->ox = psp->x;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
if (psp->x > 320 || psp->x < 0 || psp->y > 200)
{
@ -5044,7 +5044,7 @@ DoPanelJump(PANEL_SPRITEp psp)
{
int jump_adj;
int y = FIXED(psp->y, psp->yfract);
double y = xs_CRoundToInt(psp->y * FRACUNIT) | psp->yfract;
// precalculate jump value to adjust jump speed by
jump_adj = psp->jump_grav;
@ -5064,7 +5064,7 @@ DoPanelJump(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
return 0;
}
@ -5087,7 +5087,7 @@ DoBeginPanelFall(PANEL_SPRITEp psp)
int
DoPanelFall(PANEL_SPRITEp psp)
{
int y = FIXED(psp->y, psp->yfract);
double y = xs_CRoundToInt(psp->y * FRACUNIT) | psp->yfract;
// adjust jump speed by gravity
psp->jump_speed += psp->jump_grav;
@ -5098,7 +5098,7 @@ DoPanelFall(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
return 0;
}
@ -5241,8 +5241,8 @@ pGrenadeRecoilDown(PANEL_SPRITEp psp)
{
// short picnum = psp->picndx;
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
@ -5251,9 +5251,9 @@ pGrenadeRecoilDown(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->vel -= 24 * synctics;
@ -5272,8 +5272,8 @@ pGrenadeRecoilDown(PANEL_SPRITEp psp)
void
pGrenadeRecoilUp(PANEL_SPRITEp psp)
{
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
@ -5282,9 +5282,9 @@ pGrenadeRecoilUp(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->vel += 15 * synctics;
@ -5303,8 +5303,8 @@ pGrenadeRecoilUp(PANEL_SPRITEp psp)
void
pGrenadePresent(PANEL_SPRITEp psp)
{
double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
double x = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
double y = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
if (TEST(psp->PlayerP->Flags, PF_WEAPON_RETRACT))
return;
@ -5316,9 +5316,9 @@ pGrenadePresent(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(x);
psp->x = x / (double)(FRACUNIT);
psp->x = x / FRACUNIT;
psp->yfract = LSW(y);
psp->y = y / (double)(FRACUNIT);
psp->y = y / FRACUNIT;
psp->rotate_ang = NORM_ANGLE(psp->rotate_ang + (6 * synctics));
@ -6242,8 +6242,8 @@ pFistSlide(PANEL_SPRITEp psp)
double ny;
short vel_adj;
//nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
//nx = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
ny = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
SpawnFistBlur(psp);
vel_adj = 68;
@ -6255,9 +6255,9 @@ pFistSlide(PANEL_SPRITEp psp)
psp->oy = psp->y;
//psp->xfract = LSW(nx);
//psp->x = nx / (double)(FRACUNIT);
//psp->x = FixedToFloat(nx);
psp->yfract = LSW(ny);
psp->y = ny / (double)(FRACUNIT);
psp->y = FixedToFloat(ny);
psp->vel += vel_adj * synctics;
}
@ -6268,8 +6268,8 @@ pFistSlideDown(PANEL_SPRITEp psp)
double nx, ny;
short vel, vel_adj;
nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
nx = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
ny = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
SpawnFistBlur(psp);
vel_adj = 48;
@ -6287,9 +6287,9 @@ pFistSlideDown(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(nx);
psp->x = nx / (double)(FRACUNIT);
psp->x = FixedToFloat(nx);
psp->yfract = LSW(ny);
psp->y = ny / (double)(FRACUNIT);
psp->y = FixedToFloat(ny);
psp->vel += vel_adj * synctics;
@ -6361,8 +6361,8 @@ pFistSlideR(PANEL_SPRITEp psp)
double ny;
short vel_adj;
//nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
//nx = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
ny = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
SpawnFistBlur(psp);
vel_adj = 68;
@ -6374,9 +6374,9 @@ pFistSlideR(PANEL_SPRITEp psp)
psp->oy = psp->y;
//psp->xfract = LSW(nx);
//psp->x = nx / (double)(FRACUNIT);
//psp->x = FixedToFloat(nx);
psp->yfract = LSW(ny);
psp->y = ny / (double)(FRACUNIT);
psp->y = FixedToFloat(ny);
psp->vel += vel_adj * synctics;
}
@ -6387,8 +6387,8 @@ pFistSlideDownR(PANEL_SPRITEp psp)
double nx, ny;
short vel, vel_adj;
nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
nx = xs_CRoundToInt(FloatToFixed(psp->x)) | psp->xfract;
ny = xs_CRoundToInt(FloatToFixed(psp->y)) | psp->yfract;
SpawnFistBlur(psp);
vel_adj = 48;
@ -6406,9 +6406,9 @@ pFistSlideDownR(PANEL_SPRITEp psp)
psp->oy = psp->y;
psp->xfract = LSW(nx);
psp->x = nx / (double)(FRACUNIT);
psp->x = FixedToFloat(nx);
psp->yfract = LSW(ny);
psp->y = ny / (double)(FRACUNIT);
psp->y = FixedToFloat(ny);
psp->vel += vel_adj * synctics;
@ -6757,7 +6757,7 @@ pSpawnSprite(PLAYERp pp, PANEL_STATEp state, uint8_t priority, double x, double
psp->ang = 0;
psp->vel = 0;
psp->rotate_ang = 0;
psp->scale = 1 << 16;
psp->scale = FRACUNIT;
psp->ID = 0;
for (i = 0; i < SIZ(psp->over); i++)

View file

@ -1141,21 +1141,21 @@ GetDeltaAngle(short ang1, short ang2)
}
fix16_t
GetDeltaQ16Angle(fix16_t ang1, fix16_t ang2)
fixed_t
GetDeltaQ16Angle(fixed_t ang1, fixed_t ang2)
{
// Look at the smaller angle if > 1024 (180 degrees)
if (fix16_abs(ang1 - ang2) > fix16_from_int(1024))
if (abs(ang1 - ang2) > IntToFixed(1024))
{
if (ang1 <= fix16_from_int(1024))
ang1 += fix16_from_int(2048);
if (ang1 <= IntToFixed(1024))
ang1 += IntToFixed(2048);
if (ang2 <= fix16_from_int(1024))
ang2 += fix16_from_int(2048);
if (ang2 <= IntToFixed(1024))
ang2 += IntToFixed(2048);
}
//if (ang1 - ang2 == -fix16_from_int(1024))
// return(fix16_from_int(1024));
//if (ang1 - ang2 == -IntToFixed(1024))
// return(IntToFixed(1024));
return ang1 - ang2;
}
@ -1235,7 +1235,7 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets)
angle2 = NORM_ANGLE(getangle(ep->x - sp->x, ep->y - sp->y));
// Get the angle difference
// delta_ang = labs(fix16_to_int(pp->q16ang) - angle2);
// delta_ang = labs(FixedToInt(pp->q16ang) - angle2);
delta_ang = labs(GetDeltaAngle(sp->ang, angle2));
@ -1281,9 +1281,9 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets)
ts->dang = delta_ang;
ts->dist = dist;
// gives a value between 0 and 65535
ang_weight = ((max_delta_ang - ts->dang)<<16)/max_delta_ang;
ang_weight = IntToFixed(max_delta_ang - ts->dang)/max_delta_ang;
// gives a value between 0 and 65535
dist_weight = ((DIV2(PICK_DIST) - DIV2(ts->dist))<<16)/DIV2(PICK_DIST);
dist_weight = IntToFixed(DIV2(PICK_DIST) - DIV2(ts->dist))/DIV2(PICK_DIST);
//weighted average
ts->weight = (ang_weight + dist_weight*4)/5;
@ -1338,7 +1338,7 @@ DoPlayerTeleportPause(PLAYERp pp)
void
DoPlayerTeleportToSprite(PLAYERp pp, SPRITEp sp)
{
pp->camq16ang = pp->q16ang = pp->oq16ang = fix16_from_int(sp->ang);
pp->camq16ang = pp->q16ang = pp->oq16ang = IntToFixed(sp->ang);
pp->camq16horiz = pp->q16horiz; // Ensure horiz is initially locked
pp->posx = pp->oposx = pp->oldposx = sp->x;
pp->posy = pp->oposy = pp->oldposy = sp->y;
@ -1545,7 +1545,7 @@ DoPlayerCrawlHeight(PLAYERp pp)
double scaleAdjustmentToInterval(double x);
void
DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
DoPlayerTurn(PLAYERp pp, fixed_t *pq16ang, fixed_t q16angvel)
{
#define TURN_SHIFT 2
@ -1555,11 +1555,11 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
pp->q16ang = pp->input.q16ang;
if ((pp == &Player[myconnectindex]) || (pp == ppp)) // No coop view?
pp->oq16ang = pp->q16ang;
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
sprite[pp->PlayerSprite].ang = FixedToInt(*pq16ang);
if (!Prediction)
{
if (pp->PlayerUnderSprite >= 0)
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
sprite[pp->PlayerUnderSprite].ang = FixedToInt(*pq16ang);
}
return;
}
@ -1574,17 +1574,16 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
pp->KeyPressBits &= ~SB_TURNAROUND;
pp->turn180_target = NORM_ANGLE(fix16_to_int(*pq16ang) + 1024);
pp->turn180_target = NORM_ANGLE(FixedToInt(*pq16ang) + 1024);
// make the first turn in the clockwise direction
// the rest will follow
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(*pq16ang));
delta_ang = GetDeltaAngle(pp->turn180_target, FixedToInt(*pq16ang));
if (PedanticMode)
*pq16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(*pq16ang) + (labs(delta_ang) >> TURN_SHIFT)));
*pq16ang = IntToFixed(NORM_ANGLE(FixedToInt(*pq16ang) + (labs(delta_ang) >> TURN_SHIFT)));
else
// Add at least 1 unit to ensure the turn direction is clockwise
*pq16ang = NORM_Q16ANGLE(fix16_sadd(*pq16ang,
fix16_max(fix16_one,fix16_from_float(scaleAdjustmentToInterval(labs(delta_ang) >> TURN_SHIFT)))));
*pq16ang = NORM_Q16ANGLE(*pq16ang + max(FRACUNIT, FloatToFixed(scaleAdjustmentToInterval(labs(delta_ang) >> TURN_SHIFT))));
SET(pp->Flags, PF_TURN_180);
}
@ -1599,42 +1598,42 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
{
short delta_ang;
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(*pq16ang));
delta_ang = GetDeltaAngle(pp->turn180_target, FixedToInt(*pq16ang));
if (PedanticMode)
*pq16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(*pq16ang) + (delta_ang >> TURN_SHIFT)));
*pq16ang = IntToFixed(NORM_ANGLE(FixedToInt(*pq16ang) + (delta_ang >> TURN_SHIFT)));
else
*pq16ang = NORM_Q16ANGLE(fix16_sadd(*pq16ang, fix16_from_float(scaleAdjustmentToInterval(delta_ang >> TURN_SHIFT))));
*pq16ang = NORM_Q16ANGLE(*pq16ang + FloatToFixed(scaleAdjustmentToInterval(delta_ang >> TURN_SHIFT)));
if (pq16ang == &pp->q16ang)
{
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
sprite[pp->PlayerSprite].ang = FixedToInt(*pq16ang);
if (!Prediction)
{
if (pp->PlayerUnderSprite >= 0)
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
sprite[pp->PlayerUnderSprite].ang = FixedToInt(*pq16ang);
}
}
// get new delta to see how close we are
delta_ang = GetDeltaAngle(pp->turn180_target, fix16_to_int(*pq16ang));
delta_ang = GetDeltaAngle(pp->turn180_target, FixedToInt(*pq16ang));
if (labs(delta_ang) < (3<<TURN_SHIFT))
{
*pq16ang = fix16_from_int(pp->turn180_target);
*pq16ang = IntToFixed(pp->turn180_target);
RESET(pp->Flags, PF_TURN_180);
}
else
return;
}
q16angvel = fix16_smul(q16angvel, fix16_from_int(PLAYER_TURN_SCALE));
q16angvel *= PLAYER_TURN_SCALE;
if (q16angvel != 0)
{
// running is not handled here now
q16angvel += fix16_sdiv(q16angvel, fix16_from_int(4));
q16angvel += q16angvel / 4;
*pq16ang += fix16_sdiv(fix16_mul(q16angvel, fix16_from_int(synctics)), fix16_from_int(32));
*pq16ang += (q16angvel * synctics) / 32;
*pq16ang = PedanticQ16AngleFloor(NORM_Q16ANGLE(*pq16ang));
// update players sprite angle
@ -1643,11 +1642,11 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel)
// all cases.
if (pq16ang == &pp->q16ang)
{
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
sprite[pp->PlayerSprite].ang = FixedToInt(*pq16ang);
if (!Prediction)
{
if (pp->PlayerUnderSprite >= 0)
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
sprite[pp->PlayerUnderSprite].ang = FixedToInt(*pq16ang);
}
}
}
@ -1663,7 +1662,7 @@ DoPlayerTurnBoat(PLAYERp pp)
if (sop->drive_angspeed)
{
int drive_oangvel = pp->drive_angvel;
pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed);
pp->drive_angvel = mulscale16(FixedToInt(pp->input.q16avel), sop->drive_angspeed);
angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide;
@ -1672,15 +1671,15 @@ DoPlayerTurnBoat(PLAYERp pp)
}
else
{
angvel = fix16_to_int(pp->input.q16avel) * PLAYER_TURN_SCALE;
angvel = FixedToInt(pp->input.q16avel) * PLAYER_TURN_SCALE;
angvel += angvel - DIV4(angvel);
angvel = DIV32(angvel * synctics);
}
if (angvel != 0)
{
pp->camq16ang = pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
pp->camq16ang = pp->q16ang = IntToFixed(NORM_ANGLE(FixedToInt(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
}
}
@ -1695,7 +1694,7 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist)
int angslide;
int drive_oangvel = pp->drive_angvel;
pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed);
pp->drive_angvel = mulscale16(FixedToInt(pp->input.q16avel), sop->drive_angspeed);
angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide;
@ -1704,15 +1703,15 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist)
}
else
{
angvel = DIV8(fix16_to_int(pp->input.q16avel) * synctics);
angvel = DIV8(FixedToInt(pp->input.q16avel) * synctics);
}
if (angvel != 0)
{
if (MultiClipTurn(pp, NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel), z, floor_dist))
if (MultiClipTurn(pp, NORM_ANGLE(FixedToInt(pp->q16ang) + angvel), z, floor_dist))
{
pp->camq16ang = pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
pp->camq16ang = pp->q16ang = IntToFixed(NORM_ANGLE(FixedToInt(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
}
}
}
@ -1728,7 +1727,7 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
int angslide;
int drive_oangvel = pp->drive_angvel;
pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed);
pp->drive_angvel = mulscale16(FixedToInt(pp->input.q16avel), sop->drive_angspeed);
angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide;
@ -1737,15 +1736,15 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy)
}
else
{
angvel = DIV8(fix16_to_int(pp->input.q16avel) * synctics);
angvel = DIV8(FixedToInt(pp->input.q16avel) * synctics);
}
if (angvel != 0)
{
if (RectClipTurn(pp, NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel), x, y, ox, oy))
if (RectClipTurn(pp, NORM_ANGLE(FixedToInt(pp->q16ang) + angvel), x, y, ox, oy))
{
pp->camq16ang = pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
pp->camq16ang = pp->q16ang = IntToFixed(NORM_ANGLE(FixedToInt(pp->q16ang) + angvel));
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
}
}
}
@ -1777,7 +1776,7 @@ DoPlayerTurnTurret(PLAYERp pp)
int angslide;
int drive_oangvel = pp->drive_angvel;
pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed);
pp->drive_angvel = mulscale16(FixedToInt(pp->input.q16avel), sop->drive_angspeed);
angslide = sop->drive_angslide;
pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide;
@ -1786,12 +1785,12 @@ DoPlayerTurnTurret(PLAYERp pp)
}
else
{
angvel = DIV4(fix16_to_int(pp->input.q16avel) * synctics);
angvel = DIV4(FixedToInt(pp->input.q16avel) * synctics);
}
if (angvel != 0)
{
new_ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + angvel);
new_ang = NORM_ANGLE(FixedToInt(pp->q16ang) + angvel);
if (sop->limit_ang_center >= 0)
{
@ -1807,8 +1806,8 @@ DoPlayerTurnTurret(PLAYERp pp)
}
}
pp->camq16ang = pp->q16ang = fix16_from_int(new_ang);
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
pp->camq16ang = pp->q16ang = IntToFixed(new_ang);
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
}
}
@ -1842,8 +1841,8 @@ PlayerAutoLook(PLAYERp pp)
&& TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE)) // If the floor is sloped
{
// Get a point, 512 units ahead of player's position
x = pp->posx + (sintable[(fix16_to_int(pp->q16ang) + 512) & 2047] >> 5);
y = pp->posy + (sintable[fix16_to_int(pp->q16ang) & 2047] >> 5);
x = pp->posx + (sintable[(FixedToInt(pp->q16ang) + 512) & 2047] >> 5);
y = pp->posy + (sintable[FixedToInt(pp->q16ang) & 2047] >> 5);
tempsect = pp->cursectnum;
COVERupdatesector(x, y, &tempsect);
@ -1863,9 +1862,9 @@ PlayerAutoLook(PLAYERp pp)
(klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)))
{
if (PedanticMode)
pp->q16horizoff += fix16_from_int((((j - k) * 160) >> 16));
pp->q16horizoff += (j - k) * 160;
else
pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(mulscale16((j - k), 160))));
pp->q16horizoff += FloatToFixed(scaleAdjustmentToInterval(mulscale16((j - k), 160)));
}
}
}
@ -1874,12 +1873,12 @@ PlayerAutoLook(PLAYERp pp)
if (TEST(pp->Flags, PF_CLIMBING))
{
// tilt when climbing but you can't even really tell it
if (pp->q16horizoff < fix16_from_int(100))
if (pp->q16horizoff < IntToFixed(100))
{
if (PedanticMode)
pp->q16horizoff += fix16_from_int((((100 - fix16_to_int(pp->q16horizoff)) >> 3) + 1));
pp->q16horizoff += IntToFixed((((100 - FixedToInt(pp->q16horizoff)) >> 3) + 1));
else
pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(((fix16_from_int(100) - pp->q16horizoff) >> 3) + fix16_one))));
pp->q16horizoff += FloatToFixed(scaleAdjustmentToInterval(FixedToFloat(((IntToFixed(100) - pp->q16horizoff) >> 3) + FRACUNIT)));
}
}
else
@ -1889,21 +1888,21 @@ PlayerAutoLook(PLAYERp pp)
if (pp->q16horizoff > 0)
{
if (PedanticMode)
pp->q16horizoff -= fix16_from_int(((fix16_to_int(pp->q16horizoff) >> 3) + 1));
pp->q16horizoff -= IntToFixed(((FixedToInt(pp->q16horizoff) >> 3) + 1));
else
{
pp->q16horizoff = fix16_ssub(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float((pp->q16horizoff >> 3) + fix16_one))));
pp->q16horizoff = fix16_max(pp->q16horizoff, 0);
pp->q16horizoff -= FloatToFixed(scaleAdjustmentToInterval(FixedToFloat((pp->q16horizoff >> 3) + FRACUNIT)));
pp->q16horizoff = max(pp->q16horizoff, 0);
}
}
if (pp->q16horizoff < 0)
{
if (PedanticMode)
pp->q16horizoff += fix16_from_int((((fix16_to_int(-pp->q16horizoff)) >> 3) + 1));
pp->q16horizoff += IntToFixed((((FixedToInt(-pp->q16horizoff)) >> 3) + 1));
else
{
pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float((-pp->q16horizoff >> 3) + fix16_one))));
pp->q16horizoff = fix16_min(pp->q16horizoff, 0);
pp->q16horizoff += FloatToFixed(scaleAdjustmentToInterval(FixedToFloat((-pp->q16horizoff >> 3) + FRACUNIT)));
pp->q16horizoff = min(pp->q16horizoff, 0);
}
}
}
@ -1911,12 +1910,12 @@ PlayerAutoLook(PLAYERp pp)
extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
void
DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz)
{
int i;
#define HORIZ_SPEED (16)
// //DSPRINTF(ds,"fix16_to_int(pp->q16horizoff), %d", fix16_to_int(pp->q16horizoff));
// //DSPRINTF(ds,"FixedToInt(pp->q16horizoff), %d", FixedToInt(pp->q16horizoff));
// MONO_PRINT(ds);
if (!PedanticMode && (pq16horiz == &pp->q16horiz))
@ -1941,18 +1940,18 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
if ((pp->input.actions & SB_CENTERVIEW) || pp->centering)
{
if (PedanticMode)
pp->q16horizbase = fix16_from_int(100);
else if (pp->q16horizbase > fix16_from_int(100))
pp->q16horizbase = IntToFixed(100);
else if (pp->q16horizbase > IntToFixed(100))
{
pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED*6))));
pp->q16horizbase = fix16_max(pp->q16horizbase, fix16_from_int(100));
pp->q16horizbase -= FloatToFixed(scaleAdjustmentToInterval((HORIZ_SPEED*6)));
pp->q16horizbase = max(pp->q16horizbase, IntToFixed(100));
}
else if (pp->q16horizbase < fix16_from_int(100))
else if (pp->q16horizbase < IntToFixed(100))
{
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED*6))));
pp->q16horizbase = fix16_min(pp->q16horizbase, fix16_from_int(100));
pp->q16horizbase += FloatToFixed(scaleAdjustmentToInterval((HORIZ_SPEED*6)));
pp->q16horizbase = min(pp->q16horizbase, IntToFixed(100));
}
pp->centering = pp->q16horizbase != fix16_from_int(100);
pp->centering = pp->q16horizbase != IntToFixed(100);
*pq16horiz = pp->q16horizbase;
pp->q16horizoff = 0;
}
@ -1967,18 +1966,18 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
if (pp->input.actions & SB_AIM_DOWN)
{
if (PedanticMode)
pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2));
pp->q16horizbase -= IntToFixed((HORIZ_SPEED/2));
else
pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED/2))));
pp->q16horizbase -= FloatToFixed(scaleAdjustmentToInterval((HORIZ_SPEED/2)));
}
// adjust *pq16horiz positive
if (pp->input.actions & SB_AIM_UP)
{
if (PedanticMode)
pp->q16horizbase += fix16_from_int((HORIZ_SPEED/2));
pp->q16horizbase += IntToFixed((HORIZ_SPEED/2));
else
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED/2))));
pp->q16horizbase += FloatToFixed(scaleAdjustmentToInterval((HORIZ_SPEED/2)));
}
pp->centering = false;
}
@ -1993,18 +1992,18 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
if (pp->input.actions & SB_LOOK_DOWN)
{
if (PedanticMode)
pp->q16horizbase -= fix16_from_int(HORIZ_SPEED);
pp->q16horizbase -= IntToFixed(HORIZ_SPEED);
else
pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(HORIZ_SPEED)));
pp->q16horizbase -= FloatToFixed(scaleAdjustmentToInterval(HORIZ_SPEED));
}
// adjust *pq16horiz positive
if (pp->input.actions & SB_LOOK_UP)
{
if (PedanticMode)
pp->q16horizbase += fix16_from_int(HORIZ_SPEED);
pp->q16horizbase += IntToFixed(HORIZ_SPEED);
else
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(HORIZ_SPEED)));
pp->q16horizbase += FloatToFixed(scaleAdjustmentToInterval(HORIZ_SPEED));
}
pp->centering = false;
}
@ -2014,7 +2013,7 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
if (!(pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
{
// not pressing the *pq16horiz keys
if (pp->q16horizbase != fix16_from_int(100))
if (pp->q16horizbase != IntToFixed(100))
{
// move *pq16horiz back to 100
@ -2022,9 +2021,9 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
{
// this formula does not work for *pq16horiz = 101-103
if (PedanticMode)
pp->q16horizbase += fix16_from_int(25 - (fix16_to_int(pp->q16horizbase) >> 2));
pp->q16horizbase += IntToFixed(25) - (pp->q16horizbase >> 2);
else
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(fix16_ssub(fix16_from_int(25), fix16_sdiv(pp->q16horizbase, fix16_from_int(4)))))));
pp->q16horizbase += FloatToFixed(scaleAdjustmentToInterval(FixedToFloat(IntToFixed(25) - (pp->q16horizbase >> 2))));
}
}
else
@ -2037,21 +2036,21 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
#if 1
// bound the base
pp->q16horizbase = fix16_max(pp->q16horizbase, fix16_from_int(PLAYER_HORIZ_MIN));
pp->q16horizbase = fix16_min(pp->q16horizbase, fix16_from_int(PLAYER_HORIZ_MAX));
pp->q16horizbase = max(pp->q16horizbase, IntToFixed(PLAYER_HORIZ_MIN));
pp->q16horizbase = min(pp->q16horizbase, IntToFixed(PLAYER_HORIZ_MAX));
// bound adjust q16horizoff
if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN))
pp->q16horizoff = fix16_from_int(PLAYER_HORIZ_MIN) - pp->q16horizbase;
else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX))
pp->q16horizoff = fix16_from_int(PLAYER_HORIZ_MAX) - pp->q16horizbase;
if (pp->q16horizbase + pp->q16horizoff < IntToFixed(PLAYER_HORIZ_MIN))
pp->q16horizoff = IntToFixed(PLAYER_HORIZ_MIN) - pp->q16horizbase;
else if (pp->q16horizbase + pp->q16horizoff > IntToFixed(PLAYER_HORIZ_MAX))
pp->q16horizoff = IntToFixed(PLAYER_HORIZ_MAX) - pp->q16horizbase;
// add base and offsets
*pq16horiz = pp->q16horizbase + pp->q16horizoff;
#else
if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN))
pp->q16horizbase += fix16_from_int(HORIZ_SPEED);
else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX))
if (pp->q16horizbase + pp->q16horizoff < IntToFixed(PLAYER_HORIZ_MIN))
pp->q16horizbase += IntToFixed(HORIZ_SPEED);
else if (pp->q16horizbase + pp->q16horizoff > IntToFixed(PLAYER_HORIZ_MAX))
pp->q16horizbase -= HORIZ_SPEED;
*pq16horiz = pp->q16horizbase + pp->q16horizoff;
@ -2247,7 +2246,7 @@ UpdatePlayerSprite(PLAYERp pp)
if (TEST(pp->Flags, PF_DEAD))
{
changespritesect(pp->PlayerSprite, pp->cursectnum);
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
UpdatePlayerUnderSprite(pp);
return;
}
@ -2322,7 +2321,7 @@ UpdatePlayerSprite(PLAYERp pp)
UpdatePlayerUnderSprite(pp);
sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang);
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
}
void
@ -2509,11 +2508,11 @@ MoveScrollMode2D(PLAYERp pp)
if (mfsvel > MAXSVEL)
mfsvel = MAXSVEL;
momx = mulscale9(mfvel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + 512)]);
momy = mulscale9(mfvel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang))]);
momx = mulscale9(mfvel, sintable[NORM_ANGLE(FixedToInt(pp->q16ang) + 512)]);
momy = mulscale9(mfvel, sintable[NORM_ANGLE(FixedToInt(pp->q16ang))]);
momx += mulscale9(mfsvel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang))]);
momy += mulscale9(mfsvel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + 1536)]);
momx += mulscale9(mfsvel, sintable[NORM_ANGLE(FixedToInt(pp->q16ang))]);
momy += mulscale9(mfsvel, sintable[NORM_ANGLE(FixedToInt(pp->q16ang) + 1536)]);
//mfvel = momx;
//mfsvel = momy;
@ -2897,13 +2896,13 @@ DoPlayerMoveBoat(PLAYERp pp)
z = pp->posz + Z(10);
save_sectnum = pp->cursectnum;
OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), MAXSO, MAXSO);
OperateSectorObject(pp->sop, FixedToInt(pp->q16ang), MAXSO, MAXSO);
pp->cursectnum = pp->sop->op_main_sector; // for speed
floor_dist = labs(z - pp->sop->floor_loz);
clipmove_old(&pp->posx, &pp->posy, &z, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER);
OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->posx, pp->posy);
OperateSectorObject(pp->sop, FixedToInt(pp->q16ang), pp->posx, pp->posy);
pp->cursectnum = save_sectnum; // for speed
DoPlayerHorizon(pp, &pp->q16horiz, pp->input.q16horz);
@ -2923,7 +2922,7 @@ void DoTankTreads(PLAYERp pp)
return;
vel = FindDistance2D(pp->xvect>>8, pp->yvect>>8);
dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang)+512)], sintable[fix16_to_int(pp->q16ang)]);
dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(FixedToInt(pp->q16ang)+512)], sintable[FixedToInt(pp->q16ang)]);
if (dot < 0)
reverse = TRUE;
@ -3150,7 +3149,7 @@ DriveCrush(PLAYERp pp, int *x, int *y)
continue;
damage = -(u->Health + 100);
PlayerDamageSlide(u->PlayerP, damage, fix16_to_int(pp->q16ang));
PlayerDamageSlide(u->PlayerP, damage, FixedToInt(pp->q16ang));
PlayerUpdateHealth(u->PlayerP, damage);
//PlayerCheckDeath(u->PlayerP, -1);
PlayerCheckDeath(u->PlayerP, pp->PlayerSprite);
@ -3285,7 +3284,7 @@ DoPlayerMoveTank(PLAYERp pp)
}
save_sectnum = pp->cursectnum;
OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), MAXSO, MAXSO);
OperateSectorObject(pp->sop, FixedToInt(pp->q16ang), MAXSO, MAXSO);
pp->cursectnum = pp->sop->op_main_sector; // for speed
floor_dist = labs(z - pp->sop->floor_loz);
@ -3315,7 +3314,7 @@ DoPlayerMoveTank(PLAYERp pp)
hitscan(&hit_pos, pp->cursectnum,
//pp->xvect, pp->yvect, 0,
MOVEx(256, fix16_to_int(pp->q16ang)), MOVEy(256, fix16_to_int(pp->q16ang)), 0,
MOVEx(256, FixedToInt(pp->q16ang)), MOVEy(256, FixedToInt(pp->q16ang)), 0,
&hitinfo, CLIPMASK_PLAYER);
////DSPRINTF(ds,"hitinfo.sect %d, hitinfo.wall %d, hitinfo.pos.x %d, hitinfo.pos.y %d, hitinfo.pos.z %d",hitinfo.sect, hitinfo.wall, hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z);
@ -3382,7 +3381,7 @@ DoPlayerMoveTank(PLAYERp pp)
}
}
OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->posx, pp->posy);
OperateSectorObject(pp->sop, FixedToInt(pp->q16ang), pp->posx, pp->posy);
pp->cursectnum = save_sectnum; // for speed
DoPlayerHorizon(pp, &pp->q16horiz, pp->input.q16horz);
@ -3400,7 +3399,7 @@ DoPlayerMoveTurret(PLAYERp pp)
else
SET(pp->Flags, PF_PLAYER_MOVED);
OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->sop->xmid, pp->sop->ymid);
OperateSectorObject(pp->sop, FixedToInt(pp->q16ang), pp->sop->xmid, pp->sop->ymid);
DoPlayerHorizon(pp, &pp->q16horiz, pp->input.q16horz);
}
@ -3830,7 +3829,7 @@ DoPlayerClimb(PLAYERp pp)
pp->xvect = pp->yvect = 0;
climbvel = FindDistance2D(pp->xvect, pp->yvect)>>9;
dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang)+512)], sintable[fix16_to_int(pp->q16ang)]);
dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(FixedToInt(pp->q16ang)+512)], sintable[FixedToInt(pp->q16ang)]);
if (dot < 0)
climbvel = -climbvel;
@ -4000,7 +3999,7 @@ DoPlayerClimb(PLAYERp pp)
// constantly look for new ladder sector because of warping at any time
neartag(pp->posx, pp->posy, pp->posz,
pp->cursectnum, fix16_to_int(pp->q16ang),
pp->cursectnum, FixedToInt(pp->q16ang),
&sec, &wal, &spr,
&dist, 800L, NTAG_SEARCH_LO_HI, NULL);
@ -4025,7 +4024,7 @@ DoPlayerClimb(PLAYERp pp)
pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5;
pp->camq16ang = pp->q16ang = fix16_from_int(pp->LadderAngle);
pp->camq16ang = pp->q16ang = IntToFixed(pp->LadderAngle);
}
}
}
@ -4045,8 +4044,8 @@ DoPlayerWadeSuperJump(PLAYERp pp)
for (i = 0; i < SIZ(angs); i++)
{
FAFhitscan(pp->posx, pp->posy, zh, pp->cursectnum, // Start position
sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + angs[i] + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + angs[i])], // Y vector of 3D ang
sintable[NORM_ANGLE(FixedToInt(pp->q16ang) + angs[i] + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(FixedToInt(pp->q16ang) + angs[i])], // Y vector of 3D ang
0, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
@ -4408,11 +4407,11 @@ PlayerOnLadder(PLAYERp pp)
if (Prediction)
return 0;
neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, fix16_to_int(pp->q16ang),
neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, FixedToInt(pp->q16ang),
&neartagsector, &neartagwall, &neartagsprite,
&neartaghitdist, 1024L+768L, NTAG_SEARCH_LO_HI, NULL);
dir = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang)+512)], sintable[fix16_to_int(pp->q16ang)]);
dir = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(FixedToInt(pp->q16ang)+512)], sintable[FixedToInt(pp->q16ang)]);
if (dir < 0)
return FALSE;
@ -4422,7 +4421,7 @@ PlayerOnLadder(PLAYERp pp)
for (i = 0; i < SIZ(angles); i++)
{
neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, NORM_ANGLE(fix16_to_int(pp->q16ang) + angles[i]),
neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, NORM_ANGLE(FixedToInt(pp->q16ang) + angles[i]),
&sec, &wal, &spr,
&dist, 600L, NTAG_SEARCH_LO_HI, NULL);
@ -4430,8 +4429,8 @@ PlayerOnLadder(PLAYERp pp)
return FALSE;
FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum,
sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + angles[i] + 512)],
sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + angles[i])],
sintable[NORM_ANGLE(FixedToInt(pp->q16ang) + angles[i] + 512)],
sintable[NORM_ANGLE(FixedToInt(pp->q16ang) + angles[i])],
0,
&hitinfo, CLIPMASK_MISSILE);
@ -4486,7 +4485,7 @@ PlayerOnLadder(PLAYERp pp)
pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5;
pp->camq16ang = pp->q16ang = fix16_from_int(pp->LadderAngle);
pp->camq16ang = pp->q16ang = IntToFixed(pp->LadderAngle);
return TRUE;
}
@ -5726,7 +5725,7 @@ DoPlayerBeginOperate(PLAYERp pp)
pp->sop = pp->sop_control = sop;
sop->controller = pp->SpriteP;
pp->camq16ang = pp->q16ang = fix16_from_int(sop->ang);
pp->camq16ang = pp->q16ang = IntToFixed(sop->ang);
pp->posx = sop->xmid;
pp->posy = sop->ymid;
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
@ -5811,7 +5810,7 @@ DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop)
save_sectnum = pp->cursectnum;
pp->camq16ang = pp->q16ang = fix16_from_int(sop->ang);
pp->camq16ang = pp->q16ang = IntToFixed(sop->ang);
pp->posx = sop->xmid;
pp->posy = sop->ymid;
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
@ -5940,9 +5939,9 @@ DoPlayerStopOperate(PLAYERp pp)
if (pp->sop_remote)
{
if (TEST_BOOL1(pp->remote_sprite))
pp->camq16ang = pp->q16ang = pp->oq16ang = fix16_from_int(pp->remote_sprite->ang);
pp->camq16ang = pp->q16ang = pp->oq16ang = IntToFixed(pp->remote_sprite->ang);
else
pp->camq16ang = pp->q16ang = pp->oq16ang = fix16_from_int(getangle(pp->sop_remote->xmid - pp->posx, pp->sop_remote->ymid - pp->posy));
pp->camq16ang = pp->q16ang = pp->oq16ang = IntToFixed(getangle(pp->sop_remote->xmid - pp->posx, pp->sop_remote->ymid - pp->posy));
}
if (pp->sop_control)
@ -6494,22 +6493,22 @@ DoPlayerBeginDie(PLAYERp pp)
int
DoPlayerDeathHoriz(PLAYERp pp, short target, short speed)
{
if (pp->q16horiz > fix16_from_int(target))
if (pp->q16horiz > IntToFixed(target))
{
pp->q16horiz -= fix16_from_int(speed);
if (pp->q16horiz <= fix16_from_int(target))
pp->q16horiz = fix16_from_int(target);
pp->q16horiz -= IntToFixed(speed);
if (pp->q16horiz <= IntToFixed(target))
pp->q16horiz = IntToFixed(target);
}
if (pp->q16horiz < fix16_from_int(target))
if (pp->q16horiz < IntToFixed(target))
{
pp->q16horiz += fix16_from_int(speed);
if (pp->q16horiz >= fix16_from_int(target))
pp->q16horiz = fix16_from_int(target);
pp->q16horiz += IntToFixed(speed);
if (pp->q16horiz >= IntToFixed(target))
pp->q16horiz = IntToFixed(target);
}
pp->camq16horiz = pp->q16horiz;
return pp->q16horiz == fix16_from_int(target);
return pp->q16horiz == IntToFixed(target);
}
int
@ -6599,7 +6598,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
if (pp->Killer > -1)
{
SPRITEp kp = &sprite[pp->Killer];
fix16_t q16ang2, delta_q16ang;
fixed_t q16ang2, delta_q16ang;
if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum,
pp->posx, pp->posy, pp->posz, pp->cursectnum))
@ -6643,7 +6642,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp)
pp->SpriteP->x = pp->posx;
pp->SpriteP->y = pp->posy;
pp->SpriteP->z = pp->posz+PLAYER_HEIGHT;
pp->SpriteP->ang = fix16_to_int(pp->q16ang);
pp->SpriteP->ang = FixedToInt(pp->q16ang);
DoSpawnTeleporterEffect(pp->SpriteP);
PlaySound(DIGI_TELEPORT, pp, v3df_none);
@ -6664,7 +6663,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp)
sp->yrepeat = PLAYER_NINJA_YREPEAT;
//pp->tilt = 0;
pp->camq16horiz = pp->q16horiz = pp->q16horizbase = fix16_from_int(100);
pp->camq16horiz = pp->q16horiz = pp->q16horizbase = IntToFixed(100);
DoPlayerResetMovement(pp);
u->ID = NINJA_RUN_R0;
PlayerDeathReset(pp);
@ -7687,7 +7686,7 @@ domovethings(void)
// auto tracking mode for single player multi-game
if (numplayers <= 1 && PlayerTrackingMode && pnum == screenpeek && screenpeek != myconnectindex)
{
Player[screenpeek].camq16ang = Player[screenpeek].q16ang = fix16_from_int(getangle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy));
Player[screenpeek].camq16ang = Player[screenpeek].q16ang = IntToFixed(getangle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy));
}
if (!TEST(pp->Flags, PF_DEAD))
@ -7761,7 +7760,7 @@ InitAllPlayers(void)
//getzsofslope(pfirst->cursectnum, pfirst->posx, pfirst->posy, &cz, &fz);
//pfirst->posz = fz - PLAYER_HEIGHT;
pfirst->q16horiz = pfirst->q16horizbase = fix16_from_int(100);
pfirst->q16horiz = pfirst->q16horizbase = IntToFixed(100);
// Initialize all [MAX_SW_PLAYERS] arrays here!
for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++)
@ -7917,7 +7916,7 @@ PlayerSpawnPosition(PLAYERp pp)
pp->posx = pp->oposx = sp->x;
pp->posy = pp->oposy = sp->y;
pp->posz = pp->oposz = sp->z;
pp->camq16ang = pp->q16ang = pp->oq16ang = fix16_from_int(sp->ang);
pp->camq16ang = pp->q16ang = pp->oq16ang = IntToFixed(sp->ang);
pp->cursectnum = sp->sectnum;
getzsofslope(pp->cursectnum, pp->posx, pp->posy, &cz, &fz);
@ -7976,7 +7975,7 @@ InitMultiPlayerInfo(void)
continue;
}
start0 = SpawnSprite(MultiStatList[stat], ST1, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, fix16_to_int(pp->q16ang), 0);
start0 = SpawnSprite(MultiStatList[stat], ST1, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, FixedToInt(pp->q16ang), 0);
ASSERT(start0 >= 0);
if (User[start0])
{

View file

@ -45,7 +45,7 @@ PLAYERp ppp = &PredictPlayer;
typedef struct
{
int x,y,z;
fix16_t q16horiz, q16ang;
fixed_t q16horiz, q16ang;
short filler;
} PREDICT, *PREDICTp;
@ -142,7 +142,7 @@ CorrectPrediction(int actualfifoplc)
return;
}
// //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", fix16_to_int(predict->q16ang), fix16_to_int(Player[myconnectindex].q16ang), predict->x, Player[myconnectindex].posx, predict->y, Player[myconnectindex].posy, predict->z, Player[myconnectindex].posz, fix16_to_int(predict->q16horiz),fix16_to_int(Player[myconnectindex].q16horiz));
// //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", FixedToInt(predict->q16ang), FixedToInt(Player[myconnectindex].q16ang), predict->x, Player[myconnectindex].posx, predict->y, Player[myconnectindex].posy, predict->z, Player[myconnectindex].posz, FixedToInt(predict->q16horiz),FixedToInt(Player[myconnectindex].q16horiz));
// MONO_PRINT(ds);
InitPrediction(&Player[myconnectindex]);

View file

@ -32,7 +32,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS
void FAF_DrawRooms(int posx, int posy, int posz, fix16_t q16ang, fix16_t q16horiz, short cursectnum);
void FAF_DrawRooms(int posx, int posy, int posz, fixed_t q16ang, fixed_t q16horiz, short cursectnum);
////////////////////////////////////////////////////////////////////
//
@ -1008,7 +1008,7 @@ ViewSectorInScene(short cursectnum, short level)
}
void
DrawOverlapRoom(int tx, int ty, int tz, fix16_t tq16ang, fix16_t tq16horiz, short tsectnum)
DrawOverlapRoom(int tx, int ty, int tz, fixed_t tq16ang, fixed_t tq16horiz, short tsectnum)
{
short i;
short match;

View file

@ -636,7 +636,7 @@ private:
25, 19, 15, 9, 1, 1, 9, 15, 19, 25
};
ang = fix16_to_int(pp->q16ang);
ang = FixedToInt(pp->q16ang);
if (pp->sop_remote)
ang = 0;

View file

@ -2329,7 +2329,7 @@ SWBOOL NearThings(PLAYERp pp)
return FALSE;
}
neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, fix16_to_int(pp->q16ang),
neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, FixedToInt(pp->q16ang),
&neartagsect, &neartagwall, &neartagsprite,
&neartaghitdist, 1024L, NTAG_SEARCH_LO_HI, NULL);
@ -2363,7 +2363,7 @@ SWBOOL NearThings(PLAYERp pp)
// This only gets called if nothing else worked, check for nearness to a wall
{
hitdata_t hitinfo = { { 0, 0, 0 }, 0, 0, 0 };
short dang = fix16_to_int(pp->q16ang);
short dang = FixedToInt(pp->q16ang);
FAFhitscan(pp->posx, pp->posy, pp->posz - Z(30), pp->cursectnum, // Start position
sintable[NORM_ANGLE(dang + 512)], // X vector of 3D ang
@ -2427,7 +2427,7 @@ NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int coun
int neartaghitdist;
neartag(pp->posx, pp->posy, z, pp->cursectnum, fix16_to_int(pp->q16ang),
neartag(pp->posx, pp->posy, z, pp->cursectnum, FixedToInt(pp->q16ang),
&neartagsector, &neartagwall, &neartagsprite,
&neartaghitdist, dist, type, NULL);
@ -2983,7 +2983,7 @@ AnimDelete(int *animptr)
short
AnimSet(int *animptr, int thegoal, int thevel)
AnimSet(int *animptr, fixed_t thegoal, int thevel)
{
int i, j;

View file

@ -590,7 +590,7 @@ void GameInterface::UpdateSounds(void)
PLAYERp pp = Player + screenpeek;
SoundListener listener;
listener.angle = -fix16_to_float(pp->q16ang) * pi::pi() / 1024; // Build uses a period of 2048.
listener.angle = -FixedToFloat(pp->q16ang) * pi::pi() / 1024; // Build uses a period of 2048.
listener.velocity.Zero();
listener.position = GetSoundPos((vec3_t*)&pp->posx);
listener.underwater = false;

View file

@ -58,7 +58,7 @@ PlayerSync(void)
updatecrc(crc, pp->posx & 255);
updatecrc(crc, pp->posy & 255);
updatecrc(crc, pp->posz & 255);
updatecrc(crc, fix16_to_int(pp->q16ang) & 255);
updatecrc(crc, FixedToInt(pp->q16ang) & 255);
}
return (uint8_t) crc & 255;
@ -75,7 +75,7 @@ PlayerSync2(void)
{
pp = Player + i;
updatecrc(crc, fix16_to_int(pp->q16horiz) & 255);
updatecrc(crc, FixedToInt(pp->q16horiz) & 255);
updatecrc(crc, User[pp->PlayerSprite]->Health & 255);
updatecrc(crc, pp->bcnt & 255);
}

View file

@ -1662,7 +1662,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
pp->RevolveY += BOUND_4PIX(ny);
// Last known angle is now adjusted by the delta angle
pp->RevolveQ16Ang = NORM_Q16ANGLE(pp->q16ang - fix16_from_int(pp->RevolveDeltaAng));
pp->RevolveQ16Ang = NORM_Q16ANGLE(pp->q16ang - IntToFixed(pp->RevolveDeltaAng));
}
// increment Players delta angle
@ -1676,9 +1676,9 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
// New angle is formed by taking last known angle and
// adjusting by the delta angle
pp->camq16ang += NORM_Q16ANGLE(pp->RevolveQ16Ang + fix16_from_int(pp->RevolveDeltaAng)) - pp->q16ang;
pp->camq16ang += NORM_Q16ANGLE(pp->RevolveQ16Ang + IntToFixed(pp->RevolveDeltaAng)) - pp->q16ang;
pp->camq16ang = NORM_Q16ANGLE(pp->camq16ang);
pp->q16ang = NORM_Q16ANGLE(pp->RevolveQ16Ang + fix16_from_int(pp->RevolveDeltaAng));
pp->q16ang = NORM_Q16ANGLE(pp->RevolveQ16Ang + IntToFixed(pp->RevolveDeltaAng));
UpdatePlayerSprite(pp);
}
@ -2291,7 +2291,7 @@ void CallbackSOsink(ANIMp ap, void *data)
// Added a depth_fract to the struct so I could do a
// 16.16 Fixed point representation to change the depth
// in a more precise way
ndx = AnimSet((int *)&su->depth_fract, tgt_depth<<16, (ap->vel<<8)>>8);
ndx = AnimSet((int *)&su->depth_fract, IntToFixed(tgt_depth), (ap->vel<<8)>>8);
AnimSetVelAdj(ndx, ap->vel_adj);
found = TRUE;
@ -2309,7 +2309,7 @@ void CallbackSOsink(ANIMp ap, void *data)
// Added a depth_fract to the struct so I could do a
// 16.16 Fixed point representation to change the depth
// in a more precise way
ndx = AnimSet((int *)&su->depth_fract, tgt_depth<<16, (ap->vel<<8)>>8);
ndx = AnimSet((int *)&su->depth_fract, IntToFixed(tgt_depth), (ap->vel<<8)>>8);
AnimSetVelAdj(ndx, ap->vel_adj);
found = TRUE;
break;

View file

@ -67,7 +67,6 @@ DAMAGE_DATA DamageData[] =
#undef DAMAGE_TABLE
short ADJUST=120;
int ADJUSTV=1<<16;
FOOT_TYPE FootMode=WATER_FOOT;
SWBOOL left_foot = FALSE;
@ -5669,11 +5668,11 @@ GetDamage(short SpriteNum, short Weapon, short DamageNdx)
if ((unsigned)dist < d->radius)
{
damage_per_pixel = (d->damage_hi<<16)/d->radius;
damage_per_pixel = IntToFixed(d->damage_hi)/d->radius;
//the closer your distance is to 0 the more damage
damage_force = (d->radius - dist);
damage_amt = -((damage_force * damage_per_pixel)>>16);
damage_amt = -FixedToInt(damage_force * damage_per_pixel);
//return(damage_amt);
// formula: damage_amt = 75% + random(25%)
@ -5708,14 +5707,14 @@ RadiusGetDamage(short SpriteNum, short Weapon, int max_damage)
if ((unsigned)dist < wu->Radius)
{
damage_per_pixel = (max_damage<<16)/wu->Radius;
damage_per_pixel = IntToFixed(max_damage)/wu->Radius;
//the closer your distance is to 0 the more damage
damage_force = (wu->Radius - dist);
// fudge factor
//damage_force += 400;
damage_amt = -((damage_force * damage_per_pixel)>>16);
damage_amt = -FixedToInt(damage_force * damage_per_pixel);
}
else
{
@ -12828,7 +12827,7 @@ DoRing(int16_t Weapon)
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14;
if (User[sp->owner]->PlayerP)
sp->z += (u->Dist * ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT)) >> 9;
sp->z += (u->Dist * ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT)) >> 9;
//sp->ang = NORM_ANGLE(sp->ang + 512);
//updatesector(sp->x, sp->y);
@ -12876,7 +12875,7 @@ InitSpellRing(PLAYERp pp)
ang_diff = 2048 / max_missiles;
ang_start = NORM_ANGLE(fix16_to_int(pp->q16ang) - DIV2(2048));
ang_start = NORM_ANGLE(FixedToInt(pp->q16ang) - DIV2(2048));
if (!SW_SHAREWARE)
PlaySound(DIGI_RFWIZ, pp, v3df_none);
@ -12915,7 +12914,7 @@ InitSpellRing(PLAYERp pp)
// put it out there
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14;
sp->z = pp->posz + Z(20) + ((u->Dist * ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT)) >> 9);
sp->z = pp->posz + Z(20) + ((u->Dist * ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT)) >> 9);
sp->ang = NORM_ANGLE(sp->ang + 512);
@ -13435,7 +13434,7 @@ InitSpellNapalm(PLAYERp pp)
for (i = 0; i < SIZ(mp); i++)
{
SpriteNum = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Napalm, pp->cursectnum,
pp->posx, pp->posy, pp->posz + Z(12), fix16_to_int(pp->q16ang), NAPALM_VELOCITY*2);
pp->posx, pp->posy, pp->posz + Z(12), FixedToInt(pp->q16ang), NAPALM_VELOCITY*2);
sp = &sprite[SpriteNum];
u = User[SpriteNum];
@ -13454,7 +13453,7 @@ InitSpellNapalm(PLAYERp pp)
sp->xrepeat = 32;
sp->yrepeat = 32;
sp->clipdist = 0;
sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
sp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER);
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
SET(u->Flags2, SPR2_BLUR_TAPER_FAST);
@ -13595,7 +13594,7 @@ InitSpellMirv(PLAYERp pp)
return 0;
SpriteNum = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Mirv, pp->cursectnum,
pp->posx, pp->posy, pp->posz + Z(12), fix16_to_int(pp->q16ang), MIRV_VELOCITY);
pp->posx, pp->posy, pp->posz + Z(12), FixedToInt(pp->q16ang), MIRV_VELOCITY);
sp = &sprite[SpriteNum];
u = User[SpriteNum];
@ -13609,7 +13608,7 @@ InitSpellMirv(PLAYERp pp)
sp->xrepeat = 72;
sp->yrepeat = 72;
sp->clipdist = 32L >> 2;
sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
sp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER);
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
@ -13710,7 +13709,7 @@ InitSwordAttack(PLAYERp pp)
{
bp = &sprite[bubble];
bp->ang = fix16_to_int(pp->q16ang);
bp->ang = FixedToInt(pp->q16ang);
random_amt = (RANDOM_P2(32<<8)>>8) - 16;
@ -13759,8 +13758,8 @@ InitSwordAttack(PLAYERp pp)
short daang;
int daz;
daang = fix16_to_int(pp->q16ang);
daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
daang = FixedToInt(pp->q16ang);
daz = ((100 - FixedToInt(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
@ -13887,7 +13886,7 @@ InitFistAttack(PLAYERp pp)
{
bp = &sprite[bubble];
bp->ang = fix16_to_int(pp->q16ang);
bp->ang = FixedToInt(pp->q16ang);
random_amt = (RANDOM_P2(32<<8)>>8) - 16;
@ -13949,8 +13948,8 @@ InitFistAttack(PLAYERp pp)
short daang;
int daz;
daang = fix16_to_int(pp->q16ang);
daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
daang = FixedToInt(pp->q16ang);
daz = ((100 - FixedToInt(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
@ -14608,7 +14607,7 @@ InitStar(PLAYERp pp)
// Spawn a shot
// Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, STAR1, s_Star, pp->cursectnum, nx, ny, nz, fix16_to_int(pp->q16ang), STAR_VELOCITY);
w = SpawnSprite(STAT_MISSILE, STAR1, s_Star, pp->cursectnum, nx, ny, nz, FixedToInt(pp->q16ang), STAR_VELOCITY);
wp = &sprite[w];
wu = User[w];
@ -14623,7 +14622,7 @@ InitStar(PLAYERp pp)
wp->clipdist = 32L >> 2;
// wp->zvel was overflowing with this calculation - had to move to a local
// long var
zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+STAR_HORIZ_ADJ));
zvel = ((100 - FixedToInt(pp->q16horiz)) * (HORIZ_MULT+STAR_HORIZ_ADJ));
wu->ceiling_dist = Z(1);
wu->floor_dist = Z(1);
@ -14680,7 +14679,7 @@ InitStar(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(np))
SET(nu->Flags, SPR_UNDERWATER);
zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+STAR_HORIZ_ADJ));
zvel = ((100 - FixedToInt(pp->q16horiz)) * (HORIZ_MULT+STAR_HORIZ_ADJ));
np->zvel = zvel >> 1;
if (MissileSetPos(nw, DoStar, 1000))
@ -14731,7 +14730,7 @@ InitHeartAttack(PLAYERp pp)
return;
SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, BLOOD_WORM, s_BloodWorm, pp->cursectnum,
pp->posx, pp->posy, pp->posz + Z(12), fix16_to_int(pp->q16ang), BLOOD_WORM_VELOCITY*2);
pp->posx, pp->posy, pp->posz + Z(12), FixedToInt(pp->q16ang), BLOOD_WORM_VELOCITY*2);
sp = &sprite[SpriteNum];
u = User[SpriteNum];
@ -14744,7 +14743,7 @@ InitHeartAttack(PLAYERp pp)
sp->xrepeat = 52;
sp->yrepeat = 52;
sp->clipdist = 0;
sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
sp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
SET(u->Flags2, SPR2_DONT_TARGET_OWNER);
SET(sp->cstat, CSTAT_SPRITE_INVISIBLE);
@ -14807,7 +14806,7 @@ InitHeartAttack(PLAYERp pp)
return;
SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, BLOOD_WORM, s_BloodWorm, pp->cursectnum,
pp->posx, pp->posy, pp->posz + Z(12), fix16_to_int(pp->q16ang), BLOOD_WORM_VELOCITY*2);
pp->posx, pp->posy, pp->posz + Z(12), FixedToInt(pp->q16ang), BLOOD_WORM_VELOCITY*2);
sp = &sprite[SpriteNum];
u = User[SpriteNum];
@ -14968,8 +14967,8 @@ InitShotgun(PLAYERp pp)
}
else
{
daz = (100 - fix16_to_int(pp->q16horiz)) * 2000;
daang = fix16_to_int(pp->q16ang);
daz = (100 - FixedToInt(pp->q16horiz)) * 2000;
daang = FixedToInt(pp->q16ang);
}
for (i = 0; i < 12; i++)
@ -15131,7 +15130,7 @@ InitLaser(PLAYERp pp)
// Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, s_Laser, pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), 300);
nx, ny, nz, FixedToInt(pp->q16ang), 300);
wp = &sprite[w];
wu = User[w];
@ -15144,7 +15143,7 @@ InitLaser(PLAYERp pp)
wp->clipdist = 64L>>2;
// the slower the missile travels the less of a zvel it needs
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
wp->zvel /= 4;
wu->WeaponNum = u->WeaponNum;
@ -15243,7 +15242,7 @@ InitRail(PLAYERp pp)
// Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R1, &s_Rail[0][0], pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), 1200);
nx, ny, nz, FixedToInt(pp->q16ang), 1200);
wp = &sprite[w];
wu = User[w];
@ -15252,7 +15251,7 @@ InitRail(PLAYERp pp)
wp->yrepeat = 52;
wp->xrepeat = 52;
wp->shade = -15;
zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+17));
zvel = ((100 - FixedToInt(pp->q16horiz)) * (HORIZ_MULT+17));
wu->RotNum = 5;
NewStateGroup(w, &sg_Rail[0]);
@ -15443,7 +15442,7 @@ InitRocket(PLAYERp pp)
//nz = pp->posz + pp->bob_z + Z(12);
nz = pp->posz + pp->bob_z + Z(8);
w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), ROCKET_VELOCITY);
nx, ny, nz, FixedToInt(pp->q16ang), ROCKET_VELOCITY);
wp = &sprite[w];
wu = User[w];
@ -15453,7 +15452,7 @@ InitRocket(PLAYERp pp)
wp->yrepeat = 90;
wp->xrepeat = 90;
wp->shade = -15;
zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+35));
zvel = ((100 - FixedToInt(pp->q16horiz)) * (HORIZ_MULT+35));
wp->clipdist = 64L>>2;
@ -15574,7 +15573,7 @@ InitBunnyRocket(PLAYERp pp)
//nz = pp->posz + pp->bob_z + Z(12);
nz = pp->posz + pp->bob_z + Z(8);
w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R4, &s_BunnyRocket[0][0], pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), ROCKET_VELOCITY);
nx, ny, nz, FixedToInt(pp->q16ang), ROCKET_VELOCITY);
wp = &sprite[w];
wu = User[w];
@ -15584,7 +15583,7 @@ InitBunnyRocket(PLAYERp pp)
wp->yrepeat = 64;
wp->xrepeat = 64;
wp->shade = -15;
zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+35));
zvel = ((100 - FixedToInt(pp->q16horiz)) * (HORIZ_MULT+35));
wp->clipdist = 64L>>2;
@ -15688,7 +15687,7 @@ InitNuke(PLAYERp pp)
//nz = pp->posz + pp->bob_z + Z(12);
nz = pp->posz + pp->bob_z + Z(8);
w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), 700);
nx, ny, nz, FixedToInt(pp->q16ang), 700);
wp = &sprite[w];
wu = User[w];
@ -15698,7 +15697,7 @@ InitNuke(PLAYERp pp)
wp->yrepeat = 128;
wp->xrepeat = 128;
wp->shade = -15;
zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT-36));
zvel = ((100 - FixedToInt(pp->q16horiz)) * (HORIZ_MULT-36));
wp->clipdist = 64L>>2;
// Set to red palette
@ -15751,7 +15750,7 @@ InitNuke(PLAYERp pp)
wu->ychange = MOVEy(wp->xvel, wp->ang);
wu->zchange = zvel;
PlayerDamageSlide(pp, -40, NORM_ANGLE(fix16_to_int(pp->q16ang)+1024)); // Recoil slide
PlayerDamageSlide(pp, -40, NORM_ANGLE(FixedToInt(pp->q16ang)+1024)); // Recoil slide
return 0;
}
@ -15886,7 +15885,7 @@ InitMicro(PLAYERp pp)
{
hp = NULL;
hu = NULL;
ang = fix16_to_int(pp->q16ang);
ang = FixedToInt(pp->q16ang);
}
nz = pp->posz + pp->bob_z + Z(14);
@ -15905,7 +15904,7 @@ InitMicro(PLAYERp pp)
wp->yrepeat = 24;
wp->xrepeat = 24;
wp->shade = -15;
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
wp->clipdist = 64L>>2;
// randomize zvelocity
@ -17435,14 +17434,14 @@ InitTracerUzi(PLAYERp pp)
nx = pp->posx;
ny = pp->posy;
//nz = pp->posz + pp->bob_z + Z(8);
//nz = pp->posz + pp->bob_z + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72);
nz = pp->posz + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72);
//nz = pp->posz + pp->bob_z + Z(8) + ((100 - FixedToInt(pp->q16horiz)) * 72);
nz = pp->posz + Z(8) + ((100 - FixedToInt(pp->q16horiz)) * 72);
// Spawn a shot
// Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, 0, s_Tracer, pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), TRACER_VELOCITY);
nx, ny, nz, FixedToInt(pp->q16ang), TRACER_VELOCITY);
wp = &sprite[w];
wu = User[w];
@ -17454,7 +17453,7 @@ InitTracerUzi(PLAYERp pp)
wp->xrepeat = 10;
wp->shade = -40;
wp->zvel = 0;
//wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
//wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
wp->clipdist = 32 >> 2;
wu->WeaponNum = u->WeaponNum;
@ -17481,7 +17480,7 @@ InitTracerUzi(PLAYERp pp)
return 0;
}
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8));
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * (wp->xvel/8));
pp->SpriteP->clipdist = oclipdist;
@ -17724,8 +17723,8 @@ int SpawnWallHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_
sp->ang = NORM_ANGLE(wall_ang + 1024);
// int nx,ny;
//nx = (sintable[(512 + fix16_to_int(Player[0].q16ang)) & 2047] >> 7);
//ny = (sintable[fix16_to_int(Player[0].q16ang)] >> 7);
//nx = (sintable[(512 + FixedToInt(Player[0].q16ang)) & 2047] >> 7);
//ny = (sintable[FixedToInt(Player[0].q16ang)] >> 7);
//sp->x -= nx;
//sp->y -= ny;
@ -17831,9 +17830,9 @@ InitUzi(PLAYERp pp)
}
else
{
//daang = NORM_ANGLE(fix16_to_int(pp->q16ang) + (RANDOM_RANGE(50) - 25));
daang = NORM_ANGLE(fix16_to_int(pp->q16ang) + (RANDOM_RANGE(24) - 12));
daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
//daang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(50) - 25));
daang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(24) - 12));
daz = ((100 - FixedToInt(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
}
@ -18008,8 +18007,8 @@ InitEMP(PLAYERp pp)
InitTracerUzi(pp);
//daz = nz = pp->posz + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72);
//daang = NORM_ANGLE(fix16_to_int(pp->q16ang) + (RANDOM_RANGE(50) - 25));
//daz = nz = pp->posz + Z(8) + ((100 - FixedToInt(pp->q16horiz)) * 72);
//daang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(50) - 25));
daz = nz = pp->posz + pp->bob_z;
daang = 64;
@ -18018,8 +18017,8 @@ InitEMP(PLAYERp pp)
}
else
{
daz = (100 - fix16_to_int(pp->q16horiz)) * 2000;
daang = fix16_to_int(pp->q16ang);
daz = (100 - FixedToInt(pp->q16horiz)) * 2000;
daang = FixedToInt(pp->q16ang);
}
FAFhitscan(pp->posx, pp->posy, nz, pp->cursectnum, // Start position
@ -18192,7 +18191,7 @@ InitTankShell(short SpriteNum, PLAYERp pp)
SET(wp->cstat, CSTAT_SPRITE_YCENTER);
SET(wp->cstat, CSTAT_SPRITE_INVISIBLE);
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8));
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * (wp->xvel/8));
WeaponAutoAim(sp, w, 64, FALSE);
// a bit of randomness
@ -18271,7 +18270,7 @@ InitTurretMicro(short SpriteNum, PLAYERp pp)
wp->yrepeat = 24;
wp->xrepeat = 24;
wp->shade = -15;
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
wp->clipdist = 64L>>2;
// randomize zvelocity
@ -18352,7 +18351,7 @@ InitTurretRocket(short SpriteNum, PLAYERp pp)
SET(wu->Flags2, SPR2_SO_MISSILE);
SET(wp->cstat, CSTAT_SPRITE_YCENTER);
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8));
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * (wp->xvel/8));
WeaponAutoAim(sp, w, 64, FALSE);
// a bit of randomness
@ -18399,7 +18398,7 @@ InitTurretFireball(short SpriteNum, PLAYERp pp)
SET(wu->Flags2, SPR2_SO_MISSILE);
SET(wp->cstat, CSTAT_SPRITE_YCENTER);
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8));
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * (wp->xvel/8));
WeaponAutoAim(sp, w, 64, FALSE);
// a bit of randomness
@ -18448,7 +18447,7 @@ InitTurretRail(short SpriteNum, PLAYERp pp)
wp->yrepeat = 52;
wp->xrepeat = 52;
wp->shade = -15;
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
wu->RotNum = 5;
NewStateGroup(w, &sg_Rail[0]);
@ -18508,7 +18507,7 @@ InitTurretLaser(short SpriteNum, PLAYERp pp)
wp->shade = -15;
// the slower the missile travels the less of a zvel it needs
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
wp->zvel /= 4;
wu->Radius = 200;
@ -18555,7 +18554,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
nsect = sp->sectnum;
if (RANDOM_P2(1024) < 200)
InitTracerTurret(sp - sprite, pp->PlayerSprite, fix16_to_int(pp->q16horiz));
InitTracerTurret(sp - sprite, pp->PlayerSprite, FixedToInt(pp->q16horiz));
daang = 64;
if (WeaponAutoAimHitscan(sp, &daz, &daang, FALSE) != -1)
@ -18566,7 +18565,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
else
{
int horiz;
horiz = fix16_to_int(pp->q16horiz);
horiz = FixedToInt(pp->q16horiz);
if (horiz < 75)
horiz = 75;
@ -19276,7 +19275,7 @@ InitGrenade(PLAYERp pp)
// Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, GRENADE, &s_Grenade[0][0], pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), GRENADE_VELOCITY);
nx, ny, nz, FixedToInt(pp->q16ang), GRENADE_VELOCITY);
wp = &sprite[w];
wu = User[w];
@ -19308,9 +19307,9 @@ InitGrenade(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER);
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
////DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",fix16_to_int(pp->q16horiz), fix16_to_int(pp->q16horizoff), fix16_to_int(pp->q16horizoff + pp->q16horiz));
////DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",FixedToInt(pp->q16horiz), FixedToInt(pp->q16horizoff), FixedToInt(pp->q16horizoff + pp->q16horiz));
//MONO_PRINT(ds);
oclipdist = pp->SpriteP->clipdist;
@ -19445,7 +19444,7 @@ InitMine(PLAYERp pp)
// Inserting and setting up variables
w = SpawnSprite(STAT_MISSILE, MINE, s_Mine, pp->cursectnum,
nx, ny, nz, fix16_to_int(pp->q16ang), MINE_VELOCITY);
nx, ny, nz, FixedToInt(pp->q16ang), MINE_VELOCITY);
wp = &sprite[w];
wu = User[w];
@ -19455,7 +19454,7 @@ InitMine(PLAYERp pp)
wp->xrepeat = 32;
wp->shade = -15;
wp->clipdist = 128L>>2;
wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
wu->WeaponNum = u->WeaponNum;
wu->Radius = 200;
wu->ceiling_dist = Z(5);
@ -19468,7 +19467,7 @@ InitMine(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER);
//wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
//wp->zvel = ((100 - FixedToInt(pp->q16horiz)) * HORIZ_MULT);
MissileSetPos(w, DoMine, 800);
@ -19476,7 +19475,7 @@ InitMine(PLAYERp pp)
wu->xchange = MOVEx(wp->xvel, wp->ang);
wu->ychange = MOVEy(wp->xvel, wp->ang);
dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang)+512)], sintable[fix16_to_int(pp->q16ang)]);
dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(FixedToInt(pp->q16ang)+512)], sintable[FixedToInt(pp->q16ang)]);
// don't adjust for strafing
if (labs(dot) > 10000)
@ -19606,7 +19605,7 @@ InitFireball(PLAYERp pp)
nz = pp->posz + pp->bob_z + Z(15);
w = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Fireball, pp->cursectnum, nx, ny, nz, fix16_to_int(pp->q16ang), FIREBALL_VELOCITY);
w = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Fireball, pp->cursectnum, nx, ny, nz, FixedToInt(pp->q16ang), FIREBALL_VELOCITY);
wp = &sprite[w];
wu = User[w];
@ -19621,8 +19620,8 @@ InitFireball(PLAYERp pp)
wu->ceiling_dist = Z(6);
wu->floor_dist = Z(6);
//zvel = ((100 - fix16_to_int(pp->q16horiz)) * (100+ADJUST));
zvel = ((100 - fix16_to_int(pp->q16horiz)) * (240L));
//zvel = ((100 - FixedToInt(pp->q16horiz)) * (100+ADJUST));
zvel = ((100 - FixedToInt(pp->q16horiz)) * (240L));
//wu->RotNum = 5;
//NewStateGroup(w, &sg_Fireball);

Some files were not shown because too many files have changed in this diff Show more