diff --git a/src/actor.h b/src/actor.h index 76301fb3d..0019aa8dc 100644 --- a/src/actor.h +++ b/src/actor.h @@ -600,7 +600,7 @@ public: // Adjusts the angle for deflection/reflection of incoming missiles // Returns true if the missile should be allowed to explode anyway - bool AdjustReflectionAngle (AActor *thing, angle_t &angle); + bool AdjustReflectionAngle (AActor *thing, DAngle &angle); // Returns true if this actor is within melee range of its target bool CheckMeleeRange(); @@ -782,9 +782,9 @@ public: } // These also set CF_INTERPVIEW for players. - void SetPitch(int p, bool interpolate, bool forceclamp = false); - void SetAngle(angle_t ang, bool interpolate); - void SetRoll(angle_t roll, bool interpolate); + void SetPitch(DAngle p, bool interpolate, bool forceclamp = false); + void SetAngle(DAngle ang, bool interpolate); + void SetRoll(DAngle roll, bool interpolate); PClassActor *GetBloodType(int type = 0) const { @@ -872,6 +872,18 @@ public: return R_PointToAngle2(X(), Y(), other->X() + oxofs, other->Y() + oyofs); } + DAngle _f_AngleTo(AActor *other, bool absolute = false) + { + fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); + return g_atan2(otherpos.y - Y(), otherpos.x - X()); + } + + DAngle _f_AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const + { + fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); + return g_atan2(otherpos.y + oxofs - Y(), otherpos.x + oyofs - X()); + } + fixedvec2 Vec2To(AActor *other) const { fixedvec3 otherpos = other->PosRelative(this); @@ -973,7 +985,20 @@ public: AActor *snext, **sprev; // links in sector (if needed) fixedvec3 __pos; // double underscores so that it won't get used by accident. Access to this should be exclusively through the designated access functions. + /* angle_t angle; + fixed_t pitch; + angle_t roll; // This was fixed_t before, which is probably wrong + */ + + DRotator Angles; + + // intentionally stange names so that searching for them is easier. + angle_t _f_angle() { return FLOAT2ANGLE(Angles.Yaw.Degrees); } + int _f_pitch() { return FLOAT2ANGLE(Angles.Pitch.Degrees); } + angle_t _f_roll() { return FLOAT2ANGLE(Angles.Roll.Degrees); } + + WORD sprite; // used to find patch_t and flip value BYTE frame; // sprite frame to draw fixed_t scaleX, scaleY; // Scaling values; FRACUNIT is normal size @@ -985,8 +1010,6 @@ public: DWORD fillcolor; // Color to draw when STYLE_Shaded // interaction info - fixed_t pitch; - angle_t roll; // This was fixed_t before, which is probably wrong FBlockNode *BlockNode; // links in blocks (if needed) struct sector_t *Sector; subsector_t * subsector; @@ -1148,7 +1171,8 @@ public: // [RH] Used to interpolate the view to get >35 FPS fixed_t PrevX, PrevY, PrevZ; - angle_t PrevAngle; + //angle_t PrevAngle; + DRotator PrevAngles; int PrevPortalGroup; // ThingIDs @@ -1284,6 +1308,56 @@ public: __pos.y = npos.y; __pos.z = npos.z; } + + fixed_t VelXYToSpeed() const + { + return xs_CRoundToInt(sqrt((double)vel.x * vel.x + (double)vel.y*vel.y)); + } + + fixed_t VelToSpeed() const + { + return xs_CRoundToInt(sqrt((double)vel.x * vel.x + (double)vel.y*vel.y + (double)vel.z*vel.z)); + } + + void AngleFromVel() + { + Angles.Yaw = vectoyaw(DVector2(vel.x, vel.y)); + } + + void VelFromAngle() + { + vel.x = xs_CRoundToInt(Speed * Angles.Yaw.Cos()); + vel.y = xs_CRoundToInt(Speed * Angles.Yaw.Sin()); + } + + void VelFromAngle(fixed_t speed) + { + vel.x = xs_CRoundToInt(speed * Angles.Yaw.Cos()); + vel.y = xs_CRoundToInt(speed * Angles.Yaw.Sin()); + } + + void VelFromAngle(DAngle angle, fixed_t speed) + { + vel.x = xs_CRoundToInt(speed * angle.Cos()); + vel.y = xs_CRoundToInt(speed * angle.Sin()); + } + + void Vel3DFromAngle(DAngle angle, DAngle pitch, fixed_t speed) + { + double cospitch = pitch.Cos(); + vel.x = xs_CRoundToInt(speed * cospitch * angle.Cos()); + vel.y = xs_CRoundToInt(speed * cospitch * angle.Sin()); + vel.z = xs_CRoundToInt(speed * -pitch.Sin()); + } + + void Vel3DFromAngle(DAngle pitch, fixed_t speed) + { + double cospitch = pitch.Cos(); + vel.x = xs_CRoundToInt(speed * cospitch * Angles.Yaw.Cos()); + vel.y = xs_CRoundToInt(speed * cospitch * Angles.Yaw.Sin()); + vel.z = xs_CRoundToInt(speed * -pitch.Sin()); + } + }; class FActorIterator @@ -1394,6 +1468,11 @@ inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle) return ret; } +inline fixedvec2 Vec2Angle(fixed_t length, DAngle angle) +{ + return { xs_CRoundToInt(length * angle.Cos()), xs_CRoundToInt(length * angle.Sin()) }; +} + void PrintMiscActorInfo(AActor * query); AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, ActorFlags actorMask, DWORD wallMask); @@ -1401,7 +1480,7 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, struct FTranslatedLineTarget { AActor *linetarget; - angle_t angleFromSource; + DAngle angleFromSource; bool unlinked; // found by a trace that went through an unlinked portal. }; diff --git a/src/am_map.cpp b/src/am_map.cpp index 8fab7e5ac..02b34b9cf 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1129,7 +1129,7 @@ static void AM_ClipRotatedExtents (fixed_t pivotx, fixed_t pivoty) { xs[i] -= pivotx; ys[i] -= pivoty; - AM_rotate (&xs[i], &ys[i], ANG90 - players[consoleplayer].camera->angle); + AM_rotate (&xs[i], &ys[i], ANG90 - players[consoleplayer].camera->_f_angle()); if (i == 5) break; @@ -1150,7 +1150,7 @@ static void AM_ClipRotatedExtents (fixed_t pivotx, fixed_t pivoty) // ys[4] = rmax_y; // else if (ys[4] < rmin_y) // ys[4] = rmin_y; - AM_rotate (&xs[4], &ys[4], ANG270 - players[consoleplayer].camera->angle); + AM_rotate (&xs[4], &ys[4], ANG270 - players[consoleplayer].camera->_f_angle()); m_x = xs[4] + pivotx - m_w/2; m_y = ys[4] + pivoty - m_h/2; #endif @@ -1216,7 +1216,7 @@ void AM_changeWindowLoc () oincy = incy = Scale(m_paninc.y, SCREENHEIGHT, 200); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - AM_rotate(&incx, &incy, players[consoleplayer].camera->angle - ANG90); + AM_rotate(&incx, &incy, players[consoleplayer].camera->_f_angle() - ANG90); } m_x += incx; @@ -1598,7 +1598,7 @@ void AM_doFollowPlayer () sy = (f_oldloc.y - players[consoleplayer].camera->Y()) >> FRACTOMAPBITS; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - AM_rotate (&sx, &sy, players[consoleplayer].camera->angle - ANG90); + AM_rotate (&sx, &sy, players[consoleplayer].camera->_f_angle() - ANG90); } AM_ScrollParchment (sx, sy); @@ -2042,7 +2042,7 @@ void AM_drawSubsectors() // Apply the automap's rotation to the texture origin. if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - rotation += ANG90 - players[consoleplayer].camera->angle; + rotation += ANG90 - players[consoleplayer].camera->_f_angle(); AM_rotatePoint(&originpt.x, &originpt.y); } originx = f_x + ((originpt.x - m_x) * scale / float(1 << 24)); @@ -2588,7 +2588,7 @@ void AM_rotatePoint (fixed_t *x, fixed_t *y) fixed_t pivoty = m_y + m_h/2; *x -= pivotx; *y -= pivoty; - AM_rotate (x, y, ANG90 - players[consoleplayer].camera->angle); + AM_rotate (x, y, ANG90 - players[consoleplayer].camera->_f_angle()); *x += pivotx; *y += pivoty; } @@ -2678,7 +2678,7 @@ void AM_drawPlayers () } else { - angle = players[consoleplayer].camera->angle; + angle = players[consoleplayer].camera->_f_angle(); } if (am_cheat != 0 && CheatMapArrow.Size() > 0) @@ -2736,12 +2736,12 @@ void AM_drawPlayers () pt.x = pos.x >> FRACTOMAPBITS; pt.y = pos.y >> FRACTOMAPBITS; - angle = p->mo->angle; + angle = p->mo->_f_angle(); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&pt.x, &pt.y); - angle -= players[consoleplayer].camera->angle - ANG90; + angle -= players[consoleplayer].camera->_f_angle() - ANG90; } AM_drawLineCharacter(&MapArrow[0], MapArrow.Size(), 0, angle, color, pt.x, pt.y); @@ -2770,12 +2770,12 @@ void AM_drawKeys () p.x = pos.x >> FRACTOMAPBITS; p.y = pos.y >> FRACTOMAPBITS; - angle = key->angle; + angle = key->_f_angle(); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&p.x, &p.y); - angle += ANG90 - players[consoleplayer].camera->angle; + angle += ANG90 - players[consoleplayer].camera->_f_angle(); } if (key->flags & MF_SPECIAL) @@ -2830,11 +2830,11 @@ void AM_drawThings () const size_t spriteIndex = sprite.spriteframes + (show > 1 ? t->frame : 0); frame = &SpriteFrames[spriteIndex]; - angle_t angle = ANGLE_270 - t->angle; + angle_t angle = ANGLE_270 - t->_f_angle(); if (frame->Texture[0] != frame->Texture[1]) angle += (ANGLE_180 / 16); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - angle += players[consoleplayer].camera->angle - ANGLE_90; + angle += players[consoleplayer].camera->_f_angle() - ANGLE_90; } rotation = angle >> 28; @@ -2853,12 +2853,12 @@ void AM_drawThings () else { drawTriangle: - angle = t->angle; + angle = t->_f_angle(); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&p.x, &p.y); - angle += ANG90 - players[consoleplayer].camera->angle; + angle += ANG90 - players[consoleplayer].camera->_f_angle(); } color = AMColors[AMColors.ThingColor]; @@ -2920,7 +2920,7 @@ void AM_drawThings () { { -MAPUNIT, MAPUNIT }, { -MAPUNIT, -MAPUNIT } }, }; - AM_drawLineCharacter (box, 4, t->radius >> FRACTOMAPBITS, angle - t->angle, color, p.x, p.y); + AM_drawLineCharacter (box, 4, t->radius >> FRACTOMAPBITS, angle - t->_f_angle(), color, p.x, p.y); } } } diff --git a/src/b_func.cpp b/src/b_func.cpp index 70ffadce8..62f2eb89b 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -127,7 +127,7 @@ bool DBot::Check_LOS (AActor *to, angle_t vangle) if (vangle == 0) return false; //Looker seems to be blind. - return absangle(player->mo->AngleTo(to) - player->mo->angle) <= vangle/2; + return absangle(player->mo->AngleTo(to) - player->mo->_f_angle()) <= vangle/2; } //------------------------------------- @@ -212,7 +212,7 @@ void DBot::Dofire (ticcmd_t *cmd) { angle = an; //have to be somewhat precise. to avoid suicide. - if (absangle(angle - player->mo->angle) < 12*ANGLE_1) + if (absangle(angle - player->mo->_f_angle()) < 12*ANGLE_1) { t_rocket = 9; no_fire = false; @@ -254,7 +254,7 @@ shootmissile: angle -= m; } - if (absangle(angle - player->mo->angle) < 4*ANGLE_1) + if (absangle(angle - player->mo->_f_angle()) < 4*ANGLE_1) { increase = !increase; } @@ -456,7 +456,7 @@ void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum) // //Returns NULL if shouldn't fire //else an angle (in degrees) are given -//This function assumes actor->player->angle +//This function assumes actor->player->_f_angle() //has been set an is the main aiming angle. diff --git a/src/b_move.cpp b/src/b_move.cpp index 3a4cf3c3a..02fd77049 100644 --- a/src/b_move.cpp +++ b/src/b_move.cpp @@ -305,13 +305,13 @@ bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm return true; } -#define OKAYRANGE (5*ANGLE_1) //counts *2, when angle is in range, turning is not executed. -#define MAXTURN (15*ANGLE_1) //Max degrees turned in one tic. Lower is smother but may cause the bot not getting where it should = crash +#define OKAYRANGE (5) //counts *2, when angle is in range, turning is not executed. +#define MAXTURN (15) //Max degrees turned in one tic. Lower is smother but may cause the bot not getting where it should = crash #define TURNSENS 3 //Higher is smoother but slower turn. void DBot::TurnToAng () { - int maxturn = MAXTURN; + double maxturn = MAXTURN; if (player->ReadyWeapon != NULL) { @@ -331,16 +331,16 @@ void DBot::TurnToAng () maxturn = 3; } - int distance = angle - player->mo->angle; + DAngle distance = deltaangle(player->mo->Angles.Yaw, ANGLE2DBL(angle)); - if (abs (distance) < OKAYRANGE && !enemy) + if (fabs (distance) < OKAYRANGE && !enemy) return; distance /= TURNSENS; - if (abs (distance) > maxturn) + if (fabs (distance) > maxturn) distance = distance < 0 ? -maxturn : maxturn; - player->mo->angle += distance; + player->mo->Angles.Yaw += distance; } void DBot::Pitch (AActor *target) @@ -350,7 +350,7 @@ void DBot::Pitch (AActor *target) diff = target->Z() - player->mo->Z(); aim = g_atan(diff / (double)player->mo->AproxDistance(target)); - player->mo->pitch = -(int)(aim * ANGLE_180/M_PI); + player->mo->Angles.Pitch = ToDegrees(aim); } //Checks if a sector is dangerous. diff --git a/src/b_think.cpp b/src/b_think.cpp index 88c17fd87..eb7acf3a2 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -20,6 +20,7 @@ #include "d_net.h" #include "d_event.h" #include "d_player.h" +#include "vectors.h" static FRandom pr_botmove ("BotMove"); @@ -39,20 +40,21 @@ void DBot::Think () if (teamplay || !deathmatch) mate = Choose_Mate (); - angle_t oldyaw = player->mo->angle; - int oldpitch = player->mo->pitch; + AActor *actor = player->mo; + DAngle oldyaw = actor->Angles.Yaw; + DAngle oldpitch = actor->Angles.Pitch; Set_enemy (); ThinkForMove (cmd); TurnToAng (); - cmd->ucmd.yaw = (short)((player->mo->angle - oldyaw) >> 16) / ticdup; - cmd->ucmd.pitch = (short)((oldpitch - player->mo->pitch) >> 16); + cmd->ucmd.yaw = (short)((actor->Angles.Yaw - oldyaw).Degrees * (65536 / 360.f)) / ticdup; + cmd->ucmd.pitch = (short)((oldpitch - actor->Angles.Pitch).Degrees * (65536 / 360.f)); if (cmd->ucmd.pitch == -32768) cmd->ucmd.pitch = -32767; cmd->ucmd.pitch /= ticdup; - player->mo->angle = oldyaw + (cmd->ucmd.yaw << 16) * ticdup; - player->mo->pitch = oldpitch - (cmd->ucmd.pitch << 16) * ticdup; + actor->Angles.Yaw = oldyaw + DAngle(cmd->ucmd.yaw * ticdup * (360 / 65536.f)); + actor->Angles.Pitch = oldpitch - DAngle(cmd->ucmd.pitch * ticdup * (360 / 65536.f)); } if (t_active) t_active--; @@ -91,10 +93,10 @@ void DBot::ThinkForMove (ticcmd_t *cmd) missile = NULL; //Probably ended its travel. } - if (player->mo->pitch > 0) - player->mo->pitch -= 80; - else if (player->mo->pitch <= -60) - player->mo->pitch += 80; + if (player->mo->Angles.Pitch > 0) + player->mo->Angles.Pitch -= 80; + else if (player->mo->Angles.Pitch <= -60) + player->mo->Angles.Pitch += 80; //HOW TO MOVE: if (missile && (player->mo->AproxDistance(missile)angle,MISSILERANGE, &t, 0); + P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->_f_angle(),MISSILERANGE, &t, 0); if (t.linetarget) { Printf("Target=%s, Health=%d, Spawnhealth=%d\n", @@ -892,7 +892,7 @@ CCMD(info) FTranslatedLineTarget t; if (CheckCheatmode () || players[consoleplayer].mo == NULL) return; - P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->angle,MISSILERANGE, + P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->_f_angle(),MISSILERANGE, &t, 0, ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART); if (t.linetarget) { @@ -1087,7 +1087,7 @@ CCMD(currentpos) if(mo) { Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", - FIXED2DBL(mo->X()), FIXED2DBL(mo->Y()), FIXED2DBL(mo->Z()), ANGLE2DBL(mo->angle), FIXED2DBL(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); + FIXED2DBL(mo->X()), FIXED2DBL(mo->Y()), FIXED2DBL(mo->Z()), ANGLE2DBL(mo->_f_angle()), FIXED2DBL(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); } else { diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 8c456517e..6ad966682 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1342,7 +1342,7 @@ static int PatchSound (int soundNum) else CHECKKEY ("Zero/One", info->singularity) else CHECKKEY ("Value", info->priority) else CHECKKEY ("Zero 1", info->link) - else CHECKKEY ("Neg. One 1", info->pitch) + else CHECKKEY ("Neg. One 1", info->_f_pitch()) else CHECKKEY ("Neg. One 2", info->volume) else CHECKKEY ("Zero 2", info->data) else CHECKKEY ("Zero 3", info->usefulness) diff --git a/src/d_net.cpp b/src/d_net.cpp index 4d8e33d3d..1e8906e86 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2321,7 +2321,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) else { const AActor *def = GetDefaultByType (typeinfo); - fixedvec3 spawnpos = source->Vec3Angle(def->radius * 2 + source->radius, source->angle, 8 * FRACUNIT); + fixedvec3 spawnpos = source->Vec3Angle(def->radius * 2 + source->radius, source->_f_angle(), 8 * FRACUNIT); AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE); if (spawned != NULL) @@ -2348,7 +2348,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) } if (type >= DEM_SUMMON2 && type <= DEM_SUMMONFOE2) { - spawned->angle = source->angle - (ANGLE_1 * angle); + spawned->Angles.Yaw -= angle; spawned->tid = tid; spawned->special = special; for(i = 0; i < 5; i++) { @@ -2366,8 +2366,8 @@ void Net_DoCommand (int type, BYTE **stream, int player) { FTraceResults trace; - angle_t ang = players[player].mo->angle >> ANGLETOFINESHIFT; - angle_t pitch = (angle_t)(players[player].mo->pitch) >> ANGLETOFINESHIFT; + angle_t ang = players[player].mo->_f_angle() >> ANGLETOFINESHIFT; + angle_t pitch = (angle_t)(players[player].mo->_f_pitch()) >> ANGLETOFINESHIFT; fixed_t vx = FixedMul (finecosine[pitch], finecosine[ang]); fixed_t vy = FixedMul (finecosine[pitch], finesine[ang]); fixed_t vz = -finesine[pitch]; @@ -2656,8 +2656,8 @@ void Net_DoCommand (int type, BYTE **stream, int player) break; case DEM_SETPITCHLIMIT: - players[player].MinPitch = ReadByte(stream) * -ANGLE_1; // up - players[player].MaxPitch = ReadByte(stream) * ANGLE_1; // down + players[player].MinPitch = ReadByte(stream); // up + players[player].MaxPitch = ReadByte(stream); // down break; case DEM_ADVANCEINTER: diff --git a/src/d_player.h b/src/d_player.h index 749736996..1102dd05a 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -488,8 +488,8 @@ public: FString LogText; // [RH] Log for Strife - int MinPitch; // Viewpitch limits (negative is up, positive is down) - int MaxPitch; + DAngle MinPitch; // Viewpitch limits (negative is up, positive is down) + DAngle MaxPitch; fixed_t crouchfactor; fixed_t crouchoffset; @@ -499,7 +499,7 @@ public: // [CW] I moved these here for multiplayer conversation support. TObjPtr ConversationNPC, ConversationPC; - angle_t ConversationNPCAngle; + DAngle ConversationNPCAngle; bool ConversationFaceTalker; fixed_t GetDeltaViewHeight() const diff --git a/src/farchive.cpp b/src/farchive.cpp index 8fd647fd2..c47c98cf1 100644 --- a/src/farchive.cpp +++ b/src/farchive.cpp @@ -1532,3 +1532,18 @@ FArchive &operator<< (FArchive &arc, side_t *&side) { return arc.SerializePointer (sides, (BYTE **)&side, sizeof(*sides)); } + +FArchive &operator<<(FArchive &arc, DAngle &ang) +{ + if (SaveVersion >= 4534) + { + arc << ang.Degrees; + } + else + { + angle_t an; + arc << an; + ang.Degrees = ANGLE2DBL(an); + } + return arc; +} diff --git a/src/farchive.h b/src/farchive.h index b646827de..c08ba525f 100644 --- a/src/farchive.h +++ b/src/farchive.h @@ -324,6 +324,8 @@ FArchive &operator<< (FArchive &arc, line_t *&line); FArchive &operator<< (FArchive &arc, vertex_t *&vert); FArchive &operator<< (FArchive &arc, side_t *&side); +FArchive &operator<<(FArchive &arc, DAngle &ang); + template diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 576bcb31a..a3c2274b0 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -864,7 +864,7 @@ void FParser::SF_Spawn(void) { int x, y, z; PClassActor *pclass; - angle_t angle = 0; + DAngle angle = 0; if (CheckArgs(3)) { @@ -890,7 +890,7 @@ void FParser::SF_Spawn(void) if(t_argc >= 4) { - angle = intvalue(t_argv[3]) * (SQWORD)ANG45 / 45; + angle = floatvalue(t_argv[3]); } t_return.type = svt_mobj; @@ -898,7 +898,7 @@ void FParser::SF_Spawn(void) if (t_return.value.mobj) { - t_return.value.mobj->angle = angle; + t_return.value.mobj->Angles.Yaw = angle; if (!DFraggleThinker::ActiveThinker->nocheckposition) { @@ -1054,7 +1054,7 @@ void FParser::SF_ObjAngle(void) } t_return.type = svt_fixed; // haleyjd: fixed-point -- SoM again :) - t_return.value.f = mo ? (fixed_t)AngleToFixed(mo->angle) : 0; // null ptr check + t_return.value.f = mo ? (fixed_t)AngleToFixed(mo->_f_angle()) : 0; // null ptr check } @@ -1449,7 +1449,7 @@ void FParser::SF_PointToDist(void) void FParser::SF_SetCamera(void) { - angle_t angle; + DAngle angle; player_t * player; AActor * newcamera; @@ -1465,20 +1465,14 @@ void FParser::SF_SetCamera(void) return; // nullptr check } - angle = t_argc < 2 ? newcamera->angle : (fixed_t)FixedToAngle(fixedvalue(t_argv[1])); + angle = t_argc < 2 ? newcamera->Angles.Yaw : floatvalue(t_argv[1]); - newcamera->special1=newcamera->angle; + newcamera->special1 = newcamera->Angles.Yaw.BAMs(); newcamera->special2=newcamera->Z(); newcamera->SetZ(t_argc < 3 ? (newcamera->Z() + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS)); - newcamera->angle = angle; - if(t_argc < 4) newcamera->pitch = 0; - else - { - fixed_t pitch = fixedvalue(t_argv[3]); - if (pitch < -50 * FRACUNIT) pitch = -50 * FRACUNIT; - if (pitch > 50 * FRACUNIT) pitch = 50 * FRACUNIT; - newcamera->pitch = xs_CRoundToUInt((pitch / 65536.0f)*(ANGLE_45 / 45.0f)*(20.0f / 32.0f)); - } + newcamera->Angles.Yaw = angle; + if (t_argc < 4) newcamera->Angles.Pitch = 0; + else newcamera->Angles.Pitch = clamp(floatvalue(t_argv[3]), -50., 50.) * (20. / 32.); player->camera=newcamera; } } @@ -1499,7 +1493,7 @@ void FParser::SF_ClearCamera(void) if (cam) { player->camera=player->mo; - cam->angle=cam->special1; + cam->Angles.Yaw = ANGLE2DBL(cam->special1); cam->SetZ(cam->special2); } @@ -3115,15 +3109,16 @@ void FParser::SF_MoveCamera(void) //180--+--0 // Q2|Q3 // 270 + angle_t camangle = cam->Angles.Yaw.BAMs(); quad1 = targetangle / ANG90; - quad2 = cam->angle / ANG90; - bigangle = targetangle > cam->angle ? targetangle : cam->angle; - smallangle = targetangle < cam->angle ? targetangle : cam->angle; + quad2 = camangle / ANG90; + bigangle = targetangle > camangle ? targetangle : camangle; + smallangle = targetangle < camangle ? targetangle : camangle; if((quad1 > quad2 && quad1 - 1 == quad2) || (quad2 > quad1 && quad2 - 1 == quad1) || quad1 == quad2) { angledist = bigangle - smallangle; - angledir = targetangle > cam->angle ? 1 : -1; + angledir = targetangle > cam->_f_angle() ? 1 : -1; } else { @@ -3145,10 +3140,10 @@ void FParser::SF_MoveCamera(void) if(angledist > ANG180) { angledist = diff180; - angledir = targetangle > cam->angle ? -1 : 1; + angledir = targetangle > camangle ? -1 : 1; } else - angledir = targetangle > cam->angle ? 1 : -1; + angledir = targetangle > camangle ? 1 : -1; } } @@ -3203,17 +3198,17 @@ void FParser::SF_MoveCamera(void) } if(anglestep >= angledist) - cam->angle = targetangle; + cam->Angles.Yaw = ANGLE2DBL(targetangle); else { if(angledir == 1) { - cam->angle += anglestep; + cam->Angles.Yaw += ANGLE2DBL(anglestep); moved = 1; } else if(angledir == -1) { - cam->angle -= anglestep; + cam->Angles.Yaw -= ANGLE2DBL(anglestep); moved = 1; } } @@ -4288,7 +4283,7 @@ void FParser::SF_SpawnShot2(void) { S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM); mo->target = source; - P_ThrustMobj(mo, mo->angle = source->angle, mo->Speed); + P_ThrustMobj(mo, (mo->Angles.Yaw = source->Angles.Yaw), mo->Speed); if (!P_CheckMissileSpawn(mo, source->radius)) mo = NULL; } t_return.value.mobj = mo; diff --git a/src/g_doom/a_archvile.cpp b/src/g_doom/a_archvile.cpp index 11cbcf15d..bf1ff0bde 100644 --- a/src/g_doom/a_archvile.cpp +++ b/src/g_doom/a_archvile.cpp @@ -68,7 +68,7 @@ void A_Fire(AActor *self, int height) if (!P_CheckSight (self->target, dest, 0) ) return; - fixedvec3 newpos = dest->Vec3Angle(24 * FRACUNIT, dest->angle, height); + fixedvec3 newpos = dest->Vec3Angle(24 * FRACUNIT, dest->_f_angle(), height); self->SetOrigin(newpos, true); } @@ -147,7 +147,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack) if (fire != NULL) { // move the fire between the vile and the player - fixedvec3 pos = target->Vec3Angle(-24 * FRACUNIT, self->angle, 0); + fixedvec3 pos = target->Vec3Angle(-24 * FRACUNIT, self->_f_angle(), 0); fire->SetOrigin (pos, true); P_RadiusAttack (fire, self, blastdmg, blastrad, dmgtype, 0); diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index b43b5a1d5..43feadc93 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -50,7 +50,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch) if (self->FindInventory()) damage *= 10; - angle = self->angle; + angle = self->_f_angle(); angle += pr_punch.Random2() << 18; pitch = P_AimLineAttack (self, angle, MELEERANGE); @@ -61,7 +61,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch) if (t.linetarget) { S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM); - self->angle = t.angleFromSource; + self->Angles.Yaw = t.angleFromSource; } return 0; } @@ -158,7 +158,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) range = MELEERANGE+1; } - angle = self->angle + (pr_saw.Random2() * (spread_xy / 255)); + angle = self->_f_angle() + (pr_saw.Random2() * (spread_xy / 255)); slope = P_AimLineAttack (self, angle, range, &t) + (pr_saw.Random2() * (spread_z / 255)); AWeapon *weapon = self->player->ReadyWeapon; @@ -232,20 +232,21 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) // turn to face target if (!(flags & SF_NOTURN)) { - angle = t.angleFromSource; - if (angle - self->angle > ANG180) + DAngle anglediff = deltaangle(self->Angles.Yaw, t.angleFromSource); + + if (anglediff < 0.0) { - if (angle - self->angle < (angle_t)(-ANG90 / 20)) - self->angle = angle + ANG90 / 21; + if (anglediff < -4.5) + self->Angles.Yaw = angle + 90.0 / 21; else - self->angle -= ANG90 / 20; + self->Angles.Yaw -= 4.5; } else { - if (angle - self->angle > ANG90 / 20) - self->angle = angle - ANG90 / 21; + if (anglediff > 4.5) + self->Angles.Yaw = angle - 90.0 / 21; else - self->angle += ANG90 / 20; + self->Angles.Yaw += 4.5; } } if (!(flags & SF_NOPULLIN)) @@ -320,7 +321,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2) for (i=0 ; i<20 ; i++) { damage = 5*(pr_fireshotgun2()%3+1); - angle = self->angle; + angle = self->_f_angle(); angle += pr_fireshotgun2.Random2() << 19; // Doom adjusts the bullet slope by shifting a random number [-255,255] @@ -501,10 +502,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade) } // Temporarily raise the pitch to send the grenade slightly upwards - fixed_t SavedPlayerPitch = self->pitch; - self->pitch -= (1152 << FRACBITS); + DAngle SavedPlayerPitch = self->Angles.Pitch; + self->Angles.Pitch -= 6.328125; //(1152 << FRACBITS); P_SpawnPlayerMissile(self, grenade); - self->pitch = SavedPlayerPitch; + self->Angles.Pitch = SavedPlayerPitch; return 0; } @@ -619,7 +620,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG) return 0; } - P_SpawnPlayerMissile (self, 0, 0, 0, PClass::FindActor("BFGBall"), self->angle, NULL, NULL, !!(dmflags2 & DF2_NO_FREEAIMBFG)); + P_SpawnPlayerMissile (self, 0, 0, 0, PClass::FindActor("BFGBall"), self->_f_angle(), NULL, NULL, !!(dmflags2 & DF2_NO_FREEAIMBFG)); return 0; } @@ -659,7 +660,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) // offset angles from its attack angle for (i = 0; i < numrays; i++) { - an = self->angle - angle / 2 + angle / numrays*i; + an = self->_f_angle() - angle / 2 + angle / numrays*i; // self->target is the originator (player) of the missile P_AimLineAttack(self->target, an, distance, &t, vrange); @@ -696,7 +697,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) damage = defdamage; } - int newdam = P_DamageMobj(t.linetarget, self->target, self->target, damage, dmgType, dmgFlags|DMG_USEANGLE, t.angleFromSource); + int newdam = P_DamageMobj(t.linetarget, self->target, self->target, damage, dmgType, dmgFlags|DMG_USEANGLE, FLOAT2ANGLE(t.angleFromSource.Degrees)); P_TraceBleed(newdam > 0 ? newdam : damage, &t, self); } } @@ -749,16 +750,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG) self->player->extralight = 2; // Save values temporarily - angle_t SavedPlayerAngle = self->angle; - fixed_t SavedPlayerPitch = self->pitch; + DAngle SavedPlayerAngle = self->Angles.Yaw; + DAngle SavedPlayerPitch = self->Angles.Pitch; for (int i = 0; i < 2; i++) // Spawn two plasma balls in sequence { - self->angle += ((pr_oldbfg()&127) - 64) * (ANG90/768); - self->pitch += ((pr_oldbfg()&127) - 64) * (ANG90/640); + self->Angles.Yaw += ((pr_oldbfg()&127) - 64) * (90./768); + self->Angles.Pitch += ((pr_oldbfg()&127) - 64) * (90./640); mo = P_SpawnPlayerMissile (self, plasma[i]); // Restore saved values - self->angle = SavedPlayerAngle; - self->pitch = SavedPlayerPitch; + self->Angles.Yaw = SavedPlayerAngle; + self->Angles.Pitch = SavedPlayerPitch; } if (doesautoaim && weapon != NULL) { // Restore autoaim setting diff --git a/src/g_doom/a_fatso.cpp b/src/g_doom/a_fatso.cpp index e79362316..f55686aeb 100644 --- a/src/g_doom/a_fatso.cpp +++ b/src/g_doom/a_fatso.cpp @@ -15,7 +15,7 @@ // firing three missiles in three different directions? // Doesn't look like it. // -#define FATSPREAD (ANG90/8) +#define FATSPREAD (90./8) DEFINE_ACTION_FUNCTION(AActor, A_FatRaise) { @@ -32,7 +32,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack1) PARAM_CLASS_OPT(spawntype, AActor) { spawntype = NULL; } AActor *missile; - angle_t an; if (!self->target) return 0; @@ -41,16 +40,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack1) A_FaceTarget (self); // Change direction to ... - self->angle += FATSPREAD; + self->Angles.Yaw += FATSPREAD; P_SpawnMissile (self, self->target, spawntype); missile = P_SpawnMissile (self, self->target, spawntype); if (missile != NULL) { - missile->angle += FATSPREAD; - an = missile->angle >> ANGLETOFINESHIFT; - missile->vel.x = FixedMul (missile->Speed, finecosine[an]); - missile->vel.y = FixedMul (missile->Speed, finesine[an]); + missile->Angles.Yaw += FATSPREAD; + missile->VelFromAngle(); } return 0; } @@ -61,7 +58,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack2) PARAM_CLASS_OPT(spawntype, AActor) { spawntype = NULL; } AActor *missile; - angle_t an; if (!self->target) return 0; @@ -70,16 +66,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack2) A_FaceTarget (self); // Now here choose opposite deviation. - self->angle -= FATSPREAD; + self->Angles.Yaw -= FATSPREAD; P_SpawnMissile (self, self->target, spawntype); missile = P_SpawnMissile (self, self->target, spawntype); if (missile != NULL) { - missile->angle -= FATSPREAD*2; - an = missile->angle >> ANGLETOFINESHIFT; - missile->vel.x = FixedMul (missile->Speed, finecosine[an]); - missile->vel.y = FixedMul (missile->Speed, finesine[an]); + missile->Angles.Yaw -= FATSPREAD*2; + missile->VelFromAngle(); } return 0; } @@ -90,7 +84,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack3) PARAM_CLASS_OPT(spawntype, AActor) { spawntype = NULL; } AActor *missile; - angle_t an; if (!self->target) return 0; @@ -102,19 +95,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack3) missile = P_SpawnMissile (self, self->target, spawntype); if (missile != NULL) { - missile->angle -= FATSPREAD/2; - an = missile->angle >> ANGLETOFINESHIFT; - missile->vel.x = FixedMul (missile->Speed, finecosine[an]); - missile->vel.y = FixedMul (missile->Speed, finesine[an]); + missile->Angles.Yaw -= FATSPREAD/2; + missile->VelFromAngle(); } missile = P_SpawnMissile (self, self->target, spawntype); if (missile != NULL) { - missile->angle += FATSPREAD/2; - an = missile->angle >> ANGLETOFINESHIFT; - missile->vel.x = FixedMul (missile->Speed, finecosine[an]); - missile->vel.y = FixedMul (missile->Speed, finesine[an]); + missile->Angles.Yaw += FATSPREAD/2; + missile->VelFromAngle(); } return 0; } diff --git a/src/g_doom/a_lostsoul.cpp b/src/g_doom/a_lostsoul.cpp index 8aa7108cf..90f54038f 100644 --- a/src/g_doom/a_lostsoul.cpp +++ b/src/g_doom/a_lostsoul.cpp @@ -33,7 +33,7 @@ void A_SkullAttack(AActor *self, fixed_t speed) S_Sound (self, CHAN_VOICE, self->AttackSound, 1, ATTN_NORM); A_FaceTarget (self); - an = self->angle >> ANGLETOFINESHIFT; + an = self->_f_angle() >> ANGLETOFINESHIFT; self->vel.x = FixedMul (speed, finecosine[an]); self->vel.y = FixedMul (speed, finesine[an]); dist = self->AproxDistance (dest); diff --git a/src/g_doom/a_painelemental.cpp b/src/g_doom/a_painelemental.cpp index acdfdb04d..7477812db 100644 --- a/src/g_doom/a_painelemental.cpp +++ b/src/g_doom/a_painelemental.cpp @@ -166,7 +166,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PainAttack) if (!(flags & PAF_AIMFACING)) A_FaceTarget (self); - A_PainShootSkull (self, self->angle+angle, spawntype, flags, limit); + A_PainShootSkull (self, self->_f_angle()+angle, spawntype, flags, limit); return 0; } @@ -179,8 +179,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DualPainAttack) return 0; A_FaceTarget (self); - A_PainShootSkull (self, self->angle + ANG45, spawntype); - A_PainShootSkull (self, self->angle - ANG45, spawntype); + A_PainShootSkull (self, self->_f_angle() + ANG45, spawntype); + A_PainShootSkull (self, self->_f_angle() - ANG45, spawntype); return 0; } @@ -194,8 +194,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PainDie) self->flags &= ~MF_FRIENDLY; } A_Unblock(self, true); - A_PainShootSkull (self, self->angle + ANG90, spawntype); - A_PainShootSkull (self, self->angle + ANG180, spawntype); - A_PainShootSkull (self, self->angle + ANG270, spawntype); + A_PainShootSkull (self, self->_f_angle() + ANG90, spawntype); + A_PainShootSkull (self, self->_f_angle() + ANG180, spawntype); + A_PainShootSkull (self, self->_f_angle() + ANG270, spawntype); return 0; } diff --git a/src/g_doom/a_possessed.cpp b/src/g_doom/a_possessed.cpp index 5fc2e6b89..f790e9ad2 100644 --- a/src/g_doom/a_possessed.cpp +++ b/src/g_doom/a_possessed.cpp @@ -30,7 +30,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PosAttack) return 0; A_FaceTarget (self); - angle = self->angle; + angle = self->_f_angle(); slope = P_AimLineAttack (self, angle, MISSILERANGE); S_Sound (self, CHAN_WEAPON, "grunt/attack", 1, ATTN_NORM); @@ -47,7 +47,7 @@ static void A_SPosAttack2 (AActor *self) int slope; A_FaceTarget (self); - bangle = self->angle; + bangle = self->_f_angle(); slope = P_AimLineAttack (self, bangle, MISSILERANGE); for (i=0 ; i<3 ; i++) @@ -104,7 +104,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CPosAttack) S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); A_FaceTarget (self); - bangle = self->angle; + bangle = self->_f_angle(); slope = P_AimLineAttack (self, bangle, MISSILERANGE); angle = bangle + (pr_cposattack.Random2() << 20); diff --git a/src/g_doom/a_revenant.cpp b/src/g_doom/a_revenant.cpp index 252a1c1cd..12c76dc33 100644 --- a/src/g_doom/a_revenant.cpp +++ b/src/g_doom/a_revenant.cpp @@ -39,13 +39,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile) return 0; } -#define TRACEANGLE (0xc000000) +#define TRACEANGLE (16.875) DEFINE_ACTION_FUNCTION(AActor, A_Tracer) { PARAM_ACTION_PROLOGUE; - angle_t exact; fixed_t dist; fixed_t slope; AActor *dest; @@ -64,7 +63,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) return 0; // spawn a puff of smoke behind the rocket - P_SpawnPuff (self, PClass::FindActor(NAME_BulletPuff), self->Pos(), self->angle, self->angle, 3); + P_SpawnPuff (self, PClass::FindActor(NAME_BulletPuff), self->Pos(), self->_f_angle(), self->_f_angle(), 3); smoke = Spawn ("RevenantTracerSmoke", self->Vec3Offset(-self->vel.x, -self->vel.y, 0), ALLOW_REPLACE); @@ -80,27 +79,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) return 0; // change angle - exact = self->AngleTo(dest); + DAngle exact = self->_f_AngleTo(dest); + DAngle diff = deltaangle(self->Angles.Yaw, exact); - if (exact != self->angle) + if (diff < 0) { - if (exact - self->angle > 0x80000000) - { - self->angle -= TRACEANGLE; - if (exact - self->angle < 0x80000000) - self->angle = exact; - } - else - { - self->angle += TRACEANGLE; - if (exact - self->angle > 0x80000000) - self->angle = exact; - } + self->Angles.Yaw -= TRACEANGLE; + if (deltaangle(self->Angles.Yaw, exact) > 0) + self->Angles.Yaw = exact; } - - exact = self->angle>>ANGLETOFINESHIFT; - self->vel.x = FixedMul (self->Speed, finecosine[exact]); - self->vel.y = FixedMul (self->Speed, finesine[exact]); + else if (diff > 0) + { + self->Angles.Yaw += TRACEANGLE; + if (deltaangle(self->Angles.Yaw, exact) < 0.) + self->Angles.Yaw = exact; + } + + self->VelFromAngle(); if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { diff --git a/src/g_doom/a_scriptedmarine.cpp b/src/g_doom/a_scriptedmarine.cpp index 0f9e48e59..ed2791193 100644 --- a/src/g_doom/a_scriptedmarine.cpp +++ b/src/g_doom/a_scriptedmarine.cpp @@ -275,14 +275,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw) A_FaceTarget (self); if (self->CheckMeleeRange ()) { - angle_t angle; + angle_t Angle; FTranslatedLineTarget t; damage *= (pr_m_saw()%10+1); - angle = self->angle + (pr_m_saw.Random2() << 18); + Angle = self->_f_angle() + (pr_m_saw.Random2() << 18); - P_LineAttack (self, angle, MELEERANGE+1, - P_AimLineAttack (self, angle, MELEERANGE+1), damage, + P_LineAttack (self, Angle, MELEERANGE+1, + P_AimLineAttack (self, Angle, MELEERANGE+1), damage, NAME_Melee, pufftype, false, &t); if (!t.linetarget) @@ -293,20 +293,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw) S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM); // turn to face target - angle = t.angleFromSource; - if (angle - self->angle > ANG180) + DAngle angle = t.angleFromSource; + DAngle anglediff = deltaangle(self->Angles.Yaw, angle); + + if (anglediff < 0.0) { - if (angle - self->angle < (angle_t)(-ANG90/20)) - self->angle = angle + ANG90/21; + if (anglediff < -4.5) + self->Angles.Yaw = angle + 90.0 / 21; else - self->angle -= ANG90/20; + self->Angles.Yaw -= 4.5; } else { - if (angle - self->angle > ANG90/20) - self->angle = angle - ANG90/21; + if (anglediff > 4.5) + self->Angles.Yaw = angle - 90.0 / 21; else - self->angle += ANG90/20; + self->Angles.Yaw += 4.5; } } else @@ -336,7 +338,7 @@ static void MarinePunch(AActor *self, int damagemul) damage = ((pr_m_punch()%10+1) << 1) * damagemul; A_FaceTarget (self); - angle = self->angle + (pr_m_punch.Random2() << 18); + angle = self->_f_angle() + (pr_m_punch.Random2() << 18); pitch = P_AimLineAttack (self, angle, MELEERANGE); P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true, &t); @@ -344,7 +346,7 @@ static void MarinePunch(AActor *self, int damagemul) if (t.linetarget) { S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM); - self->angle = t.angleFromSource; + self->Angles.Yaw = t.angleFromSource; } } @@ -369,7 +371,7 @@ void P_GunShot2 (AActor *mo, bool accurate, int pitch, PClassActor *pufftype) int damage; damage = 5*(pr_m_gunshot()%3+1); - angle = mo->angle; + angle = mo->_f_angle(); if (!accurate) { @@ -395,7 +397,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FirePistol) S_Sound (self, CHAN_WEAPON, "weapons/pistol", 1, ATTN_NORM); A_FaceTarget (self); - P_GunShot2 (self, accurate, P_AimLineAttack (self, self->angle, MISSILERANGE), + P_GunShot2 (self, accurate, P_AimLineAttack (self, self->_f_angle(), MISSILERANGE), PClass::FindActor(NAME_BulletPuff)); return 0; } @@ -417,7 +419,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun) S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM); A_FaceTarget (self); - pitch = P_AimLineAttack (self, self->angle, MISSILERANGE); + pitch = P_AimLineAttack (self, self->_f_angle(), MISSILERANGE); for (int i = 0; i < 7; ++i) { P_GunShot2 (self, false, pitch, PClass::FindActor(NAME_BulletPuff)); @@ -464,11 +466,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun2) S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM); A_FaceTarget (self); - pitch = P_AimLineAttack (self, self->angle, MISSILERANGE); + pitch = P_AimLineAttack (self, self->_f_angle(), MISSILERANGE); for (int i = 0; i < 20; ++i) { int damage = 5*(pr_m_fireshotgun2()%3+1); - angle_t angle = self->angle + (pr_m_fireshotgun2.Random2() << 19); + angle_t angle = self->_f_angle() + (pr_m_fireshotgun2.Random2() << 19); P_LineAttack (self, angle, MISSILERANGE, pitch + (pr_m_fireshotgun2.Random2() * 332063), damage, @@ -494,7 +496,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FireCGun) S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM); A_FaceTarget (self); - P_GunShot2 (self, accurate, P_AimLineAttack (self, self->angle, MISSILERANGE), + P_GunShot2 (self, accurate, P_AimLineAttack (self, self->_f_angle(), MISSILERANGE), PClass::FindActor(NAME_BulletPuff)); return 0; } diff --git a/src/g_game.cpp b/src/g_game.cpp index 627853acb..1ff95537e 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1183,7 +1183,7 @@ void G_Ticker () if (players[i].mo) { DWORD sum = rngsum + players[i].mo->X() + players[i].mo->Y() + players[i].mo->Z() - + players[i].mo->angle + players[i].mo->pitch; + + players[i].mo->_f_angle() + players[i].mo->_f_pitch(); sum ^= players[i].health; consistancy[i][buf] = sum; } diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index 80c5d215a..3d9fcb894 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -43,7 +43,7 @@ void AChickenPlayer::MorphPlayerThink () } if (!(vel.x | vel.y) && pr_chickenplayerthink () < 160) { // Twitch view angle - angle += pr_chickenplayerthink.Random2 () << 19; + Angles.Yaw += pr_chickenplayerthink.Random2() * (360. / 256. / 32.); } if ((Z() <= floorz) && (pr_chickenplayerthink() < 32)) { // Jump and noise @@ -184,12 +184,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1) } damage = 1 + (pr_beakatkpl1()&3); - angle = player->mo->angle; + angle = player->mo->_f_angle(); slope = P_AimLineAttack (player->mo, angle, MELEERANGE); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &t); if (t.linetarget) { - player->mo->angle = t.angleFromSource; + player->mo->Angles.Yaw = t.angleFromSource; } P_PlayPeck (player->mo); player->chickenPeck = 12; @@ -219,12 +219,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2) } damage = pr_beakatkpl2.HitDice (4); - angle = player->mo->angle; + angle = player->mo->_f_angle(); slope = P_AimLineAttack (player->mo, angle, MELEERANGE); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &t); if (t.linetarget) { - player->mo->angle = t.angleFromSource; + player->mo->Angles.Yaw = t.angleFromSource; } P_PlayPeck (player->mo); player->chickenPeck = 12; diff --git a/src/g_heretic/a_dsparil.cpp b/src/g_heretic/a_dsparil.cpp index ed2b97321..3c35a794a 100644 --- a/src/g_heretic/a_dsparil.cpp +++ b/src/g_heretic/a_dsparil.cpp @@ -94,7 +94,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack) if (mo != NULL) { vz = mo->vel.z; - angle = mo->angle; + angle = mo->_f_angle(); P_SpawnMissileAngleZ (self, self->Z() + 48*FRACUNIT, fx, angle-ANGLE_1*3, vz); P_SpawnMissileAngleZ (self, self->Z() + 48*FRACUNIT, fx, angle+ANGLE_1*3, vz); } @@ -130,7 +130,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcererRise) mo = Spawn("Sorcerer2", self->Pos(), ALLOW_REPLACE); mo->Translation = self->Translation; mo->SetState (mo->FindState("Rise")); - mo->angle = self->angle; + mo->Angles.Yaw = self->Angles.Yaw; mo->CopyFriendliness (self, true); return 0; } @@ -166,7 +166,7 @@ void P_DSparilTeleport (AActor *actor) actor->SetState (actor->FindState("Teleport")); S_Sound (actor, CHAN_BODY, "misc/teleport", 1, ATTN_NORM); actor->SetZ(actor->floorz, false); - actor->angle = spot->angle; + actor->Angles.Yaw = spot->Angles.Yaw; actor->vel.x = actor->vel.y = actor->vel.z = 0; } } @@ -230,8 +230,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr2Attack) PClassActor *fx = PClass::FindActor("Sorcerer2FX2"); if (fx) { - P_SpawnMissileAngle (self, fx, self->angle-ANG45, FRACUNIT/2); - P_SpawnMissileAngle (self, fx, self->angle+ANG45, FRACUNIT/2); + P_SpawnMissileAngle (self, fx, self->_f_angle()-ANG45, FRACUNIT/2); + P_SpawnMissileAngle (self, fx, self->_f_angle()+ANG45, FRACUNIT/2); } } else diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp index 2ed4da34c..3eb4de206 100644 --- a/src/g_heretic/a_hereticartifacts.cpp +++ b/src/g_heretic/a_hereticartifacts.cpp @@ -70,9 +70,9 @@ IMPLEMENT_CLASS (AArtiTimeBomb) bool AArtiTimeBomb::Use (bool pickup) { - angle_t angle = Owner->angle >> ANGLETOFINESHIFT; + angle_t angle = Owner->_f_angle() >> ANGLETOFINESHIFT; AActor *mo = Spawn("ActivatedTimeBomb", - Owner->Vec3Angle(24*FRACUNIT, Owner->angle, - Owner->floorclip), ALLOW_REPLACE); + Owner->Vec3Angle(24*FRACUNIT, Owner->_f_angle(), - Owner->floorclip), ALLOW_REPLACE); mo->target = Owner; return true; } diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index af8431a95..d42167fbe 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -172,18 +172,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcanoBlast) int i; int count; AActor *blast; - angle_t angle; count = 1 + (pr_blast() % 3); for (i = 0; i < count; i++) { blast = Spawn("VolcanoBlast", self->PosPlusZ(44*FRACUNIT), ALLOW_REPLACE); blast->target = self; - angle = pr_blast () << 24; - blast->angle = angle; - angle >>= ANGLETOFINESHIFT; - blast->vel.x = FixedMul (1*FRACUNIT, finecosine[angle]); - blast->vel.y = FixedMul (1*FRACUNIT, finesine[angle]); + blast->Angles.Yaw = pr_blast() * (360 / 256.f); + blast->VelFromAngle(1 * FRACUNIT); blast->vel.z = (FRACUNIT*5/2) + (pr_blast() << 10); S_Sound (blast, CHAN_BODY, "world/volcano/shoot", 1, ATTN_NORM); P_CheckMissileSpawn (blast, self->radius); @@ -203,7 +199,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) unsigned int i; AActor *tiny; - angle_t angle; if (self->Z() <= self->floorz) { @@ -217,11 +212,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) { tiny = Spawn("VolcanoTBlast", self->Pos(), ALLOW_REPLACE); tiny->target = self; - angle = i*ANG90; - tiny->angle = angle; - angle >>= ANGLETOFINESHIFT; - tiny->vel.x = FixedMul (FRACUNIT*7/10, finecosine[angle]); - tiny->vel.y = FixedMul (FRACUNIT*7/10, finesine[angle]); + tiny->Angles.Yaw = 90.*i; + tiny->VelFromAngle(FRACUNIT * 7 / 10); tiny->vel.z = FRACUNIT + (pr_volcimpact() << 9); P_CheckMissileSpawn (tiny, self->radius); } diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index c7a818496..debceea4c 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -86,7 +86,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack) { puff = PClass::FindActor(NAME_BulletPuff); // just to be sure } - angle = self->angle; + angle = self->_f_angle(); angle += pr_sap.Random2() << 18; slope = P_AimLineAttack (self, angle, MELEERANGE); P_LineAttack (self, angle, MELEERANGE, slope, damage, NAME_Melee, puff, true, &t); @@ -94,7 +94,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack) { //S_StartSound(player->mo, sfx_stfhit); // turn to face target - self->angle = t.angleFromSource; + self->Angles.Yaw = t.angleFromSource; } return 0; } @@ -127,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL1) } angle_t pitch = P_BulletSlope(self); damage = 7+(pr_fgw()&7); - angle = self->angle; + angle = self->_f_angle(); if (player->refire) { angle += pr_fgw.Random2() << 18; @@ -167,9 +167,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL2) angle_t pitch = P_BulletSlope(self); vz = FixedMul (GetDefaultByName("GoldWandFX2")->Speed, finetangent[FINEANGLES/4-((signed)pitch>>ANGLETOFINESHIFT)]); - P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->angle-(ANG45/8), vz); - P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->angle+(ANG45/8), vz); - angle = self->angle-(ANG45/8); + P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->_f_angle()-(ANG45/8), vz); + P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->_f_angle()+(ANG45/8), vz); + angle = self->_f_angle()-(ANG45/8); for(i = 0; i < 5; i++) { damage = 1+(pr_fgw2()&7); @@ -204,8 +204,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL1) return 0; } P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX1")); - P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->angle-(ANG45/10)); - P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->angle+(ANG45/10)); + P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->_f_angle()-(ANG45/10)); + P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->_f_angle()+(ANG45/10)); return 0; } @@ -233,10 +233,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL2) return 0; } P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2")); - P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"), self->angle-(ANG45/10)); - P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"), self->angle+(ANG45/10)); - P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->angle-(ANG45/5)); - P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->angle+(ANG45/5)); + P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"), self->_f_angle()-(ANG45/10)); + P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"), self->_f_angle()+(ANG45/10)); + P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->_f_angle()-(ANG45/5)); + P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->_f_angle()+(ANG45/5)); return 0; } @@ -250,7 +250,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) { PARAM_ACTION_PROLOGUE; - angle_t angle; + angle_t Angle; int damage; int slope; int randVal; @@ -275,23 +275,23 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) } player->psprites[ps_weapon].sx = ((pr_gatk()&3)-2) * FRACUNIT; player->psprites[ps_weapon].sy = WEAPONTOP + (pr_gatk()&3) * FRACUNIT; - angle = self->angle; + Angle = self->_f_angle(); if (power) { damage = pr_gatk.HitDice (2); dist = 4*MELEERANGE; - angle += pr_gatk.Random2() << 17; + Angle += pr_gatk.Random2() << 17; pufftype = PClass::FindActor("GauntletPuff2"); } else { damage = pr_gatk.HitDice (2); dist = MELEERANGE+1; - angle += pr_gatk.Random2() << 18; + Angle += pr_gatk.Random2() << 18; pufftype = PClass::FindActor("GauntletPuff1"); } - slope = P_AimLineAttack (self, angle, dist); - P_LineAttack (self, angle, dist, slope, damage, NAME_Melee, pufftype, false, &t, &actualdamage); + slope = P_AimLineAttack (self, Angle, dist); + P_LineAttack (self, Angle, dist, slope, damage, NAME_Melee, pufftype, false, &t, &actualdamage); if (!t.linetarget) { if (pr_gatk() > 64) @@ -324,20 +324,22 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) S_Sound (self, CHAN_AUTO, "weapons/gauntletshit", 1, ATTN_NORM); } // turn to face target - angle = t.angleFromSource; - if (angle-self->angle > ANG180) + DAngle angle = t.angleFromSource; + DAngle anglediff = deltaangle(self->Angles.Yaw, angle); + + if (anglediff < 0.0) { - if ((int)(angle-self->angle) < -ANG90/20) - self->angle = angle+ANG90/21; + if (anglediff < -4.5) + self->Angles.Yaw = angle + 90.0 / 21; else - self->angle -= ANG90/20; + self->Angles.Yaw -= 4.5; } else { - if (angle-self->angle > ANG90/20) - self->angle = angle-ANG90/21; + if (anglediff > 4.5) + self->Angles.Yaw = angle - 90.0 / 21; else - self->angle += ANG90/20; + self->Angles.Yaw += 4.5; } self->flags |= MF_JUSTATTACKED; return 0; @@ -387,7 +389,6 @@ int AMaceFX4::DoSpecialDamage (AActor *target, int damage, FName damagetype) void FireMacePL1B (AActor *actor) { AActor *ball; - angle_t angle; player_t *player; if (NULL == (player = actor->player)) @@ -402,15 +403,13 @@ void FireMacePL1B (AActor *actor) return; } ball = Spawn("MaceFX2", actor->PosPlusZ(28*FRACUNIT - actor->floorclip), ALLOW_REPLACE); - ball->vel.z = 2*FRACUNIT+/*((player->lookdir)<<(FRACBITS-5))*/ - finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)]; - angle = actor->angle; + ball->vel.z = FLOAT2FIXED(2 + g_tan(-actor->Angles.Pitch.Degrees)); ball->target = actor; - ball->angle = angle; - ball->AddZ(2*finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)]); - angle >>= ANGLETOFINESHIFT; - ball->vel.x = (actor->vel.x>>1) + FixedMul(ball->Speed, finecosine[angle]); - ball->vel.y = (actor->vel.y>>1) + FixedMul(ball->Speed, finesine[angle]); + ball->Angles.Yaw = actor->Angles.Yaw; + ball->AddZ(ball->vel.z); + ball->VelFromAngle(); + ball->vel.x += (actor->vel.x>>1); + ball->vel.y += (actor->vel.y>>1); S_Sound (ball, CHAN_BODY, "weapons/maceshoot", 1, ATTN_NORM); P_CheckMissileSpawn (ball, actor->radius); } @@ -447,7 +446,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL1) player->psprites[ps_weapon].sx = ((pr_maceatk()&3)-2)*FRACUNIT; player->psprites[ps_weapon].sy = WEAPONTOP+(pr_maceatk()&3)*FRACUNIT; ball = P_SpawnPlayerMissile (self, PClass::FindActor("MaceFX1"), - self->angle+(((pr_maceatk()&7)-4)<<24)); + self->_f_angle()+(((pr_maceatk()&7)-4)<<24)); if (ball) { ball->special1 = 16; // tics till dropoff @@ -480,7 +479,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MacePL1Check) // [RH] Avoid some precision loss by scaling the velocity directly #if 0 // This is the original code, for reference. - angle_t angle = self->angle>>ANGLETOFINESHIFT; + angle_t angle = self->_f_angle()>>ANGLETOFINESHIFT; self->vel.x = FixedMul(7*FRACUNIT, finecosine[angle]); self->vel.y = FixedMul(7*FRACUNIT, finesine[angle]); #else @@ -533,7 +532,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact2) PARAM_ACTION_PROLOGUE; AActor *tiny; - angle_t angle; if ((self->Z() <= self->floorz) && P_HitFloor (self)) { // Landed in some sort of liquid @@ -552,22 +550,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact2) self->SetState (self->SpawnState); tiny = Spawn("MaceFX3", self->Pos(), ALLOW_REPLACE); - angle = self->angle+ANG90; tiny->target = self->target; - tiny->angle = angle; - angle >>= ANGLETOFINESHIFT; - tiny->vel.x = (self->vel.x>>1) + FixedMul(self->vel.z-FRACUNIT, finecosine[angle]); - tiny->vel.y = (self->vel.y>>1) + FixedMul(self->vel.z-FRACUNIT, finesine[angle]); + tiny->Angles.Yaw = self->Angles.Yaw + 90.; + tiny->VelFromAngle(self->vel.z - FRACUNIT); + tiny->vel.x += (self->vel.x >> 1); + tiny->vel.y += (self->vel.y >> 1); tiny->vel.z = self->vel.z; P_CheckMissileSpawn (tiny, self->radius); tiny = Spawn("MaceFX3", self->Pos(), ALLOW_REPLACE); - angle = self->angle-ANG90; tiny->target = self->target; - tiny->angle = angle; - angle >>= ANGLETOFINESHIFT; - tiny->vel.x = (self->vel.x>>1) + FixedMul(self->vel.z-FRACUNIT, finecosine[angle]); - tiny->vel.y = (self->vel.y>>1) + FixedMul(self->vel.z-FRACUNIT, finesine[angle]); + tiny->Angles.Yaw = self->Angles.Yaw - 90.; + tiny->VelFromAngle(self->vel.z - FRACUNIT); + tiny->vel.x += (self->vel.x >> 1); + tiny->vel.y += (self->vel.y >> 1); tiny->vel.z = self->vel.z; P_CheckMissileSpawn (tiny, self->radius); } @@ -607,13 +603,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL2) if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; } - mo = P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AMaceFX4), self->angle, &t); + mo = P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AMaceFX4), self->_f_angle(), &t); if (mo) { mo->vel.x += self->vel.x; mo->vel.y += self->vel.y; mo->vel.z = 2*FRACUNIT+ - clamp(finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)], -5*FRACUNIT, 5*FRACUNIT); + clamp(finetangent[FINEANGLES/4-(self->_f_pitch()>>ANGLETOFINESHIFT)], -5*FRACUNIT, 5*FRACUNIT); if (t.linetarget && !t.unlinked) { mo->tracer = t.linetarget; @@ -635,7 +631,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) int i; AActor *target; - angle_t angle = 0; + DAngle angle = 0; bool newAngle; FTranslatedLineTarget t; @@ -662,7 +658,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) } else { // Seek - angle = self->AngleTo(target); + angle = self->_f_AngleTo(target); newAngle = true; } } @@ -671,7 +667,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) angle = 0; for (i = 0; i < 16; i++) { - P_AimLineAttack (self, angle, 10*64*FRACUNIT, &t, 0, ALF_NOFRIENDS|ALF_PORTALRESTRICT, NULL, self->target); + P_AimLineAttack (self, FLOAT2ANGLE(angle.Degrees), 10*64*FRACUNIT, &t, 0, ALF_NOFRIENDS|ALF_PORTALRESTRICT, NULL, self->target); if (t.linetarget && self->target != t.linetarget) { self->tracer = t.linetarget; @@ -679,15 +675,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) newAngle = true; break; } - angle += ANGLE_45/2; + angle += 22.5; } } if (newAngle) { - self->angle = angle; - angle >>= ANGLETOFINESHIFT; - self->vel.x = FixedMul (self->Speed, finecosine[angle]); - self->vel.y = FixedMul (self->Speed, finesine[angle]); + self->Angles.Yaw = angle; + self->VelFromAngle(); } self->SetState (self->SpawnState); S_Sound (self, CHAN_BODY, "weapons/macestop", 1, ATTN_NORM); @@ -795,7 +789,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBlasterPL1) } angle_t pitch = P_BulletSlope(self); damage = pr_fb1.HitDice (4); - angle = self->angle; + angle = self->_f_angle(); if (player->refire) { angle += pr_fb1.Random2() << 18; @@ -816,18 +810,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnRippers) PARAM_ACTION_PROLOGUE; unsigned int i; - angle_t angle; + DAngle angle; AActor *ripper; for(i = 0; i < 8; i++) { ripper = Spawn (self->Pos(), ALLOW_REPLACE); - angle = i*ANG45; + angle = i*45.; ripper->target = self->target; - ripper->angle = angle; - angle >>= ANGLETOFINESHIFT; - ripper->vel.x = FixedMul (ripper->Speed, finecosine[angle]); - ripper->vel.y = FixedMul (ripper->Speed, finesine[angle]); + ripper->Angles.Yaw = angle; + ripper->VelFromAngle(); P_CheckMissileSpawn (ripper, self->radius); } return 0; @@ -955,7 +947,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSkullRodPL2) if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; } - P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AHornRodFX2), self->angle, &t, &MissileActor); + P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AHornRodFX2), self->_f_angle(), &t, &MissileActor); // Use MissileActor instead of the return value from // P_SpawnPlayerMissile because we need to give info to the mobj // even if it exploded immediately. @@ -1252,7 +1244,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL1) return 0; } P_SpawnPlayerMissile (self, RUNTIME_CLASS(APhoenixFX1)); - angle = self->angle + ANG180; + angle = self->_f_angle() + ANG180; angle >>= ANGLETOFINESHIFT; self->vel.x += FixedMul (4*FRACUNIT, finecosine[angle]); self->vel.y += FixedMul (4*FRACUNIT, finesine[angle]); @@ -1275,13 +1267,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_PhoenixPuff) //[RH] Heretic never sets the target for seeking //P_SeekerMissile (self, ANGLE_1*5, ANGLE_1*10); puff = Spawn("PhoenixPuff", self->Pos(), ALLOW_REPLACE); - angle = self->angle + ANG90; + angle = self->_f_angle() + ANG90; angle >>= ANGLETOFINESHIFT; puff->vel.x = FixedMul (FRACUNIT*13/10, finecosine[angle]); puff->vel.y = FixedMul (FRACUNIT*13/10, finesine[angle]); puff->vel.z = 0; puff = Spawn("PhoenixPuff", self->Pos(), ALLOW_REPLACE); - angle = self->angle - ANG90; + angle = self->_f_angle() - ANG90; angle >>= ANGLETOFINESHIFT; puff->vel.x = FixedMul (FRACUNIT*13/10, finecosine[angle]); puff->vel.y = FixedMul (FRACUNIT*13/10, finesine[angle]); @@ -1323,7 +1315,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) PARAM_ACTION_PROLOGUE; AActor *mo; - angle_t angle; fixed_t slope; FSoundID soundid; @@ -1345,19 +1336,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) S_StopSound (self, CHAN_WEAPON); return 0; } - angle = self->angle; + slope = FLOAT2FIXED(g_tan(-self->Angles.Pitch.Degrees)); fixed_t xo = (pr_fp2.Random2() << 9); fixed_t yo = (pr_fp2.Random2() << 9); fixedvec3 pos = self->Vec3Offset(xo, yo, - 26*FRACUNIT + finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] - self->floorclip); + 26*FRACUNIT + slope - self->floorclip); - slope = finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] + (FRACUNIT/10); + slope += (FRACUNIT/10); mo = Spawn("PhoenixFX2", pos, ALLOW_REPLACE); mo->target = self; - mo->angle = angle; - mo->vel.x = self->vel.x + FixedMul (mo->Speed, finecosine[angle>>ANGLETOFINESHIFT]); - mo->vel.y = self->vel.y + FixedMul (mo->Speed, finesine[angle>>ANGLETOFINESHIFT]); + mo->Angles.Yaw = self->Angles.Yaw; + mo->VelFromAngle(); + mo->vel.x += self->vel.x; + mo->vel.y += self->vel.y; mo->vel.z = FixedMul (mo->Speed, slope); if (!player->refire || !S_IsActorPlayingSomething (self, CHAN_WEAPON, -1)) { diff --git a/src/g_heretic/a_ironlich.cpp b/src/g_heretic/a_ironlich.cpp index 5c7746e82..cdab04b27 100644 --- a/src/g_heretic/a_ironlich.cpp +++ b/src/g_heretic/a_ironlich.cpp @@ -30,7 +30,7 @@ int AWhirlwind::DoSpecialDamage (AActor *target, int damage, FName damagetype) if (!(target->flags7 & MF7_DONTTHRUST)) { - target->angle += pr_foo.Random2() << 20; + target->Angles.Yaw += pr_foo.Random2() * (360 / 4096.); target->vel.x += pr_foo.Random2() << 10; target->vel.y += pr_foo.Random2() << 10; } @@ -114,10 +114,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) S_Sound (self, CHAN_BODY, "ironlich/attack1", 1, ATTN_NORM); } fire->target = baseFire->target; - fire->angle = baseFire->angle; - fire->vel.x = baseFire->vel.x; - fire->vel.y = baseFire->vel.y; - fire->vel.z = baseFire->vel.z; + fire->Angles.Yaw = baseFire->Angles.Yaw; + fire->vel = baseFire->vel; fire->Damage = NULL; fire->health = (i+1) * 2; P_CheckMissileSpawn (fire, self->radius); @@ -180,18 +178,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) PARAM_ACTION_PROLOGUE; unsigned int i; - angle_t angle; AActor *shard; for (i = 0; i < 8; i++) { shard = Spawn("HeadFX2", self->Pos(), ALLOW_REPLACE); - angle = i*ANG45; shard->target = self->target; - shard->angle = angle; - angle >>= ANGLETOFINESHIFT; - shard->vel.x = FixedMul (shard->Speed, finecosine[angle]); - shard->vel.y = FixedMul (shard->Speed, finesine[angle]); + shard->Angles.Yaw = i*45.; + shard->VelFromAngle(); shard->vel.z = -FRACUNIT*6/10; P_CheckMissileSpawn (shard, self->radius); } diff --git a/src/g_heretic/a_wizard.cpp b/src/g_heretic/a_wizard.cpp index 7a92a1155..42ae691cd 100644 --- a/src/g_heretic/a_wizard.cpp +++ b/src/g_heretic/a_wizard.cpp @@ -88,8 +88,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_WizAtk3) mo = P_SpawnMissile (self, self->target, fx); if (mo != NULL) { - P_SpawnMissileAngle(self, fx, mo->angle-(ANG45/8), mo->vel.z); - P_SpawnMissileAngle(self, fx, mo->angle+(ANG45/8), mo->vel.z); + P_SpawnMissileAngle(self, fx, mo->_f_angle()-(ANG45/8), mo->vel.z); + P_SpawnMissileAngle(self, fx, mo->_f_angle()+(ANG45/8), mo->vel.z); } return 0; } diff --git a/src/g_hexen/a_bats.cpp b/src/g_hexen/a_bats.cpp index 2bde56340..5ef7d0427 100644 --- a/src/g_hexen/a_bats.cpp +++ b/src/g_hexen/a_bats.cpp @@ -47,7 +47,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatSpawn) delta = self->args[1]; if (delta==0) delta=1; - angle = self->angle + (((pr_batspawn()%delta)-(delta>>1))<<24); + angle = self->_f_angle() + (((pr_batspawn()%delta)-(delta>>1))<<24); mo = P_SpawnMissileAngle (self, PClass::FindActor("Bat"), angle, 0); if (mo) { @@ -74,11 +74,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatMove) if (pr_batmove()<128) { - newangle = self->angle + ANGLE_1*self->args[4]; + newangle = self->_f_angle() + ANGLE_1*self->args[4]; } else { - newangle = self->angle - ANGLE_1*self->args[4]; + newangle = self->_f_angle() - ANGLE_1*self->args[4]; } // Adjust velocity vector to new direction diff --git a/src/g_hexen/a_bishop.cpp b/src/g_hexen/a_bishop.cpp index 649e5b273..3ef2e19a8 100644 --- a/src/g_hexen/a_bishop.cpp +++ b/src/g_hexen/a_bishop.cpp @@ -118,15 +118,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopDoBlur) self->special1 = (pr_doblur() & 3) + 3; // Random number of blurs if (pr_doblur() < 120) { - P_ThrustMobj (self, self->angle + ANG90, 11*FRACUNIT); + P_ThrustMobj (self, self->_f_angle() + ANG90, 11*FRACUNIT); } else if (pr_doblur() > 125) { - P_ThrustMobj (self, self->angle - ANG90, 11*FRACUNIT); + P_ThrustMobj (self, self->_f_angle() - ANG90, 11*FRACUNIT); } else { // Thrust forward - P_ThrustMobj (self, self->angle, 11*FRACUNIT); + P_ThrustMobj (self, self->_f_angle(), 11*FRACUNIT); } S_Sound (self, CHAN_BODY, "BishopBlur", 1, ATTN_NORM); return 0; @@ -160,7 +160,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) mo = Spawn ("BishopBlur", self->Pos(), ALLOW_REPLACE); if (mo) { - mo->angle = self->angle; + mo->Angles.Yaw = self->Angles.Yaw; } return 0; } @@ -225,7 +225,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopPainBlur) mo = Spawn ("BishopPainBlur", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { - mo->angle = self->angle; + mo->Angles.Yaw = self->Angles.Yaw; } return 0; } diff --git a/src/g_hexen/a_clericflame.cpp b/src/g_hexen/a_clericflame.cpp index 62395d321..04ee1235c 100644 --- a/src/g_hexen/a_clericflame.cpp +++ b/src/g_hexen/a_clericflame.cpp @@ -56,7 +56,7 @@ void ACFlameMissile::Effect () AActor *mo = Spawn ("CFlameFloor", X(), Y(), newz, ALLOW_REPLACE); if (mo) { - mo->angle = angle; + mo->Angles.Yaw = Angles.Yaw; } } } @@ -117,7 +117,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) PARAM_ACTION_PROLOGUE; int i; - int an, an90; + DAngle an; fixed_t dist; AActor *mo; @@ -129,30 +129,29 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) dist = BlockingMobj->radius+18*FRACUNIT; for (i = 0; i < 4; i++) { - an = (i*ANG45)>>ANGLETOFINESHIFT; - an90 = (i*ANG45+ANG90)>>ANGLETOFINESHIFT; + an = i*45.; mo = Spawn ("CircleFlame", BlockingMobj->Vec3Offset( - FixedMul(dist, finecosine[an]), - FixedMul(dist, finesine[an]), + xs_CRoundToInt(an.Cos()*dist), xs_CRoundToInt(an.Sin()*dist), 5*FRACUNIT), ALLOW_REPLACE); if (mo) { - mo->angle = an<Angles.Yaw = an; mo->target = self->target; - mo->vel.x = mo->special1 = FixedMul(FLAMESPEED, finecosine[an]); - mo->vel.y = mo->special2 = FixedMul(FLAMESPEED, finesine[an]); + mo->VelFromAngle(FLAMESPEED); + mo->special1 = mo->vel.x; + mo->special2 = mo->vel.y; mo->tics -= pr_missile()&3; } mo = Spawn ("CircleFlame", BlockingMobj->Vec3Offset( - -FixedMul(dist, finecosine[an]), - -FixedMul(dist, finesine[an]), + -xs_CRoundToInt(an.Cos()*dist), -xs_CRoundToInt(an.Sin()*dist), 5*FRACUNIT), ALLOW_REPLACE); if(mo) { - mo->angle = ANG180+(an<Angles.Yaw = an + 180.; mo->target = self->target; - mo->vel.x = mo->special1 = FixedMul(-FLAMESPEED, finecosine[an]); - mo->vel.y = mo->special2 = FixedMul(-FLAMESPEED, finesine[an]); + mo->VelFromAngle(-FLAMESPEED); + mo->special1 = mo->vel.x; + mo->special2 = mo->vel.y; mo->tics -= pr_missile()&3; } } @@ -171,11 +170,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameRotate) { PARAM_ACTION_PROLOGUE; - int an; + DAngle an = self->Angles.Yaw + 90.; + self->VelFromAngle(an, FLAMEROTSPEED); + self->vel.x += self->special1; + self->vel.y += self->special2; - an = (self->angle+ANG90)>>ANGLETOFINESHIFT; - self->vel.x = self->special1+FixedMul(FLAMEROTSPEED, finecosine[an]); - self->vel.y = self->special2+FixedMul(FLAMEROTSPEED, finesine[an]); - self->angle += ANG90/15; + self->Angles.Yaw += 6.; return 0; } diff --git a/src/g_hexen/a_clericholy.cpp b/src/g_hexen/a_clericholy.cpp index fe71289ac..8b947598d 100644 --- a/src/g_hexen/a_clericholy.cpp +++ b/src/g_hexen/a_clericholy.cpp @@ -160,8 +160,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) break; } mo->SetZ(self->Z()); - mo->angle = self->angle+(ANGLE_45+ANGLE_45/2)-ANGLE_45*j; - P_ThrustMobj(mo, mo->angle, mo->Speed); + mo->Angles.Yaw = self->Angles.Yaw + 67.5 - 45.*j; + P_ThrustMobj(mo, mo->_f_angle(), mo->Speed); mo->target = self->target; mo->args[0] = 10; // initial turn value mo->args[1] = 0; // initial look angle @@ -225,7 +225,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack) if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; } - AActor *missile = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindActor("HolyMissile"), self->angle, &t); + AActor *missile = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindActor("HolyMissile"), self->_f_angle(), &t); if (missile != NULL && !t.unlinked) { missile->tracer = t.linetarget; @@ -342,8 +342,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyTail) else { if (P_TryMove (self, - parent->X() - 14*finecosine[parent->angle>>ANGLETOFINESHIFT], - parent->Y() - 14*finesine[parent->angle>>ANGLETOFINESHIFT], true)) + parent->X() - 14*finecosine[parent->_f_angle()>>ANGLETOFINESHIFT], + parent->Y() - 14*finesine[parent->_f_angle()>>ANGLETOFINESHIFT], true)) { self->SetZ(parent->Z()-5*FRACUNIT); } @@ -377,12 +377,11 @@ static void CHolyFindTarget (AActor *actor) // Similar to P_SeekerMissile, but seeks to a random Z on the target //============================================================================ -static void CHolySeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax) +static void CHolySeekerMissile (AActor *actor, DAngle thresh, DAngle turnMax) { int dir; int dist; - angle_t delta; - angle_t angle; + DAngle delta; AActor *target; fixed_t newZ; fixed_t deltaZ; @@ -404,7 +403,7 @@ static void CHolySeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax) dir = P_FaceMobj (actor, target, &delta); if (delta > thresh) { - delta >>= 1; + delta /= 2; if (delta > turnMax) { delta = turnMax; @@ -412,15 +411,14 @@ static void CHolySeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax) } if (dir) { // Turn clockwise - actor->angle += delta; + actor->Angles.Yaw += delta; } else { // Turn counter clockwise - actor->angle -= delta; + actor->Angles.Yaw -= delta; } - angle = actor->angle>>ANGLETOFINESHIFT; - actor->vel.x = FixedMul (actor->Speed, finecosine[angle]); - actor->vel.y = FixedMul (actor->Speed, finesine[angle]); + actor->VelFromAngle(); + if (!(level.time&15) || actor->Z() > target->Top() || actor->Top() < target->Z()) @@ -463,7 +461,7 @@ void CHolyWeave (AActor *actor, FRandom &pr_random) weaveXY = actor->special2 >> 16; weaveZ = actor->special2 & FINEMASK; - angle = (actor->angle + ANG90) >> ANGLETOFINESHIFT; + angle = (actor->_f_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; @@ -500,8 +498,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolySeek) } if (self->tracer) { - CHolySeekerMissile (self, self->args[0]*ANGLE_1, - self->args[0]*ANGLE_1*2); + CHolySeekerMissile (self, self->args[0], self->args[0]*2); if (!((level.time+7)&15)) { self->args[0] = 5+(pr_holyseek()/20); diff --git a/src/g_hexen/a_clericmace.cpp b/src/g_hexen/a_clericmace.cpp index 6b7fe06ae..cb778a447 100644 --- a/src/g_hexen/a_clericmace.cpp +++ b/src/g_hexen/a_clericmace.cpp @@ -36,7 +36,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack) { for (int j = 1; j >= -1; j -= 2) { - angle = player->mo->angle + j*i*(ANG45 / 16); + angle = player->mo->_f_angle() + j*i*(ANG45 / 16); slope = P_AimLineAttack(player->mo, angle, 2 * MELEERANGE, &t); if (t.linetarget) { @@ -52,7 +52,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack) // didn't find any creatures, so try to strike any walls player->mo->weaponspecial = 0; - angle = player->mo->angle; + angle = player->mo->_f_angle(); slope = P_AimLineAttack (player->mo, angle, MELEERANGE); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, hammertime); macedone: diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp index fcad8f20c..b4d90c9e7 100644 --- a/src/g_hexen/a_clericstaff.cpp +++ b/src/g_hexen/a_clericstaff.cpp @@ -72,14 +72,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck) { for (int j = 1; j >= -1; j -= 2) { - angle = pmo->angle + j*i*(ANG45 / 16); + angle = pmo->_f_angle() + j*i*(ANG45 / 16); slope = P_AimLineAttack(pmo, angle, fixed_t(1.5*MELEERANGE), &t, 0, ALF_CHECK3D); if (t.linetarget) { P_LineAttack(pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, puff, false, &t); if (t.linetarget != NULL) { - pmo->angle = t.angleFromSource; + pmo->Angles.Yaw = t.angleFromSource; if (((t.linetarget->player && (!t.linetarget->IsTeammate(pmo) || level.teamdamage != 0)) || t.linetarget->flags3&MF3_ISMONSTER) && (!(t.linetarget->flags2&(MF2_DORMANT | MF2_INVULNERABLE)))) { @@ -131,12 +131,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffAttack) if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; } - mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->angle-(ANG45/15)); + mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->_f_angle()-(ANG45/15)); if (mo) { mo->WeaveIndexXY = 32; } - mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->angle+(ANG45/15)); + mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->_f_angle()+(ANG45/15)); if (mo) { mo->WeaveIndexXY = 0; diff --git a/src/g_hexen/a_dragon.cpp b/src/g_hexen/a_dragon.cpp index f9b38268b..d29f3770c 100644 --- a/src/g_hexen/a_dragon.cpp +++ b/src/g_hexen/a_dragon.cpp @@ -22,12 +22,11 @@ DECLARE_ACTION(A_DragonFlight) // //============================================================================ -static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax) +static void DragonSeek (AActor *actor, DAngle thresh, DAngle turnMax) { int dir; int dist; - angle_t delta; - angle_t angle; + DAngle delta; AActor *target; int i; angle_t bestAngle; @@ -42,7 +41,7 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax) dir = P_FaceMobj (actor, target, &delta); if (delta > thresh) { - delta >>= 1; + delta /= 2; if (delta > turnMax) { delta = turnMax; @@ -50,15 +49,14 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax) } if (dir) { // Turn clockwise - actor->angle += delta; + actor->Angles.Yaw += delta; } else { // Turn counter clockwise - actor->angle -= delta; + actor->Angles.Yaw -= delta; } - angle = actor->angle>>ANGLETOFINESHIFT; - actor->vel.x = FixedMul (actor->Speed, finecosine[angle]); - actor->vel.y = FixedMul (actor->Speed, finesine[angle]); + actor->VelFromAngle(); + dist = actor->AproxDistance (target) / actor->Speed; if (actor->Top() < target->Z() || target->Top() < actor->Z()) @@ -73,7 +71,7 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax) { // attack the destination mobj if it's attackable AActor *oldTarget; - if (absangle(actor->angle - actor->AngleTo(target)) < ANGLE_45/2) + if (absangle(actor->_f_angle() - actor->AngleTo(target)) < ANGLE_45/2) { oldTarget = actor->target; actor->target = target; @@ -184,7 +182,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight) angle_t angle; - DragonSeek (self, 4*ANGLE_1, 8*ANGLE_1); + DragonSeek (self, 4, 8); if (self->target) { if(!(self->target->flags&MF_SHOOTABLE)) @@ -193,14 +191,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight) return 0; } angle = self->AngleTo(self->target); - if (absangle(self->angle-angle) < ANGLE_45/2 && self->CheckMeleeRange()) + if (absangle(self->_f_angle()-angle) < ANGLE_45/2 && self->CheckMeleeRange()) { int damage = pr_dragonflight.HitDice (8); int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee); P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); } - else if (absangle(self->angle-angle) <= ANGLE_1*20) + else if (absangle(self->_f_angle()-angle) <= ANGLE_1*20) { self->SetState (self->MissileState); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); diff --git a/src/g_hexen/a_fighteraxe.cpp b/src/g_hexen/a_fighteraxe.cpp index aa6a6ec5c..c7abe78c3 100644 --- a/src/g_hexen/a_fighteraxe.cpp +++ b/src/g_hexen/a_fighteraxe.cpp @@ -236,7 +236,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) { for (int j = 1; j >= -1; j -= 2) { - angle = pmo->angle + j*i*(ANG45 / 16); + angle = pmo->_f_angle() + j*i*(ANG45 / 16); slope = P_AimLineAttack(pmo, angle, AXERANGE, &t); if (t.linetarget) { @@ -257,7 +257,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) // didn't find any creatures, so try to strike any walls pmo->weaponspecial = 0; - angle = pmo->angle; + angle = pmo->_f_angle(); slope = P_AimLineAttack (pmo, angle, MELEERANGE); P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true); diff --git a/src/g_hexen/a_fighterhammer.cpp b/src/g_hexen/a_fighterhammer.cpp index eadf7a05c..590ad99bc 100644 --- a/src/g_hexen/a_fighterhammer.cpp +++ b/src/g_hexen/a_fighterhammer.cpp @@ -47,7 +47,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) hammertime = PClass::FindActor("HammerPuff"); for (i = 0; i < 16; i++) { - angle = pmo->angle + i*(ANG45/32); + angle = pmo->_f_angle() + i*(ANG45/32); slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &t, 0, ALF_CHECK3D); if (t.linetarget != NULL) { @@ -63,7 +63,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) goto hammerdone; } } - angle = pmo->angle-i*(ANG45/32); + angle = pmo->_f_angle()-i*(ANG45/32); slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &t, 0, ALF_CHECK3D); if (t.linetarget != NULL) { @@ -81,7 +81,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) } } // didn't find any targets in meleerange, so set to throw out a hammer - angle = pmo->angle; + angle = pmo->_f_angle(); slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, NULL, 0, ALF_CHECK3D); if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true) != NULL) { diff --git a/src/g_hexen/a_fighterplayer.cpp b/src/g_hexen/a_fighterplayer.cpp index 24d54dd4d..4da0c08f3 100644 --- a/src/g_hexen/a_fighterplayer.cpp +++ b/src/g_hexen/a_fighterplayer.cpp @@ -23,29 +23,25 @@ static FRandom pr_fpatk ("FPunchAttack"); // //============================================================================ -#define MAX_ANGLE_ADJUST (5*ANGLE_1) +#define MAX_ANGLE_ADJUST (5.) void AdjustPlayerAngle (AActor *pmo, FTranslatedLineTarget *t) { - angle_t angle; - int difference; - - angle = t->angleFromSource; - difference = (int)angle - (int)pmo->angle; - if (abs(difference) > MAX_ANGLE_ADJUST) + DAngle difference = deltaangle(pmo->Angles.Yaw, t->angleFromSource); + if (fabs(difference) > MAX_ANGLE_ADJUST) { if (difference > 0) { - pmo->angle += MAX_ANGLE_ADJUST; + pmo->Angles.Yaw += MAX_ANGLE_ADJUST; } else { - pmo->angle -= MAX_ANGLE_ADJUST; + pmo->Angles.Yaw -= MAX_ANGLE_ADJUST; } } else { - pmo->angle = angle; + pmo->Angles.Yaw = t->angleFromSource; } } @@ -116,8 +112,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) power = 2*FRACUNIT; for (i = 0; i < 16; i++) { - if (TryPunch(pmo, pmo->angle + i*(ANG45/16), damage, power) || - TryPunch(pmo, pmo->angle - i*(ANG45/16), damage, power)) + if (TryPunch(pmo, pmo->_f_angle() + i*(ANG45/16), damage, power) || + TryPunch(pmo, pmo->_f_angle() - i*(ANG45/16), damage, power)) { // hit something if (pmo->weaponspecial >= 3) { @@ -131,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) // didn't find any creatures, so try to strike any walls pmo->weaponspecial = 0; - int slope = P_AimLineAttack (pmo, pmo->angle, MELEERANGE); - P_LineAttack (pmo, pmo->angle, MELEERANGE, slope, damage, NAME_Melee, PClass::FindActor("PunchPuff"), true); + int slope = P_AimLineAttack (pmo, pmo->_f_angle(), MELEERANGE); + P_LineAttack (pmo, pmo->_f_angle(), MELEERANGE, slope, damage, NAME_Melee, PClass::FindActor("PunchPuff"), true); return 0; } diff --git a/src/g_hexen/a_fighterquietus.cpp b/src/g_hexen/a_fighterquietus.cpp index cb797f661..8b0256ea5 100644 --- a/src/g_hexen/a_fighterquietus.cpp +++ b/src/g_hexen/a_fighterquietus.cpp @@ -95,11 +95,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FSwordAttack) if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; } - P_SpawnPlayerMissile (self, 0, 0, -10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle+ANGLE_45/4); - P_SpawnPlayerMissile (self, 0, 0, -5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle+ANGLE_45/8); - P_SpawnPlayerMissile (self, 0, 0, 0, RUNTIME_CLASS(AFSwordMissile), self->angle); - P_SpawnPlayerMissile (self, 0, 0, 5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle-ANGLE_45/8); - P_SpawnPlayerMissile (self, 0, 0, 10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle-ANGLE_45/4); + P_SpawnPlayerMissile (self, 0, 0, -10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()+ANGLE_45/4); + P_SpawnPlayerMissile (self, 0, 0, -5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()+ANGLE_45/8); + P_SpawnPlayerMissile (self, 0, 0, 0, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()); + P_SpawnPlayerMissile (self, 0, 0, 5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()-ANGLE_45/8); + P_SpawnPlayerMissile (self, 0, 0, 10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()-ANGLE_45/4); S_Sound (self, CHAN_WEAPON, "FighterSwordFire", 1, ATTN_NORM); return 0; } @@ -138,7 +138,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FighterAttack) if (!self->target) return 0; - angle_t angle = self->angle; + angle_t angle = self->_f_angle(); P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle+ANG45/4, 0); P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle+ANG45/8, 0); diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 73beb03b2..195e77514 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -39,7 +39,7 @@ IMPLEMENT_CLASS (AArtiPoisonBag1) bool AArtiPoisonBag1::Use (bool pickup) { - angle_t angle = Owner->angle >> ANGLETOFINESHIFT; + angle_t angle = Owner->_f_angle() >> ANGLETOFINESHIFT; AActor *mo; mo = Spawn ("PoisonBag", Owner->Vec3Offset( @@ -67,7 +67,7 @@ IMPLEMENT_CLASS (AArtiPoisonBag2) bool AArtiPoisonBag2::Use (bool pickup) { - angle_t angle = Owner->angle >> ANGLETOFINESHIFT; + angle_t angle = Owner->_f_angle() >> ANGLETOFINESHIFT; AActor *mo; mo = Spawn ("FireBomb", Owner->Vec3Offset( @@ -100,12 +100,12 @@ bool AArtiPoisonBag3::Use (bool pickup) mo = Spawn("ThrowingBomb", Owner->PosPlusZ(-Owner->floorclip+35*FRACUNIT + (Owner->player? Owner->player->crouchoffset : 0)), ALLOW_REPLACE); if (mo) { - mo->angle = Owner->angle + (((pr_poisonbag()&7) - 4) << 24); + mo->Angles.Yaw = Owner->Angles.Yaw + (((pr_poisonbag() & 7) - 4) * 22.5f); /* Original flight code from Hexen * mo->momz = 4*FRACUNIT+((player->lookdir)<<(FRACBITS-4)); * mo->z += player->lookdir<<(FRACBITS-4); - * P_ThrustMobj(mo, mo->angle, mo->info->speed); + * P_ThrustMobj(mo, mo->_f_angle(), mo->info->speed); * mo->momx += player->mo->momx>>1; * mo->momy += player->mo->momy>>1; */ @@ -114,9 +114,9 @@ bool AArtiPoisonBag3::Use (bool pickup) // is as set by the projectile. To accommodate this with a proper trajectory, we // aim the projectile ~20 degrees higher than we're looking at and increase the // speed we fire at accordingly. - angle_t orgpitch = angle_t(-Owner->pitch) >> ANGLETOFINESHIFT; - angle_t modpitch = angle_t(0xDC00000 - Owner->pitch) >> ANGLETOFINESHIFT; - angle_t angle = mo->angle >> ANGLETOFINESHIFT; + angle_t orgpitch = angle_t(-Owner->_f_pitch()) >> ANGLETOFINESHIFT; + angle_t modpitch = angle_t(0xDC00000 - Owner->_f_pitch()) >> ANGLETOFINESHIFT; + angle_t angle = mo->_f_angle() >> ANGLETOFINESHIFT; fixed_t speed = fixed_t(g_sqrt((double)mo->Speed*mo->Speed + (4.0*65536*4*65536))); fixed_t xyscale = FixedMul(speed, finecosine[modpitch]); diff --git a/src/g_hexen/a_flies.cpp b/src/g_hexen/a_flies.cpp index 16fefef73..397874b9e 100644 --- a/src/g_hexen/a_flies.cpp +++ b/src/g_hexen/a_flies.cpp @@ -84,9 +84,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlyBuzz) return 0; } - angle_t ang = self->AngleTo(targ); - self->angle = ang; + self->Angles.Yaw = self->_f_AngleTo(targ); self->args[0]++; + angle_t ang = self->AngleTo(targ); ang >>= ANGLETOFINESHIFT; if (!P_TryMove(self, self->X() + 6 * finecosine[ang], self->Y() + 6 * finesine[ang], true)) { diff --git a/src/g_hexen/a_fog.cpp b/src/g_hexen/a_fog.cpp index d974910cc..a1cd099b3 100644 --- a/src/g_hexen/a_fog.cpp +++ b/src/g_hexen/a_fog.cpp @@ -51,7 +51,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn) { delta = self->args[1]; if (delta==0) delta=1; - mo->angle = self->angle + (((pr_fogspawn()%delta)-(delta>>1))<<24); + mo->Angles.Yaw = self->Angles.Yaw + (((pr_fogspawn() % delta) - (delta >> 1)) * (360 / 256.)); mo->target = self; if (self->args[0] < 1) self->args[0] = 1; mo->args[0] = (pr_fogspawn() % (self->args[0]))+1; // Random speed @@ -94,7 +94,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogMove) self->special2 = (weaveindex + 1) & 63; } - angle = self->angle>>ANGLETOFINESHIFT; + angle = self->_f_angle()>>ANGLETOFINESHIFT; self->vel.x = FixedMul(speed, finecosine[angle]); self->vel.y = FixedMul(speed, finesine[angle]); return 0; diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index 0cdc7922b..ed6608c24 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -296,7 +296,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) baseangle = (angle_t)parent->special1; angle = baseangle + actor->AngleOffset; - actor->angle = angle; + actor->Angles.Yaw = ANGLE2FLOAT(angle); angle >>= ANGLETOFINESHIFT; switch (mode) @@ -318,13 +318,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) case SORC_STOPPING: // Balls stopping if ((parent->StopBall == actor->GetClass()) && (parent->args[1] > SORCBALL_SPEED_ROTATIONS) && - (absangle(angle - (parent->angle>>ANGLETOFINESHIFT)) < (30<<5))) + (absangle(angle - (parent->_f_angle()>>ANGLETOFINESHIFT)) < (30<<5))) { // Can stop now actor->target->args[3] = SORC_FIRESPELL; actor->target->args[4] = 0; // Set angle so self angle == sorcerer angle - parent->special1 = (int)(parent->angle - actor->AngleOffset); + parent->special1 = (int)(parent->_f_angle() - actor->AngleOffset); } else { @@ -573,8 +573,8 @@ void ASorcBall3::CastSorcererSpell () angle_t ang1, ang2; AActor *parent = target; - ang1 = angle - ANGLE_45; - ang2 = angle + ANGLE_45; + ang1 = FLOAT2ANGLE(Angles.Yaw.Degrees) - ANGLE_45; + ang2 = FLOAT2ANGLE(Angles.Yaw.Degrees) + ANGLE_45; PClassActor *cls = PClass::FindActor("SorcFX3"); if (health < (SpawnHealth()/3)) { // Spawn 2 at a time @@ -622,8 +622,8 @@ void ASorcBall1::CastSorcererSpell () angle_t ang1, ang2; AActor *parent = target; - ang1 = angle + ANGLE_1*70; - ang2 = angle - ANGLE_1*70; + ang1 = FLOAT2ANGLE(Angles.Yaw.Degrees) + ANGLE_1*70; + ang2 = FLOAT2ANGLE(Angles.Yaw.Degrees) - ANGLE_1*70; PClassActor *cls = PClass::FindActor("SorcFX1"); mo = P_SpawnMissileAngle (parent, cls, ang1, 0); if (mo) @@ -670,7 +670,7 @@ void A_SorcOffense2(AActor *actor) actor->args[4] = (actor->args[4] + 15) & 255; delta = (finesine[index])*SORCFX4_SPREAD_ANGLE; delta = (delta>>FRACBITS)*ANGLE_1; - ang1 = actor->angle + delta; + ang1 = actor->_f_angle() + delta; mo = P_SpawnMissileAngle(parent, PClass::FindActor("SorcFX4"), ang1, 0); if (mo) { @@ -715,13 +715,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnFizzle) AActor *mo; int ix; - fixedvec3 pos = self->Vec3Angle(dist, self->angle, -self->floorclip + (self->height >> 1)); + fixedvec3 pos = self->Vec3Angle(dist, self->_f_angle(), -self->floorclip + (self->height >> 1)); for (ix=0; ix<5; ix++) { mo = Spawn("SorcSpark1", pos, ALLOW_REPLACE); if (mo) { - rangle = (self->angle >> ANGLETOFINESHIFT) + ((pr_heresiarch()%5) << 1); + rangle = (self->_f_angle() >> ANGLETOFINESHIFT) + ((pr_heresiarch()%5) << 1); mo->vel.x = FixedMul(pr_heresiarch()%speed, finecosine[rangle]); mo->vel.y = FixedMul(pr_heresiarch()%speed, finesine[rangle]); mo->vel.z = FRACUNIT*2; @@ -776,7 +776,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) { mo->target = self->target; mo->args[0] = 0; // CW - mo->special1 = self->angle; // Set angle + mo->special1 = self->_f_angle(); // Set angle mo->SetState (mo->FindState("Orbit")); } mo = Spawn(self->GetClass(), self->Pos(), NO_REPLACE); @@ -784,7 +784,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) { mo->target = self->target; mo->args[0] = 1; // CCW - mo->special1 = self->angle; // Set angle + mo->special1 = self->_f_angle(); // Set angle mo->SetState (mo->FindState("Orbit")); } self->Destroy (); diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index 2e9304cdc..8c54de6f2 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -117,7 +117,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryCheck) if (playeringame[i]) { AActor *pmo = players[i].mo; - if (P_CheckSight (self, pmo) && (absangle(pmo->AngleTo(self) - pmo->angle) <= ANGLE_45)) + if (P_CheckSight (self, pmo) && (absangle(pmo->AngleTo(self) - pmo->_f_angle()) <= ANGLE_45)) { // Previous state (pottery bit waiting state) self->SetState (self->state - 1); return 0; @@ -222,7 +222,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn) if (mo) { - P_ThrustMobj (mo, self->angle, (pr_leaf()<<9)+3*FRACUNIT); + P_ThrustMobj (mo, self->_f_angle(), (pr_leaf()<<9)+3*FRACUNIT); mo->target = self; mo->special1 = 0; } @@ -263,7 +263,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafCheck) self->SetState (NULL); return 0; } - angle_t ang = self->target ? self->target->angle : self->angle; + angle_t ang = self->target ? self->target->_f_angle() : self->_f_angle(); if (pr_leafcheck() > 64) { if (!self->vel.x && !self->vel.y) diff --git a/src/g_hexen/a_iceguy.cpp b/src/g_hexen/a_iceguy.cpp index babc14f8f..699c50ca5 100644 --- a/src/g_hexen/a_iceguy.cpp +++ b/src/g_hexen/a_iceguy.cpp @@ -35,7 +35,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyLook) if (pr_iceguylook() < 64) { dist = ((pr_iceguylook()-128)*self->radius)>>7; - an = (self->angle+ANG90)>>ANGLETOFINESHIFT; + an = (self->_f_angle()+ANG90)>>ANGLETOFINESHIFT; Spawn(WispTypes[pr_iceguylook() & 1], self->Vec3Offset( FixedMul(dist, finecosine[an]), @@ -63,7 +63,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) if (pr_iceguychase() < 128) { dist = ((pr_iceguychase()-128)*self->radius)>>7; - an = (self->angle+ANG90)>>ANGLETOFINESHIFT; + an = (self->_f_angle()+ANG90)>>ANGLETOFINESHIFT; mo = Spawn(WispTypes[pr_iceguychase() & 1], self->Vec3Offset( FixedMul(dist, finecosine[an]), @@ -94,8 +94,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyAttack) { return 0; } - P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->angle+ANG90, 40*FRACUNIT), self, self->target, PClass::FindActor ("IceGuyFX")); - P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->angle-ANG90, 40*FRACUNIT), self, self->target, PClass::FindActor ("IceGuyFX")); + P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->_f_angle()+ANG90, 40*FRACUNIT), self, self->target, PClass::FindActor ("IceGuyFX")); + P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->_f_angle()-ANG90, 40*FRACUNIT), self, self->target, PClass::FindActor ("IceGuyFX")); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); return 0; } diff --git a/src/g_hexen/a_korax.cpp b/src/g_hexen/a_korax.cpp index fdcf95365..ba0917ce1 100644 --- a/src/g_hexen/a_korax.cpp +++ b/src/g_hexen/a_korax.cpp @@ -99,7 +99,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) spot = iterator.Next (); if (spot != NULL) { - P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, TELF_SOURCEFOG | TELF_DESTFOG); + P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->Angles.Yaw, TELF_SOURCEFOG | TELF_DESTFOG); } P_StartScript (self, NULL, 249, NULL, NULL, 0, 0); @@ -141,7 +141,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) self->tracer = spot; if (spot) { - P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, TELF_SOURCEFOG | TELF_DESTFOG); + P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->Angles.Yaw, TELF_SOURCEFOG | TELF_DESTFOG); } } } @@ -273,7 +273,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxCommand) S_Sound (self, CHAN_VOICE, "KoraxCommand", 1, ATTN_NORM); // Shoot stream of lightning to ceiling - ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; + ang = (self->_f_angle() - ANGLE_90) >> ANGLETOFINESHIFT; fixedvec3 pos = self->Vec3Offset( KORAX_COMMAND_OFFSET * finecosine[ang], KORAX_COMMAND_OFFSET * finesine[ang], @@ -331,7 +331,7 @@ void KoraxFire (AActor *actor, PClassActor *type, int arm) angle_t ang; - ang = (actor->angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE)) >> ANGLETOFINESHIFT; + ang = (actor->_f_angle() + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE)) >> ANGLETOFINESHIFT; fixedvec3 pos = actor->Vec3Offset( extension[arm] * finecosine[ang], extension[arm] * finesine[ang], @@ -354,12 +354,11 @@ void CHolyWeave (AActor *actor, FRandom &pr_random); // //============================================================================ -void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax) +static void A_KSpiritSeeker (AActor *actor, DAngle thresh, DAngle turnMax) { int dir; int dist; - angle_t delta; - angle_t angle; + DAngle delta; AActor *target; fixed_t newZ; fixed_t deltaZ; @@ -372,7 +371,7 @@ void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax) dir = P_FaceMobj (actor, target, &delta); if (delta > thresh) { - delta >>= 1; + delta /= 2; if(delta > turnMax) { delta = turnMax; @@ -380,15 +379,13 @@ void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax) } if(dir) { // Turn clockwise - actor->angle += delta; + actor->Angles.Yaw += delta; } else { // Turn counter clockwise - actor->angle -= delta; + actor->Angles.Yaw -= delta; } - angle = actor->angle>>ANGLETOFINESHIFT; - actor->vel.x = FixedMul (actor->Speed, finecosine[angle]); - actor->vel.y = FixedMul (actor->Speed, finesine[angle]); + actor->VelFromAngle(); if (!(level.time&15) || actor->Z() > target->Z()+(target->GetDefault()->height) @@ -436,8 +433,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KSpiritRoam) { if (self->tracer) { - A_KSpiritSeeker (self, self->args[0]*ANGLE_1, - self->args[0]*ANGLE_1*2); + A_KSpiritSeeker(self, self->args[0], self->args[0] * 2); } CHolyWeave(self, pr_kspiritweave); if (pr_kspiritroam()<50) @@ -507,7 +503,7 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z, AActor *source, AActor *dest, PClassActor *type) { AActor *th; - angle_t an; + DAngle an; int dist; z -= source->floorclip; @@ -516,12 +512,10 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z, an = th->AngleTo(dest); if (dest->flags & MF_SHADOW) { // Invisible target - an += pr_kmissile.Random2()<<21; + an += pr_missile.Random2() * (45/256.); } - th->angle = an; - an >>= ANGLETOFINESHIFT; - th->vel.x = FixedMul (th->Speed, finecosine[an]); - th->vel.y = FixedMul (th->Speed, finesine[an]); + th->Angles.Yaw = an; + th->VelFromAngle(); dist = dest->AproxDistance (th) / th->Speed; if (dist < 1) { diff --git a/src/g_hexen/a_magecone.cpp b/src/g_hexen/a_magecone.cpp index 69cc31f4f..c04dbe2bc 100644 --- a/src/g_hexen/a_magecone.cpp +++ b/src/g_hexen/a_magecone.cpp @@ -78,11 +78,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1) damage = 90+(pr_cone()&15); for (i = 0; i < 16; i++) { - angle = self->angle+i*(ANG45/16); + angle = self->_f_angle()+i*(ANG45/16); slope = P_AimLineAttack (self, angle, MELEERANGE, &t, 0, ALF_CHECK3D); if (t.linetarget) { - P_DamageMobj (t.linetarget, self, self, damage, NAME_Ice, DMG_USEANGLE, t.angleFromSource); + P_DamageMobj (t.linetarget, self, self, damage, NAME_Ice, DMG_USEANGLE, FLOAT2ANGLE(t.angleFromSource.Degrees)); conedone = true; break; } @@ -128,7 +128,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) // every so many calls, spawn a new missile in its set directions if (spawndir & SHARDSPAWN_LEFT) { - mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->angle+(ANG45/9), + mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->_f_angle()+(ANG45/9), 0, (20+2*spermcount)<target); if (mo) { @@ -140,7 +140,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_RIGHT) { - mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->angle-(ANG45/9), + mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->_f_angle()-(ANG45/9), 0, (20+2*spermcount)<target); if (mo) { @@ -152,7 +152,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_UP) { - mo = P_SpawnMissileAngleZSpeed (self, self->Z()+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, + mo = P_SpawnMissileAngleZSpeed (self, self->Z()+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->_f_angle(), 0, (15+2*spermcount)<target); if (mo) { @@ -167,7 +167,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_DOWN) { - mo = P_SpawnMissileAngleZSpeed (self, self->Z()-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, + mo = P_SpawnMissileAngleZSpeed (self, self->Z()-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->_f_angle(), 0, (15+2*spermcount)<target); if (mo) { diff --git a/src/g_hexen/a_magelightning.cpp b/src/g_hexen/a_magelightning.cpp index 2c9b0d8c1..a49215906 100644 --- a/src/g_hexen/a_magelightning.cpp +++ b/src/g_hexen/a_magelightning.cpp @@ -170,19 +170,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) zigZag = pr_lightningclip(); if((zigZag > 128 && self->special1 < 2) || self->special1 < -2) { - P_ThrustMobj(self, self->angle+ANG90, ZAGSPEED); + P_ThrustMobj(self, self->_f_angle()+ANG90, ZAGSPEED); if(cMo) { - P_ThrustMobj(cMo, self->angle+ANG90, ZAGSPEED); + P_ThrustMobj(cMo, self->_f_angle()+ANG90, ZAGSPEED); } self->special1++; } else { - P_ThrustMobj(self, self->angle-ANG90, ZAGSPEED); + P_ThrustMobj(self, self->_f_angle()-ANG90, ZAGSPEED); if(cMo) { - P_ThrustMobj(cMo, cMo->angle-ANG90, ZAGSPEED); + P_ThrustMobj(cMo, cMo->_f_angle()-ANG90, ZAGSPEED); } self->special1--; } @@ -195,10 +195,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) } else { - self->angle = self->AngleTo(target); + self->Angles.Yaw = self->_f_AngleTo(target); self->vel.x = 0; self->vel.y = 0; - P_ThrustMobj (self, self->angle, self->Speed>>1); + P_ThrustMobj (self, self->Angles.Yaw, self->Speed>>1); } } return 0; diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index ee31257d6..17df610a0 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -139,7 +139,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack) if (!weapon->DepleteAmmo (weapon->bAltFire)) return 0; } - angle = self->angle; + angle = self->_f_angle(); // [RH] Let's try and actually track what the player aimed at P_AimLineAttack (self, angle, PLAYERMISSILERANGE, &t, ANGLE_1*32); @@ -258,7 +258,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MageAttack) return 0; } angle_t angle; - angle = self->angle; + angle = self->_f_angle(); MStaffSpawn2 (self, angle); MStaffSpawn2 (self, angle-ANGLE_1*5); MStaffSpawn2 (self, angle+ANGLE_1*5); diff --git a/src/g_hexen/a_pig.cpp b/src/g_hexen/a_pig.cpp index 4d3201ac4..df5e4728c 100644 --- a/src/g_hexen/a_pig.cpp +++ b/src/g_hexen/a_pig.cpp @@ -73,7 +73,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack) } damage = 3+(pr_snoutattack()&3); - angle = player->mo->angle; + angle = player->mo->_f_angle(); slope = P_AimLineAttack(player->mo, angle, MELEERANGE); puff = P_LineAttack(player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "SnoutPuff", true, &t); S_Sound(player->mo, CHAN_VOICE, "PigActive", 1, ATTN_NORM); diff --git a/src/g_hexen/a_teleportother.cpp b/src/g_hexen/a_teleportother.cpp index 3daca2103..2a8c3192e 100644 --- a/src/g_hexen/a_teleportother.cpp +++ b/src/g_hexen/a_teleportother.cpp @@ -55,7 +55,7 @@ static void TeloSpawn (AActor *source, const char *type) if (fx) { fx->special1 = TELEPORT_LIFE; // Lifetime countdown - fx->angle = source->angle; + fx->Angles.Yaw = source->Angles.Yaw; fx->target = source->target; fx->vel.x = source->vel.x >> 1; fx->vel.y = source->vel.y >> 1; @@ -167,13 +167,11 @@ int ATelOtherFX1::DoSpecialDamage (AActor *target, int damage, FName damagetype) void P_TeleportToPlayerStarts (AActor *victim) { fixed_t destX,destY; - angle_t destAngle; FPlayerStart *start = G_PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK); destX = start->x; destY = start->y; - destAngle = ANG45 * (start->angle/45); - P_Teleport (victim, destX, destY, ONFLOORZ, destAngle, TELF_SOURCEFOG | TELF_DESTFOG); + P_Teleport (victim, destX, destY, ONFLOORZ, start->angle, TELF_SOURCEFOG | TELF_DESTFOG); } //=========================================================================== @@ -186,7 +184,6 @@ void P_TeleportToDeathmatchStarts (AActor *victim) { unsigned int i, selections; fixed_t destX,destY; - angle_t destAngle; selections = deathmatchstarts.Size (); if (selections > 0) @@ -194,8 +191,7 @@ void P_TeleportToDeathmatchStarts (AActor *victim) i = pr_teledm() % selections; destX = deathmatchstarts[i].x; destY = deathmatchstarts[i].y; - destAngle = ANG45 * (deathmatchstarts[i].angle/45); - P_Teleport (victim, destX, destY, ONFLOORZ, destAngle, TELF_SOURCEFOG | TELF_DESTFOG); + P_Teleport (victim, destX, destY, ONFLOORZ, deathmatchstarts[i].angle, TELF_SOURCEFOG | TELF_DESTFOG); } else { diff --git a/src/g_hexen/a_wraith.cpp b/src/g_hexen/a_wraith.cpp index 44aa2c308..94dd17570 100644 --- a/src/g_hexen/a_wraith.cpp +++ b/src/g_hexen/a_wraith.cpp @@ -129,11 +129,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2) { if (pr_wraithfx2 ()<128) { - angle = self->angle+(pr_wraithfx2()<<22); + angle = self->_f_angle()+(pr_wraithfx2()<<22); } else { - angle = self->angle-(pr_wraithfx2()<<22); + angle = self->_f_angle()-(pr_wraithfx2()<<22); } mo->vel.z = 0; mo->vel.x = FixedMul((pr_wraithfx2()<<7)+FRACUNIT, diff --git a/src/g_level.cpp b/src/g_level.cpp index 844311092..e283d86f8 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1240,8 +1240,7 @@ void G_FinishTravel () { if (!(changeflags & CHANGELEVEL_KEEPFACING)) { - pawn->angle = pawndup->angle; - pawn->pitch = pawndup->pitch; + pawn->Angles = pawndup->Angles; } pawn->SetXYZ(pawndup->X(), pawndup->Y(), pawndup->Z()); pawn->vel.x = pawndup->vel.x; diff --git a/src/g_raven/a_artitele.cpp b/src/g_raven/a_artitele.cpp index 88739492d..8f5696f8a 100644 --- a/src/g_raven/a_artitele.cpp +++ b/src/g_raven/a_artitele.cpp @@ -29,7 +29,7 @@ bool AArtiTeleport::Use (bool pickup) { fixed_t destX; fixed_t destY; - angle_t destAngle; + int destAngle; if (deathmatch) { @@ -37,14 +37,14 @@ bool AArtiTeleport::Use (bool pickup) unsigned int i = pr_tele() % selections; destX = deathmatchstarts[i].x; destY = deathmatchstarts[i].y; - destAngle = ANG45 * (deathmatchstarts[i].angle/45); + destAngle = deathmatchstarts[i].angle; } else { FPlayerStart *start = G_PickPlayerStart(int(Owner->player - players)); destX = start->x; destY = start->y; - destAngle = ANG45 * (start->angle/45); + destAngle = start->angle; } P_Teleport (Owner, destX, destY, ONFLOORZ, destAngle, TELF_SOURCEFOG | TELF_DESTFOG); bool canlaugh = true; diff --git a/src/g_raven/a_minotaur.cpp b/src/g_raven/a_minotaur.cpp index 8bd648f66..0a519fb14 100644 --- a/src/g_raven/a_minotaur.cpp +++ b/src/g_raven/a_minotaur.cpp @@ -210,7 +210,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) self->flags2 |= MF2_INVULNERABLE; } A_FaceTarget (self); - angle = self->angle>>ANGLETOFINESHIFT; + angle = self->_f_angle()>>ANGLETOFINESHIFT; self->vel.x = FixedMul (MNTR_CHARGE_SPEED, finecosine[angle]); self->vel.y = FixedMul (MNTR_CHARGE_SPEED, finesine[angle]); self->special1 = TICRATE/2; // Charge duration @@ -312,7 +312,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) { // S_Sound (mo, CHAN_WEAPON, "minotaur/attack2", 1, ATTN_NORM); vz = mo->vel.z; - angle = mo->angle; + angle = mo->_f_angle(); P_SpawnMissileAngleZ (self, z, fx, angle-(ANG45/8), vz); P_SpawnMissileAngleZ (self, z, fx, angle+(ANG45/8), vz); P_SpawnMissileAngleZ (self, z, fx, angle-(ANG45/16), vz); diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 29335e618..9ace9ac13 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -315,7 +315,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) head->vel.x = pr_freeze.Random2 () << (FRACBITS-7); head->vel.y = pr_freeze.Random2 () << (FRACBITS-7); head->health = self->health; - head->angle = self->angle; + head->Angles.Yaw = self->Angles.Yaw; if (head->IsKindOf(RUNTIME_CLASS(APlayerPawn))) { head->player = self->player; @@ -323,7 +323,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) self->player = NULL; head->ObtainInventory (self); } - head->pitch = 0; + head->Angles.Pitch = 0; head->RenderStyle = self->RenderStyle; head->alpha = self->alpha; if (head->player->camera == self) @@ -638,32 +638,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_LowGravity) void FaceMovementDirection (AActor *actor) { - switch (actor->movedir) + if (actor->movedir >= DI_EAST && actor->movedir <= DI_NORTHEAST) { - case DI_EAST: - actor->angle = 0<<24; - break; - case DI_NORTHEAST: - actor->angle = 32<<24; - break; - case DI_NORTH: - actor->angle = 64<<24; - break; - case DI_NORTHWEST: - actor->angle = 96<<24; - break; - case DI_WEST: - actor->angle = 128<<24; - break; - case DI_SOUTHWEST: - actor->angle = 160<<24; - break; - case DI_SOUTH: - actor->angle = 192<<24; - break; - case DI_SOUTHEAST: - actor->angle = 224<<24; - break; + actor->Angles.Yaw = 45. * actor->movedir; } } diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 25646ba35..6397b9f72 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1267,7 +1267,7 @@ void APowerSpeed::DoEffect () AActor *speedMo = Spawn (Owner->Pos(), NO_REPLACE); if (speedMo) { - speedMo->angle = Owner->angle; + speedMo->Angles.Yaw = Owner->Angles.Yaw; speedMo->Translation = Owner->Translation; speedMo->target = Owner; speedMo->sprite = Owner->sprite; diff --git a/src/g_shared/a_bridge.cpp b/src/g_shared/a_bridge.cpp index 3b1b34d71..11df5e495 100644 --- a/src/g_shared/a_bridge.cpp +++ b/src/g_shared/a_bridge.cpp @@ -101,18 +101,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit) } // Set default values // Every five tics, Hexen moved the ball 3/256th of a revolution. - int rotationspeed = ANGLE_45/32*3/5; - int rotationradius = ORBIT_RADIUS * FRACUNIT; + DAngle rotationspeed = 45./32*3/5; + int rotationradius = ORBIT_RADIUS; // If the bridge is custom, set non-default values if any. // Set angular speed; 1--128: counterclockwise rotation ~=1--180°; 129--255: clockwise rotation ~= 180--1° - if (self->target->args[3] > 128) rotationspeed = ANGLE_45/32 * (self->target->args[3]-256) / TICRATE; - else if (self->target->args[3] > 0) rotationspeed = ANGLE_45/32 * (self->target->args[3]) / TICRATE; + if (self->target->args[3] > 128) rotationspeed = 45./32 * (self->target->args[3]-256) / TICRATE; + else if (self->target->args[3] > 0) rotationspeed = 45./32 * (self->target->args[3]) / TICRATE; // Set rotation radius if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / 100); - self->angle += rotationspeed; - self->SetOrigin(self->target->Vec3Angle(rotationradius, self->angle, 0), true); + self->Angles.Yaw += rotationspeed; + self->SetOrigin(self->target->Vec3Angle(rotationradius, self->_f_angle(), 0), true); self->floorz = self->target->floorz; self->ceilingz = self->target->ceilingz; return 0; @@ -124,7 +124,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit) PARAM_ACTION_PROLOGUE; PARAM_CLASS_OPT(balltype, AActor) { balltype = NULL; } - angle_t startangle; AActor *ball; if (balltype == NULL) @@ -132,7 +131,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit) balltype = PClass::FindActor("BridgeBall"); } - startangle = pr_orbit() << 24; + DAngle startangle = pr_orbit() * (360./256.); // Spawn triad into world -- may be more than a triad now. int ballcount = self->args[2]==0 ? 3 : self->args[2]; @@ -140,7 +139,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit) for (int i = 0; i < ballcount; i++) { ball = Spawn(balltype, self->Pos(), ALLOW_REPLACE); - ball->angle = startangle + (ANGLE_45/32) * (256/ballcount) * i; + ball->Angles.Yaw = startangle + (45./32) * (256/ballcount) * i; ball->target = self; CALL_ACTION(A_BridgeOrbit, ball); } diff --git a/src/g_shared/a_camera.cpp b/src/g_shared/a_camera.cpp index fee44a3eb..84df2a614 100644 --- a/src/g_shared/a_camera.cpp +++ b/src/g_shared/a_camera.cpp @@ -57,10 +57,10 @@ public: void Serialize (FArchive &arc); protected: - angle_t Center; - angle_t Acc; - angle_t Delta; - angle_t Range; + DAngle Center; + DAngle Acc; + DAngle Delta; + DAngle Range; }; IMPLEMENT_CLASS (ASecurityCamera) @@ -74,29 +74,25 @@ void ASecurityCamera::Serialize (FArchive &arc) void ASecurityCamera::PostBeginPlay () { Super::PostBeginPlay (); - Center = angle; + Center = Angles.Yaw; if (args[2]) - Delta = ANGLE_MAX / (args[2] * TICRATE / 8); + Delta = 360. / (args[2] * TICRATE / 8); else Delta = 0; if (args[1]) Delta /= 2; Acc = 0; - pitch = (signed int)((char)args[0]) * ANGLE_1; - if (pitch <= -ANGLE_90) - pitch = -ANGLE_90 + ANGLE_1; - else if (pitch >= ANGLE_90) - pitch = ANGLE_90 - ANGLE_1; - Range = FLOAT2ANGLE(args[1]); + Angles.Pitch = clamp((signed int)((signed char)args[0]), -89, 89); + Range = args[1]; } void ASecurityCamera::Tick () { Acc += Delta; - if (Range) - angle = Center + FixedMul (Range, finesine[Acc >> ANGLETOFINESHIFT]); - else if (Delta) - angle = Acc; + if (Range != 0) + Angles.Yaw = Center + Range * Acc.Sin(); + else if (Delta != 0) + Angles.Yaw = Acc; } /* @@ -120,7 +116,7 @@ public: void Serialize (FArchive &arc); protected: - int MaxPitchChange; + DAngle MaxPitchChange; }; IMPLEMENT_CLASS (AAimingCamera) @@ -137,7 +133,7 @@ void AAimingCamera::PostBeginPlay () args[2] = 0; Super::PostBeginPlay (); - MaxPitchChange = FLOAT2ANGLE(changepitch * TICRATE); + MaxPitchChange = changepitch / TICRATE; Range /= TICRATE; TActorIterator iterator (args[3]); @@ -161,7 +157,7 @@ void AAimingCamera::Tick () } if (tracer != NULL) { - angle_t delta; + DAngle delta; int dir = P_FaceMobj (this, tracer, &delta); if (delta > Range) { @@ -169,31 +165,32 @@ void AAimingCamera::Tick () } if (dir) { - angle += delta; + Angles.Yaw += delta; } else { - angle -= delta; + Angles.Yaw -= delta; } - if (MaxPitchChange) + if (MaxPitchChange != 0) { // Aim camera's pitch; use floats for precision fixedvec2 fv3 = tracer->Vec2To(this); DVector2 vect(fv3.x, fv3.y); double dz = Z() - tracer->Z() - tracer->height/2; double dist = vect.Length(); double ang = dist != 0.f ? g_atan2 (dz, dist) : 0; - int desiredpitch = (int)RAD2ANGLE(ang); - if (abs (desiredpitch - pitch) < MaxPitchChange) + DAngle desiredPitch = ToDegrees(ang); + DAngle diff = deltaangle(Angles.Pitch, desiredPitch); + if (fabs (diff) < MaxPitchChange) { - pitch = desiredpitch; + Angles.Pitch = desiredPitch; } - else if (desiredpitch < pitch) + else if (diff < 0) { - pitch -= MaxPitchChange; + Angles.Pitch -= MaxPitchChange; } else { - pitch += MaxPitchChange; + Angles.Pitch += MaxPitchChange; } } } diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index ab0d50933..c823e33d7 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -827,7 +827,7 @@ void ADecal::BeginPlay () // Look for a wall within 64 units behind the actor. If none can be // found, then no decal is created, and this actor is destroyed // without effectively doing anything. - if (NULL == ShootDecal(tpl, this, Sector, X(), Y(), Z(), angle + ANGLE_180, 64*FRACUNIT, true)) + if (NULL == ShootDecal(tpl, this, Sector, X(), Y(), Z(), FLOAT2ANGLE(Angles.Yaw.Degrees) + ANGLE_180, 64*FRACUNIT, true)) { DPrintf ("Could not find a wall to stick decal to at (%d,%d)\n", X()>>FRACBITS, Y()>>FRACBITS); } diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index bf35157b3..16d7601c9 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -176,7 +176,7 @@ void AFastProjectile::Effect() AActor *act = Spawn (trail, X(), Y(), hitz, ALLOW_REPLACE); if (act != NULL) { - act->angle = this->angle; + act->Angles.Yaw = Angles.Yaw; } } } diff --git a/src/g_shared/a_hatetarget.cpp b/src/g_shared/a_hatetarget.cpp index 53cec29f9..78c9ee259 100644 --- a/src/g_shared/a_hatetarget.cpp +++ b/src/g_shared/a_hatetarget.cpp @@ -43,7 +43,6 @@ class AHateTarget : public AActor DECLARE_CLASS (AHateTarget, AActor) public: void BeginPlay (); - int TakeSpecialDamage (AActor *inflictor, AActor *source, int damage, FName damagetype); }; IMPLEMENT_CLASS (AHateTarget) @@ -51,28 +50,14 @@ IMPLEMENT_CLASS (AHateTarget) void AHateTarget::BeginPlay () { Super::BeginPlay (); - if (angle != 0) + if (SpawnAngle != 0) { // Each degree translates into 10 units of health - health = Scale (angle >> 1, 1800, 0x40000000); - // Round to the nearest 10 because of inaccuracy above - health = (health + 5) / 10 * 10; + health = SpawnAngle * 10; } else { - special2 = 1; + flags5 |= MF5_NODAMAGE; health = 1000001; } } -int AHateTarget::TakeSpecialDamage (AActor *inflictor, AActor *source, int damage, FName damagetype) -{ - if (special2 != 0) - { - return 0; - } - else - { - return damage; - } -} - diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index acd5f6f5c..a72615d45 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -88,7 +88,7 @@ bool P_MorphPlayer (player_t *activator, player_t *p, PClassPlayerPawn *spawntyp actor->RemoveFromHash (); actor->tid = 0; } - morphed->angle = actor->angle; + morphed->Angles.Yaw = actor->Angles.Yaw; morphed->target = actor->target; morphed->tracer = actor; morphed->Score = actor->Score; @@ -223,7 +223,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag, mo->tid = pmo->tid; mo->AddToHash (); } - mo->angle = pmo->angle; + mo->Angles.Yaw = pmo->Angles.Yaw; mo->player = player; mo->reactiontime = 18; mo->flags = ActorFlags::FromInt (pmo->special2) & ~MF_JUSTHIT; @@ -307,7 +307,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag, } } - angle = mo->angle >> ANGLETOFINESHIFT; + angle = mo->_f_angle() >> ANGLETOFINESHIFT; AActor *eflash = NULL; if (exit_flash != NULL) { @@ -385,7 +385,7 @@ bool P_MorphMonster (AActor *actor, PClassActor *spawntype, int duration, int st morphed = static_cast(Spawn (spawntype, actor->Pos(), NO_REPLACE)); DObject::StaticPointerSubstitution (actor, morphed); morphed->tid = actor->tid; - morphed->angle = actor->angle; + morphed->Angles.Yaw = actor->Angles.Yaw; morphed->UnmorphedMe = actor; morphed->alpha = actor->alpha; morphed->RenderStyle = actor->RenderStyle; @@ -450,7 +450,7 @@ bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force) beast->UnmorphTime = level.time + 5*TICRATE; // Next try in 5 seconds return false; } - actor->angle = beast->angle; + actor->Angles.Yaw = beast->Angles.Yaw; actor->target = beast->target; actor->FriendPlayer = beast->FriendPlayer; actor->flags = beast->FlagsSave & ~MF_JUSTHIT; diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index e186f8592..bb5150537 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -102,11 +102,7 @@ void AInterpolationPoint::FormChain () if (Next == NULL && (args[3] | args[4])) Printf ("Can't find target for camera node %d\n", tid); - pitch = (signed int)((char)args[0]) * ANGLE_1; - if (pitch <= -ANGLE_90) - pitch = -ANGLE_90 + ANGLE_1; - else if (pitch >= ANGLE_90) - pitch = ANGLE_90 - ANGLE_1; + Angles.Pitch = clamp((signed char)args[0], -89, 89); if (Next != NULL) Next->FormChain (); @@ -426,7 +422,7 @@ bool APathFollower::Interpolate () } if (args[2] & 2) { // adjust yaw - angle = R_PointToAngle2 (0, 0, dx, dy); + Angles.Yaw = vectoyaw(DVector2(dx, dy)); } if (args[2] & 4) { // adjust pitch; use floats for precision @@ -435,57 +431,30 @@ bool APathFollower::Interpolate () double fdz = FIXED2DBL(-dz); double dist = g_sqrt (fdx*fdx + fdy*fdy); double ang = dist != 0.f ? g_atan2 (fdz, dist) : 0; - pitch = (fixed_t)RAD2ANGLE(ang); + Angles.Pitch = ToDegrees(ang); } } else { if (args[2] & 2) { // interpolate angle - double angle1 = (double)CurrNode->angle; - double angle2 = (double)CurrNode->Next->angle; - if (angle2 - angle1 <= -2147483648.f) - { - double lerped = Lerp (angle1, angle2 + 4294967296.f); - if (lerped >= 4294967296.f) - { - angle = xs_CRoundToUInt(lerped - 4294967296.f); - } - else - { - angle = xs_CRoundToUInt(lerped); - } - } - else if (angle2 - angle1 >= 2147483648.f) - { - double lerped = Lerp (angle1, angle2 - 4294967296.f); - if (lerped < 0.f) - { - angle = xs_CRoundToUInt(lerped + 4294967296.f); - } - else - { - angle = xs_CRoundToUInt(lerped); - } - } - else - { - angle = xs_CRoundToUInt(Lerp (angle1, angle2)); - } + DAngle angle1 = CurrNode->Angles.Yaw.Normalized180(); + DAngle angle2 = angle1 + deltaangle(angle1, CurrNode->Next->Angles.Yaw); + Angles.Yaw = Lerp(angle1.Degrees, angle2.Degrees); } if (args[2] & 1) { // linear if (args[2] & 4) { // interpolate pitch - pitch = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->pitch), FIXED2DBL(CurrNode->Next->pitch))); + Angles.Pitch = Lerp(CurrNode->Angles.Pitch.Degrees, CurrNode->Next->Angles.Pitch.Degrees); } } else { // spline if (args[2] & 4) { // interpolate pitch - pitch = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->pitch), FIXED2DBL(CurrNode->pitch), - FIXED2DBL(CurrNode->Next->pitch), FIXED2DBL(CurrNode->Next->Next->pitch))); + Angles.Pitch = Splerp(PrevNode->Angles.Pitch.Degrees, CurrNode->Angles.Pitch.Degrees, + CurrNode->Next->Angles.Pitch.Degrees, CurrNode->Next->Next->Angles.Pitch.Degrees); } } } @@ -558,9 +527,9 @@ bool AActorMover::Interpolate () } if (args[2] & 2) - tracer->angle = angle; + tracer->Angles.Yaw = Angles.Yaw; if (args[2] & 4) - tracer->pitch = pitch; + tracer->Angles.Pitch = Angles.Pitch; return true; } @@ -665,7 +634,7 @@ bool AMovingCamera::Interpolate () if (Super::Interpolate ()) { - angle = AngleTo(tracer, true); + Angles.Yaw = _f_AngleTo(tracer, true); if (args[2] & 4) { // Also aim camera's pitch; use floats for precision @@ -674,7 +643,7 @@ bool AMovingCamera::Interpolate () double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2); double dist = g_sqrt (dx*dx + dy*dy); double ang = dist != 0.f ? g_atan2 (dz, dist) : 0; - pitch = RAD2ANGLE(ang); + Angles.Pitch = ToDegrees(ang); } return true; diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index ff7121e98..51c022195 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -140,7 +140,7 @@ void DEarthquake::Tick () P_DamageMobj (victim, NULL, NULL, pr_quake.HitDice (1), NAME_None); } // Thrust player around - angle_t an = victim->angle + ANGLE_1*pr_quake(); + angle_t an = victim->_f_angle() + ANGLE_1*pr_quake(); if (m_IntensityX == m_IntensityY) { // Thrust in a circle P_ThrustMobj (victim, an, m_IntensityX << (FRACBITS-1)); diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index 5784197a2..83102aeda 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -160,7 +160,8 @@ class ARandomSpawner : public AActor if (newmobj != NULL) { // copy everything relevant - newmobj->SpawnAngle = newmobj->angle = angle; + newmobj->SpawnAngle = SpawnAngle; + newmobj->Angles = Angles; newmobj->SpawnPoint[2] = SpawnPoint[2]; newmobj->special = special; newmobj->args[0] = args[0]; diff --git a/src/g_shared/a_spark.cpp b/src/g_shared/a_spark.cpp index 7e7aa1f8e..17e2ba3bd 100644 --- a/src/g_shared/a_spark.cpp +++ b/src/g_shared/a_spark.cpp @@ -50,6 +50,6 @@ IMPLEMENT_CLASS (ASpark) void ASpark::Activate (AActor *activator) { Super::Activate (activator); - P_DrawSplash (args[0] ? args[0] : 32, X(), Y(), Z(), angle, 1); + P_DrawSplash (args[0] ? args[0] : 32, X(), Y(), Z(), FLOAT2ANGLE(Angles.Yaw.Degrees), 1); S_Sound (this, CHAN_AUTO, "world/spark", 1, ATTN_STATIC); } diff --git a/src/g_shared/sbar_mugshot.cpp b/src/g_shared/sbar_mugshot.cpp index 2eaabc7f7..e3aa8b688 100644 --- a/src/g_shared/sbar_mugshot.cpp +++ b/src/g_shared/sbar_mugshot.cpp @@ -367,16 +367,16 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags) { // The next 12 lines are from the Doom statusbar code. badguyangle = player->mo->AngleTo(player->attacker); - if (badguyangle > player->mo->angle) + if (badguyangle > player->mo->_f_angle()) { // whether right or left - diffang = badguyangle - player->mo->angle; + diffang = badguyangle - player->mo->_f_angle(); i = diffang > ANG180; } else { // whether left or right - diffang = player->mo->angle - badguyangle; + diffang = player->mo->_f_angle() - badguyangle; i = diffang <= ANG180; } // confusing, aint it? if (i && diffang >= ANG45) diff --git a/src/g_strife/a_alienspectres.cpp b/src/g_strife/a_alienspectres.cpp index 53ab1b42a..e45a442b4 100644 --- a/src/g_strife/a_alienspectres.cpp +++ b/src/g_strife/a_alienspectres.cpp @@ -74,13 +74,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_Spectre3Attack) foo->FriendPlayer = 0; foo->tracer = self->target; - self->angle -= ANGLE_180 / 20 * 10; + self->Angles.Yaw -= 90.; for (int i = 0; i < 20; ++i) { - self->angle += ANGLE_180 / 20; + self->Angles.Yaw += 9.; P_SpawnSubMissile (self, PClass::FindActor("SpectralLightningBall2"), self); } - self->angle -= ANGLE_180 / 20 * 10; + self->Angles.Yaw -= 90.; return 0; } diff --git a/src/g_strife/a_crusader.cpp b/src/g_strife/a_crusader.cpp index a7b2ac23c..1b03ea650 100644 --- a/src/g_strife/a_crusader.cpp +++ b/src/g_strife/a_crusader.cpp @@ -28,7 +28,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose) if (CrusaderCheckRange (self)) { A_FaceTarget (self); - self->angle -= ANGLE_180/16; + self->Angles.Yaw -= 180./16; P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); } else @@ -37,11 +37,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose) { A_FaceTarget (self); P_SpawnMissileZAimed (self, self->Z() + 56*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); - self->angle -= ANGLE_45/32; + self->Angles.Yaw -= 45./32; P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); - self->angle += ANGLE_45/16; + self->Angles.Yaw += 45./16; P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindActor("CrusaderMissile")); - self->angle -= ANGLE_45/16; + self->Angles.Yaw -= 45./16; self->reactiontime += 15; } self->SetState (self->SeeState); @@ -53,7 +53,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepLeft) { PARAM_ACTION_PROLOGUE; - self->angle += ANGLE_90/16; + self->Angles.Yaw += 90./16; AActor *misl = P_SpawnMissileZAimed (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); if (misl != NULL) { @@ -66,7 +66,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepRight) { PARAM_ACTION_PROLOGUE; - self->angle -= ANGLE_90/16; + self->Angles.Yaw -= 90./16; AActor *misl = P_SpawnMissileZAimed (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindActor("FastFlameMissile")); if (misl != NULL) { diff --git a/src/g_strife/a_entityboss.cpp b/src/g_strife/a_entityboss.cpp index 3195d3813..390a75ac4 100644 --- a/src/g_strife/a_entityboss.cpp +++ b/src/g_strife/a_entityboss.cpp @@ -81,7 +81,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity) AActor *entity = Spawn("EntityBoss", self->PosPlusZ(70*FRACUNIT), ALLOW_REPLACE); if (entity != NULL) { - entity->angle = self->angle; + entity->Angles.Yaw = self->Angles.Yaw; entity->CopyFriendliness(self, true); entity->vel.z = 5*FRACUNIT; entity->tracer = self; @@ -100,19 +100,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath) AActor *spot = self->tracer; if (spot == NULL) spot = self; - fixedvec3 pos = spot->Vec3Angle(secondRadius, self->angle, self->tracer? 70*FRACUNIT : 0); + fixedvec3 pos = spot->Vec3Angle(secondRadius, self->_f_angle(), self->tracer? 70*FRACUNIT : 0); - an = self->angle >> ANGLETOFINESHIFT; + an = self->_f_angle() >> ANGLETOFINESHIFT; second = Spawn("EntitySecond", pos, ALLOW_REPLACE); second->CopyFriendliness(self, true); //second->target = self->target; A_FaceTarget (second); - an = second->angle >> ANGLETOFINESHIFT; + an = second->_f_angle() >> ANGLETOFINESHIFT; second->vel.x += FixedMul (finecosine[an], 320000); second->vel.y += FixedMul (finesine[an], 320000); - pos = spot->Vec3Angle(secondRadius, self->angle + ANGLE_90, self->tracer? 70*FRACUNIT : 0); - an = (self->angle + ANGLE_90) >> ANGLETOFINESHIFT; + pos = spot->Vec3Angle(secondRadius, self->_f_angle() + ANGLE_90, self->tracer? 70*FRACUNIT : 0); + an = (self->_f_angle() + ANGLE_90) >> ANGLETOFINESHIFT; second = Spawn("EntitySecond", pos, ALLOW_REPLACE); second->CopyFriendliness(self, true); //second->target = self->target; @@ -120,8 +120,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath) second->vel.y = FixedMul (secondRadius, finesine[an]) << 2; A_FaceTarget (second); - pos = spot->Vec3Angle(secondRadius, self->angle - ANGLE_90, self->tracer? 70*FRACUNIT : 0); - an = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; + pos = spot->Vec3Angle(secondRadius, self->_f_angle() - ANGLE_90, self->tracer? 70*FRACUNIT : 0); + an = (self->_f_angle() - ANGLE_90) >> ANGLETOFINESHIFT; second = Spawn("EntitySecond", pos, ALLOW_REPLACE); second->CopyFriendliness(self, true); //second->target = self->target; diff --git a/src/g_strife/a_inquisitor.cpp b/src/g_strife/a_inquisitor.cpp index 8a44add95..dd30a7e88 100644 --- a/src/g_strife/a_inquisitor.cpp +++ b/src/g_strife/a_inquisitor.cpp @@ -62,13 +62,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorAttack) A_FaceTarget (self); self->AddZ(32*FRACUNIT); - self->angle -= ANGLE_45/32; + self->Angles.Yaw -= 45./32; proj = P_SpawnMissileZAimed (self, self->Z(), self->target, PClass::FindActor("InquisitorShot")); if (proj != NULL) { proj->vel.z += 9*FRACUNIT; } - self->angle += ANGLE_45/16; + self->Angles.Yaw += 45./16; proj = P_SpawnMissileZAimed (self, self->Z(), self->target, PClass::FindActor("InquisitorShot")); if (proj != NULL) { @@ -92,7 +92,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); self->AddZ(64*FRACUNIT); A_FaceTarget (self); - an = self->angle >> ANGLETOFINESHIFT; + an = self->_f_angle() >> ANGLETOFINESHIFT; speed = self->Speed * 2/3; self->vel.x += FixedMul (speed, finecosine[an]); self->vel.y += FixedMul (speed, finesine[an]); @@ -136,9 +136,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossArm) PARAM_ACTION_PROLOGUE; AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); - foo->angle = self->angle - ANGLE_90 + (pr_inq.Random2() << 22); - foo->vel.x = FixedMul (foo->Speed, finecosine[foo->angle >> ANGLETOFINESHIFT]) >> 3; - foo->vel.y = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]) >> 3; + foo->Angles.Yaw = self->Angles.Yaw - 90. + pr_inq.Random2() * (360./1024.); + foo->VelFromAngle(foo->Speed / 8); foo->vel.z = pr_inq() << 10; return 0; } diff --git a/src/g_strife/a_programmer.cpp b/src/g_strife/a_programmer.cpp index 214641e03..010fe7935 100644 --- a/src/g_strife/a_programmer.cpp +++ b/src/g_strife/a_programmer.cpp @@ -133,9 +133,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase) AActor *foo = Spawn("ProgrammerBase", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); if (foo != NULL) { - foo->angle = self->angle + ANGLE_180 + (pr_prog.Random2() << 22); - foo->vel.x = FixedMul (foo->Speed, finecosine[foo->angle >> ANGLETOFINESHIFT]); - foo->vel.y = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]); + foo->Angles.Yaw = self->Angles.Yaw + 180. + pr_prog.Random2() * (360. / 1024.); + foo->VelFromAngle(); foo->vel.z = pr_prog() << 9; } return 0; diff --git a/src/g_strife/a_reaver.cpp b/src/g_strife/a_reaver.cpp index 393670f06..369c4d4ee 100644 --- a/src/g_strife/a_reaver.cpp +++ b/src/g_strife/a_reaver.cpp @@ -22,7 +22,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ReaverRanged) A_FaceTarget (self); S_Sound (self, CHAN_WEAPON, "reaver/attack", 1, ATTN_NORM); - bangle = self->angle; + bangle = self->_f_angle(); pitch = P_AimLineAttack (self, bangle, MISSILERANGE); for (int i = 0; i < 3; ++i) diff --git a/src/g_strife/a_rebels.cpp b/src/g_strife/a_rebels.cpp index 6a93ef91e..3b291679e 100644 --- a/src/g_strife/a_rebels.cpp +++ b/src/g_strife/a_rebels.cpp @@ -31,8 +31,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShootGun) S_Sound (self, CHAN_WEAPON, "monsters/rifle", 1, ATTN_NORM); A_FaceTarget (self); - pitch = P_AimLineAttack (self, self->angle, MISSILERANGE); - P_LineAttack (self, self->angle + (pr_shootgun.Random2() << 19), + pitch = P_AimLineAttack (self, self->_f_angle(), MISSILERANGE); + P_LineAttack (self, self->_f_angle() + (pr_shootgun.Random2() << 19), MISSILERANGE, pitch, 3*(pr_shootgun() % 5 + 1), NAME_Hitscan, NAME_StrifePuff); return 0; @@ -115,8 +115,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon) } rebel->SetState (rebel->SeeState); - rebel->angle = self->angle; - an = self->angle >> ANGLETOFINESHIFT; + rebel->Angles.Yaw = self->Angles.Yaw; + an = self->_f_angle() >> ANGLETOFINESHIFT; Spawn (rebel->Vec3Offset(20*finecosine[an], 20*finesine[an], TELEFOGHEIGHT), ALLOW_REPLACE); if (--self->health < 0) { diff --git a/src/g_strife/a_sentinel.cpp b/src/g_strife/a_sentinel.cpp index 21eaa9993..189fefdc8 100644 --- a/src/g_strife/a_sentinel.cpp +++ b/src/g_strife/a_sentinel.cpp @@ -60,7 +60,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) for (int i = 8; i > 1; --i) { trail = Spawn("SentinelFX1", - self->Vec3Angle(missile->radius*i, missile->angle, (missile->vel.z / 4 * i)), ALLOW_REPLACE); + self->Vec3Angle(missile->radius*i, missile->_f_angle(), (missile->vel.z / 4 * i)), ALLOW_REPLACE); if (trail != NULL) { trail->target = self; diff --git a/src/g_strife/a_spectral.cpp b/src/g_strife/a_spectral.cpp index b5003105c..cc171837d 100644 --- a/src/g_strife/a_spectral.cpp +++ b/src/g_strife/a_spectral.cpp @@ -30,7 +30,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail) AActor *foo = Spawn("SpectralLightningHTail", self->Vec3Offset(-self->vel.x, -self->vel.y, 0), ALLOW_REPLACE); - foo->angle = self->angle; + foo->Angles.Yaw = self->Angles.Yaw; foo->FriendPlayer = self->FriendPlayer; return 0; } @@ -42,11 +42,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralBigBallLightning) PClassActor *cls = PClass::FindActor("SpectralLightningH3"); if (cls) { - self->angle += ANGLE_90; + self->Angles.Yaw += 90.; P_SpawnSubMissile (self, cls, self->target); - self->angle += ANGLE_180; + self->Angles.Yaw += 180.; P_SpawnSubMissile (self, cls, self->target); - self->angle += ANGLE_90; + self->Angles.Yaw -= 270.; P_SpawnSubMissile (self, cls, self->target); } return 0; @@ -87,14 +87,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning) // In Strife, this number is stored in the data segment, but it doesn't seem to be // altered anywhere. -#define TRACEANGLE (0xe000000) +#define TRACEANGLE (19.6875) DEFINE_ACTION_FUNCTION(AActor, A_Tracer2) { PARAM_ACTION_PROLOGUE; AActor *dest; - angle_t exact; fixed_t dist; fixed_t slope; @@ -103,28 +102,23 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer2) if (!dest || dest->health <= 0 || self->Speed == 0 || !self->CanSeek(dest)) return 0; - // change angle - exact = self->AngleTo(dest); + DAngle exact = self->_f_AngleTo(dest); + DAngle diff = deltaangle(self->Angles.Yaw, exact); - if (exact != self->angle) + if (diff < 0) { - if (exact - self->angle > 0x80000000) - { - self->angle -= TRACEANGLE; - if (exact - self->angle < 0x80000000) - self->angle = exact; - } - else - { - self->angle += TRACEANGLE; - if (exact - self->angle > 0x80000000) - self->angle = exact; - } + self->Angles.Yaw -= TRACEANGLE; + if (deltaangle(self->Angles.Yaw, exact) > 0) + self->Angles.Yaw = exact; + } + else if (diff > 0) + { + self->Angles.Yaw += TRACEANGLE; + if (deltaangle(self->Angles.Yaw, exact) < 0.) + self->Angles.Yaw = exact; } - exact = self->angle >> ANGLETOFINESHIFT; - self->vel.x = FixedMul (self->Speed, finecosine[exact]); - self->vel.y = FixedMul (self->Speed, finesine[exact]); + self->VelFromAngle(); if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index abbfc2300..4f1282209 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -600,7 +600,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossGib) const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat"; AActor *gib = Spawn (gibtype, self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); - angle_t an; int speed; if (gib == NULL) @@ -608,11 +607,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossGib) return 0; } - an = pr_gibtosser() << 24; - gib->angle = an; + gib->Angles.Yaw = pr_gibtosser() * (360 / 256.f); speed = pr_gibtosser() & 15; - gib->vel.x = speed * finecosine[an >> ANGLETOFINESHIFT]; - gib->vel.y = speed * finesine[an >> ANGLETOFINESHIFT]; + gib->VelFromAngle(speed); gib->vel.z = (pr_gibtosser() & 15) << FRACBITS; return 0; } diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 8129a8bfc..91331ef83 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -110,7 +110,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger) damage *= 10; } - angle = self->angle + (pr_jabdagger.Random2() << 18); + angle = self->_f_angle() + (pr_jabdagger.Random2() << 18); pitch = P_AimLineAttack (self, angle, 80*FRACUNIT); P_LineAttack (self, angle, 80*FRACUNIT, pitch, damage, NAME_Melee, "StrifeSpark", true, &t); @@ -120,7 +120,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger) S_Sound (self, CHAN_WEAPON, t.linetarget->flags & MF_NOBLOOD ? "misc/metalhit" : "misc/meathit", 1, ATTN_NORM); - self->angle = t.angleFromSource; + self->Angles.Yaw = t.angleFromSource; self->flags |= MF_JUSTATTACKED; P_DaggerAlert (self, t.linetarget); } @@ -265,11 +265,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow) if (ti) { - savedangle = self->angle; - self->angle += pr_electric.Random2 () << (18 - self->player->mo->accuracy * 5 / 100); + savedangle = self->_f_angle(); + self->Angles.Yaw += ANGLE2DBL(pr_electric.Random2() * (1 << (18 - self->player->mo->accuracy * 5 / 100))); self->player->mo->PlayAttacking2 (); P_SpawnPlayerMissile (self, ti); - self->angle = savedangle; + self->Angles.Yaw = savedangle; S_Sound (self, CHAN_WEAPON, "weapons/xbowshoot", 1, ATTN_NORM); } return 0; @@ -289,7 +289,7 @@ void P_StrifeGunShot (AActor *mo, bool accurate, angle_t pitch) int damage; damage = 4*(pr_sgunshot()%3+1); - angle = mo->angle; + angle = mo->_f_angle(); if (mo->player != NULL && !accurate) { @@ -358,11 +358,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile) return 0; } - savedangle = self->angle; - self->angle += pr_minimissile.Random2() << (19 - player->mo->accuracy * 5 / 100); + savedangle = self->_f_angle(); + self->Angles.Yaw += ANGLE2DBL(pr_minimissile.Random2() << (19 - player->mo->accuracy * 5 / 100)); player->mo->PlayAttacking2 (); P_SpawnPlayerMissile (self, PClass::FindActor("MiniMissile")); - self->angle = savedangle; + self->Angles.Yaw = savedangle; return 0; } @@ -379,7 +379,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RocketInFlight) AActor *trail; S_Sound (self, CHAN_VOICE, "misc/missileinflight", 1, ATTN_NORM); - P_SpawnPuff (self, PClass::FindActor("MiniMissilePuff"), self->Pos(), self->angle - ANGLE_180, 2, PF_HITTHING); + P_SpawnPuff (self, PClass::FindActor("MiniMissilePuff"), self->Pos(), self->_f_angle() - ANGLE_180, 2, PF_HITTHING); trail = Spawn("RocketTrail", self->Vec3Offset(-self->vel.x, -self->vel.y, 0), ALLOW_REPLACE); if (trail != NULL) { @@ -428,7 +428,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireFlamer) player->mo->PlayAttacking2 (); } - self->angle += pr_flamethrower.Random2() << 18; + self->Angles.Yaw += pr_flamethrower.Random2() * (5.625/256.); self = P_SpawnPlayerMissile (self, PClass::FindActor("FlameMissile")); if (self != NULL) { @@ -472,7 +472,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler1) for (int i = 0; i < 20; ++i) { int damage = 5 * (pr_mauler1() % 3 + 1); - angle_t angle = self->angle + (pr_mauler1.Random2() << 19); + angle_t angle = self->_f_angle() + (pr_mauler1.Random2() << 19); int pitch = bpitch + (pr_mauler1.Random2() * 332063); // Strife used a range of 2112 units for the mauler to signal that @@ -530,7 +530,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler2) } P_SpawnPlayerMissile (self, PClass::FindActor("MaulerTorpedo")); P_DamageMobj (self, self, NULL, 20, self->DamageType); - P_ThrustMobj (self, self->angle + ANGLE_180, 0x7D000); + P_ThrustMobj (self, self->_f_angle() + ANGLE_180, 0x7D000); return 0; } @@ -548,7 +548,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave) AActor *wavedef = GetDefaultByName("MaulerTorpedoWave"); fixed_t savedz; - self->angle += ANGLE_180; + self->Angles.Yaw += 180.; // If the torpedo hit the ceiling, it should still spawn the wave savedz = self->Z(); @@ -559,7 +559,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave) for (int i = 0; i < 80; ++i) { - self->angle += ANGLE_45/10; + self->Angles.Yaw += 4.5; P_SpawnSubMissile (self, PClass::FindActor("MaulerTorpedoWave"), self->target); } self->SetZ(savedz); @@ -576,10 +576,8 @@ AActor *P_SpawnSubMissile (AActor *source, PClassActor *type, AActor *target) } other->target = target; - other->angle = source->angle; - - other->vel.x = FixedMul (other->Speed, finecosine[source->angle >> ANGLETOFINESHIFT]); - other->vel.y = FixedMul (other->Speed, finesine[source->angle >> ANGLETOFINESHIFT]); + other->Angles.Yaw = source->Angles.Yaw; + other->VelFromAngle(); if (other->flags4 & MF4_SPECTRAL) { @@ -595,7 +593,7 @@ AActor *P_SpawnSubMissile (AActor *source, PClassActor *type, AActor *target) if (P_CheckMissileSpawn (other, source->radius)) { - angle_t pitch = P_AimLineAttack (source, source->angle, 1024*FRACUNIT); + angle_t pitch = P_AimLineAttack (source, source->_f_angle(), 1024*FRACUNIT); other->vel.z = FixedMul (-finesine[pitch>>ANGLETOFINESHIFT], other->Speed); return other; } @@ -728,16 +726,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) S_Sound (grenade, CHAN_VOICE, grenade->SeeSound, 1, ATTN_NORM); } - grenade->vel.z = FixedMul (finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)], grenade->Speed) + 8*FRACUNIT; + grenade->vel.z = FixedMul (finetangent[FINEANGLES/4-(self->_f_pitch()>>ANGLETOFINESHIFT)], grenade->Speed) + 8*FRACUNIT; fixedvec2 offset; - an = self->angle >> ANGLETOFINESHIFT; + an = self->_f_angle() >> ANGLETOFINESHIFT; tworadii = self->radius + grenade->radius; offset.x = FixedMul (finecosine[an], tworadii); offset.y = FixedMul (finesine[an], tworadii); - an = self->angle + angleofs; + an = self->_f_angle() + angleofs; an >>= ANGLETOFINESHIFT; offset.x += FixedMul (finecosine[an], 15*FRACUNIT); offset.y += FixedMul (finesine[an], 15*FRACUNIT); @@ -1000,8 +998,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) spot = Spawn("SpectralLightningSpot", self->Pos(), ALLOW_REPLACE); if (spot != NULL) { - spot->vel.x += 28 * finecosine[self->angle >> ANGLETOFINESHIFT]; - spot->vel.y += 28 * finesine[self->angle >> ANGLETOFINESHIFT]; + spot->vel.x += 28 * finecosine[self->_f_angle() >> ANGLETOFINESHIFT]; + spot->vel.y += 28 * finesine[self->_f_angle() >> ANGLETOFINESHIFT]; } } if (spot != NULL) @@ -1054,17 +1052,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil3) P_DamageMobj (self, self, NULL, 3*4, 0, DMG_NO_ARMOR); S_Sound (self, CHAN_WEAPON, "weapons/sigilcharge", 1, ATTN_NORM); - self->angle -= ANGLE_90; + self->Angles.Yaw -= 90.; for (i = 0; i < 20; ++i) { - self->angle += ANGLE_180/20; + self->Angles.Yaw += 9.; spot = P_SpawnSubMissile (self, PClass::FindActor("SpectralLightningBall1"), self); if (spot != NULL) { spot->SetZ(self->Z() + 32*FRACUNIT); } } - self->angle -= (ANGLE_180/20)*10; + self->Angles.Yaw -= 90.; return 0; } @@ -1091,7 +1089,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil4) P_BulletSlope (self, &t, ALF_PORTALRESTRICT); if (t.linetarget != NULL) { - spot = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindActor("SpectralLightningBigV1"), self->angle, &t, NULL, false, false, ALF_PORTALRESTRICT); + spot = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindActor("SpectralLightningBigV1"), self->_f_angle(), &t, NULL, false, false, ALF_PORTALRESTRICT); if (spot != NULL) { spot->tracer = t.linetarget; @@ -1102,8 +1100,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil4) spot = P_SpawnPlayerMissile (self, PClass::FindActor("SpectralLightningBigV1")); if (spot != NULL) { - spot->vel.x += FixedMul (spot->Speed, finecosine[self->angle >> ANGLETOFINESHIFT]); - spot->vel.y += FixedMul (spot->Speed, finesine[self->angle >> ANGLETOFINESHIFT]); + spot->vel.x += FixedMul (spot->Speed, finecosine[self->_f_angle() >> ANGLETOFINESHIFT]); + spot->vel.y += FixedMul (spot->Speed, finesine[self->_f_angle() >> ANGLETOFINESHIFT]); } } return 0; diff --git a/src/g_strife/a_templar.cpp b/src/g_strife/a_templar.cpp index 554ca141d..e46c607c2 100644 --- a/src/g_strife/a_templar.cpp +++ b/src/g_strife/a_templar.cpp @@ -25,12 +25,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_TemplarAttack) S_Sound (self, CHAN_WEAPON, "templar/shoot", 1, ATTN_NORM); A_FaceTarget (self); - pitch = P_AimLineAttack (self, self->angle, MISSILERANGE); + pitch = P_AimLineAttack (self, self->_f_angle(), MISSILERANGE); for (int i = 0; i < 10; ++i) { damage = (pr_templar() & 4) * 2; - angle = self->angle + (pr_templar.Random2() << 19); + angle = self->_f_angle() + (pr_templar.Random2() << 19); pitchdiff = pr_templar.Random2() * 332063; P_LineAttack (self, angle, MISSILERANGE+64*FRACUNIT, pitch+pitchdiff, damage, NAME_Hitscan, NAME_MaulerPuff); } diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 25f8cfca2..7d4a000c1 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -469,8 +469,8 @@ void cht_DoCheat (player_t *player, int cheat) { // Don't allow this in deathmatch even with cheats enabled, because it's // a very very cheap kill. - P_LineAttack (player->mo, player->mo->angle, PLAYERMISSILERANGE, - P_AimLineAttack (player->mo, player->mo->angle, PLAYERMISSILERANGE), TELEFRAG_DAMAGE, + P_LineAttack (player->mo, player->mo->_f_angle(), PLAYERMISSILERANGE, + P_AimLineAttack (player->mo, player->mo->_f_angle(), PLAYERMISSILERANGE), TELEFRAG_DAMAGE, NAME_MDK, NAME_BulletPuff); } break; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 397c07812..0c79c05c7 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3455,7 +3455,7 @@ int DLevelScript::DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, i actor->flags2 |= MF2_PASSMOBJ; if (force || P_TestMobjLocation (actor)) { - actor->angle = angle << 24; + actor->Angles.Yaw = angle * (360. / 256); actor->tid = tid; actor->AddToHash (); if (actor->flags & MF_SPECIAL) @@ -3508,12 +3508,12 @@ int DLevelScript::DoSpawnSpotFacing (int type, int spot, int tid, bool force) while ( (aspot = iterator.Next ()) ) { - spawned += DoSpawn (type, aspot->X(), aspot->Y(), aspot->Z(), tid, aspot->angle >> 24, force); + spawned += DoSpawn (type, aspot->X(), aspot->Y(), aspot->Z(), tid, aspot->_f_angle() >> 24, force); } } else if (activator != NULL) { - spawned += DoSpawn (type, activator->X(), activator->Y(), activator->Z(), tid, activator->angle >> 24, force); + spawned += DoSpawn (type, activator->X(), activator->Y(), activator->Z(), tid, activator->_f_angle() >> 24, force); } return spawned; } @@ -4736,7 +4736,7 @@ static bool DoSpawnDecal(AActor *actor, const FDecalTemplate *tpl, int flags, an { if (!(flags & SDF_ABSANGLE)) { - angle += actor->angle; + angle += actor->_f_angle(); } return NULL != ShootDecal(tpl, actor, actor->Sector, actor->X(), actor->Y(), actor->Z() + (actor->height>>1) - actor->floorclip + actor->GetBobOffset() + zofs, @@ -4745,11 +4745,12 @@ static bool DoSpawnDecal(AActor *actor, const FDecalTemplate *tpl, int flags, an static void SetActorAngle(AActor *activator, int tid, int angle, bool interpolate) { + DAngle an = angle * (360. / 65536); if (tid == 0) { if (activator != NULL) { - activator->SetAngle(angle << 16, interpolate); + activator->SetAngle(an, interpolate); } } else @@ -4759,18 +4760,19 @@ static void SetActorAngle(AActor *activator, int tid, int angle, bool interpolat while ((actor = iterator.Next())) { - actor->SetAngle(angle << 16, interpolate); + actor->SetAngle(an, interpolate); } } } static void SetActorPitch(AActor *activator, int tid, int angle, bool interpolate) { + DAngle an = angle * (360. / 65536); if (tid == 0) { if (activator != NULL) { - activator->SetPitch(angle << 16, interpolate); + activator->SetPitch(an, interpolate); } } else @@ -4780,18 +4782,19 @@ static void SetActorPitch(AActor *activator, int tid, int angle, bool interpolat while ((actor = iterator.Next())) { - actor->SetPitch(angle << 16, interpolate); + actor->SetPitch(an, interpolate); } } } static void SetActorRoll(AActor *activator, int tid, int angle, bool interpolate) { + DAngle an = angle * (360. / 65536); if (tid == 0) { if (activator != NULL) { - activator->SetRoll(angle << 16, interpolate); + activator->SetRoll(an, interpolate); } } else @@ -4801,7 +4804,7 @@ static void SetActorRoll(AActor *activator, int tid, int angle, bool interpolate while ((actor = iterator.Next())) { - actor->SetRoll(angle << 16, interpolate); + actor->SetRoll(an, interpolate); } } } @@ -5901,11 +5904,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) // [Nash] Actor roll functions. Let's roll! case ACSF_SetActorRoll: - actor = SingleActorFromTID(args[0], activator); - if (actor != NULL) - { - actor->SetRoll(args[1] << 16, false); - } + SetActorRoll(activator, args[0], args[1], false); return 0; case ACSF_ChangeActorRoll: @@ -5917,7 +5916,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetActorRoll: actor = SingleActorFromTID(args[0], activator); - return actor != NULL? actor->roll >> 16 : 0; + return actor != NULL? actor->Angles.Roll.FixedAngle() : 0; // [ZK] A_Warp in ACS case ACSF_Warp: @@ -8690,14 +8689,14 @@ scriptwait: case PCD_GETACTORANGLE: { AActor *actor = SingleActorFromTID(STACK(1), activator); - STACK(1) = actor == NULL ? 0 : actor->angle >> 16; + STACK(1) = actor == NULL ? 0 : actor->Angles.Yaw.FixedAngle(); } break; case PCD_GETACTORPITCH: { AActor *actor = SingleActorFromTID(STACK(1), activator); - STACK(1) = actor == NULL ? 0 : actor->pitch >> 16; + STACK(1) = actor == NULL ? 0 : actor->Angles.Pitch.FixedAngle(); } break; @@ -9034,15 +9033,15 @@ scriptwait: // Like Thing_Projectile(Gravity) specials, but you can give the // projectile a TID. // Thing_Projectile2 (tid, type, angle, speed, vspeed, gravity, newtid); - P_Thing_Projectile (STACK(7), activator, STACK(6), NULL, ((angle_t)(STACK(5)<<24)), - STACK(4)<<(FRACBITS-3), STACK(3)<<(FRACBITS-3), 0, NULL, STACK(2), STACK(1), false); + P_Thing_Projectile(STACK(7), activator, STACK(6), NULL, STACK(5) * (360. / 256.), + STACK(4) << (FRACBITS - 3), STACK(3) << (FRACBITS - 3), 0, NULL, STACK(2), STACK(1), false); sp -= 7; break; case PCD_SPAWNPROJECTILE: // Same, but takes an actor name instead of a spawn ID. - P_Thing_Projectile (STACK(7), activator, 0, FBehavior::StaticLookupString (STACK(6)), ((angle_t)(STACK(5)<<24)), - STACK(4)<<(FRACBITS-3), STACK(3)<<(FRACBITS-3), 0, NULL, STACK(2), STACK(1), false); + P_Thing_Projectile(STACK(7), activator, 0, FBehavior::StaticLookupString(STACK(6)), STACK(5) * (360. / 256.), + STACK(4) << (FRACBITS - 3), STACK(3) << (FRACBITS - 3), 0, NULL, STACK(2), STACK(1), false); sp -= 7; break; diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 77de53345..7a88f5d8c 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -1110,14 +1110,14 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang pc->player->ConversationFaceTalker = facetalker; if (saveangle) { - pc->player->ConversationNPCAngle = npc->angle; + pc->player->ConversationNPCAngle = npc->Angles.Yaw; } oldtarget = npc->target; npc->target = pc; if (facetalker) { A_FaceTarget (npc); - pc->angle = pc->AngleTo(npc); + pc->Angles.Yaw = pc->_f_AngleTo(npc); } if ((npc->flags & MF_FRIENDLY) || (npc->flags4 & MF4_NOHATEPLAYERS)) { @@ -1227,7 +1227,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply if (reply == NULL) { // The default reply was selected - npc->angle = player->ConversationNPCAngle; + npc->Angles.Yaw = player->ConversationNPCAngle; npc->flags5 &= ~MF5_INCONVERSATION; return; } @@ -1243,7 +1243,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply TerminalResponse(reply->QuickNo); } npc->ConversationAnimation(2); - npc->angle = player->ConversationNPCAngle; + npc->Angles.Yaw = player->ConversationNPCAngle; npc->flags5 &= ~MF5_INCONVERSATION; return; } @@ -1371,7 +1371,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply } } - npc->angle = player->ConversationNPCAngle; + npc->Angles.Yaw = player->ConversationNPCAngle; // [CW] Set these to NULL because we're not using to them // anymore. However, this can interfere with slideshows @@ -1421,7 +1421,7 @@ void P_ConversationCommand (int netcode, int pnum, BYTE **stream) assert(netcode == DEM_CONVNULL || netcode == DEM_CONVCLOSE); if (player->ConversationNPC != NULL) { - player->ConversationNPC->angle = player->ConversationNPCAngle; + player->ConversationNPC->Angles.Yaw = player->ConversationNPCAngle; player->ConversationNPC->flags5 &= ~MF5_INCONVERSATION; } if (netcode == DEM_CONVNULL) diff --git a/src/p_effect.cpp b/src/p_effect.cpp index ad1795e0e..b2979172f 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -440,7 +440,7 @@ void P_RunEffect (AActor *actor, int effects) } else { - moveangle = actor->angle; + moveangle = actor->_f_angle(); } particle_t *particle; @@ -878,7 +878,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, AActor *thing = Spawn (spawnclass, FLOAT2FIXED(postmp.X), FLOAT2FIXED(postmp.Y), FLOAT2FIXED(postmp.Z), ALLOW_REPLACE); if (thing) - thing->angle = angle; + thing->Angles.Yaw = ANGLE2DBL(angle); pos += trail_step; } } diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 2266cffb8..8a34d44e8 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1191,7 +1191,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams if (fov && fov < ANGLE_MAX) { - angle_t an = lookee->AngleTo(other) - lookee->angle; + angle_t an = lookee->AngleTo(other) - lookee->_f_angle(); if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) { @@ -2135,15 +2135,15 @@ void A_Wander(AActor *self, int flags) // turn towards movement direction if not there yet if (!(flags & CHF_NODIRECTIONTURN) && (self->movedir < DI_NODIR)) { - self->angle &= (angle_t)(7 << 29); - int delta = self->angle - (self->movedir << 29); - if (delta > 0) + self->Angles.Yaw = floor(self->Angles.Yaw.Degrees / 45) * 45.; + DAngle delta = deltaangle(self->Angles.Yaw, (self->movedir * 45)); + if (delta < 0) { - self->angle -= ANG90 / 2; + self->Angles.Yaw -= 45; } - else if (delta < 0) + else if (delta > 0) { - self->angle += ANG90 / 2; + self->Angles.Yaw += 45; } } @@ -2228,7 +2228,6 @@ nosee: void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags) { - int delta; if (actor->flags5 & MF5_INCONVERSATION) return; @@ -2290,15 +2289,15 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele } else if (!(flags & CHF_NODIRECTIONTURN) && actor->movedir < 8) { - actor->angle &= (angle_t)(7<<29); - delta = actor->angle - (actor->movedir << 29); - if (delta > 0) + actor->Angles.Yaw = floor(actor->Angles.Yaw.Degrees / 45) * 45.; + DAngle delta = deltaangle(actor->Angles.Yaw, (actor->movedir * 45)); + if (delta < 0) { - actor->angle -= ANG90/2; + actor->Angles.Yaw -= 45; } - else if (delta < 0) + else if (delta > 0) { - actor->angle += ANG90/2; + actor->Angles.Yaw += 45; } } @@ -2414,7 +2413,7 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele spec->args[1], spec->args[2], spec->args[3], spec->args[4]); } - angle_t lastgoalang = actor->goal->angle; + DAngle lastgoalang = actor->goal->Angles.Yaw; int delay; AActor * newgoal = iterator.Next (); if (newgoal != NULL && actor->goal == actor->target) @@ -2426,7 +2425,7 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele { delay = 0; actor->reactiontime = actor->GetDefault()->reactiontime; - actor->angle = lastgoalang; // Look in direction of last goal + actor->Angles.Yaw = lastgoalang; // Look in direction of last goal } if (actor->target == actor->goal) actor->target = NULL; actor->flags |= MF_JUSTATTACKED; @@ -2820,7 +2819,7 @@ enum FAF_Flags FAF_TOP = 4, FAF_NODISTFACTOR = 8, // deprecated }; -void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags, fixed_t z_add) +void A_Face (AActor *self, AActor *other, angle_t _max_turn, angle_t _max_pitch, angle_t _ang_offset, angle_t _pitch_offset, int flags, fixed_t z_add) { if (!other) return; @@ -2833,43 +2832,35 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a self->flags &= ~MF_AMBUSH; - angle_t other_angle = self->AngleTo(other); + DAngle max_turn = ANGLE2DBL(_max_turn); + DAngle ang_offset = ANGLE2DBL(_ang_offset); + DAngle max_pitch = ANGLE2DBL(_max_pitch); + DAngle pitch_offset = ANGLE2DBL(_pitch_offset); + DAngle other_angle = self->_f_AngleTo(other); + + DAngle delta = deltaangle(self->Angles.Yaw, other_angle); // 0 means no limit. Also, if we turn in a single step anyways, no need to go through the algorithms. // It also means that there is no need to check for going past the other. - if (max_turn && (max_turn < absangle(self->angle - other_angle))) + if (max_turn != 0 && (max_turn < fabs(delta))) { - if (self->angle > other_angle) + if (delta > 0) { - if (self->angle - other_angle < ANGLE_180) - { - self->angle -= max_turn + ang_offset; - } - else - { - self->angle += max_turn + ang_offset; - } + self->Angles.Yaw -= max_turn + ang_offset; } else { - if (other_angle - self->angle < ANGLE_180) - { - self->angle += max_turn + ang_offset; - } - else - { - self->angle -= max_turn + ang_offset; - } + self->Angles.Yaw += max_turn + ang_offset; } } else { - self->angle = other_angle + ang_offset; + self->Angles.Yaw = other_angle + ang_offset; } // [DH] Now set pitch. In order to maintain compatibility, this can be // disabled and is so by default. - if (max_pitch <= ANGLE_180) + if (max_pitch <= 180.) { fixedvec2 pos = self->Vec2To(other); DVector2 dist(pos.x, pos.y); @@ -2898,34 +2889,35 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a double dist_z = target_z - source_z; double ddist = g_sqrt(dist.X*dist.X + dist.Y*dist.Y + dist_z*dist_z); - int other_pitch = (int)RAD2ANGLE(g_asin(dist_z / ddist)); + + DAngle other_pitch = DAngle(ToDegrees(g_asin(dist_z / ddist))).Normalized180(); if (max_pitch != 0) { - if (self->pitch > other_pitch) + if (self->Angles.Pitch > other_pitch) { - max_pitch = MIN(max_pitch, unsigned(self->pitch - other_pitch)); - self->pitch -= max_pitch; + max_pitch = MIN(max_pitch, (self->Angles.Pitch - other_pitch).Normalized360()); + self->Angles.Pitch -= max_pitch; } else { - max_pitch = MIN(max_pitch, unsigned(other_pitch - self->pitch)); - self->pitch += max_pitch; + max_pitch = MIN(max_pitch, (other_pitch - self->Angles.Pitch).Normalized360()); + self->Angles.Pitch += max_pitch; } } else { - self->pitch = other_pitch; + self->Angles.Pitch = other_pitch; } - self->pitch += pitch_offset; + self->Angles.Pitch += pitch_offset; } // This will never work well if the turn angle is limited. - if (max_turn == 0 && (self->angle == other_angle) && other->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE) ) + if (max_turn == 0 && (self->Angles.Yaw == other_angle) && other->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE) ) { - self->angle += pr_facetarget.Random2() << 21; + self->Angles.Yaw += pr_facetarget.Random2() * (45 / 256.); } } @@ -2990,7 +2982,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) if (!self->target) return 0; - fixed_t saved_pitch = self->pitch; + DAngle saved_pitch = self->Angles.Pitch; FTranslatedLineTarget t; // [RH] Andy Baker's stealth monsters @@ -3001,28 +2993,28 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) self->flags &= ~MF_AMBUSH; - self->angle = self->AngleTo(self->target); + self->Angles.Yaw = self->_f_AngleTo(self->target); - self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &t, ANGLE_1*60, 0, self->target); + self->Angles.Pitch = ANGLE2DBL(P_AimLineAttack (self, self->_f_angle(), MISSILERANGE, &t, ANGLE_1*60, 0, self->target)); if (t.linetarget == NULL) { // We probably won't hit the target, but aim at it anyway so we don't look stupid. fixedvec2 pos = self->Vec2To(self->target); DVector2 xydiff(pos.x, pos.y); double zdiff = (self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip); - self->pitch = int(g_atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI); + self->Angles.Pitch = -ToDegrees(g_atan2(zdiff, xydiff.Length())); } // Let the aim trail behind the player - self->angle = self->AngleTo(self->target, -self->target->vel.x * 3, -self->target->vel.y * 3); + self->Angles.Yaw = ANGLE2DBL(self->AngleTo(self->target, -self->target->vel.x * 3, -self->target->vel.y * 3)); if (self->target->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE)) { - self->angle += pr_railface.Random2() << 21; + self->Angles.Yaw += pr_railface.Random2() * 45./256; } P_RailAttack (self, self->GetMissileDamage (0, 1), 0); - self->pitch = saved_pitch; + self->Angles.Pitch = saved_pitch; return 0; } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 7c6f05b29..14a2a6330 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -82,7 +82,8 @@ static const BYTE ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 }; #define SPEED(a) ((a)*(FRACUNIT/8)) #define TICS(a) (((a)*TICRATE)/35) #define OCTICS(a) (((a)*TICRATE)/8) -#define BYTEANGLE(a) ((angle_t)((a)<<24)) +#define _f_BYTEANGLE(a) ((angle_t)((a)<<24)) +#define BYTEANGLE(a) ((a) * (360./256.)) #define CRUSH(a) ((a) > 0? (a) : -1) #define CRUSHTYPE(a) ((a)==1? false : (a)==2? true : gameinfo.gametype == GAME_Hexen) #define CHANGE(a) (((a) >= 0 && (a)<=7)? ChangeMap[a]:0) @@ -146,13 +147,13 @@ FUNC(LS_Polyobj_RotateRight) FUNC(LS_Polyobj_Move) // Polyobj_Move (po, speed, angle, distance) { - return EV_MovePoly (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg3 * FRACUNIT, false); + return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, false); } FUNC(LS_Polyobj_MoveTimes8) // Polyobj_MoveTimes8 (po, speed, angle, distance) { - return EV_MovePoly (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg3 * FRACUNIT * 8, false); + return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, false); } FUNC(LS_Polyobj_MoveTo) @@ -173,13 +174,13 @@ FUNC(LS_Polyobj_MoveToSpot) FUNC(LS_Polyobj_DoorSwing) // Polyobj_DoorSwing (po, speed, angle, delay) { - return EV_OpenPolyDoor (ln, arg0, arg1, BYTEANGLE(arg2), arg3, 0, PODOOR_SWING); + return EV_OpenPolyDoor (ln, arg0, arg1, _f_BYTEANGLE(arg2), arg3, 0, PODOOR_SWING); } FUNC(LS_Polyobj_DoorSlide) // Polyobj_DoorSlide (po, speed, angle, distance, delay) { - return EV_OpenPolyDoor (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg4, arg3*FRACUNIT, PODOOR_SLIDE); + return EV_OpenPolyDoor (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg4, arg3*FRACUNIT, PODOOR_SLIDE); } FUNC(LS_Polyobj_OR_RotateLeft) @@ -197,13 +198,13 @@ FUNC(LS_Polyobj_OR_RotateRight) FUNC(LS_Polyobj_OR_Move) // Polyobj_OR_Move (po, speed, angle, distance) { - return EV_MovePoly (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg3 * FRACUNIT, true); + return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, true); } FUNC(LS_Polyobj_OR_MoveTimes8) // Polyobj_OR_MoveTimes8 (po, speed, angle, distance) { - return EV_MovePoly (ln, arg0, SPEED(arg1), BYTEANGLE(arg2), arg3 * FRACUNIT * 8, true); + return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, true); } FUNC(LS_Polyobj_OR_MoveTo) @@ -1100,7 +1101,7 @@ FUNC(LS_Teleport_Line) return EV_SilentLineTeleport (ln, backSide, it, arg1, arg2); } -static void ThrustThingHelper (AActor *it, angle_t angle, int force, INTBOOL nolimit); +static void ThrustThingHelper (AActor *it, DAngle angle, int force, INTBOOL nolimit); FUNC(LS_ThrustThing) // ThrustThing (angle, force, nolimit, tid) { @@ -1125,11 +1126,9 @@ FUNC(LS_ThrustThing) return false; } -static void ThrustThingHelper (AActor *it, angle_t angle, int force, INTBOOL nolimit) +static void ThrustThingHelper (AActor *it, DAngle angle, int force, INTBOOL nolimit) { - angle >>= ANGLETOFINESHIFT; - it->vel.x += force * finecosine[angle]; - it->vel.y += force * finesine[angle]; + it->VelFromAngle(angle, force << FRACBITS); if (!nolimit) { it->vel.x = clamp (it->vel.x, -MAXMOVE, MAXMOVE); @@ -1661,7 +1660,7 @@ FUNC(LS_Thing_SpawnNoFog) FUNC(LS_Thing_SpawnFacing) // Thing_SpawnFacing (tid, type, nofog, newtid) { - return P_Thing_Spawn (arg0, it, arg1, ANGLE_MAX, arg2 ? false : true, arg3); + return P_Thing_Spawn (arg0, it, arg1, 1000000., arg2 ? false : true, arg3); } FUNC(LS_Thing_Raise) @@ -3217,7 +3216,7 @@ FUNC(LS_ForceField) if (it != NULL) { P_DamageMobj (it, NULL, NULL, 16, NAME_None); - P_ThrustMobj (it, it->angle + ANGLE_180, 0x7D000); + P_ThrustMobj (it, it->_f_angle() + ANGLE_180, 0x7D000); } return true; } @@ -3272,8 +3271,6 @@ FUNC(LS_GlassBreak) { // Break some glass fixed_t x, y; AActor *glass; - angle_t an; - int speed; x = ln->v1->x + ln->dx/2; y = ln->v1->y + ln->dy/2; @@ -3286,12 +3283,9 @@ FUNC(LS_GlassBreak) glass->AddZ(24 * FRACUNIT); glass->SetState (glass->SpawnState + (pr_glass() % glass->health)); - an = pr_glass() << (32-8); - glass->angle = an; - an >>= ANGLETOFINESHIFT; - speed = pr_glass() & 3; - glass->vel.x = finecosine[an] * speed; - glass->vel.y = finesine[an] * speed; + + glass->Angles.Yaw = pr_glass() * (360 / 256.); + glass->VelFromAngle(pr_glass() & 3); glass->vel.z = (pr_glass() & 7) << FRACBITS; // [RH] Let the shards stick around longer than they did in Strife. glass->tics += pr_glass(); diff --git a/src/p_local.h b/src/p_local.h index 8acfe2d34..ba91462a4 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -25,6 +25,7 @@ #include "doomtype.h" #include "tables.h" +#include "vectors.h" class player_t; class AActor; @@ -129,7 +130,12 @@ void P_PredictionLerpReset(); APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags=0); void P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move); -int P_FaceMobj (AActor *source, AActor *target, angle_t *delta); +inline void P_ThrustMobj(AActor *mo, DAngle angle, fixed_t move) +{ + P_ThrustMobj(mo, FLOAT2ANGLE(angle.Degrees), move); +} + +int P_FaceMobj (AActor *source, AActor *target, DAngle *delta); bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool precise = false, bool usecurspeed=false); enum EPuffFlags @@ -187,8 +193,8 @@ AActor *P_SpawnSubMissile (AActor *source, PClassActor *type, AActor *target); / extern FClassMap SpawnableThings; extern FClassMap StrifeTypes; -bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, int newtid); -bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_name, angle_t angle, +bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid); +bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_name, DAngle angle, fixed_t speed, fixed_t vspeed, int dest, AActor *forcedest, int gravity, int newtid, bool leadTarget); bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog); diff --git a/src/p_map.cpp b/src/p_map.cpp index a6f5020da..ac58c84ce 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2348,7 +2348,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, thing->UnlinkFromWorld(); thing->SetXYZ(pos); P_TranslatePortalVXVY(ld, thing->vel.x, thing->vel.y); - P_TranslatePortalAngle(ld, thing->angle); + P_TranslatePortalAngle(ld, thing->Angles.Yaw); thing->LinkToWorld(); P_FindFloorCeiling(thing); thing->ClearInterpolation(); @@ -3314,7 +3314,7 @@ bool FSlide::BounceWall(AActor *mo) } moveangle = R_PointToAngle2(0, 0, mo->vel.x, mo->vel.y); deltaangle = (2 * lineangle) - moveangle; - mo->angle = deltaangle; + mo->Angles.Yaw = ANGLE2DBL(deltaangle); deltaangle >>= ANGLETOFINESHIFT; @@ -3379,13 +3379,11 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) if (!ontop) { fixed_t speed; - angle_t angle = BlockingMobj->AngleTo(mo) + ANGLE_1*((pr_bounce() % 16) - 8); + DAngle angle = BlockingMobj->_f_AngleTo(mo) + ((pr_bounce() % 16) - 8); speed = P_AproxDistance(mo->vel.x, mo->vel.y); speed = FixedMul(speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent - mo->angle = angle; - angle >>= ANGLETOFINESHIFT; - mo->vel.x = FixedMul(speed, finecosine[angle]); - mo->vel.y = FixedMul(speed, finesine[angle]); + mo->Angles.Yaw = ANGLE2DBL(angle); + mo->VelFromAngle(speed); mo->PlayBounceSound(true); if (mo->BounceFlags & BOUNCE_UseBounceState) { @@ -3533,7 +3531,7 @@ struct aim_t { res.linetarget = th; res.pitch = pitch; - res.angleFromSource = R_PointToAngle2(startpos.x, startpos.y, th->X(), th->Y()); + res.angleFromSource = vectoyaw(DVector2(th->X() - startpos.x, th->Y() - startpos.y)); res.unlinked = unlinked; res.frac = frac; } @@ -4095,10 +4093,10 @@ fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, FTranslated aim.startpos = t1->Pos(); aim.aimtrace = Vec2Angle(distance, angle); aim.limitz = aim.shootz = shootz; - aim.toppitch = t1->pitch - vrange; - aim.bottompitch = t1->pitch + vrange; + aim.toppitch = t1->_f_pitch() - vrange; + aim.bottompitch = t1->_f_pitch() + vrange; aim.attackrange = distance; - aim.aimpitch = t1->pitch; + aim.aimpitch = t1->_f_pitch(); aim.lastsector = t1->Sector; aim.startfrac = 0; aim.unlinked = false; @@ -4112,7 +4110,7 @@ fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, FTranslated { *pLineTarget = *result; } - return result->linetarget ? result->pitch : t1->pitch; + return result->linetarget ? result->pitch : t1->_f_pitch(); } @@ -4399,7 +4397,7 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, if (victim != NULL) { victim->linetarget = trace.Actor; - victim->angleFromSource = trace.SrcAngleToTarget; + victim->angleFromSource = ANGLE2DBL(trace.SrcAngleToTarget); victim->unlinked = trace.unlinked; } } @@ -4625,7 +4623,7 @@ void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff) fixed_t randpitch = (pr_tracebleed() - 128) << 16; P_TraceBleed(damage, t->linetarget->X(), t->linetarget->Y(), t->linetarget->Z() + t->linetarget->height / 2, - t->linetarget, t->angleFromSource, 0); + t->linetarget, FLOAT2ANGLE(t->angleFromSource.Degrees), 0); } //========================================================================== @@ -4722,8 +4720,8 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i puffclass = PClass::FindActor(NAME_BulletPuff); } - pitch = ((angle_t)(-source->pitch) + pitchoffset) >> ANGLETOFINESHIFT; - angle = (source->angle + angleoffset) >> ANGLETOFINESHIFT; + pitch = ((angle_t)(-source->_f_pitch()) + pitchoffset) >> ANGLETOFINESHIFT; + angle = (source->_f_angle() + angleoffset) >> ANGLETOFINESHIFT; vx = FixedMul(finecosine[pitch], finecosine[angle]); vy = FixedMul(finecosine[pitch], finesine[angle]); @@ -4743,7 +4741,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i } } - angle = ((source->angle + angleoffset) - ANG90) >> ANGLETOFINESHIFT; + angle = ((source->_f_angle() + angleoffset) - ANG90) >> ANGLETOFINESHIFT; fixedvec2 xy = source->Vec2Offset(offset_xy * finecosine[angle], offset_xy * finesine[angle]); @@ -4822,7 +4820,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i if (bleed) { P_SpawnBlood(hitpos, hitangle, newdam > 0 ? newdam : damage, hitactor); - P_TraceBleed(newdam > 0 ? newdam : damage, hitpos, hitactor, source->angle, pitch); + P_TraceBleed(newdam > 0 ? newdam : damage, hitpos, hitactor, source->_f_angle(), pitch); } } @@ -4874,7 +4872,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i end.X = FIXED2DBL(trace.HitPos.x); end.Y = FIXED2DBL(trace.HitPos.y); end.Z = FIXED2DBL(trace.HitPos.z); - P_DrawRailTrail(source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->angle + angleoffset, duration, sparsity, drift, SpiralOffset); + P_DrawRailTrail(source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->_f_angle() + angleoffset, duration, sparsity, drift, SpiralOffset); } //========================================================================== @@ -4889,8 +4887,8 @@ CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector, bool &unlinked) { fixed_t distance = (fixed_t)(clamp(chase_dist, 0, 30000) * FRACUNIT); - angle_t angle = (t1->angle - ANG180) >> ANGLETOFINESHIFT; - angle_t pitch = (angle_t)(t1->pitch) >> ANGLETOFINESHIFT; + angle_t angle = (t1->_f_angle() - ANG180) >> ANGLETOFINESHIFT; + angle_t pitch = (angle_t)(t1->_f_pitch()) >> ANGLETOFINESHIFT; FTraceResults trace; fixed_t vx, vy, vz, sz; @@ -4937,7 +4935,7 @@ bool P_TalkFacing(AActor *player) for (int angle : angleofs) { - P_AimLineAttack(player, player->angle + angle, TALKRANGE, &t, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION | ALF_PORTALRESTRICT); + P_AimLineAttack(player, player->_f_angle() + angle, TALKRANGE, &t, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION | ALF_PORTALRESTRICT); if (t.linetarget != NULL) { if (t.linetarget->health > 0 && // Dead things can't talk. @@ -5133,7 +5131,7 @@ void P_UseLines(player_t *player) // If the player is transitioning a portal, use the group that is at its vertical center. fixedvec2 start = player->mo->GetPortalTransition(player->mo->height / 2); // [NS] Now queries the Player's UseRange. - fixedvec2 end = start + Vec2Angle(userange > 0? fixed_t(userange<mo->UseRange, player->mo->angle); + fixedvec2 end = start + Vec2Angle(userange > 0? fixed_t(userange<mo->UseRange, player->mo->_f_angle()); // old code: // @@ -5167,7 +5165,7 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) int angle; fixed_t x1, y1, x2, y2, usedist; - angle = PuzzleItemUser->angle >> ANGLETOFINESHIFT; + angle = PuzzleItemUser->_f_angle() >> ANGLETOFINESHIFT; x1 = PuzzleItemUser->X(); y1 = PuzzleItemUser->Y(); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 6a79ae015..d3e070a3a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -237,7 +237,7 @@ void AActor::Serialize (FArchive &arc) arc << __pos.x << __pos.y << __pos.z - << angle + << Angles.Yaw << frame << scaleX << scaleY @@ -252,8 +252,8 @@ void AActor::Serialize (FArchive &arc) << effects << alpha << fillcolor - << pitch - << roll + << Angles.Pitch // move these up when savegame compatibility is broken! + << Angles.Roll // For now they have to remain here. << Sector << floorz << ceilingz @@ -832,19 +832,17 @@ bool AActor::UseInventory (AInventory *item) AInventory *AActor::DropInventory (AInventory *item) { - angle_t an; AInventory *drop = item->CreateTossable (); if (drop == NULL) { return NULL; } - an = angle >> ANGLETOFINESHIFT; drop->SetOrigin(PosPlusZ(10*FRACUNIT), false); - drop->angle = angle; - drop->vel.x = vel.x + 5 * finecosine[an]; - drop->vel.y = vel.y + 5 * finesine[an]; - drop->vel.z = vel.z + FRACUNIT; + drop->Angles.Yaw = Angles.Yaw; + drop->VelFromAngle(5); + drop->vel.z = FRACUNIT; + drop->vel += vel; drop->flags &= ~MF_NOGRAVITY; // Don't float drop->ClearCounters(); // do not count for statistics again return drop; @@ -1576,7 +1574,7 @@ bool AActor::FloorBounceMissile (secplane_t &plane) vel.x -= MulScale15 (plane.a, dot); vel.y -= MulScale15 (plane.b, dot); vel.z -= MulScale15 (plane.c, dot); - angle = R_PointToAngle2 (0, 0, vel.x, vel.y); + AngleFromVel(); if (!(BounceFlags & BOUNCE_MBF)) // Heretic projectiles die, MBF projectiles don't. { flags |= MF_INBOUNCE; @@ -1592,7 +1590,7 @@ bool AActor::FloorBounceMissile (secplane_t &plane) vel.x = FixedMul (vel.x - MulScale15 (plane.a, dot), bouncefactor); vel.y = FixedMul (vel.y - MulScale15 (plane.b, dot), bouncefactor); vel.z = FixedMul (vel.z - MulScale15 (plane.c, dot), bouncefactor); - angle = R_PointToAngle2 (0, 0, vel.x, vel.y); + AngleFromVel(); } PlayBounceSound(true); @@ -1652,41 +1650,20 @@ void P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move) // //---------------------------------------------------------------------------- -int P_FaceMobj (AActor *source, AActor *target, angle_t *delta) +int P_FaceMobj (AActor *source, AActor *target, DAngle *delta) { - angle_t diff; - angle_t angle1; - angle_t angle2; + DAngle diff; - angle1 = source->angle; - angle2 = source->AngleTo(target); - if (angle2 > angle1) + diff = deltaangle(source->Angles.Yaw, source->_f_AngleTo(target)); + if (diff > 0) { - diff = angle2 - angle1; - if (diff > ANGLE_180) - { - *delta = ANGLE_MAX - diff; - return 0; - } - else - { - *delta = diff; - return 1; - } + *delta = diff; + return 0; } else { - diff = angle1 - angle2; - if (diff > ANGLE_180) - { - *delta = ANGLE_MAX - diff; - return 1; - } - else - { - *delta = diff; - return 0; - } + *delta = -diff; + return 1; } } @@ -1719,16 +1696,18 @@ bool AActor::CanSeek(AActor *target) const // //---------------------------------------------------------------------------- -bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool precise, bool usecurspeed) +bool P_SeekerMissile (AActor *actor, angle_t _thresh, angle_t _turnMax, bool precise, bool usecurspeed) { + DAngle thresh = ANGLE2DBL(_thresh); + DAngle turnMax = ANGLE2DBL(_turnMax); + int dir; int dist; - angle_t delta; - angle_t angle; + DAngle delta; AActor *target; fixed_t speed; - speed = !usecurspeed ? actor->Speed : xs_CRoundToInt(DVector3(actor->vel.x, actor->vel.y, actor->vel.z).Length()); + speed = !usecurspeed ? actor->Speed : actor->VelToSpeed(); target = actor->tracer; if (target == NULL || !actor->CanSeek(target)) { @@ -1746,7 +1725,7 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool preci dir = P_FaceMobj (actor, target, &delta); if (delta > thresh) { - delta >>= 1; + delta /= 2; if (delta > turnMax) { delta = turnMax; @@ -1754,18 +1733,16 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool preci } if (dir) { // Turn clockwise - actor->angle += delta; + actor->Angles.Yaw += delta; } else { // Turn counter clockwise - actor->angle -= delta; + actor->Angles.Yaw -= delta; } - angle = actor->angle>>ANGLETOFINESHIFT; if (!precise) { - actor->vel.x = FixedMul (speed, finecosine[angle]); - actor->vel.y = FixedMul (speed, finesine[angle]); + actor->VelFromAngle(speed); if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { @@ -1783,25 +1760,19 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool preci } else { - angle_t pitch = 0; + DAngle pitch = 0; if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { // Need to seek vertically - fixedvec2 vec = actor->Vec2To(target); - double dist = MAX(1.0, DVector2(vec.x, vec.y).Length()); + fixed_t dist = MAX(1, actor->Distance2D(target)); // Aim at a player's eyes and at the middle of the actor for everything else. fixed_t aimheight = target->height/2; if (target->IsKindOf(RUNTIME_CLASS(APlayerPawn))) { aimheight = static_cast(target)->ViewHeight; } - pitch = R_PointToAngle2(0, actor->Z() + actor->height/2, xs_CRoundToInt(dist), target->Z() + aimheight); - pitch >>= ANGLETOFINESHIFT; + pitch = ANGLE2DBL(R_PointToAngle2(0, actor->Z() + actor->height/2, dist, target->Z() + aimheight)); } - - fixed_t xyscale = FixedMul(speed, finecosine[pitch]); - actor->vel.z = FixedMul(speed, finesine[pitch]); - actor->vel.x = FixedMul(xyscale, finecosine[angle]); - actor->vel.y = FixedMul(xyscale, finesine[angle]); + actor->Vel3DFromAngle(pitch, speed); } return true; @@ -1820,7 +1791,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { static int pushtime = 0; bool bForceSlide = scrollx || scrolly; - angle_t angle; + DAngle Angle; fixed_t ptryx, ptryy; player_t *player; fixed_t xmove, ymove; @@ -1983,7 +1954,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) FCheckPosition tm(!!(mo->flags2 & MF2_RIP)); - angle_t oldangle = mo->angle; + angle_t oldangle = mo->_f_angle(); do { if (i_compatflags & COMPATF_WALLRUN) pushtime++; @@ -2123,7 +2094,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // Don't change the angle if there's THRUREFLECT on the monster. if (!(BlockingMobj->flags7 & MF7_THRUREFLECT)) { - angle = BlockingMobj->AngleTo(mo); + DAngle angle = BlockingMobj->_f_AngleTo(mo); bool dontReflect = (mo->AdjustReflectionAngle(BlockingMobj, angle)); // Change angle for deflection/reflection @@ -2149,17 +2120,15 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { if ((BlockingMobj->flags7 & MF7_MIRRORREFLECT) && (tg | blockingtg)) { - mo->angle += ANGLE_180; + mo->Angles.Yaw += 180.; mo->vel.x = -mo->vel.x / 2; mo->vel.y = -mo->vel.y / 2; mo->vel.z = -mo->vel.z / 2; } else { - mo->angle = angle; - angle >>= ANGLETOFINESHIFT; - mo->vel.x = FixedMul(mo->Speed >> 1, finecosine[angle]); - mo->vel.y = FixedMul(mo->Speed >> 1, finesine[angle]); + mo->Angles.Yaw = angle; + mo->VelFromAngle(mo->Speed / 2); mo->vel.z = -mo->vel.z / 2; } } @@ -2220,7 +2189,7 @@ explode: } else { - angle_t anglediff = (mo->angle - oldangle) >> ANGLETOFINESHIFT; + angle_t anglediff = (mo->_f_angle() - oldangle) >> ANGLETOFINESHIFT; if (anglediff != 0) { @@ -2229,7 +2198,7 @@ explode: xmove = xnew; ymove = ynew; - oldangle = mo->angle; // in case more moves are needed this needs to be updated. + oldangle = mo->_f_angle(); // in case more moves are needed this needs to be updated. } startx = mo->X() - Scale (xmove, step, steps); @@ -2855,7 +2824,7 @@ void P_NightmareRespawn (AActor *mobj) mo->SpawnPoint[2] = mobj->SpawnPoint[2]; mo->SpawnAngle = mobj->SpawnAngle; mo->SpawnFlags = mobj->SpawnFlags & ~MTF_DORMANT; // It wasn't dormant when it died, so it's not dormant now, either. - mo->angle = ANG45 * (mobj->SpawnAngle/45); + mo->Angles.Yaw = mobj->SpawnAngle; mo->HandleSpawnFlags (); mo->reactiontime = 18; @@ -3119,37 +3088,37 @@ int AActor::SpecialMissileHit (AActor *victim) return -1; } -bool AActor::AdjustReflectionAngle (AActor *thing, angle_t &angle) +bool AActor::AdjustReflectionAngle (AActor *thing, DAngle &angle) { if (flags2 & MF2_DONTREFLECT) return true; if (thing->flags7 & MF7_THRUREFLECT) return false; // Change angle for reflection if (thing->flags4&MF4_SHIELDREFLECT) { - // Shield reflection (from the Centaur - if (absangle(angle - thing->angle)>>24 > 45) + // Shield reflection (from the Centaur) + if (diffangle(angle, thing->Angles.Yaw) > 45) return true; // Let missile explode if (thing->IsKindOf (RUNTIME_CLASS(AHolySpirit))) // shouldn't this be handled by another flag??? return true; if (pr_reflect () < 128) - angle += ANGLE_45; + angle += 45; else - angle -= ANGLE_45; + angle -= 45; } else if (thing->flags4&MF4_DEFLECT) { // deflect (like the Heresiarch) if(pr_reflect() < 128) - angle += ANG45; + angle += 45; else - angle -= ANG45; + angle -= 45; } else { - angle += ANGLE_1 * ((pr_reflect() % 16) - 8); + angle += ((pr_reflect() % 16) - 8); } //Always check for AIMREFLECT, no matter what else is checked above. if (thing->flags7 & MF7_AIMREFLECT) @@ -3219,7 +3188,7 @@ bool AActor::IsOkayToAttack (AActor *link) // to only allow the check to succeed if the enemy was in a ~84� FOV of the player if (flags3 & MF3_SCREENSEEKER) { - angle_t angle = Friend->AngleTo(link) - Friend->angle; + angle_t angle = Friend->AngleTo(link) - Friend->_f_angle(); angle >>= 24; if (angle>226 || angle<30) { @@ -3244,11 +3213,11 @@ void AActor::SetShade (int r, int g, int b) fillcolor = MAKEARGB(ColorMatcher.Pick (r, g, b), r, g, b); } -void AActor::SetPitch(int p, bool interpolate, bool forceclamp) +void AActor::SetPitch(DAngle p, bool interpolate, bool forceclamp) { if (player != NULL || forceclamp) { // clamp the pitch we set - int min, max; + DAngle min, max; if (player != NULL) { @@ -3257,14 +3226,14 @@ void AActor::SetPitch(int p, bool interpolate, bool forceclamp) } else { - min = -ANGLE_90 + (1 << ANGLETOFINESHIFT); - max = ANGLE_90 - (1 << ANGLETOFINESHIFT); + min = -89.; + max = 89.; } - p = clamp(p, min, max); + p = clamp(p, min, max); } - if (p != pitch) + if (p != Angles.Pitch) { - pitch = p; + Angles.Pitch = p; if (player != NULL && interpolate) { player->cheats |= CF_INTERPVIEW; @@ -3272,11 +3241,11 @@ void AActor::SetPitch(int p, bool interpolate, bool forceclamp) } } -void AActor::SetAngle(angle_t ang, bool interpolate) +void AActor::SetAngle(DAngle ang, bool interpolate) { - if (ang != angle) + if (ang != Angles.Yaw) { - angle = ang; + Angles.Yaw = ang; if (player != NULL && interpolate) { player->cheats |= CF_INTERPVIEW; @@ -3284,11 +3253,11 @@ void AActor::SetAngle(angle_t ang, bool interpolate) } } -void AActor::SetRoll(angle_t r, bool interpolate) +void AActor::SetRoll(DAngle r, bool interpolate) { - if (r != roll) + if (r != Angles.Roll) { - roll = r; + Angles.Roll = r; if (player != NULL && interpolate) { player->cheats |= CF_INTERPVIEW; @@ -4453,7 +4422,7 @@ void AActor::PostBeginPlay () { Renderer->StateChanged(this); } - PrevAngle = angle; + PrevAngles = Angles; flags7 |= MF7_HANDLENODELAY; } @@ -4613,7 +4582,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) APlayerPawn *mobj, *oldactor; BYTE state; fixed_t spawn_x, spawn_y, spawn_z; - angle_t spawn_angle; + DAngle SpawnAngle; if (mthing == NULL) { @@ -4672,25 +4641,18 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) spawn_y = p->mo->Y(); spawn_z = p->mo->Z(); - spawn_angle = p->mo->angle; + SpawnAngle = p->mo->Angles.Yaw; } else { spawn_x = mthing->x; spawn_y = mthing->y; - // Allow full angular precision but avoid roundoff errors for multiples of 45 degrees. - if (mthing->angle % 45 != 0) - { - spawn_angle = mthing->angle * (ANG45 / 45); - } - else - { - spawn_angle = ANG45 * (mthing->angle / 45); - } + // Allow full angular precision + SpawnAngle = mthing->angle; if (i_compatflags2 & COMPATF2_BADANGLES) { - spawn_angle += 1 << ANGLETOFINESHIFT; + SpawnAngle += 0.01; } if (GetDefaultByType(p->cls)->flags & MF_SPAWNCEILING) @@ -4741,8 +4703,8 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) mobj->Translation = TRANSLATION(TRANSLATION_Players,playernum); } - mobj->angle = spawn_angle; - mobj->pitch = mobj->roll = 0; + mobj->Angles.Yaw = SpawnAngle; + mobj->Angles.Pitch = mobj->Angles.Roll = 0; mobj->health = p->health; // [RH] Set player sprite based on skin @@ -4829,7 +4791,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) if (multiplayer) { - unsigned an = mobj->angle >> ANGLETOFINESHIFT; + unsigned an = mobj->_f_angle() >> ANGLETOFINESHIFT; Spawn ("TeleportFog", mobj->Vec3Offset(20*finecosine[an], 20*finesine[an], TELEFOGHEIGHT), ALLOW_REPLACE); } @@ -4946,7 +4908,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) polyspawn->x = mthing->x; polyspawn->y = mthing->y; polyspawn->angle = mthing->angle; - polyspawn->type = mentry->Special; + polyspawn->type = mentry->Special; polyspawns = polyspawn; if (mentry->Special != SMT_PolyAnchor) po_NumPolyobjs++; @@ -5205,7 +5167,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) mobj->tid = mthing->thingid; mobj->AddToHash (); - mobj->PrevAngle = mobj->angle = (DWORD)((mthing->angle * CONST64(0x100000000)) / 360); + mobj->PrevAngles.Yaw = mobj->Angles.Yaw = mthing->angle; // Check if this actor's mapthing has a conversation defined if (mthing->Conversation > 0) @@ -5229,9 +5191,9 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) if (mthing->scaleY) mobj->scaleY = FixedMul(mthing->scaleY, mobj->scaleY); if (mthing->pitch) - mobj->pitch = ANGLE_1 * mthing->pitch; + mobj->Angles.Pitch = mthing->pitch; if (mthing->roll) - mobj->roll = ANGLE_1 * mthing->roll; + mobj->Angles.Roll = mthing->roll; if (mthing->score) mobj->Score = mthing->score; if (mthing->fillcolor) @@ -5295,7 +5257,7 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y puff->target = source; // Angle is the opposite of the hit direction (i.e. the puff faces the source.) - puff->angle = hitdir + ANGLE_180; + puff->Angles.Yaw = ANGLE2DBL(hitdir + ANGLE_180); // If a puff has a crash state and an actor was not hit, // it will enter the crash state. This is used by the StrifeSpark @@ -5361,7 +5323,7 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc z += pr_spawnblood.Random2 () << 10; th = Spawn (bloodcls, x, y, z, NO_REPLACE); // GetBloodType already performed the replacement th->vel.z = FRACUNIT*2; - th->angle = dir; + th->Angles.Yaw = ANGLE2DBL(dir); // [NG] Applying PUFFGETSOWNER to the blood will make it target the owner if (th->flags5 & MF5_PUFFGETSOWNER) th->target = originator; if (gameinfo.gametype & GAME_DoomChex) @@ -6029,7 +5991,7 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, th->vel.y = newy; } - th->angle = R_PointToAngle2 (0, 0, th->vel.x, th->vel.y); + th->AngleFromVel(); if (th->flags4 & MF4_SPECTRAL) { @@ -6045,17 +6007,14 @@ AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassAct { return NULL; } - angle_t an; fixed_t dist; AActor *th = Spawn (type, source->PosPlusZ(4*8*FRACUNIT), ALLOW_REPLACE); P_PlaySpawnSound(th, source); th->target = owner; // record missile's originator - th->angle = an = source->AngleTo(dest); - an >>= ANGLETOFINESHIFT; - th->vel.x = FixedMul (th->Speed, finecosine[an]); - th->vel.y = FixedMul (th->Speed, finesine[an]); + th->Angles.Yaw = source->_f_AngleTo(dest); + th->VelFromAngle(); dist = source->AproxDistance (dest); if (th->Speed) dist = dist / th->Speed; @@ -6112,7 +6071,7 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, PClassAct fixed_t speed; fixed_t vz; - an = source->angle; + an = source->_f_angle(); if (dest->flags & MF_SHADOW) { @@ -6164,10 +6123,8 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, P_PlaySpawnSound(mo, source); if (owner == NULL) owner = source; mo->target = owner; - mo->angle = angle; - angle >>= ANGLETOFINESHIFT; - mo->vel.x = FixedMul (speed, finecosine[angle]); - mo->vel.y = FixedMul (speed, finesine[angle]); + mo->Angles.Yaw = ANGLE2DBL(angle); + mo->VelFromAngle(speed); mo->vel.z = vz; if (mo->flags4 & MF4_SPECTRAL) @@ -6193,7 +6150,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, PClassActor *type) { return NULL; } - return P_SpawnPlayerMissile (source, 0, 0, 0, type, source->angle); + return P_SpawnPlayerMissile (source, 0, 0, 0, type, source->_f_angle()); } AActor *P_SpawnPlayerMissile (AActor *source, PClassActor *type, angle_t angle) @@ -6221,7 +6178,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, { // Keep exactly the same angle and pitch as the player's own aim an = angle; - pitch = source->pitch; + pitch = source->_f_pitch(); pLineTarget->linetarget = NULL; } else // see which target is to be aimed at @@ -6279,25 +6236,15 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, if (pMissileActor) *pMissileActor = MissileActor; P_PlaySpawnSound(MissileActor, source); MissileActor->target = source; - MissileActor->angle = an; - - fixed_t vx, vy, vz, speed; - - vx = FixedMul (finecosine[pitch>>ANGLETOFINESHIFT], finecosine[an>>ANGLETOFINESHIFT]); - vy = FixedMul (finecosine[pitch>>ANGLETOFINESHIFT], finesine[an>>ANGLETOFINESHIFT]); - vz = -finesine[pitch>>ANGLETOFINESHIFT]; - speed = MissileActor->Speed; - - DVector3 vec(vx, vy, vz); - - if (MissileActor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)) + MissileActor->Angles.Yaw = ANGLE2DBL(an); + if (MissileActor->flags3 & (MF3_FLOORHUGGER | MF3_CEILINGHUGGER)) { - vec.Z = 0; + MissileActor->VelFromAngle(); + } + else + { + MissileActor->Vel3DFromAngle(ANGLE2DBL(pitch), MissileActor->Speed); } - vec.Resize(speed); - MissileActor->vel.x = xs_CRoundToInt(vec.X); - MissileActor->vel.y = xs_CRoundToInt(vec.Y); - MissileActor->vel.z = xs_CRoundToInt(vec.Z); if (MissileActor->flags4 & MF4_SPECTRAL) { diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 60eae8731..1ef362077 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -932,7 +932,7 @@ angle_t P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget, int aimfl i = 2; do { - an = mo->angle + angdiff[i]; + an = mo->_f_angle() + angdiff[i]; pitch = P_AimLineAttack (mo, an, 16*64*FRACUNIT, pLineTarget, 0, aimflags); if (mo->player != NULL && @@ -956,7 +956,7 @@ void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, angle_t pitch) int damage; damage = 5*(pr_gunshot()%3+1); - angle = mo->angle; + angle = mo->_f_angle(); if (!accurate) { diff --git a/src/p_spec.h b/src/p_spec.h index e3b1c05ad..fe4f39ec5 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -919,7 +919,7 @@ inline void P_SpawnTeleportFog(AActor *mobj, const fixedvec3 &pos, bool beforeTe { P_SpawnTeleportFog(mobj, pos.x, pos.y, pos.z, beforeTele, setTarget); } -bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int flags); // bool useFog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false +bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, int flags); // bool useFog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags); bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse); bool EV_TeleportOther (int other_tid, int dest_tid, bool fog); diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 254abb0ad..13b29e6de 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -143,8 +143,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo fixedvec3 pos = optpos? *optpos : user->PosRelative(line); dlu.x = pos.x; dlu.y = pos.y; - dlu.dx = finecosine[user->angle >> ANGLETOFINESHIFT]; - dlu.dy = finesine[user->angle >> ANGLETOFINESHIFT]; + dlu.dx = finecosine[user->_f_angle() >> ANGLETOFINESHIFT]; + dlu.dy = finesine[user->_f_angle() >> ANGLETOFINESHIFT]; inter = P_InterceptVector(&dll, &dlu); diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index b6bdceda5..690759a5e 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -99,7 +99,7 @@ void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool befo // TELEPORTATION // -bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int flags) +bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, int flags) { bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING)); @@ -171,16 +171,16 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, player->viewz = thing->Z() + player->viewheight; if (resetpitch) { - player->mo->pitch = 0; + player->mo->Angles.Pitch = 0; } } if (!(flags & TELF_KEEPORIENTATION)) { - thing->angle = angle; + thing->Angles.Yaw = angle; } else { - angle = thing->angle; + angle = thing->Angles.Yaw; } // Spawn teleport fog at source and destination if ((flags & TELF_SOURCEFOG) && !predicting) @@ -214,9 +214,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, } if (thing->flags & MF_MISSILE) { - angle >>= ANGLETOFINESHIFT; - thing->vel.x = FixedMul (missilespeed, finecosine[angle]); - thing->vel.y = FixedMul (missilespeed, finesine[angle]); + thing->VelFromAngle(missilespeed); } // [BC] && bHaltVelocity. else if (!(flags & TELF_KEEPORIENTATION) && !(flags & TELF_KEEPVELOCITY)) @@ -328,10 +326,10 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f { AActor *searcher; fixed_t z; - angle_t angle = 0; + DAngle angle = 0; fixed_t s = 0, c = 0; fixed_t vx = 0, vy = 0; - angle_t badangle = 0; + DAngle badangle = 0; if (thing == NULL) { // Teleport function called with an invalid actor @@ -358,11 +356,11 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f // Rotate 90 degrees, so that walking perpendicularly across // teleporter linedef causes thing to exit in the direction // indicated by the exit thing. - angle = R_PointToAngle2 (0, 0, line->dx, line->dy) - searcher->angle + ANG90; + angle = vectoyaw(DVector2(line->dx, line->dy)) - searcher->Angles.Yaw + 90; // Sine, cosine of angle adjustment - s = finesine[angle>>ANGLETOFINESHIFT]; - c = finecosine[angle>>ANGLETOFINESHIFT]; + s = FLOAT2FIXED(angle.Sin()); + c = FLOAT2FIXED(angle.Cos()); // Velocity of thing crossing teleporter linedef vx = thing->vel.x; @@ -380,15 +378,15 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f } if ((i_compatflags2 & COMPATF2_BADANGLES) && (thing->player != NULL)) { - badangle = 1 << ANGLETOFINESHIFT; + badangle = 0.01; } - if (P_Teleport (thing, searcher->X(), searcher->Y(), z, searcher->angle + badangle, flags)) + if (P_Teleport (thing, searcher->X(), searcher->Y(), z, searcher->Angles.Yaw + badangle, flags)) { // [RH] Lee Killough's changes for silent teleporters from BOOM if (!(flags & TELF_DESTFOG) && line && (flags & TELF_KEEPORIENTATION)) { // Rotate thing according to difference in angles - thing->angle += angle; + thing->Angles.Yaw += angle; // Rotate thing's velocity to come out of exit just like it entered thing->vel.x = FixedMul(vx, c) - FixedMul(vy, s); @@ -551,7 +549,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO } // Rotate thing's orientation according to difference in linedef angles - thing->angle += angle; + thing->Angles.Yaw += ANGLE2DBL(angle); // Velocity of thing crossing teleporter linedef x = thing->vel.x; @@ -611,10 +609,9 @@ bool EV_TeleportOther (int other_tid, int dest_tid, bool fog) static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool floorz, bool fog) { - int an = (dest->angle - source->angle) >> ANGLETOFINESHIFT; + int an = (dest->_f_angle() - source->_f_angle()) >> ANGLETOFINESHIFT; fixed_t offX = victim->X() - source->X(); fixed_t offY = victim->Y() - source->Y(); - angle_t offAngle = victim->angle - source->angle; fixed_t newX = DMulScale16 (offX, finecosine[an], -offY, finesine[an]); fixed_t newY = DMulScale16 (offX, finesine[an], offY, finecosine[an]); @@ -624,7 +621,7 @@ static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool fl floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z(), 0, fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION); // P_Teleport only changes angle if fog is true - victim->angle = dest->angle + offAngle; + victim->Angles.Yaw = (dest->Angles.Yaw + victim->Angles.Yaw - source->Angles.Yaw).Normalized360(); return res; } @@ -632,7 +629,7 @@ static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool fl #if 0 static void MoveTheDecal (DBaseDecal *decal, fixed_t z, AActor *source, AActor *dest) { - int an = (dest->angle - source->angle) >> ANGLETOFINESHIFT; + int an = (dest->_f_angle() - source->_f_angle()) >> ANGLETOFINESHIFT; fixed_t offX = decal->x - source->x; fixed_t offY = decal->y - source->y; fixed_t newX = DMulScale16 (offX, finecosine[an], -offY, finesine[an]); @@ -691,7 +688,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t didSomething |= P_Teleport (sourceOrigin, destOrigin->X(), destOrigin->Y(), floorz ? ONFLOORZ : destOrigin->Z(), 0, TELF_KEEPORIENTATION); - sourceOrigin->angle = destOrigin->angle; + sourceOrigin->Angles.Yaw = destOrigin->Angles.Yaw; } return didSomething; diff --git a/src/p_things.cpp b/src/p_things.cpp index 6a4508240..324ec95aa 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -57,7 +57,7 @@ FClassMap SpawnableThings; static FRandom pr_leadtarget ("LeadTarget"); -bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, int newtid) +bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid) { int rtn = 0; PClassActor *kind; @@ -95,7 +95,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, if (P_TestMobjLocation (mobj)) { rtn++; - mobj->angle = (angle != ANGLE_MAX ? angle : spot->angle); + mobj->Angles.Yaw = (angle != 1000000. ? angle : spot->Angles.Yaw); if (fog) { P_SpawnTeleportFog(mobj, spot->X(), spot->Y(), spot->Z() + TELEFOGHEIGHT, false, true); @@ -172,7 +172,7 @@ bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog) return false; } -bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_name, angle_t angle, +bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_name, DAngle angle, fixed_t speed, fixed_t vspeed, int dest, AActor *forcedest, int gravity, int newtid, bool leadTarget) { @@ -303,12 +303,12 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam mobj->vel.x = fixed_t (aimvec[0] * aimscale); mobj->vel.y = fixed_t (aimvec[1] * aimscale); mobj->vel.z = fixed_t (aimvec[2] * aimscale); - mobj->angle = R_PointToAngle2 (0, 0, mobj->vel.x, mobj->vel.y); + mobj->AngleFromVel(); } else { nolead: - mobj->angle = mobj->AngleTo(targ); + mobj->Angles.Yaw = mobj->_f_AngleTo(targ); aim.Resize (fspeed); mobj->vel.x = fixed_t(aim[0]); mobj->vel.y = fixed_t(aim[1]); @@ -321,9 +321,8 @@ nolead: } else { - mobj->angle = angle; - mobj->vel.x = FixedMul (speed, finecosine[angle>>ANGLETOFINESHIFT]); - mobj->vel.y = FixedMul (speed, finesine[angle>>ANGLETOFINESHIFT]); + mobj->Angles.Yaw = angle; + mobj->VelFromAngle(); mobj->vel.z = vspeed; } // Set the missile's speed to reflect the speed it was spawned at. @@ -701,7 +700,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, if (!(flags & WARPF_ABSOLUTEANGLE)) { - angle += (flags & WARPF_USECALLERANGLE) ? caller->angle : reference->angle; + angle += (flags & WARPF_USECALLERANGLE) ? caller->_f_angle() : reference->_f_angle(); } const fixed_t rad = FixedMul(radiusoffset, reference->radius); @@ -762,13 +761,13 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, } else { - caller->angle = angle; + caller->Angles.Yaw = ANGLE2DBL(angle); if (flags & WARPF_COPYPITCH) - caller->SetPitch(reference->pitch, false); + caller->SetPitch(reference->Angles.Pitch, false); if (pitch) - caller->SetPitch(caller->pitch + pitch, false); + caller->SetPitch(caller->Angles.Pitch + ANGLE2DBL(pitch), false); if (flags & WARPF_COPYVELOCITY) { diff --git a/src/p_user.cpp b/src/p_user.cpp index 5a26d46f3..f3082f659 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1660,7 +1660,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop) mo->ObtainInventory (self); mo->player = player; mo->health = self->health; - mo->angle = self->angle; + mo->Angles.Yaw = self->Angles.Yaw; if (player != NULL) { player->mo = mo; @@ -1768,9 +1768,9 @@ void P_ForwardThrust (player_t *player, angle_t angle, fixed_t move) angle >>= ANGLETOFINESHIFT; if ((player->mo->waterlevel || (player->mo->flags & MF_NOGRAVITY)) - && player->mo->pitch != 0) + && player->mo->_f_pitch() != 0) { - angle_t pitch = (angle_t)player->mo->pitch >> ANGLETOFINESHIFT; + angle_t pitch = (angle_t)player->mo->_f_pitch() >> ANGLETOFINESHIFT; fixed_t zpush = FixedMul (move, finesine[pitch]); if (player->mo->waterlevel && player->mo->waterlevel < 2 && zpush < 0) zpush = 0; @@ -1796,9 +1796,9 @@ void P_Bob (player_t *player, angle_t angle, fixed_t move, bool forward) { if (forward && (player->mo->waterlevel || (player->mo->flags & MF_NOGRAVITY)) - && player->mo->pitch != 0) + && player->mo->_f_pitch() != 0) { - angle_t pitch = (angle_t)player->mo->pitch >> ANGLETOFINESHIFT; + angle_t pitch = (angle_t)player->mo->_f_pitch() >> ANGLETOFINESHIFT; move = FixedMul (move, finecosine[pitch]); } @@ -1956,11 +1956,11 @@ void P_MovePlayer (player_t *player) if (player->turnticks) { player->turnticks--; - mo->angle += (ANGLE_180 / TURN180_TICKS); + mo->Angles.Yaw += (180. / TURN180_TICKS); } else { - mo->angle += cmd->ucmd.yaw << 16; + mo->Angles.Yaw += cmd->ucmd.yaw * (360./65536.); } player->onground = (mo->Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (player->cheats & CF_NOCLIP2); @@ -2007,13 +2007,13 @@ void P_MovePlayer (player_t *player) if (forwardmove) { - P_Bob (player, mo->angle, (cmd->ucmd.forwardmove * bobfactor) >> 8, true); - P_ForwardThrust (player, mo->angle, forwardmove); + P_Bob (player, mo->_f_angle(), (cmd->ucmd.forwardmove * bobfactor) >> 8, true); + P_ForwardThrust (player, mo->_f_angle(), forwardmove); } if (sidemove) { - P_Bob (player, mo->angle-ANG90, (cmd->ucmd.sidemove * bobfactor) >> 8, false); - P_SideThrust (player, mo->angle, sidemove); + P_Bob (player, mo->_f_angle()-ANG90, (cmd->ucmd.sidemove * bobfactor) >> 8, false); + P_SideThrust (player, mo->_f_angle(), sidemove); } if (debugfile) @@ -2147,8 +2147,7 @@ void P_FallingDamage (AActor *actor) void P_DeathThink (player_t *player) { int dir; - angle_t delta; - int lookDelta; + DAngle delta; P_MovePsprites (player); @@ -2159,10 +2158,10 @@ void P_DeathThink (player_t *player) player->deltaviewheight = 0; if (player->onground) { - if (player->mo->pitch > -(int)ANGLE_1*19) + if (player->mo->Angles.Pitch > -19.) { - lookDelta = (-(int)ANGLE_1*19 - player->mo->pitch) / 8; - player->mo->pitch += lookDelta; + DAngle lookDelta = (-19. - player->mo->Angles.Pitch) / 8; + player->mo->Angles.Pitch += lookDelta; } } } @@ -2177,17 +2176,17 @@ void P_DeathThink (player_t *player) { player->viewheight = 6*FRACUNIT; } - if (player->mo->pitch < 0) + if (player->mo->Angles.Pitch < 0) { - player->mo->pitch += ANGLE_1*3; + player->mo->Angles.Pitch += 3; } - else if (player->mo->pitch > 0) + else if (player->mo->Angles.Pitch > 0) { - player->mo->pitch -= ANGLE_1*3; + player->mo->Angles.Pitch -= 3; } - if (abs(player->mo->pitch) < ANGLE_1*3) + if (fabs(player->mo->Angles.Pitch) < 3) { - player->mo->pitch = 0; + player->mo->Angles.Pitch = 0; } } P_CalcHeight (player); @@ -2195,7 +2194,7 @@ void P_DeathThink (player_t *player) if (player->attacker && player->attacker != player->mo) { // Watch killer dir = P_FaceMobj (player->mo, player->attacker, &delta); - if (delta < ANGLE_1*10) + if (delta < 10) { // Looking at killer, so fade damage and poison counters if (player->damagecount) { @@ -2207,17 +2206,17 @@ void P_DeathThink (player_t *player) } } delta /= 8; - if (delta > ANGLE_1*5) + if (delta > 5) { - delta = ANGLE_1*5; + delta = 5; } if (dir) { // Turn clockwise - player->mo->angle += delta; + player->mo->Angles.Yaw += delta; } else { // Turn counter clockwise - player->mo->angle -= delta; + player->mo->Angles.Yaw -= delta; } } else @@ -2304,7 +2303,7 @@ void P_PlayerThink (player_t *player) { fprintf (debugfile, "tic %d for pl %d: (%d, %d, %d, %u) b:%02x p:%d y:%d f:%d s:%d u:%d\n", gametic, (int)(player-players), player->mo->X(), player->mo->Y(), player->mo->Z(), - player->mo->angle>>ANGLETOFINESHIFT, player->cmd.ucmd.buttons, + player->mo->_f_angle()>>ANGLETOFINESHIFT, player->cmd.ucmd.buttons, player->cmd.ucmd.pitch, player->cmd.ucmd.yaw, player->cmd.ucmd.forwardmove, player->cmd.ucmd.sidemove, player->cmd.ucmd.upmove); } @@ -2493,54 +2492,38 @@ void P_PlayerThink (player_t *player) // [RH] Look up/down stuff if (!level.IsFreelookAllowed()) { - player->mo->pitch = 0; + player->mo->Angles.Pitch = 0; } else { - int look = cmd->ucmd.pitch << 16; - // The player's view pitch is clamped between -32 and +56 degrees, // which translates to about half a screen height up and (more than) // one full screen height down from straight ahead when view panning // is used. - if (look) + int clook = cmd->ucmd.pitch; + if (clook != 0) { - if (look == -32768 << 16) + if (clook == -32768) { // center view player->centering = true; } else if (!player->centering) { - fixed_t oldpitch = player->mo->pitch; - player->mo->pitch -= look; - if (look > 0) - { // look up - player->mo->pitch = MAX(player->mo->pitch, player->MinPitch); - if (player->mo->pitch > oldpitch) - { - player->mo->pitch = player->MinPitch; - } - } - else - { // look down - player->mo->pitch = MIN(player->mo->pitch, player->MaxPitch); - if (player->mo->pitch < oldpitch) - { - player->mo->pitch = player->MaxPitch; - } - } + // no more overflows with floating point. Yay! :) + player->mo->Angles.Pitch = clamp(player->mo->Angles.Pitch - clook * (360. / 65536.), player->MinPitch, player->MaxPitch); } } } if (player->centering) { - if (abs(player->mo->pitch) > 2*ANGLE_1) + player->mo->Angles.Pitch.Normalize180(); // make sure we are in the proper range here for the following code. + if (fabs(player->mo->Angles.Pitch) > 2.) { - player->mo->pitch = FixedMul(player->mo->pitch, FRACUNIT*2/3); + player->mo->Angles.Pitch *= (2. / 3.); } else { - player->mo->pitch = 0; + player->mo->Angles.Pitch = 0; player->centering = false; if (player - players == consoleplayer) { @@ -3158,7 +3141,7 @@ void player_t::Serialize (FArchive &arc) arc << LogText << ConversationNPC << ConversationPC - << ConversationNPCAngle + << ConversationNPCAngle.Degrees << ConversationFaceTalker; for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index 309e12921..c8712a07d 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -102,7 +102,7 @@ static int WriteTHINGS (FILE *file) mt.x = LittleShort(short(mo->X() >> FRACBITS)); mt.y = LittleShort(short(mo->Y() >> FRACBITS)); - mt.angle = LittleShort(short(MulScale32 (mo->angle >> ANGLETOFINESHIFT, 360))); + mt.angle = LittleShort(short(MulScale32 (mo->_f_angle() >> ANGLETOFINESHIFT, 360))); mt.type = LittleShort((short)1); mt.flags = LittleShort((short)(7|224|MTF_SINGLE)); fwrite (&mt, sizeof(mt), 1, file); diff --git a/src/po_man.cpp b/src/po_man.cpp index b7cd7e249..586e84d91 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -174,8 +174,6 @@ void PO_Init (void); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -static void RotatePt (int an, fixed_t *x, fixed_t *y, fixed_t startSpotX, - fixed_t startSpotY); static void UnLinkPolyobj (FPolyObj *po); static void LinkPolyobj (FPolyObj *po); static bool CheckMobjBlocking (side_t *seg, FPolyObj *po); @@ -1036,13 +1034,16 @@ void FPolyObj::DoMovePolyobj (int x, int y) // //========================================================================== -static void RotatePt (int an, fixed_t *x, fixed_t *y, fixed_t startSpotX, fixed_t startSpotY) +static void RotatePt (DAngle an, fixed_t *x, fixed_t *y, fixed_t startSpotX, fixed_t startSpotY) { fixed_t tr_x = *x; fixed_t tr_y = *y; - *x = (DMulScale16 (tr_x, finecosine[an], -tr_y, finesine[an]) & 0xFFFFFE00) + startSpotX; - *y = (DMulScale16 (tr_x, finesine[an], tr_y, finecosine[an]) & 0xFFFFFE00) + startSpotY; + double s = an.Sin(); + double c = an.Cos(); + + *x = (xs_CRoundToInt(tr_x * c - tr_y*s) & 0xfffffe00) + startSpotX; + *y = (xs_CRoundToInt(tr_x * s + tr_y*c) & 0xfffffe00) + startSpotX; } //========================================================================== @@ -1053,11 +1054,11 @@ static void RotatePt (int an, fixed_t *x, fixed_t *y, fixed_t startSpotX, fixed_ bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave) { - int an; + DAngle an; bool blocked; FBoundingBox oldbounds = Bounds; - an = (this->angle+angle)>>ANGLETOFINESHIFT; + an = ANGLE2DBL(this->angle + angle); UnLinkPolyobj(); diff --git a/src/portal.cpp b/src/portal.cpp index 8c7824ac8..86fe880c2 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -253,7 +253,7 @@ static void SetRotation(FLinePortal *port) double angle = g_atan2(dst->dy, dst->dx) - g_atan2(line->dy, line->dx) + M_PI; port->mSinRot = FLOAT2FIXED(g_sin(angle)); port->mCosRot = FLOAT2FIXED(g_cos(angle)); - port->mAngleDiff = RAD2ANGLE(angle); + port->mAngleDiff = ToDegrees(angle); } } @@ -606,12 +606,12 @@ void P_TranslatePortalVXVY(line_t* src, fixed_t& vx, fixed_t& vy) // //============================================================================ -void P_TranslatePortalAngle(line_t* src, angle_t& angle) +void P_TranslatePortalAngle(line_t* src, DAngle& angle) { if (!src) return; FLinePortal *port = src->getPortal(); if (!port) return; - angle += port->mAngleDiff; + angle = (angle + port->mAngleDiff).Normalized360(); } //============================================================================ diff --git a/src/portal.h b/src/portal.h index d5a781f2d..c99a87b28 100644 --- a/src/portal.h +++ b/src/portal.h @@ -179,7 +179,7 @@ struct FLinePortal BYTE mFlags; BYTE mDefFlags; BYTE mAlign; - angle_t mAngleDiff; + DAngle mAngleDiff; fixed_t mSinRot; fixed_t mCosRot; }; @@ -203,7 +203,7 @@ inline int P_NumPortalGroups() bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t viewy, bool partial = true, bool samebehind = true); void P_TranslatePortalXY(line_t* src, fixed_t& x, fixed_t& y); void P_TranslatePortalVXVY(line_t* src, fixed_t& vx, fixed_t& vy); -void P_TranslatePortalAngle(line_t* src, angle_t& angle); +void P_TranslatePortalAngle(line_t* src, DAngle& angle); void P_TranslatePortalZ(line_t* src, fixed_t& z); void P_NormalizeVXVY(fixed_t& vx, fixed_t& vy); fixed_t P_PointLineDistance(line_t* line, fixed_t x, fixed_t y); diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 04c3a3f2e..90bc42663 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -491,7 +491,7 @@ void SDLFB::Update () return; pixels = Surface->pixels; - pitch = Surface->pitch; + pitch = Surface->_f_pitch(); } if (NotPaletted) diff --git a/src/r_defs.h b/src/r_defs.h index d04afbf88..953695801 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1287,7 +1287,7 @@ inline void AActor::ClearInterpolation() PrevX = X(); PrevY = Y(); PrevZ = Z(); - PrevAngle = angle; + PrevAngles = Angles; if (Sector) PrevPortalGroup = Sector->PortalGroup; else PrevPortalGroup = 0; } diff --git a/src/r_main.cpp b/src/r_main.cpp index 44ed781bb..8add28594 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -735,7 +735,9 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) { P_TranslatePortalXY(pds->src, viewx, viewy); P_TranslatePortalZ(pds->src, viewz); - P_TranslatePortalAngle(pds->src, viewangle); + DAngle va = ANGLE2DBL(viewangle); + P_TranslatePortalAngle(pds->src, va); + viewangle = va.BAMs(); } viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 15653a1e8..465ecf8e0 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1106,7 +1106,7 @@ void R_DrawHeightPlanes(fixed_t height) void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked) { -// pl->angle = pa<_f_angle() = pa<left >= pl->right) return; @@ -1243,7 +1243,7 @@ void R_DrawSkyBoxes () viewx = viewpos.x; viewy = viewpos.y; viewz = viewpos.z; - viewangle = savedangle + sky->PrevAngle + FixedMul(r_TicFrac, sky->angle - sky->PrevAngle); + viewangle = savedangle + FLOAT2ANGLE(sky->PrevAngles.Yaw.Degrees) + FixedMul(r_TicFrac, sky->_f_angle() - FLOAT2ANGLE(sky->PrevAngles.Yaw.Degrees)); R_CopyStackedViewParameters(); } diff --git a/src/r_things.cpp b/src/r_things.cpp index 644ca7899..1c1bfe209 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -807,11 +807,11 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor angle_t rot; if (sprframe->Texture[0] == sprframe->Texture[1]) { - rot = (ang - thing->angle + (angle_t)(ANGLE_45/2)*9) >> 28; + rot = (ang - thing->_f_angle() + (angle_t)(ANGLE_45/2)*9) >> 28; } else { - rot = (ang - thing->angle + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; + rot = (ang - thing->_f_angle() + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; } picnum = sprframe->Texture[rot]; if (sprframe->Flip & (1 << rot)) @@ -846,11 +846,11 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor angle_t rot; if (sprframe->Texture[0] == sprframe->Texture[1]) { - rot = (ang - thing->angle + (angle_t)(ANGLE_45/2)*9) >> 28; + rot = (ang - thing->_f_angle() + (angle_t)(ANGLE_45/2)*9) >> 28; } else { - rot = (ang - thing->angle + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; + rot = (ang - thing->_f_angle() + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; } picnum = sprframe->Texture[rot]; if (sprframe->Flip & (1 << rot)) @@ -999,7 +999,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor vis->texturemid = (tex->TopOffset << FRACBITS) - FixedDiv (viewz - fz + thing->floorclip, yscale); vis->x1 = x1 < WindowLeft ? WindowLeft : x1; vis->x2 = x2 > WindowRight ? WindowRight : x2; - vis->angle = thing->angle; + vis->angle = thing->_f_angle(); if (renderflags & RF_XFLIP) { @@ -1029,7 +1029,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor fz -= thing->floorclip; - vis->angle = thing->angle + voxel->AngleOffset; + vis->angle = thing->_f_angle() + voxel->AngleOffset; int voxelspin = (thing->flags & MF_DROPPED) ? voxel->DroppedSpin : voxel->PlacedSpin; if (voxelspin != 0) @@ -1149,7 +1149,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f fixed_t lx1, lx2, ly1, ly2; fixed_t gzb, gzt, tz; FTexture *pic = TexMan(picnum, true); - angle_t ang = (thing->angle + ANGLE_90) >> ANGLETOFINESHIFT; + angle_t ang = (thing->_f_angle() + ANGLE_90) >> ANGLETOFINESHIFT; vissprite_t *vis; // Determine left and right edges of sprite. The sprite's angle is its normal, diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 336b4cc2c..eef0b1947 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -618,7 +618,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi fixedvec3a &end = InterpolationPath[i]; pathlen += xs_CRoundToInt(DVector2(end.x - start.x, end.y - start.y).Length()); totalzdiff += start.z; - totaladiff += start.angle; + totaladiff += FLOAT2ANGLE(start.angle.Degrees); } fixed_t interpolatedlen = FixedMul(frac, pathlen); @@ -628,7 +628,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi fixedvec3a &end = InterpolationPath[i]; fixed_t fraglen = xs_CRoundToInt(DVector2(end.x - start.x, end.y - start.y).Length()); zdiff += start.z; - adiff += start.angle; + adiff += FLOAT2ANGLE(start.angle.Degrees); if (fraglen <= interpolatedlen) { interpolatedlen -= fraglen; @@ -681,11 +681,11 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi // Avoid overflowing viewpitch (can happen when a netgame is stalled) if (viewpitch > INT_MAX - delta) { - viewpitch = player->MaxPitch; + viewpitch = FLOAT2ANGLE(player->MaxPitch.Degrees); } else { - viewpitch = MIN(viewpitch + delta, player->MaxPitch); + viewpitch = MIN(viewpitch + delta, FLOAT2ANGLE(player->MaxPitch.Degrees)); } } else if (delta < 0) @@ -693,11 +693,11 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi // Avoid overflowing viewpitch (can happen when a netgame is stalled) if (viewpitch < INT_MIN - delta) { - viewpitch = player->MinPitch; + viewpitch = FLOAT2ANGLE(player->MinPitch.Degrees); } else { - viewpitch = MAX(viewpitch + delta, player->MinPitch); + viewpitch = MAX(viewpitch + delta, FLOAT2ANGLE(player->MinPitch.Degrees)); } } } @@ -989,13 +989,13 @@ void R_SetupFrame (AActor *actor) viewsector = camera->Sector; r_showviewer = false; } - iview->nviewpitch = camera->pitch; + iview->nviewpitch = camera->_f_pitch(); if (camera->player != 0) { player = camera->player; } - iview->nviewangle = camera->angle; + iview->nviewangle = camera->_f_angle(); if (iview->otic == -1 || r_NoInterpolate) { R_ResetViewInterpolation (); @@ -1050,14 +1050,14 @@ void R_SetupFrame (AActor *actor) if ((jiggers.RelIntensityX | jiggers.RelOffsetX) != 0) { - int ang = (camera->angle) >> ANGLETOFINESHIFT; + int ang = (camera->_f_angle()) >> ANGLETOFINESHIFT; fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityX, jiggers.RelOffsetX); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if ((jiggers.RelIntensityY | jiggers.RelOffsetY) != 0) { - int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; + int ang = (camera->_f_angle() + ANG90) >> ANGLETOFINESHIFT; fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityY, jiggers.RelOffsetY); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); diff --git a/src/r_utility.h b/src/r_utility.h index d12d8f5ae..0d4b4d023 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -67,7 +67,7 @@ inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, f struct fixedvec3a { fixed_t x, y, z; - angle_t angle; + DAngle angle; }; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 38a43a430..fee5f3383 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1950,7 +1950,7 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor) { if (listenactor != NULL) { - listener.angle = ANGLE2RADF(listenactor->angle); + listener.angle = ANGLE2RADF(listenactor->_f_angle()); /* listener.velocity.X = listenactor->vel.x * (TICRATE/65536.f); listener.velocity.Y = listenactor->vel.z * (TICRATE/65536.f); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index dfdc5be60..cdad029d1 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -830,7 +830,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BulletAttack) if (!self->target) return 0; A_FaceTarget (self); - bangle = self->angle; + bangle = self->_f_angle(); slope = P_AimLineAttack (self, bangle, MISSILERANGE); @@ -1203,9 +1203,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) PARAM_CLASS (ti, AActor); PARAM_FIXED_OPT (spawnheight) { spawnheight = 32*FRACUNIT; } PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } - PARAM_ANGLE_OPT (angle) { angle = 0; } + PARAM_DANGLE_OPT(Angle) { Angle = 0; } PARAM_INT_OPT (flags) { flags = 0; } - PARAM_ANGLE_OPT (pitch) { pitch = 0; } + PARAM_DANGLE_OPT(Pitch) { Pitch = 0; } PARAM_INT_OPT (ptr) { ptr = AAPTR_TARGET; } AActor *ref = COPY_AAPTR(self, ptr); @@ -1219,7 +1219,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) { if (ti) { - angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; + angle_t ang = (self->_f_angle() - ANGLE_90) >> ANGLETOFINESHIFT; fixed_t x = spawnofs_xy * finecosine[ang]; fixed_t y = spawnofs_xy * finesine[ang]; fixed_t z = spawnheight + self->GetBobOffset() - 32*FRACUNIT + (self->player? self->player->crouchoffset : 0); @@ -1241,7 +1241,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) case 2: self->SetXYZ(self->Vec3Offset(x, y, 0)); - missile = P_SpawnMissileAngleZSpeed(self, self->Z() + self->GetBobOffset() + spawnheight, ti, self->angle, 0, GetDefaultByType(ti)->Speed, self, false); + missile = P_SpawnMissileAngleZSpeed(self, self->Z() + self->GetBobOffset() + spawnheight, ti, self->_f_angle(), 0, GetDefaultByType(ti)->Speed, self, false); self->SetXYZ(pos); flags |= CMF_ABSOLUTEPITCH; @@ -1262,11 +1262,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) if (CMF_OFFSETPITCH & flags) { DVector2 velocity (missile->vel.x, missile->vel.y); - pitch += R_PointToAngle2(0,0, xs_CRoundToInt(velocity.Length()), missile->vel.z); + Pitch += vectoyaw(DVector2(velocity.Length(), (double)missile->vel.z)); } - ang = pitch >> ANGLETOFINESHIFT; - missilespeed = abs(FixedMul(finecosine[ang], missile->Speed)); - missile->vel.z = FixedMul(finesine[ang], missile->Speed); + missilespeed = abs(fixed_t(Pitch.Cos() * missile->Speed)); + missile->vel.z = fixed_t(Pitch.Sin() * missile->Speed); } else { @@ -1276,17 +1275,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) if (CMF_SAVEPITCH & flags) { - missile->pitch = pitch; + missile->Angles.Pitch = Pitch; // In aimmode 0 and 1 without absolutepitch or offsetpitch, the pitch parameter // contains the unapplied parameter. In that case, it is set as pitch without // otherwise affecting the spawned actor. } - missile->angle = (CMF_ABSOLUTEANGLE & flags) ? angle : missile->angle + angle ; + missile->Angles.Yaw = (CMF_ABSOLUTEANGLE & flags) ? Angle : missile->Angles.Yaw + Angle ; - ang = missile->angle >> ANGLETOFINESHIFT; - missile->vel.x = FixedMul(missilespeed, finecosine[ang]); - missile->vel.y = FixedMul(missilespeed, finesine[ang]); + missile->VelFromAngle(missilespeed); // handle projectile shooting projectiles - track the // links back to a real owner @@ -1375,7 +1372,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) { A_Face(self, ref); } - bangle = self->angle; + bangle = self->_f_angle(); if (!(flags & CBAF_NOPITCH)) bslope = P_AimLineAttack (self, bangle, MISSILERANGE); @@ -1564,7 +1561,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) if (!(flags & FBF_NOFLASH)) static_cast(self)->PlayAttacking2 (); if (!(flags & FBF_NOPITCH)) bslope = P_BulletSlope(self); - bangle = self->angle; + bangle = self->_f_angle(); if (pufftype == NULL) pufftype = PClass::FindActor(NAME_BulletPuff); @@ -1630,12 +1627,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) { PARAM_ACTION_PROLOGUE; PARAM_CLASS (ti, AActor); - PARAM_ANGLE_OPT (angle) { angle = 0; } + PARAM_DANGLE_OPT(angle) { angle = 0; } PARAM_BOOL_OPT (useammo) { useammo = true; } PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } PARAM_FIXED_OPT (spawnheight) { spawnheight = 0; } PARAM_INT_OPT (flags) { flags = 0; } - PARAM_ANGLE_OPT (pitch) { pitch = 0; } + PARAM_DANGLE_OPT(pitch) { pitch = 0; } if (!self->player) return 0; @@ -1653,19 +1650,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) if (ti) { - angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; + angle_t ang = (self->_f_angle() - ANGLE_90) >> ANGLETOFINESHIFT; fixed_t x = spawnofs_xy * finecosine[ang]; fixed_t y = spawnofs_xy * finesine[ang]; fixed_t z = spawnheight; - fixed_t shootangle = self->angle; + DAngle shootangle = self->Angles.Yaw; if (flags & FPF_AIMATANGLE) shootangle += angle; // Temporarily adjusts the pitch - fixed_t saved_player_pitch = self->pitch; - self->pitch -= pitch; - AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &t, NULL, false, (flags & FPF_NOAUTOAIM) != 0); - self->pitch = saved_player_pitch; + DAngle saved_player_pitch = self->Angles.Pitch; + self->Angles.Pitch -= pitch; + AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, FLOAT2ANGLE(shootangle.Degrees), &t, NULL, false, (flags & FPF_NOAUTOAIM) != 0); + self->Angles.Pitch = saved_player_pitch; // automatic handling of seeker missiles if (misl) @@ -1680,10 +1677,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) // the angle from the resulting direction. DVector3 velocity(misl->vel.x, misl->vel.y, 0); fixed_t missilespeed = xs_CRoundToInt(velocity.Length()); - misl->angle += angle; - angle_t an = misl->angle >> ANGLETOFINESHIFT; - misl->vel.x = FixedMul (missilespeed, finecosine[an]); - misl->vel.y = FixedMul (missilespeed, finesine[an]); + misl->Angles.Yaw += angle; + misl->VelFromAngle(); } } } @@ -1738,7 +1733,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) if (!norandom) damage *= pr_cwpunch() % 8 + 1; - angle = self->angle + (pr_cwpunch.Random2() << 18); + angle = self->_f_angle() + (pr_cwpunch.Random2() << 18); if (range == 0) range = MELEERANGE; pitch = P_AimLineAttack (self, angle, range, &t); @@ -1799,7 +1794,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) if (!(flags & CPF_NOTURN)) { // turn to face target - self->angle = t.angleFromSource; + self->Angles.Yaw = t.angleFromSource; } if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED; @@ -1908,8 +1903,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) FTranslatedLineTarget t; fixedvec3 savedpos = self->Pos(); - angle_t saved_angle = self->angle; - fixed_t saved_pitch = self->pitch; + DAngle saved_angle = self->Angles.Yaw; + DAngle saved_pitch = self->Angles.Pitch; if (aim && self->target == NULL) { @@ -1926,9 +1921,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) if (aim) { - self->angle = self->AngleTo(self->target); + self->Angles.Yaw = self->_f_AngleTo(self->target); } - self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &t, ANGLE_1*60, 0, aim ? self->target : NULL); + self->Angles.Pitch = ANGLE2DBL(P_AimLineAttack (self, self->_f_angle(), MISSILERANGE, &t, ANGLE_1*60, 0, aim ? self->target : NULL)); if (t.linetarget == NULL && aim) { // We probably won't hit the target, but aim at it anyway so we don't look stupid. @@ -1936,33 +1931,32 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) DVector2 xydiff(pos.x, pos.y); double zdiff = (self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip); - self->pitch = int(g_atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI); + self->Angles.Pitch = vectoyaw(DVector2(xydiff.Length(), zdiff)); } // Let the aim trail behind the player if (aim) { - saved_angle = self->angle = self->AngleTo(self->target, -self->target->vel.x * 3, -self->target->vel.y * 3); + saved_angle = self->Angles.Yaw = self->_f_AngleTo(self->target, -self->target->vel.x * 3, -self->target->vel.y * 3); if (aim == CRF_AIMDIRECT) { // Tricky: We must offset to the angle of the current position // but then change the angle again to ensure proper aim. self->SetXY(self->Vec2Offset( - spawnofs_xy * finecosine[self->angle], - spawnofs_xy * finesine[self->angle])); + FLOAT2FIXED(spawnofs_xy * self->Angles.Yaw.Cos()), + FLOAT2FIXED(spawnofs_xy * self->Angles.Yaw.Sin()))); spawnofs_xy = 0; - self->angle = self->AngleTo(self->target,- self->target->vel.x * 3, -self->target->vel.y * 3); + self->Angles.Yaw = self->_f_AngleTo(self->target,- self->target->vel.x * 3, -self->target->vel.y * 3); } if (self->target->flags & MF_SHADOW) { - angle_t rnd = pr_crailgun.Random2() << 21; - self->angle += rnd; - saved_angle = rnd; + DAngle rnd = pr_crailgun.Random2() * (45. / 256.); + self->Angles.Yaw += rnd; } } - angle_t angle = (self->angle - ANG90) >> ANGLETOFINESHIFT; + angle_t angle = (self->_f_angle() - ANG90) >> ANGLETOFINESHIFT; angle_t angleoffset; angle_t slopeoffset; @@ -1981,8 +1975,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun) P_RailAttack (self, damage, spawnofs_xy, spawnofs_z, color1, color2, maxdiff, flags, pufftype, angleoffset, slopeoffset, range, duration, sparsity, driftspeed, spawnclass,SpiralOffset); self->SetXYZ(savedpos); - self->angle = saved_angle; - self->pitch = saved_pitch; + self->Angles.Yaw = saved_angle; + self->Angles.Pitch = saved_pitch; return 0; } @@ -2244,10 +2238,10 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) mo->tracer = self->tracer; } - mo->angle = self->angle; + mo->Angles.Yaw = self->Angles.Yaw; if (flags & SIXF_TRANSFERPITCH) { - mo->pitch = self->pitch; + mo->Angles.Pitch = self->Angles.Pitch; } if (!(flags & SIXF_ORIGINATOR)) { @@ -2368,7 +2362,7 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) if (flags & SIXF_TRANSFERROLL) { - mo->roll = self->roll; + mo->Angles.Roll = self->Angles.Roll; } if (flags & SIXF_ISTARGET) @@ -2435,7 +2429,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) } } - AActor *mo = Spawn( missile, self->Vec3Angle(distance, self->angle, -self->floorclip + self->GetBobOffset() + zheight), ALLOW_REPLACE); + AActor *mo = Spawn( missile, self->Vec3Angle(distance, self->_f_angle(), -self->floorclip + self->GetBobOffset() + zheight), ALLOW_REPLACE); int flags = (transfer_translation ? SIXF_TRANSFERTRANSLATION : 0) + (useammo ? SIXF_SETMASTER : 0); ACTION_RETURN_BOOL(InitSpawnedItem(self, mo, flags)); // for an inventory item's use state @@ -2458,7 +2452,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) PARAM_FIXED_OPT (xvel) { xvel = 0; } PARAM_FIXED_OPT (yvel) { yvel = 0; } PARAM_FIXED_OPT (zvel) { zvel = 0; } - PARAM_ANGLE_OPT (angle) { angle = 0; } + PARAM_DANGLE_OPT(angle) { angle = 0; } PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (chance) { chance = 0; } PARAM_INT_OPT (tid) { tid = 0; } @@ -2481,10 +2475,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) if (!(flags & SIXF_ABSOLUTEANGLE)) { - angle += self->angle; + angle += self->Angles.Yaw; } - - angle_t ang = angle >> ANGLETOFINESHIFT; + double s = angle.Sin(); + double c = angle.Cos(); if (flags & SIXF_ABSOLUTEPOSITION) { @@ -2494,16 +2488,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) { // in relative mode negative y values mean 'left' and positive ones mean 'right' // This is the inverse orientation of the absolute mode! - pos = self->Vec2Offset( - FixedMul(xofs, finecosine[ang]) + FixedMul(yofs, finesine[ang]), - FixedMul(xofs, finesine[ang]) - FixedMul(yofs, finecosine[ang])); + pos = self->Vec2Offset(fixed_t(xofs * c + yofs * s), fixed_t(xofs * s - yofs*c)); } if (!(flags & SIXF_ABSOLUTEVELOCITY)) { // Same orientation issue here! - fixed_t newxvel = FixedMul(xvel, finecosine[ang]) + FixedMul(yvel, finesine[ang]); - yvel = FixedMul(xvel, finesine[ang]) - FixedMul(yvel, finecosine[ang]); + fixed_t newxvel = fixed_t(xvel * c + yvel * s); + yvel = fixed_t(xvel * s - yvel * c); xvel = newxvel; } @@ -2529,7 +2521,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) mo->vel.y = yvel; mo->vel.z = zvel; } - mo->angle = angle; + mo->Angles.Yaw = angle; } ACTION_RETURN_BOOL(res); // for an inventory item's use state } @@ -2579,10 +2571,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) P_PlaySpawnSound(bo, self); if (xyvel != 0) bo->Speed = xyvel; - bo->angle = self->angle + (((pr_grenade()&7) - 4) << 24); + bo->Angles.Yaw = self->Angles.Yaw + (((pr_grenade()&7) - 4) * (360./256.)); - angle_t pitch = angle_t(-self->pitch) >> ANGLETOFINESHIFT; - angle_t angle = bo->angle >> ANGLETOFINESHIFT; + angle_t pitch = angle_t(-self->_f_pitch()) >> ANGLETOFINESHIFT; + angle_t angle = bo->_f_angle() >> ANGLETOFINESHIFT; // There are two vectors we are concerned about here: xy and z. We rotate // them separately according to the shooter's pitch and then sum them to @@ -2593,7 +2585,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) fixed_t xy_velx = FixedMul(xy_xyscale, finecosine[angle]); fixed_t xy_vely = FixedMul(xy_xyscale, finesine[angle]); - pitch = angle_t(self->pitch) >> ANGLETOFINESHIFT; + pitch = angle_t(self->_f_pitch()) >> ANGLETOFINESHIFT; fixed_t z_xyscale = FixedMul(zvel, finesine[pitch]); fixed_t z_velz = FixedMul(zvel, finecosine[pitch]); fixed_t z_velx = FixedMul(z_xyscale, finecosine[angle]); @@ -2624,7 +2616,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Recoil) PARAM_ACTION_PROLOGUE; PARAM_FIXED(xyvel); - angle_t angle = self->angle + ANG180; + angle_t angle = self->_f_angle() + ANG180; angle >>= ANGLETOFINESHIFT; self->vel.x += FixedMul(xyvel, finecosine[angle]); self->vel.y += FixedMul(xyvel, finesine[angle]); @@ -3035,7 +3027,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle) if (lifetime != 0) { - const angle_t ang = (angle + ((flags & SPF_RELANG) ? self->angle : 0)) >> ANGLETOFINESHIFT; + const angle_t ang = (angle + ((flags & SPF_RELANG) ? self->_f_angle() : 0)) >> ANGLETOFINESHIFT; fixedvec3 pos; //[MC] Code ripped right out of A_SpawnItemEx. if (flags & SPF_RELPOS) @@ -3798,7 +3790,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) if (flags & CLOFF_NOAIM_HORZ) { - ang = self->angle; + ang = self->_f_angle(); } else ang = self->AngleTo (target); @@ -3816,7 +3808,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) if (flags & CLOFF_NOAIM_VERT) { - pitch += self->pitch; + pitch += self->_f_pitch(); } else if (flags & CLOFF_AIM_VERT_NOOFFSET) { @@ -3829,10 +3821,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) } else if (flags & CLOFF_ALLOWNULL) { - angle += self->angle; - pitch += self->pitch; + angle += self->_f_angle(); + pitch += self->_f_pitch(); - angle_t ang = self->angle >> ANGLETOFINESHIFT; + angle_t ang = self->_f_angle() >> ANGLETOFINESHIFT; fixedvec2 xy = self->Vec2Offset( FixedMul(offsetforward, finecosine[ang]) + FixedMul(offsetwidth, finesine[ang]), @@ -3977,7 +3969,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) else { // Does the player aim at something that can be shot? - P_AimLineAttack(self, self->angle, MISSILERANGE, &t, (flags & JLOSF_NOAUTOAIM) ? ANGLE_1/2 : 0, ALF_PORTALRESTRICT); + P_AimLineAttack(self, self->_f_angle(), MISSILERANGE, &t, (flags & JLOSF_NOAUTOAIM) ? ANGLE_1/2 : 0, ALF_PORTALRESTRICT); if (!t.linetarget) { @@ -4049,7 +4041,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) if (fov && (fov < ANGLE_MAX)) { - an = viewport->AngleTo(target) - viewport->angle; + an = viewport->AngleTo(target) - viewport->_f_angle(); if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) { @@ -4129,7 +4121,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) if (fov && (fov < ANGLE_MAX)) { - an = target->AngleTo(self) - target->angle; + an = target->AngleTo(self) - target->_f_angle(); if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2))) { @@ -4464,7 +4456,7 @@ enum DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle) { PARAM_ACTION_PROLOGUE; - PARAM_ANGLE_OPT(angle) { angle = 0; } + PARAM_FLOAT_OPT(angle) { angle = 0; } PARAM_INT_OPT(flags) { flags = 0; } PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } @@ -4487,7 +4479,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) { PARAM_ACTION_PROLOGUE; - PARAM_ANGLE(pitch); + PARAM_FLOAT(pitch); PARAM_INT_OPT(flags) { flags = 0; } PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } @@ -4498,23 +4490,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) return 0; } - if (ref->player != NULL || (flags & SPF_FORCECLAMP)) - { // clamp the pitch we set - int min, max; - - if (ref->player != NULL) - { - min = ref->player->MinPitch; - max = ref->player->MaxPitch; - } - else - { - min = -ANGLE_90 + (1 << ANGLETOFINESHIFT); - max = ANGLE_90 - (1 << ANGLETOFINESHIFT); - } - pitch = clamp(pitch, min, max); - } - ref->SetPitch(pitch, !!(flags & SPF_INTERPOLATE), !!(flags & SPF_FORCECLAMP)); return 0; } @@ -4530,7 +4505,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetRoll) { PARAM_ACTION_PROLOGUE; - PARAM_ANGLE (roll); + PARAM_FLOAT (roll); PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (ptr) { ptr = AAPTR_DEFAULT; } AActor *ref = COPY_AAPTR(self, ptr); @@ -4603,8 +4578,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity) INTBOOL was_moving = ref->vel.x | ref->vel.y | ref->vel.z; fixed_t vx = x, vy = y, vz = z; - fixed_t sina = finesine[ref->angle >> ANGLETOFINESHIFT]; - fixed_t cosa = finecosine[ref->angle >> ANGLETOFINESHIFT]; + fixed_t sina = finesine[ref->_f_angle() >> ANGLETOFINESHIFT]; + fixed_t cosa = finecosine[ref->_f_angle() >> ANGLETOFINESHIFT]; if (flags & 1) // relative axes - make x, y relative to actor's current angle { @@ -4901,7 +4876,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport) ref->SetZ((flags & TF_USESPOTZ) ? spot->Z() : ref->floorz, false); if (!(flags & TF_KEEPANGLE)) - ref->angle = spot->angle; + ref->Angles.Yaw = spot->Angles.Yaw; if (!(flags & TF_KEEPVELOCITY)) ref->vel.x = ref->vel.y = ref->vel.z = 0; @@ -4941,8 +4916,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Turn) { PARAM_ACTION_PROLOGUE; - PARAM_ANGLE_OPT(angle) { angle = 0; } - self->angle += angle; + PARAM_FLOAT_OPT(angle) { angle = 0; } + self->Angles.Yaw += angle; return 0; } @@ -5006,7 +4981,7 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis weaveXY = self->WeaveIndexXY & 63; weaveZ = self->WeaveIndexZ & 63; - angle = (self->angle + ANG90) >> ANGLETOFINESHIFT; + angle = (self->_f_angle() + ANG90) >> ANGLETOFINESHIFT; if (xydist != 0 && xyspeed != 0) { @@ -5122,7 +5097,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) A_FaceTarget (self); // Target can dodge if it can see enemy - angle_t angle = self->target->AngleTo(self) - self->target->angle; + angle_t angle = self->target->AngleTo(self) - self->target->_f_angle(); angle >>= 24; bool dodge = (P_CheckSight(self->target, self) && (angle>226 || angle<30)); @@ -6779,7 +6754,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) //Don't bother calculating this if we don't have any horizontal movement. if (!(flags & FMDF_NOANGLE) && (mobj->vel.x != 0 || mobj->vel.y != 0)) { - angle_t current = mobj->angle; + angle_t current = mobj->_f_angle(); const angle_t angle = R_PointToAngle2(0, 0, mobj->vel.x, mobj->vel.y); //Done because using anglelimit directly causes a signed/unsigned mismatch. const angle_t limit = anglelimit; @@ -6795,7 +6770,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) current += limit + offset; else current -= limit + offset; - mobj->SetAngle(current, !!(flags & FMDF_INTERPOLATE)); + mobj->SetAngle(ANGLE2DBL(current), !!(flags & FMDF_INTERPOLATE)); } else if (current > angle) { @@ -6803,18 +6778,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) current -= limit + offset; else current += limit + offset; - mobj->SetAngle(current, !!(flags & FMDF_INTERPOLATE)); + mobj->SetAngle(ANGLE2DBL(current), !!(flags & FMDF_INTERPOLATE)); } else - mobj->SetAngle(angle + ANGLE_180 + offset, !!(flags & FMDF_INTERPOLATE)); + mobj->SetAngle(ANGLE2DBL(angle + ANGLE_180 + offset), !!(flags & FMDF_INTERPOLATE)); } else - mobj->SetAngle(angle + offset, !!(flags & FMDF_INTERPOLATE)); + mobj->SetAngle(ANGLE2DBL(angle + offset), !!(flags & FMDF_INTERPOLATE)); } if (!(flags & FMDF_NOPITCH)) { - fixed_t current = mobj->pitch; + fixed_t current = mobj->_f_pitch(); const DVector2 velocity(mobj->vel.x, mobj->vel.y); const fixed_t pitch = R_PointToAngle2(0, 0, xs_CRoundToInt(velocity.Length()), -mobj->vel.z); if (pitchlimit > 0) @@ -6840,17 +6815,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) max = MIN(plimit, (pitch - current)); current += max; } - mobj->SetPitch(current, !!(flags & FMDF_INTERPOLATE)); + mobj->SetPitch(ANGLE2DBL(current), !!(flags & FMDF_INTERPOLATE)); } else { - mobj->SetPitch(pitch, !!(flags & FMDF_INTERPOLATE)); + mobj->SetPitch(ANGLE2DBL(pitch), !!(flags & FMDF_INTERPOLATE)); } } else { - mobj->SetPitch(pitch, !!(flags & FMDF_INTERPOLATE)); + mobj->SetPitch(ANGLE2DBL(pitch), !!(flags & FMDF_INTERPOLATE)); } } ACTION_RETURN_BOOL(true); diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 132440a73..60fe737bf 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -620,14 +620,14 @@ void InitThingdef() PSymbolTable &symt = RUNTIME_CLASS(AActor)->Symbols; PType *array5 = NewArray(TypeSInt32, 5); symt.AddSymbol(new PField(NAME_Alpha, TypeFixed, VARF_Native, myoffsetof(AActor,alpha))); - symt.AddSymbol(new PField(NAME_Angle, TypeAngle, VARF_Native, myoffsetof(AActor,angle))); + symt.AddSymbol(new PField(NAME_Angle, TypeFloat64,VARF_Native, myoffsetof(AActor,Angles.Yaw))); symt.AddSymbol(new PField(NAME_Args, array5, VARF_Native, myoffsetof(AActor,args))); symt.AddSymbol(new PField(NAME_CeilingZ, TypeFixed, VARF_Native, myoffsetof(AActor,ceilingz))); symt.AddSymbol(new PField(NAME_FloorZ, TypeFixed, VARF_Native, myoffsetof(AActor,floorz))); symt.AddSymbol(new PField(NAME_Health, TypeSInt32, VARF_Native, myoffsetof(AActor,health))); symt.AddSymbol(new PField(NAME_Mass, TypeSInt32, VARF_Native, myoffsetof(AActor,Mass))); - symt.AddSymbol(new PField(NAME_Pitch, TypeAngle, VARF_Native, myoffsetof(AActor,pitch))); - symt.AddSymbol(new PField(NAME_Roll, TypeAngle, VARF_Native, myoffsetof(AActor,roll))); + symt.AddSymbol(new PField(NAME_Pitch, TypeFloat64,VARF_Native, myoffsetof(AActor,Angles.Pitch))); + symt.AddSymbol(new PField(NAME_Roll, TypeFloat64,VARF_Native, myoffsetof(AActor,Angles.Roll))); symt.AddSymbol(new PField(NAME_Special, TypeSInt32, VARF_Native, myoffsetof(AActor,special))); symt.AddSymbol(new PField(NAME_TID, TypeSInt32, VARF_Native, myoffsetof(AActor,tid))); symt.AddSymbol(new PField(NAME_TIDtoHate, TypeSInt32, VARF_Native, myoffsetof(AActor,TIDtoHate))); diff --git a/src/vectors.h b/src/vectors.h index 0fb8c0905..0f196c676 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -970,6 +970,21 @@ struct TAngle return *this; } + // Same as above but doesn't alter the calling object itself + + // Ensure the angle is between [0.0,360.0) degrees + TAngle Normalized360() const + { + + return (vec_t)ANGLE2DBL((unsigned int)FLOAT2ANGLE(Degrees)); + } + + // Ensures the angle is between (-180.0,180.0] degrees + TAngle Normalized180() const + { + return (vec_t)ANGLE2DBL((signed int)FLOAT2ANGLE(Degrees)); + } + // Like Normalize360(), except the integer value is not converted back to a float. // The steps parameter must be a power of 2. int Quantize(int steps) const @@ -987,6 +1002,11 @@ struct TAngle return FLOAT2ANGLE(Degrees); } + int FixedAngle() // for ACS. This must be normalized so it just converts to BAM first and then shifts 16 bits right. + { + return FLOAT2ANGLE(Degrees) >> 16; + } + double Cos() const { return g_cosdeg(Degrees); @@ -1010,10 +1030,10 @@ inline double ToRadians (const TAngle °) return double(deg.Degrees * (M_PI / 180.0)); } -template -inline TAngle ToDegrees (double rad) +// If this gets templated there will be countless instantiation errors. +inline TAngle ToDegrees (double rad) { - return TAngle (T(rad * (180.0 / M_PI))); + return TAngle (double(rad * (180.0 / M_PI))); } template @@ -1022,16 +1042,46 @@ inline TAngle fabs (const TAngle °) return TAngle(fabs(deg.Degrees)); } +template +inline TAngle deltaangle(const TAngle &a1, const TAngle &a2) +{ + return (a2 - a1).Normalize180(); +} + +template +inline TAngle deltaangle(const TAngle &a1, double a2) +{ + return (a2 - a1).Normalize180(); +} + +template +inline TAngle deltaangle(double a1, const TAngle &a2) +{ + return (a2 - a1).Normalize180(); +} + +template +inline TAngle diffangle(const TAngle &a1, const TAngle &a2) +{ + return fabs((a1 - a2).Normalize180()); +} + +template +inline TAngle diffangle(const TAngle &a1, double a2) +{ + return fabs((a1 - a2).Normalize180()); +} + template inline TAngle vectoyaw (const TVector2 &vec) { - return (vec_t)g_atan2(vec.Y, vec.X) * (180.0 / M_PI); + return (T)g_atan2(vec.Y, vec.X) * (180.0 / M_PI); } template inline TAngle vectoyaw (const TVector3 &vec) { - return (vec_t)g_atan2(vec.Y, vec.X) * (180.0 / M_PI); + return (T)g_atan2(vec.Y, vec.X) * (180.0 / M_PI); } // Much of this is copied from TVector3. Is all that functionality really appropriate? @@ -1248,5 +1298,6 @@ typedef TVector2 DVector2; typedef TVector3 DVector3; typedef TRotator DRotator; typedef TMatrix3x3 DMatrix3x3; +typedef TAngle DAngle; #endif diff --git a/src/version.h b/src/version.h index 764675f0b..17fd288b1 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4533 +#define SAVEVER 4534 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) diff --git a/src/zscript/vm.h b/src/zscript/vm.h index 8fb740274..5afc9fa7e 100644 --- a/src/zscript/vm.h +++ b/src/zscript/vm.h @@ -896,6 +896,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction #define PARAM_FLOAT_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); double x = param[p].f; #define PARAM_FIXED_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); fixed_t x = FLOAT2FIXED(param[p].f); #define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); angle_t x = FLOAT2ANGLE(param[p].f); +#define PARAM_DANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); angle_t x = param[p].f; #define PARAM_STRING_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_STRING); FString x = param[p].s(); #define PARAM_STATE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); FState *x = (FState *)param[p].a; #define PARAM_POINTER_AT(p,x,type) assert((p) < numparam); assert(param[p].Type == REGT_POINTER); type *x = (type *)param[p].a; @@ -914,6 +915,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction #define PARAM_FLOAT_OPT_AT(p,x) double x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = param[p].f; } else #define PARAM_FIXED_OPT_AT(p,x) fixed_t x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = FLOAT2FIXED(param[p].f); } else #define PARAM_ANGLE_OPT_AT(p,x) angle_t x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = FLOAT2ANGLE(param[p].f); } else +#define PARAM_DANGLE_OPT_AT(p,x) DAngle x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = param[p].f; } else #define PARAM_STRING_OPT_AT(p,x) FString x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_STRING); x = param[p].s(); } else #define PARAM_STATE_OPT_AT(p,x) FState *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); x = (FState *)param[p].a; } else #define PARAM_POINTER_OPT_AT(p,x,type) type *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER); x = (type *)param[p].a; } else @@ -931,6 +933,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction #define PARAM_FLOAT(x) ++paramnum; PARAM_FLOAT_AT(paramnum,x) #define PARAM_FIXED(x) ++paramnum; PARAM_FIXED_AT(paramnum,x) #define PARAM_ANGLE(x) ++paramnum; PARAM_ANGLE_AT(paramnum,x) +#define PARAM_DANGLE(x) ++paramnum; PARAM_DANGLE_AT(paramnum,x) #define PARAM_STRING(x) ++paramnum; PARAM_STRING_AT(paramnum,x) #define PARAM_STATE(x) ++paramnum; PARAM_STATE_AT(paramnum,x) #define PARAM_POINTER(x,type) ++paramnum; PARAM_POINTER_AT(paramnum,x,type) @@ -945,6 +948,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction #define PARAM_FLOAT_OPT(x) ++paramnum; PARAM_FLOAT_OPT_AT(paramnum,x) #define PARAM_FIXED_OPT(x) ++paramnum; PARAM_FIXED_OPT_AT(paramnum,x) #define PARAM_ANGLE_OPT(x) ++paramnum; PARAM_ANGLE_OPT_AT(paramnum,x) +#define PARAM_DANGLE_OPT(x) ++paramnum; PARAM_DANGLE_OPT_AT(paramnum,x) #define PARAM_STRING_OPT(x) ++paramnum; PARAM_STRING_OPT_AT(paramnum,x) #define PARAM_STATE_OPT(x) ++paramnum; PARAM_STATE_OPT_AT(paramnum,x) #define PARAM_POINTER_OPT(x,type) ++paramnum; PARAM_POINTER_OPT_AT(paramnum,x,type)