diff --git a/src/g_hexen/a_bats.cpp b/src/g_hexen/a_bats.cpp index c1674d218..eda5692ae 100644 --- a/src/g_hexen/a_bats.cpp +++ b/src/g_hexen/a_bats.cpp @@ -84,6 +84,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatMove) } // Handle Z movement - self->z = self->target->z + 2*FloatBobOffsets[self->args[0]]; + self->z = self->target->z + 16*finesine[self->args[0] << BOBTOFINESHIFT]; self->args[0] = (self->args[0]+3)&63; } diff --git a/src/g_hexen/a_bishop.cpp b/src/g_hexen/a_bishop.cpp index 68b5ce9d6..f80b91cbd 100644 --- a/src/g_hexen/a_bishop.cpp +++ b/src/g_hexen/a_bishop.cpp @@ -155,9 +155,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) DEFINE_ACTION_FUNCTION(AActor, A_BishopChase) { - self->z -= FloatBobOffsets[self->special2] >> 1; + self->z -= finesine[self->special2 << BOBTOFINESHIFT] * 4; self->special2 = (self->special2 + 4) & 63; - self->z += FloatBobOffsets[self->special2] >> 1; + self->z += finesine[self->special2 << BOBTOFINESHIFT] * 4; } //============================================================================ diff --git a/src/g_hexen/a_clericholy.cpp b/src/g_hexen/a_clericholy.cpp index 3d4d92a85..2b469e5af 100644 --- a/src/g_hexen/a_clericholy.cpp +++ b/src/g_hexen/a_clericholy.cpp @@ -144,17 +144,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) switch (j) { // float bob index case 0: - mo->special2 = pr_holyatk2()&7; // upper-left + mo->special2 = pr_holyatk2(8 << BOBTOFINESHIFT); // upper-left break; case 1: - mo->special2 = 32+(pr_holyatk2()&7); // upper-right + mo->special2 = FINEANGLES/2 + pr_holyatk2(8 << BOBTOFINESHIFT); // upper-right break; case 2: - mo->special2 = (32+(pr_holyatk2()&7))<<16; // lower-left + mo->special2 = (FINEANGLES/2 + pr_holyatk2(8 << BOBTOFINESHIFT)) << 16; // lower-left break; case 3: - i = pr_holyatk2(); - mo->special2 = ((32+(i&7))<<16)+32+(pr_holyatk2()&7); + i = pr_holyatk2(8 << BOBTOFINESHIFT); + mo->special2 = ((FINEANGLES/2 + i) << 16) + FINEANGLES/2 + pr_holyatk2(8 << BOBTOFINESHIFT); break; } mo->z = self->z; @@ -448,23 +448,19 @@ void CHolyWeave (AActor *actor, FRandom &pr_random) int weaveXY, weaveZ; int angle; - weaveXY = actor->special2>>16; - weaveZ = actor->special2&0xFFFF; - angle = (actor->angle+ANG90)>>ANGLETOFINESHIFT; - newX = actor->x-FixedMul(finecosine[angle], - FloatBobOffsets[weaveXY]<<2); - newY = actor->y-FixedMul(finesine[angle], - FloatBobOffsets[weaveXY]<<2); - weaveXY = (weaveXY+(pr_random()%5))&63; - newX += FixedMul(finecosine[angle], - FloatBobOffsets[weaveXY]<<2); - newY += FixedMul(finesine[angle], - FloatBobOffsets[weaveXY]<<2); + weaveXY = actor->special2 >> 16; + weaveZ = actor->special2 & FINEMASK; + angle = (actor->angle + ANG90) >> ANGLETOFINESHIFT; + newX = actor->x - FixedMul(finecosine[angle], finesine[weaveXY] * 32); + newY = actor->y - FixedMul(finesine[angle], finesine[weaveXY] * 32); + weaveXY = (weaveXY + pr_random(5 << BOBTOFINESHIFT)) & FINEMASK; + newX += FixedMul(finecosine[angle], finesine[weaveXY] * 32); + newY += FixedMul(finesine[angle], finesine[weaveXY] * 32); P_TryMove(actor, newX, newY, true); - actor->z -= FloatBobOffsets[weaveZ]<<1; - weaveZ = (weaveZ+(pr_random()%5))&63; - actor->z += FloatBobOffsets[weaveZ]<<1; - actor->special2 = weaveZ+(weaveXY<<16); + actor->z -= finesine[weaveZ] * 16; + weaveZ = (weaveZ + pr_random(5 << BOBTOFINESHIFT)) & FINEMASK; + actor->z += finesine[weaveZ] * 16; + actor->special2 = weaveZ + (weaveXY << 16); } //============================================================================ diff --git a/src/g_hexen/a_firedemon.cpp b/src/g_hexen/a_firedemon.cpp index d0366fdf0..c588dd2ae 100644 --- a/src/g_hexen/a_firedemon.cpp +++ b/src/g_hexen/a_firedemon.cpp @@ -134,8 +134,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) if (self->threshold) self->threshold--; // Float up and down - self->z += FloatBobOffsets[weaveindex]; - self->special1 = (weaveindex+2)&63; + self->z += finesine[weaveindex << BOBTOFINESHIFT] * 8; + self->special1 = (weaveindex + 2) & 63; // Ensure it stays above certain height if (self->z < self->floorz + (64*FRACUNIT)) diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 6efa342af..97f98f1df 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -422,8 +422,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagDamage) P_RadiusAttack (self, self->target, 4, 40, self->DamageType, true); bobIndex = self->special2; - self->z += FloatBobOffsets[bobIndex]>>4; - self->special2 = (bobIndex+1)&63; + self->z += finesine[bobIndex << BOBTOFINESHIFT] >> 1; + self->special2 = (bobIndex + 1) & 63; } //=========================================================================== diff --git a/src/g_hexen/a_fog.cpp b/src/g_hexen/a_fog.cpp index 3361deb65..6bafd383c 100644 --- a/src/g_hexen/a_fog.cpp +++ b/src/g_hexen/a_fog.cpp @@ -80,8 +80,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogMove) if ((self->args[3] % 4) == 0) { weaveindex = self->special2; - self->z += FloatBobOffsets[weaveindex]>>1; - self->special2 = (weaveindex+1)&63; + self->z += finesine[weaveindex << BOBTOFINESHIFT] * 4; + self->special2 = (weaveindex + 1) & 63; } angle = self->angle>>ANGLETOFINESHIFT; diff --git a/src/g_hexen/a_korax.cpp b/src/g_hexen/a_korax.cpp index 63b61c58e..a7d8908b2 100644 --- a/src/g_hexen/a_korax.cpp +++ b/src/g_hexen/a_korax.cpp @@ -174,7 +174,7 @@ void KSpiritInit (AActor *spirit, AActor *korax) spirit->health = KORAX_SPIRIT_LIFETIME; spirit->tracer = korax; // Swarm around korax - spirit->special2 = 32+(pr_kspiritinit()&7); // Float bob index + spirit->special2 = FINEANGLES/2 + pr_kspiritinit(8 << BOBTOFINESHIFT); // Float bob index spirit->args[0] = 10; // initial turn value spirit->args[1] = 0; // initial look angle diff --git a/src/g_hexen/a_wraith.cpp b/src/g_hexen/a_wraith.cpp index 219c3a6bb..b339f14be 100644 --- a/src/g_hexen/a_wraith.cpp +++ b/src/g_hexen/a_wraith.cpp @@ -226,8 +226,8 @@ void A_WraithFX4 (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_WraithChase) { int weaveindex = self->special1; - self->z += FloatBobOffsets[weaveindex]; - self->special1 = (weaveindex+2)&63; + self->z += finesine[weaveindex << BOBTOFINESHIFT] * 8; + self->special1 = (weaveindex + 2) & 63; // if (self->floorclip > 0) // { // P_SetMobjState(self, S_WRAITH_RAISE2); diff --git a/src/p_local.h b/src/p_local.h index 840336f80..205ec15c3 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -114,8 +114,6 @@ void P_UnPredictPlayer (); #define ONCEILINGZ FIXED_MAX #define FLOATRANDZ (FIXED_MAX-1) -extern fixed_t FloatBobOffsets[64]; - APlayerPawn *P_SpawnPlayer (struct FPlayerStart *mthing, int playernum, bool tempplayer=false); void P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index de409b03e..da023800d 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -119,27 +119,6 @@ CUSTOM_CVAR (Float, sv_gravity, 800.f, CVAR_SERVERINFO|CVAR_NOSAVE) CVAR (Bool, cl_missiledecals, true, CVAR_ARCHIVE) CVAR (Bool, addrocketexplosion, false, CVAR_ARCHIVE) - -fixed_t FloatBobOffsets[64] = -{ - 0, 51389, 102283, 152192, - 200636, 247147, 291278, 332604, - 370727, 405280, 435929, 462380, - 484378, 501712, 514213, 521763, - 524287, 521763, 514213, 501712, - 484378, 462380, 435929, 405280, - 370727, 332604, 291278, 247147, - 200636, 152192, 102283, 51389, - -1, -51390, -102284, -152193, - -200637, -247148, -291279, -332605, - -370728, -405281, -435930, -462381, - -484380, -501713, -514215, -521764, - -524288, -521764, -514214, -501713, - -484379, -462381, -435930, -405280, - -370728, -332605, -291279, -247148, - -200637, -152193, -102284, -51389 -}; - CVAR (Int, cl_pufftype, 0, CVAR_ARCHIVE); CVAR (Int, cl_bloodtype, 0, CVAR_ARCHIVE); diff --git a/src/tables.h b/src/tables.h index 929fabf80..04a66376e 100644 --- a/src/tables.h +++ b/src/tables.h @@ -44,14 +44,15 @@ #endif - +#define FINEANGLEBITS 13 #define FINEANGLES 8192 #define FINEMASK (FINEANGLES-1) - // 0x100000000 to 0x2000 #define ANGLETOFINESHIFT 19 +#define BOBTOFINESHIFT (FINEANGLEBITS - 6) + // Effective size is 10240. extern fixed_t finesine[5*FINEANGLES/4]; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 13d2739d3..e80fb3879 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3831,11 +3831,11 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis if (xydist != 0 && xyspeed != 0) { - dist = FixedMul(FloatBobOffsets[weaveXY], xydist); + dist = MulScale13(finesine[weaveXY << BOBTOFINESHIFT], xydist); newX = self->x - FixedMul (finecosine[angle], dist); newY = self->y - FixedMul (finesine[angle], dist); weaveXY = (weaveXY + xyspeed) & 63; - dist = FixedMul(FloatBobOffsets[weaveXY], xydist); + dist = MulScale13(finesine[weaveXY << BOBTOFINESHIFT], xydist); newX += FixedMul (finecosine[angle], dist); newY += FixedMul (finesine[angle], dist); if (!(self->flags5 & MF5_NOINTERACTION)) @@ -3852,12 +3852,11 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis } self->WeaveIndexXY = weaveXY; } - if (zdist != 0 && zspeed != 0) { - self->z -= FixedMul(FloatBobOffsets[weaveZ], zdist); + self->z -= MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist); weaveZ = (weaveZ + zspeed) & 63; - self->z += FixedMul(FloatBobOffsets[weaveZ], zdist); + self->z += MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist); self->WeaveIndexZ = weaveZ; } }