diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 3d1a7de2f..2f1de0b1e 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4469,10 +4469,9 @@ static void ProcessTouchObjects(DBloodActor* actor) // //--------------------------------------------------------------------------- -void actAirDrag(DBloodActor* actor, int a2) +void actAirDrag(DBloodActor* actor, fixed_t drag) { - int wind_x = 0; - int wind_y = 0; + DVector2 windvel{}; assert(actor->sector()); sectortype* pSector = actor->sector(); if (pSector->hasX()) @@ -4480,15 +4479,12 @@ void actAirDrag(DBloodActor* actor, int a2) XSECTOR* pXSector = &pSector->xs(); if (pXSector->windVel && (pXSector->windAlways || pXSector->busy)) { - int wind = pXSector->windVel << 12; - if (!pXSector->windAlways && pXSector->busy) wind = MulScale(wind, pXSector->busy, 16); - wind_x = MulScale(wind, Cos(pXSector->windAng), 30); - wind_y = MulScale(wind, Sin(pXSector->windAng), 30); + double wind = FixedToFloat<4>(pXSector->windVel); + if (!pXSector->windAlways && pXSector->busy) wind *= FixedToFloat(pXSector->busy); + windvel = pXSector->windAng.ToVector() * wind; } } - actor->add_int_bvel_x(MulScale(wind_x - actor->int_vel().X, a2, 16)); - actor->add_int_bvel_y(MulScale(wind_y - actor->int_vel().Y, a2, 16)); - actor->add_int_bvel_z(-MulScale(actor->int_vel().Z, a2, 16)); + actor->vel += DVector3(windvel - actor->vel.XY(), -actor->vel.Z) * FixedToFloat(drag); } //--------------------------------------------------------------------------- @@ -5640,7 +5636,7 @@ static void actCheckThings() GetActorExtents(actor, &top, &bottom); if (getflorzofslopeptr(pSector, actor->spr.pos) <= bottom) { - int angle = pXSector->panAngle; + int angle = pXSector->panAngle.Buildang(); int speed = 0; if (pXSector->panAlways || pXSector->state || pXSector->busy) { @@ -6065,7 +6061,7 @@ static void actCheckDudes() GetActorExtents(actor, &top, &bottom); if (getflorzofslopeptr(pSector, actor->spr.pos) <= bottom) { - int angle = pXSector->panAngle; + int angle = pXSector->panAngle.Buildang(); int speed = 0; if (pXSector->panAlways || pXSector->state || pXSector->busy) { diff --git a/source/games/blood/src/actor.h b/source/games/blood/src/actor.h index 76345e58b..c2d69db80 100644 --- a/source/games/blood/src/actor.h +++ b/source/games/blood/src/actor.h @@ -218,7 +218,7 @@ bool actHealDude(DBloodActor* pXDude, int a2, int a3); void actKillDude(DBloodActor* a1, DBloodActor* pSprite, DAMAGE_TYPE a3, int a4); int actDamageSprite(DBloodActor* pSource, DBloodActor* pTarget, DAMAGE_TYPE damageType, int damage); void actHitcodeToData(int a1, HitInfo *pHitInfo, DBloodActor **actor, walltype **a7 = nullptr); -void actAirDrag(DBloodActor *pSprite, int a2); +void actAirDrag(DBloodActor *pSprite, fixed_t drag); void actExplodeSprite(DBloodActor *pSprite); void actActivateGibObject(DBloodActor *actor); void actProcessSprites(void); diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index 151271103..5654e9570 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -329,7 +329,7 @@ void dbLoadMap(const char* pPath, DVector3& pos, short* pAngle, int* cursectnum, pXSector->Underwater = bitReader.readUnsigned(1); pXSector->Depth = bitReader.readUnsigned(3); pXSector->panVel = bitReader.readUnsigned(8); - pXSector->panAngle = bitReader.readUnsigned(11); + pXSector->panAngle = mapangle(bitReader.readUnsigned(11)); pXSector->unused1 = bitReader.readUnsigned(1); pXSector->decoupled = bitReader.readUnsigned(1); pXSector->triggerOnce = bitReader.readUnsigned(1); @@ -363,7 +363,7 @@ void dbLoadMap(const char* pPath, DVector3& pos, short* pAngle, int* cursectnum, pSector->floorypan_ += bitReader.readUnsigned(8) / 256.f; pXSector->locked = bitReader.readUnsigned(1); pXSector->windVel = bitReader.readUnsigned(10); - pXSector->windAng = bitReader.readUnsigned(11); + pXSector->windAng = mapangle(bitReader.readUnsigned(11)); pXSector->windAlways = bitReader.readUnsigned(1); pXSector->dudeLockout = bitReader.readUnsigned(1); pXSector->bobTheta = bitReader.readUnsigned(11); diff --git a/source/games/blood/src/mapstructs.h b/source/games/blood/src/mapstructs.h index 423bc091c..b58f34537 100644 --- a/source/games/blood/src/mapstructs.h +++ b/source/games/blood/src/mapstructs.h @@ -201,10 +201,10 @@ struct XSECTOR { uint16_t rxID; // RX ID uint16_t busyTimeA; // OFF->ON busyTime uint16_t waitTimeA; // OFF->ON waitTime - uint16_t panAngle; // Motion angle + DAngle panAngle; // Motion angle uint16_t busyTimeB; // ON->OFF busyTime uint16_t waitTimeB; // ON->OFF waitTime - uint16_t windAng; // Wind ang + DAngle windAng; // Wind ang uint16_t bobTheta; // Motion Theta int16_t bobSpeed; // Motion speed diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 30f3acb45..b0f3d9c23 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1303,7 +1303,7 @@ void nnExtProcessSuperSprites() if ((uwater = pXSector->Underwater) != 0) airVel <<= 6; if (pXSector->panVel != 0 && getflorzofslopeptrf(debrisactor->sector(), debrisactor->spr.pos) <= bottom) { - int angle = pXSector->panAngle; int speed = 0; + int angle = pXSector->panAngle.Buildang(); int speed = 0; if (pXSector->panAlways || pXSector->state || pXSector->busy) { speed = pXSector->panVel << 9; @@ -3470,7 +3470,7 @@ void useSectorWindGen(DBloodActor* sourceactor, sectortype* pSector) sourceactor->set_int_ang(ClipLow(ang, -kAng180)); } - pXSector->windAng = sourceactor->int_ang(); + pXSector->windAng = sourceactor->spr.angle; if (sourceactor->xspr.data3 > 0 && sourceactor->xspr.data3 < 4) { diff --git a/source/games/blood/src/sectorfx.cpp b/source/games/blood/src/sectorfx.cpp index ce66a0d4d..5c67fb329 100644 --- a/source/games/blood/src/sectorfx.cpp +++ b/source/games/blood/src/sectorfx.cpp @@ -277,7 +277,7 @@ void DoSectorPanning(void) XSECTOR* pXSector = &pSector->xs(); if (pXSector->panAlways || pXSector->busy) { - int angle = pXSector->panAngle + 1024; + int angle = pXSector->panAngle.Buildang() + 1024; int speed = pXSector->panVel << 10; if (!pXSector->panAlways && (pXSector->busy & 0xffff)) speed = MulScale(speed, pXSector->busy, 16);