- several fixes.

This commit is contained in:
Christoph Oelckers 2016-03-16 22:29:35 +01:00
parent 29a7fe33f3
commit b140d71c49
26 changed files with 97 additions and 83 deletions

View file

@ -875,13 +875,13 @@ public:
DAngle _f_AngleTo(AActor *other, bool absolute = false) DAngle _f_AngleTo(AActor *other, bool absolute = false)
{ {
fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
return g_atan2(otherpos.y - Y(), otherpos.x - X()); return vectoyaw(otherpos.x - X(), otherpos.y - Y());
} }
DAngle _f_AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const DAngle _f_AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
{ {
fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
return g_atan2(otherpos.y + oxofs - Y(), otherpos.x + oyofs - X()); return vectoyaw(otherpos.y + oxofs - Y(), otherpos.x + oyofs - X());
} }
fixedvec2 Vec2To(AActor *other) const fixedvec2 Vec2To(AActor *other) const
@ -1321,7 +1321,7 @@ public:
void AngleFromVel() void AngleFromVel()
{ {
Angles.Yaw = vectoyaw(DVector2(vel.x, vel.y)); Angles.Yaw = vectoyaw(vel.x, vel.y);
} }
void VelFromAngle() void VelFromAngle()

View file

@ -2656,8 +2656,8 @@ void Net_DoCommand (int type, BYTE **stream, int player)
break; break;
case DEM_SETPITCHLIMIT: case DEM_SETPITCHLIMIT:
players[player].MinPitch = ReadByte(stream); // up players[player].MinPitch = -(double)ReadByte(stream); // up
players[player].MaxPitch = ReadByte(stream); // down players[player].MaxPitch = (double)ReadByte(stream); // down
break; break;
case DEM_ADVANCEINTER: case DEM_ADVANCEINTER:

View file

@ -864,7 +864,7 @@ void FParser::SF_Spawn(void)
{ {
int x, y, z; int x, y, z;
PClassActor *pclass; PClassActor *pclass;
DAngle angle = 0; DAngle angle = 0.;
if (CheckArgs(3)) if (CheckArgs(3))
{ {
@ -1470,7 +1470,7 @@ void FParser::SF_SetCamera(void)
newcamera->special2=newcamera->Z(); newcamera->special2=newcamera->Z();
newcamera->SetZ(t_argc < 3 ? (newcamera->Z() + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS)); newcamera->SetZ(t_argc < 3 ? (newcamera->Z() + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS));
newcamera->Angles.Yaw = angle; newcamera->Angles.Yaw = angle;
if (t_argc < 4) newcamera->Angles.Pitch = 0; if (t_argc < 4) newcamera->Angles.Pitch = 0.;
else newcamera->Angles.Pitch = clamp(floatvalue(t_argv[3]), -50., 50.) * (20. / 32.); else newcamera->Angles.Pitch = clamp(floatvalue(t_argv[3]), -50., 50.) * (20. / 32.);
player->camera=newcamera; player->camera=newcamera;
} }
@ -3865,7 +3865,8 @@ void FParser::SF_Tan()
if (CheckArgs(1)) if (CheckArgs(1))
{ {
t_return.type = svt_fixed; t_return.type = svt_fixed;
t_return.value.f = FLOAT2FIXED(g_tan(floatvalue(t_argv[0]))); t_return.value.f = FLOAT2FIXED(
g_tan(floatvalue(t_argv[0])));
} }
} }

View file

@ -22,7 +22,6 @@
void A_SkullAttack(AActor *self, fixed_t speed) void A_SkullAttack(AActor *self, fixed_t speed)
{ {
AActor *dest; AActor *dest;
angle_t an;
int dist; int dist;
if (!self->target) if (!self->target)

View file

@ -403,7 +403,7 @@ void FireMacePL1B (AActor *actor)
return; return;
} }
ball = Spawn("MaceFX2", actor->PosPlusZ(28*FRACUNIT - actor->floorclip), ALLOW_REPLACE); ball = Spawn("MaceFX2", actor->PosPlusZ(28*FRACUNIT - actor->floorclip), ALLOW_REPLACE);
ball->vel.z = FLOAT2FIXED(2 + g_tan(-actor->Angles.Pitch.Degrees)); ball->vel.z = FLOAT2FIXED(2 - actor->Angles.Pitch.Tan());
ball->target = actor; ball->target = actor;
ball->Angles.Yaw = actor->Angles.Yaw; ball->Angles.Yaw = actor->Angles.Yaw;
ball->AddZ(ball->vel.z); ball->AddZ(ball->vel.z);
@ -631,7 +631,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
int i; int i;
AActor *target; AActor *target;
DAngle angle = 0; DAngle angle = 0.;
bool newAngle; bool newAngle;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -664,7 +664,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
} }
else else
{ // Find new target { // Find new target
angle = 0; angle = 0.;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
P_AimLineAttack (self, FLOAT2ANGLE(angle.Degrees), 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);
@ -1337,7 +1337,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2)
return 0; return 0;
} }
slope = FLOAT2FIXED(g_tan(-self->Angles.Pitch.Degrees)); slope = FLOAT2FIXED(-self->Angles.Pitch.Tan());
fixed_t xo = (pr_fp2.Random2() << 9); fixed_t xo = (pr_fp2.Random2() << 9);
fixed_t yo = (pr_fp2.Random2() << 9); fixed_t yo = (pr_fp2.Random2() << 9);
fixedvec3 pos = self->Vec3Offset(xo, yo, fixedvec3 pos = self->Vec3Offset(xo, yo,

View file

@ -498,7 +498,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolySeek)
} }
if (self->tracer) if (self->tracer)
{ {
CHolySeekerMissile (self, self->args[0], self->args[0]*2); CHolySeekerMissile (self, (double)self->args[0], self->args[0]*2.);
if (!((level.time+7)&15)) if (!((level.time+7)&15))
{ {
self->args[0] = 5+(pr_holyseek()/20); self->args[0] = 5+(pr_holyseek()/20);

View file

@ -182,7 +182,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight)
angle_t angle; angle_t angle;
DragonSeek (self, 4, 8); DragonSeek (self, 4., 8.);
if (self->target) if (self->target)
{ {
if(!(self->target->flags&MF_SHOOTABLE)) if(!(self->target->flags&MF_SHOOTABLE))

View file

@ -73,7 +73,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogMove)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int speed = self->args[0]<<FRACBITS; int speed = self->args[0]<<FRACBITS;
angle_t angle;
int weaveindex; int weaveindex;
if (!self->args[4]) if (!self->args[4])

View file

@ -433,7 +433,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KSpiritRoam)
{ {
if (self->tracer) if (self->tracer)
{ {
A_KSpiritSeeker(self, self->args[0], self->args[0] * 2); A_KSpiritSeeker(self, (double)self->args[0], self->args[0] * 2.);
} }
CHolyWeave(self, pr_kspiritweave); CHolyWeave(self, pr_kspiritweave);
if (pr_kspiritroam()<50) if (pr_kspiritroam()<50)
@ -509,7 +509,7 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z,
z -= source->floorclip; z -= source->floorclip;
th = Spawn (type, x, y, z, ALLOW_REPLACE); th = Spawn (type, x, y, z, ALLOW_REPLACE);
th->target = source; // Originator th->target = source; // Originator
an = th->AngleTo(dest); an = th->_f_AngleTo(dest);
if (dest->flags & MF_SHADOW) if (dest->flags & MF_SHADOW)
{ // Invisible target { // Invisible target
an += pr_kmissile.Random2() * (45/256.); an += pr_kmissile.Random2() * (45/256.);

View file

@ -171,7 +171,7 @@ void P_TeleportToPlayerStarts (AActor *victim)
FPlayerStart *start = G_PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK); FPlayerStart *start = G_PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK);
destX = start->x; destX = start->x;
destY = start->y; destY = start->y;
P_Teleport (victim, destX, destY, ONFLOORZ, start->angle, TELF_SOURCEFOG | TELF_DESTFOG); P_Teleport (victim, destX, destY, ONFLOORZ, (double)start->angle, TELF_SOURCEFOG | TELF_DESTFOG);
} }
//=========================================================================== //===========================================================================
@ -191,7 +191,7 @@ void P_TeleportToDeathmatchStarts (AActor *victim)
i = pr_teledm() % selections; i = pr_teledm() % selections;
destX = deathmatchstarts[i].x; destX = deathmatchstarts[i].x;
destY = deathmatchstarts[i].y; destY = deathmatchstarts[i].y;
P_Teleport (victim, destX, destY, ONFLOORZ, deathmatchstarts[i].angle, TELF_SOURCEFOG | TELF_DESTFOG); P_Teleport (victim, destX, destY, ONFLOORZ, (double)deathmatchstarts[i].angle, TELF_SOURCEFOG | TELF_DESTFOG);
} }
else else
{ {

View file

@ -46,7 +46,7 @@ bool AArtiTeleport::Use (bool pickup)
destY = start->y; destY = start->y;
destAngle = start->angle; destAngle = start->angle;
} }
P_Teleport (Owner, destX, destY, ONFLOORZ, destAngle, TELF_SOURCEFOG | TELF_DESTFOG); P_Teleport (Owner, destX, destY, ONFLOORZ, (double)destAngle, TELF_SOURCEFOG | TELF_DESTFOG);
bool canlaugh = true; bool canlaugh = true;
if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYCHAOSDEVICE)) if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYCHAOSDEVICE))
{ // Teleporting away will undo any morph effects (pig) { // Teleporting away will undo any morph effects (pig)

View file

@ -323,7 +323,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
self->player = NULL; self->player = NULL;
head->ObtainInventory (self); head->ObtainInventory (self);
} }
head->Angles.Pitch = 0; head->Angles.Pitch = 0.;
head->RenderStyle = self->RenderStyle; head->RenderStyle = self->RenderStyle;
head->alpha = self->alpha; head->alpha = self->alpha;
if (head->player->camera == self) if (head->player->camera == self)

View file

@ -78,12 +78,12 @@ void ASecurityCamera::PostBeginPlay ()
if (args[2]) if (args[2])
Delta = 360. / (args[2] * TICRATE / 8); Delta = 360. / (args[2] * TICRATE / 8);
else else
Delta = 0; Delta = 0.;
if (args[1]) if (args[1])
Delta /= 2; Delta /= 2;
Acc = 0; Acc = 0.;
Angles.Pitch = clamp<int>((signed int)((signed char)args[0]), -89, 89); Angles.Pitch = (double)clamp<int>((signed char)args[0], -89, 89);
Range = args[1]; Range = (double)args[1];
} }
void ASecurityCamera::Tick () void ASecurityCamera::Tick ()
@ -133,7 +133,7 @@ void AAimingCamera::PostBeginPlay ()
args[2] = 0; args[2] = 0;
Super::PostBeginPlay (); Super::PostBeginPlay ();
MaxPitchChange = changepitch / TICRATE; MaxPitchChange = double(changepitch / TICRATE);
Range /= TICRATE; Range /= TICRATE;
TActorIterator<AActor> iterator (args[3]); TActorIterator<AActor> iterator (args[3]);
@ -177,8 +177,7 @@ void AAimingCamera::Tick ()
DVector2 vect(fv3.x, fv3.y); DVector2 vect(fv3.x, fv3.y);
double dz = Z() - tracer->Z() - tracer->height/2; double dz = Z() - tracer->Z() - tracer->height/2;
double dist = vect.Length(); double dist = vect.Length();
double ang = dist != 0.f ? g_atan2 (dz, dist) : 0; DAngle desiredPitch = dist != 0.f ? vectoyaw(dist, dz) : 0.;
DAngle desiredPitch = ToDegrees(ang);
DAngle diff = deltaangle(Angles.Pitch, desiredPitch); DAngle diff = deltaangle(Angles.Pitch, desiredPitch);
if (fabs (diff) < MaxPitchChange) if (fabs (diff) < MaxPitchChange)
{ {

View file

@ -102,7 +102,7 @@ void AInterpolationPoint::FormChain ()
if (Next == NULL && (args[3] | args[4])) if (Next == NULL && (args[3] | args[4]))
Printf ("Can't find target for camera node %d\n", tid); Printf ("Can't find target for camera node %d\n", tid);
Angles.Pitch = clamp<int>((signed char)args[0], -89, 89); Angles.Pitch = (double)clamp<int>((signed char)args[0], -89, 89);
if (Next != NULL) if (Next != NULL)
Next->FormChain (); Next->FormChain ();
@ -422,7 +422,7 @@ bool APathFollower::Interpolate ()
} }
if (args[2] & 2) if (args[2] & 2)
{ // adjust yaw { // adjust yaw
Angles.Yaw = vectoyaw(DVector2(dx, dy)); Angles.Yaw = vectoyaw(dx, dy);
} }
if (args[2] & 4) if (args[2] & 4)
{ // adjust pitch; use floats for precision { // adjust pitch; use floats for precision
@ -430,8 +430,7 @@ bool APathFollower::Interpolate ()
double fdy = FIXED2DBL(dy); double fdy = FIXED2DBL(dy);
double fdz = FIXED2DBL(-dz); double fdz = FIXED2DBL(-dz);
double dist = g_sqrt (fdx*fdx + fdy*fdy); double dist = g_sqrt (fdx*fdx + fdy*fdy);
double ang = dist != 0.f ? g_atan2 (fdz, dist) : 0; Angles.Pitch = dist != 0.f ? vectoyaw(dist, fdz) : 0.;
Angles.Pitch = ToDegrees(ang);
} }
} }
else else
@ -642,8 +641,7 @@ bool AMovingCamera::Interpolate ()
double dy = FIXED2DBL(Y() - tracer->Y()); double dy = FIXED2DBL(Y() - tracer->Y());
double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2); double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2);
double dist = g_sqrt (dx*dx + dy*dy); double dist = g_sqrt (dx*dx + dy*dy);
double ang = dist != 0.f ? g_atan2 (dz, dist) : 0; Angles.Pitch = dist != 0.f ? vectoyaw(dist, dz) : 0.;
Angles.Pitch = ToDegrees(ang);
} }
return true; return true;

View file

@ -251,7 +251,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_CLASS(ti, AActor); PARAM_CLASS(ti, AActor);
angle_t savedangle; DAngle savedangle;
if (self->player == NULL) if (self->player == NULL)
return 0; return 0;
@ -265,7 +265,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
if (ti) if (ti)
{ {
savedangle = self->_f_angle(); savedangle = self->Angles.Yaw;
self->Angles.Yaw += ANGLE2DBL(pr_electric.Random2() << (18 - self->player->mo->accuracy * 5 / 100)); self->Angles.Yaw += ANGLE2DBL(pr_electric.Random2() << (18 - self->player->mo->accuracy * 5 / 100));
self->player->mo->PlayAttacking2 (); self->player->mo->PlayAttacking2 ();
P_SpawnPlayerMissile (self, ti); P_SpawnPlayerMissile (self, ti);
@ -346,7 +346,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
player_t *player = self->player; player_t *player = self->player;
angle_t savedangle; DAngle savedangle;
if (self->player == NULL) if (self->player == NULL)
return 0; return 0;
@ -358,7 +358,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile)
return 0; return 0;
} }
savedangle = self->_f_angle(); savedangle = self->Angles.Yaw;
self->Angles.Yaw += ANGLE2DBL(pr_minimissile.Random2() << (19 - player->mo->accuracy * 5 / 100)); self->Angles.Yaw += ANGLE2DBL(pr_minimissile.Random2() << (19 - player->mo->accuracy * 5 / 100));
player->mo->PlayAttacking2 (); player->mo->PlayAttacking2 ();
P_SpawnPlayerMissile (self, PClass::FindActor("MiniMissile")); P_SpawnPlayerMissile (self, PClass::FindActor("MiniMissile"));

View file

@ -1382,7 +1382,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
player->ConversationFaceTalker = false; player->ConversationFaceTalker = false;
player->ConversationNPC = NULL; player->ConversationNPC = NULL;
player->ConversationPC = NULL; player->ConversationPC = NULL;
player->ConversationNPCAngle = 0; player->ConversationNPCAngle = 0.;
} }
if (isconsole) if (isconsole)
@ -1429,7 +1429,7 @@ void P_ConversationCommand (int netcode, int pnum, BYTE **stream)
player->ConversationFaceTalker = false; player->ConversationFaceTalker = false;
player->ConversationNPC = NULL; player->ConversationNPC = NULL;
player->ConversationPC = NULL; player->ConversationPC = NULL;
player->ConversationNPCAngle = 0; player->ConversationNPCAngle = 0.;
} }
} }
} }

View file

@ -744,7 +744,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end,
color1 = color1 == 0 ? -1 : ParticleColor(color1); color1 = color1 == 0 ? -1 : ParticleColor(color1);
pos = start; pos = start;
deg = TAngle<double>(SpiralOffset); deg = (double)SpiralOffset;
for (i = spiral_steps; i; i--) for (i = spiral_steps; i; i--)
{ {
particle_t *p = NewParticle (); particle_t *p = NewParticle ();
@ -770,7 +770,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end,
p->y = FLOAT2FIXED(tempvec.Y); p->y = FLOAT2FIXED(tempvec.Y);
p->z = FLOAT2FIXED(tempvec.Z); p->z = FLOAT2FIXED(tempvec.Z);
pos += spiral_step; pos += spiral_step;
deg += TAngle<double>(r_rail_spiralsparsity * 14); deg += double(r_rail_spiralsparsity * 14);
if (color1 == -1) if (color1 == -1)
{ {

View file

@ -3002,7 +3002,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
fixedvec2 pos = self->Vec2To(self->target); fixedvec2 pos = self->Vec2To(self->target);
DVector2 xydiff(pos.x, pos.y); DVector2 xydiff(pos.x, pos.y);
double zdiff = (self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip); double zdiff = (self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip);
self->Angles.Pitch = -ToDegrees(g_atan2(zdiff, xydiff.Length())); self->Angles.Pitch = -vectoyaw(xydiff.Length(), zdiff);
} }
// Let the aim trail behind the player // Let the aim trail behind the player

View file

@ -1635,13 +1635,13 @@ FUNC(LS_Thing_Hate)
FUNC(LS_Thing_ProjectileAimed) FUNC(LS_Thing_ProjectileAimed)
// Thing_ProjectileAimed (tid, type, speed, target, newtid) // Thing_ProjectileAimed (tid, type, speed, target, newtid)
{ {
return P_Thing_Projectile (arg0, it, arg1, NULL, 0, arg2<<(FRACBITS-3), 0, arg3, it, 0, arg4, false); return P_Thing_Projectile (arg0, it, arg1, NULL, 0., arg2<<(FRACBITS-3), 0, arg3, it, 0, arg4, false);
} }
FUNC(LS_Thing_ProjectileIntercept) FUNC(LS_Thing_ProjectileIntercept)
// Thing_ProjectileIntercept (tid, type, speed, target, newtid) // Thing_ProjectileIntercept (tid, type, speed, target, newtid)
{ {
return P_Thing_Projectile (arg0, it, arg1, NULL, 0, arg2<<(FRACBITS-3), 0, arg3, it, 0, arg4, true); return P_Thing_Projectile (arg0, it, arg1, NULL, 0., arg2<<(FRACBITS-3), 0, arg3, it, 0, arg4, true);
} }
// [BC] added newtid for next two // [BC] added newtid for next two

View file

@ -2359,7 +2359,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y,
if (thing == players[consoleplayer].camera) if (thing == players[consoleplayer].camera)
{ {
divline_t dl1 = { besthit.oldrefpos.x,besthit. oldrefpos.y, besthit.refpos.x - besthit.oldrefpos.x, besthit.refpos.y - besthit.oldrefpos.y }; divline_t dl1 = { besthit.oldrefpos.x,besthit. oldrefpos.y, besthit.refpos.x - besthit.oldrefpos.x, besthit.refpos.y - besthit.oldrefpos.y };
fixedvec3a hit = { dl1.x + FixedMul(dl1.dx, bestfrac), dl1.y + FixedMul(dl1.dy, bestfrac), 0, 0 }; fixedvec3a hit = { dl1.x + FixedMul(dl1.dx, bestfrac), dl1.y + FixedMul(dl1.dy, bestfrac), 0, 0. };
R_AddInterpolationPoint(hit); R_AddInterpolationPoint(hit);
if (port->mType == PORTT_LINKED) if (port->mType == PORTT_LINKED)
@ -3531,7 +3531,7 @@ struct aim_t
{ {
res.linetarget = th; res.linetarget = th;
res.pitch = pitch; res.pitch = pitch;
res.angleFromSource = vectoyaw(DVector2(th->X() - startpos.x, th->Y() - startpos.y)); res.angleFromSource = vectoyaw(th->X() - startpos.x, th->Y() - startpos.y);
res.unlinked = unlinked; res.unlinked = unlinked;
res.frac = frac; res.frac = frac;
} }

View file

@ -840,7 +840,7 @@ AInventory *AActor::DropInventory (AInventory *item)
} }
drop->SetOrigin(PosPlusZ(10*FRACUNIT), false); drop->SetOrigin(PosPlusZ(10*FRACUNIT), false);
drop->Angles.Yaw = Angles.Yaw; drop->Angles.Yaw = Angles.Yaw;
drop->VelFromAngle(5); drop->VelFromAngle(5*FRACUNIT);
drop->vel.z = FRACUNIT; drop->vel.z = FRACUNIT;
drop->vel += vel; drop->vel += vel;
drop->flags &= ~MF_NOGRAVITY; // Don't float drop->flags &= ~MF_NOGRAVITY; // Don't float
@ -1760,7 +1760,7 @@ bool P_SeekerMissile (AActor *actor, angle_t _thresh, angle_t _turnMax, bool pre
} }
else else
{ {
DAngle pitch = 0; DAngle pitch = 0.;
if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
{ // Need to seek vertically { // Need to seek vertically
fixed_t dist = MAX(1, actor->Distance2D(target)); fixed_t dist = MAX(1, actor->Distance2D(target));
@ -2824,7 +2824,7 @@ void P_NightmareRespawn (AActor *mobj)
mo->SpawnPoint[2] = mobj->SpawnPoint[2]; mo->SpawnPoint[2] = mobj->SpawnPoint[2];
mo->SpawnAngle = mobj->SpawnAngle; 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->SpawnFlags = mobj->SpawnFlags & ~MTF_DORMANT; // It wasn't dormant when it died, so it's not dormant now, either.
mo->Angles.Yaw = mobj->SpawnAngle; mo->Angles.Yaw = (double)mobj->SpawnAngle;
mo->HandleSpawnFlags (); mo->HandleSpawnFlags ();
mo->reactiontime = 18; mo->reactiontime = 18;
@ -4649,7 +4649,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
spawn_y = mthing->y; spawn_y = mthing->y;
// Allow full angular precision // Allow full angular precision
SpawnAngle = mthing->angle; SpawnAngle = (double)mthing->angle;
if (i_compatflags2 & COMPATF2_BADANGLES) if (i_compatflags2 & COMPATF2_BADANGLES)
{ {
SpawnAngle += 0.01; SpawnAngle += 0.01;
@ -4704,7 +4704,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
} }
mobj->Angles.Yaw = SpawnAngle; mobj->Angles.Yaw = SpawnAngle;
mobj->Angles.Pitch = mobj->Angles.Roll = 0; mobj->Angles.Pitch = mobj->Angles.Roll = 0.;
mobj->health = p->health; mobj->health = p->health;
// [RH] Set player sprite based on skin // [RH] Set player sprite based on skin
@ -4735,7 +4735,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
p->BlendR = p->BlendG = p->BlendB = p->BlendA = 0.f; p->BlendR = p->BlendG = p->BlendB = p->BlendA = 0.f;
p->mo->ResetAirSupply(false); p->mo->ResetAirSupply(false);
p->Uncrouch(); p->Uncrouch();
p->MinPitch = p->MaxPitch = 0; // will be filled in by PostBeginPlay()/netcode p->MinPitch = p->MaxPitch = 0.; // will be filled in by PostBeginPlay()/netcode
p->MUSINFOactor = NULL; p->MUSINFOactor = NULL;
p->MUSINFOtics = -1; p->MUSINFOtics = -1;
@ -5167,7 +5167,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
mobj->tid = mthing->thingid; mobj->tid = mthing->thingid;
mobj->AddToHash (); mobj->AddToHash ();
mobj->PrevAngles.Yaw = mobj->Angles.Yaw = mthing->angle; mobj->PrevAngles.Yaw = mobj->Angles.Yaw = (double)mthing->angle;
// Check if this actor's mapthing has a conversation defined // Check if this actor's mapthing has a conversation defined
if (mthing->Conversation > 0) if (mthing->Conversation > 0)
@ -5191,9 +5191,9 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
if (mthing->scaleY) if (mthing->scaleY)
mobj->scaleY = FixedMul(mthing->scaleY, mobj->scaleY); mobj->scaleY = FixedMul(mthing->scaleY, mobj->scaleY);
if (mthing->pitch) if (mthing->pitch)
mobj->Angles.Pitch = mthing->pitch; mobj->Angles.Pitch = (double)mthing->pitch;
if (mthing->roll) if (mthing->roll)
mobj->Angles.Roll = mthing->roll; mobj->Angles.Roll = (double)mthing->roll;
if (mthing->score) if (mthing->score)
mobj->Score = mthing->score; mobj->Score = mthing->score;
if (mthing->fillcolor) if (mthing->fillcolor)

View file

@ -171,7 +171,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i
player->viewz = thing->Z() + player->viewheight; player->viewz = thing->Z() + player->viewheight;
if (resetpitch) if (resetpitch)
{ {
player->mo->Angles.Pitch = 0; player->mo->Angles.Pitch = 0.;
} }
} }
if (!(flags & TELF_KEEPORIENTATION)) if (!(flags & TELF_KEEPORIENTATION))
@ -326,10 +326,10 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f
{ {
AActor *searcher; AActor *searcher;
fixed_t z; fixed_t z;
DAngle angle = 0; DAngle angle = 0.;
fixed_t s = 0, c = 0; fixed_t s = 0, c = 0;
fixed_t vx = 0, vy = 0; fixed_t vx = 0, vy = 0;
DAngle badangle = 0; DAngle badangle = 0.;
if (thing == NULL) if (thing == NULL)
{ // Teleport function called with an invalid actor { // Teleport function called with an invalid actor
@ -356,7 +356,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f
// Rotate 90 degrees, so that walking perpendicularly across // Rotate 90 degrees, so that walking perpendicularly across
// teleporter linedef causes thing to exit in the direction // teleporter linedef causes thing to exit in the direction
// indicated by the exit thing. // indicated by the exit thing.
angle = vectoyaw(DVector2(line->dx, line->dy)) - searcher->Angles.Yaw + 90; angle = vectoyaw(line->dx, line->dy) - searcher->Angles.Yaw + 90;
// Sine, cosine of angle adjustment // Sine, cosine of angle adjustment
s = FLOAT2FIXED(angle.Sin()); s = FLOAT2FIXED(angle.Sin());
@ -619,7 +619,7 @@ static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool fl
P_Teleport (victim, dest->X() + newX, P_Teleport (victim, dest->X() + newX,
dest->Y() + newY, dest->Y() + newY,
floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z(), floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z(),
0, fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION); 0., fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION);
// P_Teleport only changes angle if fog is true // P_Teleport only changes angle if fog is true
victim->Angles.Yaw = (dest->Angles.Yaw + victim->Angles.Yaw - source->Angles.Yaw).Normalized360(); victim->Angles.Yaw = (dest->Angles.Yaw + victim->Angles.Yaw - source->Angles.Yaw).Normalized360();
@ -687,7 +687,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t
{ {
didSomething |= didSomething |=
P_Teleport (sourceOrigin, destOrigin->X(), destOrigin->Y(), P_Teleport (sourceOrigin, destOrigin->X(), destOrigin->Y(),
floorz ? ONFLOORZ : destOrigin->Z(), 0, TELF_KEEPORIENTATION); floorz ? ONFLOORZ : destOrigin->Z(), 0., TELF_KEEPORIENTATION);
sourceOrigin->Angles.Yaw = destOrigin->Angles.Yaw; sourceOrigin->Angles.Yaw = destOrigin->Angles.Yaw;
} }

View file

@ -313,7 +313,7 @@ player_t::player_t()
crouchviewdelta(0), crouchviewdelta(0),
ConversationNPC(0), ConversationNPC(0),
ConversationPC(0), ConversationPC(0),
ConversationNPCAngle(0), ConversationNPCAngle(0.),
ConversationFaceTalker(0) ConversationFaceTalker(0)
{ {
memset (&cmd, 0, sizeof(cmd)); memset (&cmd, 0, sizeof(cmd));
@ -2186,7 +2186,7 @@ void P_DeathThink (player_t *player)
} }
if (fabs(player->mo->Angles.Pitch) < 3) if (fabs(player->mo->Angles.Pitch) < 3)
{ {
player->mo->Angles.Pitch = 0; player->mo->Angles.Pitch = 0.;
} }
} }
P_CalcHeight (player); P_CalcHeight (player);
@ -2206,9 +2206,9 @@ void P_DeathThink (player_t *player)
} }
} }
delta /= 8; delta /= 8;
if (delta > 5) if (delta > 5.)
{ {
delta = 5; delta = 5.;
} }
if (dir) if (dir)
{ // Turn clockwise { // Turn clockwise
@ -2492,7 +2492,7 @@ void P_PlayerThink (player_t *player)
// [RH] Look up/down stuff // [RH] Look up/down stuff
if (!level.IsFreelookAllowed()) if (!level.IsFreelookAllowed())
{ {
player->mo->Angles.Pitch = 0; player->mo->Angles.Pitch = 0.;
} }
else else
{ {
@ -2523,7 +2523,7 @@ void P_PlayerThink (player_t *player)
} }
else else
{ {
player->mo->Angles.Pitch = 0; player->mo->Angles.Pitch = 0.;
player->centering = false; player->centering = false;
if (player - players == consoleplayer) if (player - players == consoleplayer)
{ {

View file

@ -608,8 +608,8 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
angle_t totaladiff = 0; angle_t totaladiff = 0;
fixed_t oviewz = iview->oviewz; fixed_t oviewz = iview->oviewz;
fixed_t nviewz = iview->nviewz; fixed_t nviewz = iview->nviewz;
fixedvec3a oldpos = { iview->oviewx, iview->oviewy, 0, 0 }; fixedvec3a oldpos = { iview->oviewx, iview->oviewy, 0, 0. };
fixedvec3a newpos = { iview->nviewx, iview->nviewy, 0, 0 }; fixedvec3a newpos = { iview->nviewx, iview->nviewy, 0, 0. };
InterpolationPath.Push(newpos); // add this to the array to simplify the loops below InterpolationPath.Push(newpos); // add this to the array to simplify the loops below
for (unsigned i = 0; i < InterpolationPath.Size(); i += 2) for (unsigned i = 0; i < InterpolationPath.Size(); i += 2)

View file

@ -1203,9 +1203,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile)
PARAM_CLASS (ti, AActor); PARAM_CLASS (ti, AActor);
PARAM_FIXED_OPT (spawnheight) { spawnheight = 32*FRACUNIT; } PARAM_FIXED_OPT (spawnheight) { spawnheight = 32*FRACUNIT; }
PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; }
PARAM_DANGLE_OPT(Angle) { Angle = 0; } PARAM_DANGLE_OPT(Angle) { Angle = 0.; }
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_DANGLE_OPT(Pitch) { Pitch = 0; } PARAM_DANGLE_OPT(Pitch) { Pitch = 0.; }
PARAM_INT_OPT (ptr) { ptr = AAPTR_TARGET; } PARAM_INT_OPT (ptr) { ptr = AAPTR_TARGET; }
AActor *ref = COPY_AAPTR(self, ptr); AActor *ref = COPY_AAPTR(self, ptr);
@ -1262,7 +1262,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile)
if (CMF_OFFSETPITCH & flags) if (CMF_OFFSETPITCH & flags)
{ {
DVector2 velocity (missile->vel.x, missile->vel.y); DVector2 velocity (missile->vel.x, missile->vel.y);
Pitch += vectoyaw(DVector2(velocity.Length(), (double)missile->vel.z)); Pitch += vectoyaw(velocity.Length(), missile->vel.z);
} }
missilespeed = abs(fixed_t(Pitch.Cos() * missile->Speed)); missilespeed = abs(fixed_t(Pitch.Cos() * missile->Speed));
missile->vel.z = fixed_t(Pitch.Sin() * missile->Speed); missile->vel.z = fixed_t(Pitch.Sin() * missile->Speed);
@ -1627,12 +1627,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_CLASS (ti, AActor); PARAM_CLASS (ti, AActor);
PARAM_DANGLE_OPT(angle) { angle = 0; } PARAM_DANGLE_OPT(angle) { angle = 0.; }
PARAM_BOOL_OPT (useammo) { useammo = true; } PARAM_BOOL_OPT (useammo) { useammo = true; }
PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; }
PARAM_FIXED_OPT (spawnheight) { spawnheight = 0; } PARAM_FIXED_OPT (spawnheight) { spawnheight = 0; }
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_DANGLE_OPT(pitch) { pitch = 0; } PARAM_DANGLE_OPT(pitch) { pitch = 0.; }
if (!self->player) if (!self->player)
return 0; return 0;
@ -1931,7 +1931,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
DVector2 xydiff(pos.x, pos.y); DVector2 xydiff(pos.x, pos.y);
double zdiff = (self->target->Z() + (self->target->height>>1)) - double zdiff = (self->target->Z() + (self->target->height>>1)) -
(self->Z() + (self->height>>1) - self->floorclip); (self->Z() + (self->height>>1) - self->floorclip);
self->Angles.Pitch = vectoyaw(DVector2(xydiff.Length(), zdiff)); self->Angles.Pitch = vectoyaw(xydiff.Length(), zdiff);
} }
// Let the aim trail behind the player // Let the aim trail behind the player
if (aim) if (aim)
@ -2452,7 +2452,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx)
PARAM_FIXED_OPT (xvel) { xvel = 0; } PARAM_FIXED_OPT (xvel) { xvel = 0; }
PARAM_FIXED_OPT (yvel) { yvel = 0; } PARAM_FIXED_OPT (yvel) { yvel = 0; }
PARAM_FIXED_OPT (zvel) { zvel = 0; } PARAM_FIXED_OPT (zvel) { zvel = 0; }
PARAM_DANGLE_OPT(angle) { angle = 0; } PARAM_DANGLE_OPT(angle) { angle = 0.; }
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_INT_OPT (chance) { chance = 0; } PARAM_INT_OPT (chance) { chance = 0; }
PARAM_INT_OPT (tid) { tid = 0; } PARAM_INT_OPT (tid) { tid = 0; }

View file

@ -263,11 +263,11 @@ struct TVector2
return g_atan2 (X, Y); return g_atan2 (X, Y);
} }
// Returns a rotated vector. angle is in radians. // Returns a rotated vector. angle is in degrees.
TVector2 Rotated (double angle) TVector2 Rotated (double angle)
{ {
double cosval = g_cos (angle); double cosval = g_cosdeg (angle);
double sinval = g_sin (angle); double sinval = g_sindeg (angle);
return TVector2(X*cosval - Y*sinval, Y*cosval + X*sinval); return TVector2(X*cosval - Y*sinval, Y*cosval + X*sinval);
} }
@ -758,6 +758,17 @@ struct TAngle
{ {
vec_t Degrees; vec_t Degrees;
// This is to catch any accidental attempt to assign an angle_t to this type. Any explicit exception will require a type cast.
TAngle(int) = delete;
TAngle(unsigned int) = delete;
TAngle(long) = delete;
TAngle(unsigned long) = delete;
TAngle &operator= (int other) = delete;
TAngle &operator= (unsigned other) = delete;
TAngle &operator= (long other) = delete;
TAngle &operator= (unsigned long other) = delete;
TAngle () TAngle ()
{ {
} }
@ -767,10 +778,12 @@ struct TAngle
{ {
} }
/*
TAngle (int amt) TAngle (int amt)
: Degrees(vec_t(amt)) : Degrees(vec_t(amt))
{ {
} }
*/
TAngle (const TAngle &other) TAngle (const TAngle &other)
: Degrees(other.Degrees) : Degrees(other.Degrees)
@ -999,7 +1012,7 @@ struct TAngle
return FLOAT2ANGLE(Degrees); return FLOAT2ANGLE(Degrees);
} }
TVector2<vec_t> ToDirection(vec_t length) const TVector2<vec_t> ToVector(vec_t length) const
{ {
return TVector2(length * Cos(), length * Sin()); return TVector2(length * Cos(), length * Sin());
} }
@ -1021,7 +1034,7 @@ struct TAngle
double Tan() const double Tan() const
{ {
return g_tan(Degrees); return g_tan(Degrees * (M_PI / 180.));
} }
}; };
@ -1074,6 +1087,11 @@ inline TAngle<T> diffangle(const TAngle<T> &a1, double a2)
return fabs((a1 - a2).Normalize180()); return fabs((a1 - a2).Normalize180());
} }
inline TAngle<double> vectoyaw(double x, double y)
{
return g_atan2(y, x) * (180.0 / M_PI);
}
template<class T> template<class T>
inline TAngle<T> vectoyaw (const TVector2<T> &vec) inline TAngle<T> vectoyaw (const TVector2<T> &vec)
{ {