From 2a0d5a621a948f43aec46e11b917394efec8aac9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 23 Mar 2016 00:53:09 +0100 Subject: [PATCH 01/12] - floatified some stuff in g_shared. Note: This commit does not handle z-spawn positions correctly. --- src/actor.h | 6 ++- src/g_shared/a_fastprojectile.cpp | 32 ++++++------- src/g_shared/a_movingcamera.cpp | 78 ++++++++++++------------------- src/g_shared/a_pickups.cpp | 15 +++--- src/g_shared/a_randomspawner.cpp | 6 +-- src/p_mobj.cpp | 45 +++++++++--------- src/win32/i_system.cpp | 2 +- 7 files changed, 79 insertions(+), 105 deletions(-) diff --git a/src/actor.h b/src/actor.h index 1977f7d38..074f0478a 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1190,7 +1190,7 @@ public: // no matter what (even if shot) player_t *player; // only valid if type of APlayerPawn TObjPtr LastLookActor; // Actor last looked for (if TIDtoHate != 0) - fixed_t SpawnPoint[3]; // For nightmare respawn + DVector3 SpawnPoint; // For nightmare respawn WORD SpawnAngle; int StartHealth; BYTE WeaveIndexXY; // Separated from special2 because it's used by globally accessible functions. @@ -1341,6 +1341,10 @@ public: int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); virtual bool UpdateWaterLevel (fixed_t oldz, bool splash=true); + bool UpdateWaterLevel(double oldz, bool splash = true) + { + return UpdateWaterLevel(FLOAT2FIXED(oldz), splash); + } bool isFast(); bool isSlow(); void SetIdle(bool nofunction=false); diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index e71f809aa..3c2f26084 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -22,13 +22,11 @@ IMPLEMENT_CLASS(AFastProjectile) void AFastProjectile::Tick () { int i; - fixed_t xfrac; - fixed_t yfrac; - fixed_t zfrac; + DVector3 frac; int changexy; ClearInterpolation(); - fixed_t oldz = _f_Z(); + double oldz = Z(); if (!(flags5 & MF5_NOTIMEFREEZE)) { @@ -43,26 +41,22 @@ void AFastProjectile::Tick () // [RH] Ripping is a little different than it was in Hexen FCheckPosition tm(!!(flags2 & MF2_RIP)); - int shift = 3; int count = 8; - if (_f_radius() > 0) + if (radius > 0) { - while ( ((abs(_f_velx()) >> shift) > _f_radius()) || ((abs(_f_vely()) >> shift) > _f_radius())) + while ( fabs(Vel.X) > radius * count || fabs(Vel.Y) > radius * count) { // we need to take smaller steps. - shift++; - count<<=1; + count += count; } } // Handle movement if (!Vel.isZero() || (Z() != floorz)) { - xfrac = _f_velx() >> shift; - yfrac = _f_vely() >> shift; - zfrac = _f_velz() >> shift; - changexy = xfrac || yfrac; - int ripcount = count >> 3; + frac = Vel / count; + changexy = frac.X != 0 || frac.Y != 0; + int ripcount = count / 8; for (i = 0; i < count; i++) { if (changexy) @@ -72,14 +66,14 @@ void AFastProjectile::Tick () tm.LastRipped.Clear(); // [RH] Do rip damage each step, like Hexen } - if (!P_TryMove (this, _f_X() + xfrac,_f_Y() + yfrac, true, NULL, tm)) + if (!P_TryMove (this, X() + frac.X, Y() + frac.Y, true, NULL, tm)) { // Blocked move if (!(flags3 & MF3_SKYEXPLODE)) { if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - _f_Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline))) + Z() >= tm.ceilingline->backsector->ceilingplane.ZatPointF(PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. @@ -98,10 +92,10 @@ void AFastProjectile::Tick () return; } } - _f_AddZ(zfrac); + AddZ(frac.Z); UpdateWaterLevel (oldz); - oldz = _f_Z(); - if (Z() <= floorz) + oldz = Z(); + if (oldz <= floorz) { // Hit the floor if (floorpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index 73c49167a..158ec6b50 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -298,7 +298,7 @@ void APathFollower::Tick () if (CurrNode->args[2]) { HoldTime = level.time + CurrNode->args[2] * TICRATE / 8; - SetXYZ(CurrNode->_f_X(), CurrNode->_f_Y(), CurrNode->_f_Z()); + SetXYZ(CurrNode->Pos()); } } @@ -352,37 +352,32 @@ void APathFollower::NewNode () bool APathFollower::Interpolate () { - fixed_t dx = 0, dy = 0, dz = 0; + DVector3 dpos(0, 0, 0); if ((args[2] & 8) && Time > 0.f) { - dx = _f_X(); - dy = _f_Y(); - dz = _f_Z(); + dpos = Pos(); } if (CurrNode->Next==NULL) return false; UnlinkFromWorld (); - fixed_t x, y, z; + DVector3 newpos; if (args[2] & 1) { // linear - x = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->_f_X()), FIXED2DBL(CurrNode->Next->_f_X()))); - y = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->_f_Y()), FIXED2DBL(CurrNode->Next->_f_Y()))); - z = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->_f_Z()), FIXED2DBL(CurrNode->Next->_f_Z()))); + newpos.X = Lerp(CurrNode->X(), CurrNode->Next->X()); + newpos.Y = Lerp(CurrNode->Y(), CurrNode->Next->Y()); + newpos.Z = Lerp(CurrNode->Z(), CurrNode->Next->Z()); } else { // spline if (CurrNode->Next->Next==NULL) return false; - x = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->_f_X()), FIXED2DBL(CurrNode->_f_X()), - FIXED2DBL(CurrNode->Next->_f_X()), FIXED2DBL(CurrNode->Next->Next->_f_X()))); - y = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->_f_Y()), FIXED2DBL(CurrNode->_f_Y()), - FIXED2DBL(CurrNode->Next->_f_Y()), FIXED2DBL(CurrNode->Next->Next->_f_Y()))); - z = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->_f_Z()), FIXED2DBL(CurrNode->_f_Z()), - FIXED2DBL(CurrNode->Next->_f_Z()), FIXED2DBL(CurrNode->Next->Next->_f_Z()))); + newpos.X = Splerp(PrevNode->X(), CurrNode->X(), CurrNode->Next->X(), CurrNode->Next->Next->X()); + newpos.X = Splerp(PrevNode->Y(), CurrNode->Y(), CurrNode->Next->Y(), CurrNode->Next->Next->Y()); + newpos.X = Splerp(PrevNode->Z(), CurrNode->Z(), CurrNode->Next->Z(), CurrNode->Next->Next->Z()); } - SetXYZ(x, y, z); + SetXYZ(newpos); LinkToWorld (); if (args[2] & 6) @@ -391,46 +386,35 @@ bool APathFollower::Interpolate () { if (args[2] & 1) { // linear - dx = CurrNode->Next->_f_X() - CurrNode->_f_X(); - dy = CurrNode->Next->_f_Y() - CurrNode->_f_Y(); - dz = CurrNode->Next->_f_Z() - CurrNode->_f_Z(); + dpos.X = CurrNode->Next->X() - CurrNode->X(); + dpos.Y = CurrNode->Next->Y() - CurrNode->Y(); + dpos.Z = CurrNode->Next->Z() - CurrNode->Z(); } else if (Time > 0.f) { // spline - dx = x - dx; - dy = y - dy; - dz = z - dz; + dpos = newpos - dpos; } else { int realarg = args[2]; args[2] &= ~(2|4|8); Time += 0.1f; - dx = x; - dy = y; - dz = z; + dpos = newpos; Interpolate (); Time -= 0.1f; args[2] = realarg; - dx = x - dx; - dy = y - dy; - dz = z - dz; - x -= dx; - y -= dy; - z -= dz; - SetXYZ(x, y, z); + dpos = newpos - dpos; + newpos -= dpos; + SetXYZ(newpos); } if (args[2] & 2) { // adjust yaw - Angles.Yaw = VecToAngle(dx, dy); + Angles.Yaw = dpos.Angle(); } if (args[2] & 4) { // adjust pitch; use floats for precision - double fdx = FIXED2DBL(dx); - double fdy = FIXED2DBL(dy); - double fdz = FIXED2DBL(-dz); - double dist = g_sqrt (fdx*fdx + fdy*fdy); - Angles.Pitch = dist != 0.f ? VecToAngle(dist, fdz) : 0.; + double dist = dpos.XY().Length(); + Angles.Pitch = dist != 0.f ? VecToAngle(dist, -dpos.Z) : 0.; } } else @@ -517,11 +501,11 @@ bool AActorMover::Interpolate () if (Super::Interpolate ()) { - fixed_t savedz = tracer->_f_Z(); - tracer->_f_SetZ(_f_Z()); - if (!P_TryMove (tracer, _f_X(), _f_Y(), true)) + double savedz = tracer->Z(); + tracer->SetZ(Z()); + if (!P_TryMove (tracer, Pos(), true)) { - tracer->_f_SetZ(savedz); + tracer->SetZ(savedz); return false; } @@ -636,12 +620,10 @@ bool AMovingCamera::Interpolate () Angles.Yaw = AngleTo(tracer, true); if (args[2] & 4) - { // Also aim camera's pitch; use floats for precision - double dx = FIXED2DBL(_f_X() - tracer->_f_X()); - double dy = FIXED2DBL(_f_Y() - tracer->_f_Y()); - double dz = FIXED2DBL(_f_Z() - tracer->_f_Z() - tracer->_f_height()/2); - double dist = g_sqrt (dx*dx + dy*dy); - Angles.Pitch = dist != 0.f ? VecToAngle(dist, dz) : 0.; + { // Also aim camera's pitch; + DVector3 diff = Pos() - tracer->PosPlusZ(tracer->Height / 2); + double dist = diff.XY().Length(); + Angles.Pitch = dist != 0.f ? VecToAngle(dist, diff.Z) : 0.; } return true; diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 2e1db7c5d..9944f3154 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -413,20 +413,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) PARAM_ACTION_PROLOGUE; // Move item back to its original location - fixed_t _x, _y; - - _x = self->SpawnPoint[0]; - _y = self->SpawnPoint[1]; + DVector2 sp = self->SpawnPoint; self->UnlinkFromWorld(); - self->SetXY(_x, _y); + self->SetXY(sp); self->LinkToWorld(true); - self->_f_SetZ(self->Sector->floorplane.ZatPoint(_x, _y)); + self->SetZ(self->Sector->floorplane.ZatPoint(sp)); P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS | FFCF_NOPORTALS); // no portal checks here so that things get spawned in this sector. if (self->flags & MF_SPAWNCEILING) { - self->_f_SetZ(self->_f_ceilingz() - self->_f_height() - self->SpawnPoint[2]); + self->SetZ(self->ceilingz - self->Height - self->SpawnPoint.Z); } else if (self->flags2 & MF2_SPAWNFLOAT) { @@ -443,7 +440,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) } else { - self->_f_SetZ(self->SpawnPoint[2] + self->_f_floorz()); + self->SetZ(self->SpawnPoint.Z + self->floorz); } // Redo floor/ceiling check, in case of 3D floors and portals P_FindFloorCeiling(self, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); @@ -1354,7 +1351,7 @@ bool AInventory::DoRespawn () if (spot != NULL) { SetOrigin (spot->Pos(), false); - _f_SetZ(_f_floorz()); + SetZ(floorz); } } return true; diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index 241cb1b14..1f039bda8 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -162,7 +162,7 @@ class ARandomSpawner : public AActor // copy everything relevant newmobj->SpawnAngle = SpawnAngle; newmobj->Angles = Angles; - newmobj->SpawnPoint[2] = SpawnPoint[2]; + newmobj->SpawnPoint = SpawnPoint; newmobj->special = special; newmobj->args[0] = args[0]; newmobj->args[1] = args[1]; @@ -188,7 +188,7 @@ class ARandomSpawner : public AActor // Handle special altitude flags if (newmobj->flags & MF_SPAWNCEILING) { - newmobj->_f_SetZ(newmobj->_f_ceilingz() - newmobj->_f_height() - SpawnPoint[2]); + newmobj->SetZ(newmobj->ceilingz - newmobj->Height - SpawnPoint.Z); } else if (newmobj->flags2 & MF2_SPAWNFLOAT) { @@ -198,7 +198,7 @@ class ARandomSpawner : public AActor space -= 40; newmobj->SetZ((space * pr_randomspawn()) / 256. + newmobj->floorz + 40); } - newmobj->_f_AddZ(SpawnPoint[2]); + newmobj->AddZ(SpawnPoint.Z); } if (newmobj->flags & MF_MISSILE) P_CheckMissileSpawn(newmobj, 0); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 6c3e0adef..8c8388b9e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -315,7 +315,7 @@ void AActor::Serialize(FArchive &arc) << reactiontime << threshold << player - << SpawnPoint[0] << SpawnPoint[1] << SpawnPoint[2] + << SpawnPoint << SpawnAngle; if (SaveVersion >= 4506) { @@ -2739,7 +2739,7 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj) // void P_NightmareRespawn (AActor *mobj) { - fixed_t x, y, z; + double z; AActor *mo; AActor *info = mobj->GetDefault(); @@ -2754,13 +2754,11 @@ void P_NightmareRespawn (AActor *mobj) z = ONFLOORZ; // spawn it - x = mobj->SpawnPoint[0]; - y = mobj->SpawnPoint[1]; - mo = AActor::StaticSpawn(mobj->GetClass(), x, y, z, NO_REPLACE, true); + mo = AActor::StaticSpawn(mobj->GetClass(), mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z, NO_REPLACE, true); if (z == ONFLOORZ) { - mo->_f_AddZ(mobj->SpawnPoint[2]); + mo->AddZ(mobj->SpawnPoint.Z); if (mo->Z() < mo->floorz) { // Do not respawn monsters in the floor, even if that's where they // started. The initial P_ZMovement() call would have put them on @@ -2775,7 +2773,7 @@ void P_NightmareRespawn (AActor *mobj) } else if (z == ONCEILINGZ) { - mo->_f_AddZ(-mobj->SpawnPoint[2]); + mo->AddZ(-mobj->SpawnPoint.Z); } // If there are 3D floors, we need to find floor/ceiling again. @@ -2797,7 +2795,7 @@ void P_NightmareRespawn (AActor *mobj) } // something is occupying its position? - if (!P_CheckPosition(mo, mo->_f_X(), mo->_f_Y(), true)) + if (!P_CheckPosition(mo, mo->Pos(), true)) { //[GrafZahl] MF_COUNTKILL still needs to be checked here. mo->ClearCounters(); @@ -2808,9 +2806,7 @@ void P_NightmareRespawn (AActor *mobj) z = mo->_f_Z(); // inherit attributes from deceased one - mo->SpawnPoint[0] = mobj->SpawnPoint[0]; - mo->SpawnPoint[1] = mobj->SpawnPoint[1]; - mo->SpawnPoint[2] = mobj->SpawnPoint[2]; + mo->SpawnPoint = mobj->SpawnPoint; 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->Angles.Yaw = (double)mobj->SpawnAngle; @@ -2822,13 +2818,13 @@ void P_NightmareRespawn (AActor *mobj) mo->skillrespawncount = mobj->skillrespawncount; - mo->PrevZ = z; // Do not interpolate Z position if we changed it since spawning. + mo->PrevZ = FLOAT2FIXED(z); // Do not interpolate Z position if we changed it since spawning. // spawn a teleport fog at old spot because of removal of the body? P_SpawnTeleportFog(mobj, mobj->PosPlusZ(TELEFOGHEIGHT), true, true); // spawn a teleport fog at the new spot - P_SpawnTeleportFog(mobj, FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z) + TELEFOGHEIGHT, false, true); + P_SpawnTeleportFog(mobj, mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z + TELEFOGHEIGHT, false, true); // remove the old monster mobj->Destroy (); @@ -4132,8 +4128,12 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) // //========================================================================== -AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t iz, replace_t allowreplacement, bool SpawningMapThing) +AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_t _iz, replace_t allowreplacement, bool SpawningMapThing) { + double ix = FIXED2DBL(_ix); + double iy = FIXED2DBL(_iy); + double iz = FIXED2DBL(_iz); + if (type == NULL) { I_Error ("Tried to spawn a class-less actor\n"); @@ -4196,10 +4196,9 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t actor->LinkToWorld (SpawningMapThing); actor->ClearInterpolation(); - actor->dropoffz = // killough 11/98: for tracking dropoffs - actor->Sector->floorplane.ZatPoint (ix, iy); - actor->floorz = FIXED2DBL(actor->dropoffz); - actor->ceilingz = FIXED2DBL(actor->Sector->ceilingplane.ZatPoint (ix, iy)); + actor->floorz = actor->Sector->floorplane.ZatPoint (ix, iy); + actor->dropoffz = FLOAT2FIXED(actor->floorz); // killough 11/98: for tracking dropoffs + actor->ceilingz = actor->Sector->ceilingplane.ZatPoint (ix, iy); // The z-coordinate needs to be set once before calling P_FindFloorCeiling // For FLOATRANDZ just use the floor here. @@ -4243,8 +4242,8 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t actor->ceilingsector = actor->Sector; } - actor->SpawnPoint[0] = ix; - actor->SpawnPoint[1] = iy; + actor->SpawnPoint.X = ix; + actor->SpawnPoint.Y = iy; if (iz == ONFLOORZ) { @@ -4269,7 +4268,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t } else { - actor->SpawnPoint[2] = (actor->_f_Z() - actor->Sector->floorplane.ZatPoint(actor)); + actor->SpawnPoint.Z = (actor->Z() - actor->Sector->floorplane.ZatPointF(actor)); } if (actor->FloatBobPhase == (BYTE)-1) actor->FloatBobPhase = rng(); // Don't make everything bob in sync (unless deliberately told to do) @@ -5129,9 +5128,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) else if (z == ONCEILINGZ) mobj->_f_AddZ(-mthing->z); - mobj->SpawnPoint[0] = mthing->x; - mobj->SpawnPoint[1] = mthing->y; - mobj->SpawnPoint[2] = mthing->z; + mobj->SpawnPoint = { FIXED2DBL(mthing->x), FIXED2DBL(mthing->y),FIXED2DBL(mthing->z) }; mobj->SpawnAngle = mthing->angle; mobj->SpawnFlags = mthing->flags; if (mthing->FloatbobPhase >= 0 && mthing->FloatbobPhase < 64) mobj->FloatBobPhase = mthing->FloatbobPhase; diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index bdfd9f958..0db4dd15e 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -727,7 +727,7 @@ void CalculateCPUSpeed() PerfToMillisec = PerfToSec * 1000.0; } - if (!batchrun) Printf ("CPU _f_speed(): %.0f MHz\n", 0.001 / PerfToMillisec); + if (!batchrun) Printf ("CPU speed: %.0f MHz\n", 0.001 / PerfToMillisec); } //========================================================================== From f8cf4bcf3d76abcf461ac3f9ecc7daf3f7ac6386 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 23 Mar 2016 10:42:41 +0100 Subject: [PATCH 02/12] - trimmed down the AActor Spawn interface and removed all non-float variants. This still needs some cleanup in a few calling functions. --- src/actor.h | 82 +++---------------- src/b_bot.h | 2 +- src/b_func.cpp | 37 +++++---- src/d_net.cpp | 2 +- src/fragglescript/t_func.cpp | 52 ++++++------ src/g_shared/a_fastprojectile.cpp | 2 +- src/g_shared/a_pickups.cpp | 2 +- src/g_strife/a_entityboss.cpp | 2 +- src/g_strife/a_inquisitor.cpp | 2 +- src/g_strife/a_programmer.cpp | 2 +- src/g_strife/a_strifestuff.cpp | 2 +- src/g_strife/a_strifeweapons.cpp | 2 +- src/p_acs.cpp | 20 +++-- src/p_acs.h | 3 +- src/p_effect.cpp | 4 +- src/p_enemy.cpp | 9 +-- src/p_lnspec.cpp | 14 ++-- src/p_local.h | 7 ++ src/p_map.cpp | 4 +- src/p_mobj.cpp | 128 ++++++++++++++---------------- src/p_setup.cpp | 2 +- src/p_spec.cpp | 17 ++-- src/p_spec.h | 19 +++-- src/p_teleport.cpp | 10 +-- src/p_things.cpp | 21 +++-- src/p_tick.cpp | 2 +- src/p_user.cpp | 2 +- src/s_sound.cpp | 2 +- src/thingdef/thingdef_codeptr.cpp | 38 ++++----- 29 files changed, 214 insertions(+), 277 deletions(-) diff --git a/src/actor.h b/src/actor.h index 074f0478a..6c283b03c 100644 --- a/src/actor.h +++ b/src/actor.h @@ -580,7 +580,7 @@ public: void Serialize (FArchive &arc); - static AActor *StaticSpawn (PClassActor *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement, bool SpawningMapThing = false); + static AActor *StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing = false); inline AActor *GetDefault () const { @@ -1666,96 +1666,36 @@ public: bool P_IsTIDUsed(int tid); int P_FindUniqueTID(int start_tid, int limit); -inline AActor *Spawn (PClassActor *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) -{ - return AActor::StaticSpawn (type, x, y, z, allowreplacement); -} +PClassActor *ClassForSpawn(FName classname); + inline AActor *Spawn(PClassActor *type) { - return AActor::StaticSpawn(type, 0, 0, 0, NO_REPLACE); -} -inline AActor *Spawn (PClassActor *type, const fixedvec3 &pos, replace_t allowreplacement) -{ - return AActor::StaticSpawn (type, pos.x, pos.y, pos.z, allowreplacement); + return AActor::StaticSpawn(type, DVector3(0, 0, 0), NO_REPLACE); } inline AActor *Spawn(PClassActor *type, const DVector3 &pos, replace_t allowreplacement) { - fixed_t zz; - if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ && pos.Z != FLOATRANDZ) zz = FLOAT2FIXED(pos.Z); - else zz = (int)pos.Z; - return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement); + return AActor::StaticSpawn(type, pos, allowreplacement); } -AActor *Spawn (const char *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); -AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); - inline AActor *Spawn(FName type) { - return Spawn(type, 0, 0, 0, NO_REPLACE); -} - -inline AActor *Spawn (const char *type, const fixedvec3 &pos, replace_t allowreplacement) -{ - return Spawn (type, pos.x, pos.y, pos.z, allowreplacement); -} - -inline AActor *Spawn(const char *type, const DVector3 &pos, replace_t allowreplacement) -{ - fixed_t zz; - if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ && pos.Z != FLOATRANDZ) zz = FLOAT2FIXED(pos.Z); - else zz = (int)pos.Z; - return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement); -} - -inline AActor *Spawn (FName classname, const fixedvec3 &pos, replace_t allowreplacement) -{ - return Spawn (classname, pos.x, pos.y, pos.z, allowreplacement); + return AActor::StaticSpawn(ClassForSpawn(type), DVector3(0, 0, 0), NO_REPLACE); } inline AActor *Spawn(FName type, const DVector3 &pos, replace_t allowreplacement) { - fixed_t zz; - if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ && pos.Z != FLOATRANDZ) zz = FLOAT2FIXED(pos.Z); - else zz = (int)pos.Z; - return Spawn(type, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement); + return AActor::StaticSpawn(ClassForSpawn(type), pos, allowreplacement); } - -template -inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) +template inline T *Spawn(const DVector3 &pos, replace_t allowreplacement) { - return static_cast(AActor::StaticSpawn (RUNTIME_TEMPLATE_CLASS(T), x, y, z, allowreplacement)); + return static_cast(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), pos, allowreplacement)); } -template -inline T *Spawn (const fixedvec3 &pos, replace_t allowreplacement) +template inline T *Spawn() // for inventory items we do not need coordinates and replacement info. { - return static_cast(AActor::StaticSpawn (RUNTIME_TEMPLATE_CLASS(T), pos.x, pos.y, pos.z, allowreplacement)); -} - -template -inline T *Spawn(const DVector3 &pos, replace_t allowreplacement) -{ - fixed_t zz; - if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ && pos.Z != FLOATRANDZ) zz = FLOAT2FIXED(pos.Z); - else zz = (int)pos.Z; - return static_cast(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement)); -} - -template -inline T *Spawn(double x, double y, double z, replace_t allowreplacement) -{ - fixed_t zz; - if (z != ONFLOORZ && z != ONCEILINGZ && z != FLOATRANDZ) zz = FLOAT2FIXED(z); - else zz = (int)z; - return static_cast(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), FLOAT2FIXED(x), FLOAT2FIXED(y), zz, allowreplacement)); -} - -template -inline T *Spawn() // for inventory items we do not need coordinates and replacement info. -{ - return static_cast(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), 0, 0, 0, NO_REPLACE)); + return static_cast(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), DVector3(0, 0, 0), NO_REPLACE)); } inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle) diff --git a/src/b_bot.h b/src/b_bot.h index 1e8a0e341..5b8e48c8f 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -103,7 +103,7 @@ public: void StartTravel (); void FinishTravel (); bool IsLeader (player_t *player); - void SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum); + void SetBodyAt (const DVector3 &pos, int hostnum); fixed_t FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd); bool SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y, FCheckPosition &tm); diff --git a/src/b_func.cpp b/src/b_func.cpp index bb824d098..e088f70ac 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -141,8 +141,10 @@ void DBot::Dofire (ticcmd_t *cmd) int aiming_penalty=0; //For shooting at shading target, if screen is red, MAKEME: When screen red. int aiming_value; //The final aiming value. fixed_t dist; + double fdist; angle_t an; int m; + double fm; if (!enemy || !(enemy->flags & MF_SHOOTABLE) || enemy->health <= 0) return; @@ -221,9 +223,9 @@ void DBot::Dofire (ticcmd_t *cmd) } // prediction aiming shootmissile: - dist = player->mo->AproxDistance (enemy); - m = dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->_f_speed(); - bglobal.SetBodyAt (enemy->_f_X() + enemy->_f_velx()*m*2, enemy->_f_Y() + enemy->_f_vely()*m*2, enemy->_f_Z(), 1); + fdist = player->mo->Distance2D(enemy); + fm = fdist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed; + bglobal.SetBodyAt(enemy->Pos() + enemy->Vel.XY() * fm * 2, 1); angle = player->mo->__f_AngleTo(bglobal.body1); if (Check_LOS (enemy, SHOOTFOV)) no_fire = false; @@ -425,28 +427,28 @@ AActor *DBot::Find_enemy () //Creates a temporary mobj (invisible) at the given location. -void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum) +void FCajunMaster::SetBodyAt (const DVector3 &pos, int hostnum) { if (hostnum == 1) { if (body1) { - body1->SetOrigin (x, y, z, false); + body1->SetOrigin (pos, false); } else { - body1 = Spawn ("CajunBodyNode", x, y, z, NO_REPLACE); + body1 = Spawn ("CajunBodyNode", pos, NO_REPLACE); } } else if (hostnum == 2) { if (body2) { - body2->SetOrigin (x, y, z, false); + body2->SetOrigin (pos, false); } else { - body2 = Spawn ("CajunBodyNode", x, y, z, NO_REPLACE); + body2 = Spawn ("CajunBodyNode", pos, NO_REPLACE); } } } @@ -463,7 +465,7 @@ void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum) //Emulates missile travel. Returns distance travelled. fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) { - AActor *th = Spawn ("CajunTrace", source->PosPlusZ(4*8*FRACUNIT), NO_REPLACE); + AActor *th = Spawn ("CajunTrace", source->PosPlusZ(4*8.), NO_REPLACE); th->target = source; // where it came from @@ -485,25 +487,22 @@ fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) { - fixed_t dist; + double dist; angle_t ang; AActor *actor; - int m; + double m; - bglobal.SetBodyAt (player->mo->_f_X() + FixedMul(player->mo->_f_velx(), 5*FRACUNIT), - player->mo->_f_Y() + FixedMul(player->mo->_f_vely(), 5*FRACUNIT), - player->mo->_f_Z() + (player->mo->_f_height() / 2), 2); + bglobal.SetBodyAt(player->mo->PosPlusZ(player->mo->Height / 2) + player->mo->Vel.XY() * 5, 2); actor = bglobal.body2; - dist = actor->AproxDistance (enemy); - if (dist < SAFE_SELF_MISDIST) + dist = actor->Distance2D (enemy); + if (dist < SAFE_SELF_MISDIST/FRACUNIT) return 0; //Predict. - m = (((dist+1)/FRACUNIT) / GetDefaultByName("Rocket")->_f_speed()); + m = ((dist+1) / GetDefaultByName("Rocket")->Speed); - bglobal.SetBodyAt (enemy->_f_X() + FixedMul(enemy->_f_velx(), (m+2*FRACUNIT)), - enemy->_f_Y() + FixedMul(enemy->_f_vely(), (m+2*FRACUNIT)), ONFLOORZ, 1); + bglobal.SetBodyAt(DVector3((enemy->Pos() + enemy->Vel * (m + 2)), ONFLOORZ), 1); //try the predicted location if (P_CheckSight (actor, bglobal.body1, SF_IGNOREVISIBILITY)) //See the predicted location, so give a test missile diff --git a/src/d_net.cpp b/src/d_net.cpp index 1659b72ac..2ebb54377 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->_f_Vec3Angle(def->_f_radius() * 2 + source->_f_radius(), source->_f_angle(), 8 * FRACUNIT); + DVector3 spawnpos = source->Vec3Angle(def->radius * 2 + source->radius, source->Angles.Yaw, 8.); AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE); if (spawned != NULL) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 7cebb6148..40349d038 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -862,7 +862,7 @@ void FParser::SF_Player(void) void FParser::SF_Spawn(void) { - int x, y, z; + DVector3 pos; PClassActor *pclass; DAngle angle = 0.; @@ -870,22 +870,22 @@ void FParser::SF_Spawn(void) { if (!(pclass=T_GetMobjType(t_argv[0]))) return; - x = fixedvalue(t_argv[1]); - y = fixedvalue(t_argv[2]); + pos.X = floatvalue(t_argv[1]); + pos.Y = floatvalue(t_argv[2]); if(t_argc >= 5) { - z = fixedvalue(t_argv[4]); + pos.Z = floatvalue(t_argv[4]); // [Graf Zahl] added option of spawning with a relative z coordinate if(t_argc > 5) { - if (intvalue(t_argv[5])) z+=P_PointInSector(x, y)->floorplane.ZatPoint(x,y); + if (intvalue(t_argv[5])) pos.Z += P_PointInSector(pos)->floorplane.ZatPoint(pos); } } else { // Legacy compatibility is more important than correctness. - z = ONFLOORZ;// (GetDefaultByType(PClass)->flags & MF_SPAWNCEILING) ? ONCEILINGZ : ONFLOORZ; + pos.Z = ONFLOORZ;// (GetDefaultByType(PClass)->flags & MF_SPAWNCEILING) ? ONCEILINGZ : ONFLOORZ; } if(t_argc >= 4) @@ -894,7 +894,7 @@ void FParser::SF_Spawn(void) } t_return.type = svt_mobj; - t_return.value.mobj = Spawn(pclass, x, y, z, ALLOW_REPLACE); + t_return.value.mobj = Spawn(pclass, pos, ALLOW_REPLACE); if (t_return.value.mobj) { @@ -3340,7 +3340,7 @@ void FParser::SF_FixedValue(void) void FParser::SF_SpawnExplosion() { - fixed_t x, y, z; + DVector3 pos; AActor* spawn; PClassActor * pclass; @@ -3348,14 +3348,14 @@ void FParser::SF_SpawnExplosion() { if (!(pclass=T_GetMobjType(t_argv[0]))) return; - x = fixedvalue(t_argv[1]); - y = fixedvalue(t_argv[2]); + pos.X = floatvalue(t_argv[1]); + pos.Y = floatvalue(t_argv[2]); if(t_argc > 3) - z = fixedvalue(t_argv[3]); + pos.Z = floatvalue(t_argv[3]); else - z = P_PointInSector(x, y)->floorplane.ZatPoint(x,y); + pos.Z = P_PointInSector(pos)->floorplane.ZatPoint(pos); - spawn = Spawn (pclass, x, y, z, ALLOW_REPLACE); + spawn = Spawn (pclass, pos, ALLOW_REPLACE); t_return.type = svt_int; t_return.value.i=0; if (spawn) @@ -4239,31 +4239,31 @@ void FParser::SF_SpawnShot2(void) { AActor *source = NULL; PClassActor * pclass; - int z=0; - + double z = 0; + // t_argv[0] = type to spawn // t_argv[1] = source mobj, optional, -1 to default // shoots at source's angle - + if (CheckArgs(2)) { - if(t_argv[1].type == svt_int && t_argv[1].value.i < 0) + if (t_argv[1].type == svt_int && t_argv[1].value.i < 0) source = Script->trigger; else source = actorvalue(t_argv[1]); - if (t_argc>2) z=fixedvalue(t_argv[2]); - - if(!source) return; - - if (!(pclass=T_GetMobjType(t_argv[0]))) return; - + if (t_argc > 2) z = floatvalue(t_argv[2]); + + if (!source) return; + + if (!(pclass = T_GetMobjType(t_argv[0]))) return; + t_return.type = svt_mobj; - AActor *mo = Spawn (pclass, source->PosPlusZ(z), ALLOW_REPLACE); - if (mo) + AActor *mo = Spawn(pclass, source->PosPlusZ(z), ALLOW_REPLACE); + if (mo) { - S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM); + S_Sound(mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM); mo->target = source; mo->Angles.Yaw = source->Angles.Yaw; mo->Thrust(); diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index 3c2f26084..89b2690e1 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -66,7 +66,7 @@ void AFastProjectile::Tick () tm.LastRipped.Clear(); // [RH] Do rip damage each step, like Hexen } - if (!P_TryMove (this, X() + frac.X, Y() + frac.Y, true, NULL, tm)) + if (!P_TryMove (this, Pos() + frac, true, NULL, tm)) { // Blocked move if (!(flags3 & MF3_SKYEXPLODE)) { diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 9944f3154..7d579454e 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -787,7 +787,7 @@ AInventory *AInventory::CreateTossable () flags &= ~(MF_SPECIAL|MF_SOLID); return this; } - copy = static_cast(Spawn (GetClass(), Owner->_f_Pos(), NO_REPLACE)); + copy = static_cast(Spawn (GetClass(), Owner->Pos(), NO_REPLACE)); if (copy != NULL) { copy->MaxAmount = MaxAmount; diff --git a/src/g_strife/a_entityboss.cpp b/src/g_strife/a_entityboss.cpp index 349942fe2..72eeaac3a 100644 --- a/src/g_strife/a_entityboss.cpp +++ b/src/g_strife/a_entityboss.cpp @@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity) { PARAM_ACTION_PROLOGUE; - AActor *entity = Spawn("EntityBoss", self->PosPlusZ(70), ALLOW_REPLACE); + AActor *entity = Spawn("EntityBoss", self->PosPlusZ(70.), ALLOW_REPLACE); if (entity != NULL) { entity->Angles.Yaw = self->Angles.Yaw; diff --git a/src/g_strife/a_inquisitor.cpp b/src/g_strife/a_inquisitor.cpp index 101959ffb..e372d8de1 100644 --- a/src/g_strife/a_inquisitor.cpp +++ b/src/g_strife/a_inquisitor.cpp @@ -127,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossArm) { PARAM_ACTION_PROLOGUE; - AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24), ALLOW_REPLACE); + AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24.), ALLOW_REPLACE); foo->Angles.Yaw = self->Angles.Yaw - 90. + pr_inq.Random2() * (360./1024.); foo->VelFromAngle(foo->Speed / 8); foo->Vel.Z = pr_inq() / 64.; diff --git a/src/g_strife/a_programmer.cpp b/src/g_strife/a_programmer.cpp index 951e9d954..bed5f838b 100644 --- a/src/g_strife/a_programmer.cpp +++ b/src/g_strife/a_programmer.cpp @@ -130,7 +130,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase) { PARAM_ACTION_PROLOGUE; - AActor *foo = Spawn("ProgrammerBase", self->PosPlusZ(24), ALLOW_REPLACE); + AActor *foo = Spawn("ProgrammerBase", self->PosPlusZ(24.), ALLOW_REPLACE); if (foo != NULL) { foo->Angles.Yaw = self->Angles.Yaw + 180. + pr_prog.Random2() * (360. / 1024.); diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index c845c253c..7e5936972 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -251,7 +251,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_TossGib) PARAM_ACTION_PROLOGUE; const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat"; - AActor *gib = Spawn (gibtype, self->PosPlusZ(24), ALLOW_REPLACE); + AActor *gib = Spawn (gibtype, self->PosPlusZ(24.), ALLOW_REPLACE); if (gib == NULL) { diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 5eee0827a..9c866011b 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -667,7 +667,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination) pos = self->Pos(); } - AActor *drop = Spawn (pos.X, pos.Y, self->Z() + 4., ALLOW_REPLACE); + AActor *drop = Spawn (DVector3(pos, self->Z() + 4.), ALLOW_REPLACE); if (drop != NULL) { drop->Vel.X = self->Vel.X + pr_phburn.Random2 (7); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 7a1062975..8a302c1d7 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3462,7 +3462,7 @@ void DLevelScript::ReplaceTextures (int fromnamei, int tonamei, int flags) } } -int DLevelScript::DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, int angle, bool force) +int DLevelScript::DoSpawn (int type, const DVector3 &pos, int tid, DAngle angle, bool force) { PClassActor *info = PClass::FindActor(FBehavior::StaticLookupString (type)); AActor *actor = NULL; @@ -3478,14 +3478,14 @@ int DLevelScript::DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, i return 0; } - actor = Spawn (info, x, y, z, ALLOW_REPLACE); + actor = Spawn (info, pos, ALLOW_REPLACE); if (actor != NULL) { ActorFlags2 oldFlags2 = actor->flags2; actor->flags2 |= MF2_PASSMOBJ; if (force || P_TestMobjLocation (actor)) { - actor->Angles.Yaw = angle * (360. / 256); + actor->Angles.Yaw = angle; actor->tid = tid; actor->AddToHash (); if (actor->flags & MF_SPECIAL) @@ -3506,6 +3506,12 @@ int DLevelScript::DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, i return spawncount; } +int DLevelScript::DoSpawn(int type, int x, int y, int z, int tid, int angle, bool force) +{ + return DoSpawn(type, DVector3(ACSToDouble(x), ACSToDouble(y), ACSToDouble(z)), tid, angle * (360. / 256), force); +} + + int DLevelScript::DoSpawnSpot (int type, int spot, int tid, int angle, bool force) { int spawned = 0; @@ -3517,12 +3523,12 @@ int DLevelScript::DoSpawnSpot (int type, int spot, int tid, int angle, bool forc while ( (aspot = iterator.Next ()) ) { - spawned += DoSpawn (type, aspot->_f_X(), aspot->_f_Y(), aspot->_f_Z(), tid, angle, force); + spawned += DoSpawn (type, aspot->Pos(), tid, angle * (360. / 256), force); } } else if (activator != NULL) { - spawned += DoSpawn (type, activator->_f_X(), activator->_f_Y(), activator->_f_Z(), tid, angle, force); + spawned += DoSpawn (type, activator->Pos(), tid, angle * (360. / 256), force); } return spawned; } @@ -3538,12 +3544,12 @@ int DLevelScript::DoSpawnSpotFacing (int type, int spot, int tid, bool force) while ( (aspot = iterator.Next ()) ) { - spawned += DoSpawn (type, aspot->_f_X(), aspot->_f_Y(), aspot->_f_Z(), tid, aspot->_f_angle() >> 24, force); + spawned += DoSpawn (type, aspot->Pos(), tid, aspot->Angles.Yaw, force); } } else if (activator != NULL) { - spawned += DoSpawn (type, activator->_f_X(), activator->_f_Y(), activator->_f_Z(), tid, activator->_f_angle() >> 24, force); + spawned += DoSpawn (type, activator->Pos(), tid, activator->Angles.Yaw, force); } return spawned; } diff --git a/src/p_acs.h b/src/p_acs.h index c418dfe1a..c6dede0b8 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -907,7 +907,8 @@ protected: static int CountPlayers (); static void SetLineTexture (int lineid, int side, int position, int name); static void ReplaceTextures (int fromname, int toname, int flags); - static int DoSpawn (int type, fixed_t x, fixed_t y, fixed_t z, int tid, int angle, bool force); + static int DoSpawn (int type, const DVector3 &pos, int tid, DAngle angle, bool force); + static int DoSpawn(int type, int x, int y, int z, int tid, int angle, bool force); static bool DoCheckActorTexture(int tid, AActor *activator, int string, bool floor); int DoSpawnSpot (int type, int spot, int tid, int angle, bool forced); int DoSpawnSpotFacing (int type, int spot, int tid, bool forced); diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 4108be2d5..5de7cb523 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -862,9 +862,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, if (rnd & 4) diff.Z = clamp(diff.Z + ((rnd & 32) ? 1 : -1), -maxdiff, maxdiff); } - DVector3 postmp = pos + diff; - - AActor *thing = Spawn (spawnclass, FLOAT2FIXED(postmp.X), FLOAT2FIXED(postmp.Y), FLOAT2FIXED(postmp.Z), ALLOW_REPLACE); + AActor *thing = Spawn (spawnclass, pos + diff, ALLOW_REPLACE); if (thing) thing->Angles.Yaw = ANGLE2DBL(angle); pos += trail_step; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index a1e5d063d..77808344b 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -3161,9 +3161,8 @@ AInventory *P_DropItem (AActor *source, PClassActor *type, int dropamount, int c if (type != NULL && pr_dropitem() <= chance) { AActor *mo; - fixed_t spawnz; + double spawnz = 0; - spawnz = source->_f_Z(); if (!(i_compatflags & COMPATF_NOTOSSDROPS)) { int style = sv_dropstyle; @@ -3173,14 +3172,14 @@ AInventory *P_DropItem (AActor *source, PClassActor *type, int dropamount, int c } if (style == 2) { - spawnz += 24*FRACUNIT; + spawnz = 24*FRACUNIT; } else { - spawnz += source->_f_height() / 2; + spawnz = source->Height / 2; } } - mo = Spawn(type, source->_f_X(), source->_f_Y(), spawnz, ALLOW_REPLACE); + mo = Spawn(type, source->PosPlusZ(spawnz), ALLOW_REPLACE); if (mo != NULL) { mo->flags |= MF_DROPPED; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 3aa02f35b..833f41bad 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3268,19 +3268,23 @@ FUNC(LS_GlassBreak) { if (!arg0) { // Break some glass - fixed_t x, y; AActor *glass; - x = ln->v1->x + ln->dx/2; - y = ln->v1->y + ln->dy/2; + DVector2 linemid((ln->v1->fX() + ln->v2->fX()) / 2, (ln->v1->fY() + ln->v2->fY()) / 2); + + // remove dependence on sector size and always spawn 2 map units in front of the line. + DVector2 normal(ln->Delta().Y, -ln->Delta().X); + linemid += normal.Unit() * 2; + /* old code: x += (ln->frontsector->centerspot.x - x) / 5; y += (ln->frontsector->centerspot.y - y) / 5; + */ for (int i = 0; i < 7; ++i) { - glass = Spawn("GlassJunk", x, y, ONFLOORZ, ALLOW_REPLACE); + glass = Spawn("GlassJunk", DVector3(linemid, ONFLOORZ), ALLOW_REPLACE); - glass->_f_AddZ(24 * FRACUNIT); + glass->AddZ(24.); glass->SetState (glass->SpawnState + (pr_glass() % glass->health)); glass->Angles.Yaw = pr_glass() * (360 / 256.); diff --git a/src/p_local.h b/src/p_local.h index 6f33acc3f..e4ad4e44f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -23,10 +23,13 @@ #ifndef __P_LOCAL__ #define __P_LOCAL__ +#include #include "doomtype.h" #include "tables.h" #include "vectors.h" +const double NO_VALUE = FLT_MAX; + class player_t; class AActor; struct FPlayerStart; @@ -301,6 +304,10 @@ inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const sec { return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor); } +inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false) +{ + return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor, tm, missileCheck); +} bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y); void P_ApplyTorque(AActor *mo); bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters diff --git a/src/p_map.cpp b/src/p_map.cpp index 7e6902697..0bd03b868 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4749,7 +4749,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i // used as damage inflictor AActor *thepuff = NULL; - if (puffclass != NULL) thepuff = Spawn(puffclass, source->_f_Pos(), ALLOW_REPLACE); + if (puffclass != NULL) thepuff = Spawn(puffclass, source->Pos(), ALLOW_REPLACE); for (i = 0; i < rail_data.RailHits.Size(); i++) { @@ -5636,7 +5636,7 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos) { AActor *mo; - mo = Spawn(bloodcls, thing->PosPlusZ(thing->_f_height() / 2), ALLOW_REPLACE); + mo = Spawn(bloodcls, thing->PosPlusZ(thing->Height / 2), ALLOW_REPLACE); mo->Vel.X = pr_crunch.Random2() / 16.; mo->Vel.Y = pr_crunch.Random2() / 16.; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8c8388b9e..6cdfbb640 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -838,7 +838,7 @@ AInventory *AActor::DropInventory (AInventory *item) { return NULL; } - drop->SetOrigin(PosPlusZ(10*FRACUNIT), false); + drop->SetOrigin(PosPlusZ(10.), false); drop->Angles.Yaw = Angles.Yaw; drop->VelFromAngle(5.); drop->Vel.Z = 1.; @@ -2754,7 +2754,7 @@ void P_NightmareRespawn (AActor *mobj) z = ONFLOORZ; // spawn it - mo = AActor::StaticSpawn(mobj->GetClass(), mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z, NO_REPLACE, true); + mo = AActor::StaticSpawn(mobj->GetClass(), DVector3(mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z), NO_REPLACE, true); if (z == ONFLOORZ) { @@ -2803,7 +2803,7 @@ void P_NightmareRespawn (AActor *mobj) return; // no respawn } - z = mo->_f_Z(); + z = mo->Z(); // inherit attributes from deceased one mo->SpawnPoint = mobj->SpawnPoint; @@ -2824,7 +2824,7 @@ void P_NightmareRespawn (AActor *mobj) P_SpawnTeleportFog(mobj, mobj->PosPlusZ(TELEFOGHEIGHT), true, true); // spawn a teleport fog at the new spot - P_SpawnTeleportFog(mobj, mobj->SpawnPoint.X, mobj->SpawnPoint.Y, z + TELEFOGHEIGHT, false, true); + P_SpawnTeleportFog(mobj, DVector3(mobj->SpawnPoint, z + TELEFOGHEIGHT), false, true); // remove the old monster mobj->Destroy (); @@ -3441,7 +3441,7 @@ void AActor::Tick () { // add some smoke behind the rocket smokecounter = 0; - AActor *th = Spawn("RocketSmokeTrail", Vec3Offset(-_f_velx(), -_f_vely(), -_f_velz()), ALLOW_REPLACE); + AActor *th = Spawn("RocketSmokeTrail", Vec3Offset(-Vel), ALLOW_REPLACE); if (th) { th->tics -= pr_rockettrail()&3; @@ -4128,12 +4128,8 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) // //========================================================================== -AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_t _iz, replace_t allowreplacement, bool SpawningMapThing) +AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing) { - double ix = FIXED2DBL(_ix); - double iy = FIXED2DBL(_iy); - double iz = FIXED2DBL(_iz); - if (type == NULL) { I_Error ("Tried to spawn a class-less actor\n"); @@ -4159,7 +4155,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_ actor->Conversation = NULL; } - actor->SetXYZ(ix, iy, iz); + actor->SetXYZ(pos); actor->picnum.SetInvalid(); actor->health = actor->SpawnHealth(); @@ -4196,17 +4192,17 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_ actor->LinkToWorld (SpawningMapThing); actor->ClearInterpolation(); - actor->floorz = actor->Sector->floorplane.ZatPoint (ix, iy); + actor->floorz = actor->Sector->floorplane.ZatPoint(pos); actor->dropoffz = FLOAT2FIXED(actor->floorz); // killough 11/98: for tracking dropoffs - actor->ceilingz = actor->Sector->ceilingplane.ZatPoint (ix, iy); + actor->ceilingz = actor->Sector->ceilingplane.ZatPoint(pos); // The z-coordinate needs to be set once before calling P_FindFloorCeiling // For FLOATRANDZ just use the floor here. - if (iz == ONFLOORZ || iz == FLOATRANDZ) + if (pos.Z == ONFLOORZ || pos.Z == FLOATRANDZ) { actor->SetZ(actor->floorz); } - else if (iz == ONCEILINGZ) + else if (pos.Z == ONCEILINGZ) { actor->SetZ(actor->ceilingz - actor->Height); } @@ -4242,18 +4238,19 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_ actor->ceilingsector = actor->Sector; } - actor->SpawnPoint.X = ix; - actor->SpawnPoint.Y = iy; + actor->SpawnPoint.X = pos.X; + actor->SpawnPoint.Y = pos.Y; + // do not copy Z! - if (iz == ONFLOORZ) + if (pos.Z == ONFLOORZ) { actor->SetZ(actor->floorz); } - else if (iz == ONCEILINGZ) + else if (pos.Z == ONCEILINGZ) { actor->SetZ(actor->ceilingz - actor->Height); } - else if (iz == FLOATRANDZ) + else if (pos.Z == FLOATRANDZ) { double space = actor->ceilingz - actor->Height - actor->floorz; if (space > 48) @@ -4280,7 +4277,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_ { actor->Floorclip = 0; } - actor->UpdateWaterLevel (actor->_f_Z(), false); + actor->UpdateWaterLevel (actor->Z(), false); if (!SpawningMapThing) { actor->BeginPlay (); @@ -4311,20 +4308,10 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t _ix, fixed_t _iy, fixed_ return actor; } -AActor *Spawn (const char *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) +PClassActor *ClassForSpawn(FName classname) { - FName classname(type, true); - if (classname == NAME_None) - { - I_Error("Attempt to spawn actor of unknown type '%s'\n", type); - } - return Spawn(classname, x, y, z, allowreplacement); -} - -AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) -{ - const PClass *cls = PClass::FindClass(classname); - if (cls == NULL) + PClass *cls = PClass::FindClass(classname); + if (cls == NULL) { I_Error("Attempt to spawn actor of unknown type '%s'\n", classname.GetChars()); } @@ -4332,7 +4319,7 @@ AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allow { I_Error("Attempt to spawn non-actor of type '%s'\n", classname.GetChars()); } - return AActor::StaticSpawn (const_cast(static_cast(cls)), x, y, z, allowreplacement); + return static_cast(cls); } void AActor::LevelSpawned () @@ -4571,7 +4558,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) player_t *p; APlayerPawn *mobj, *oldactor; BYTE state; - fixed_t spawn_x, spawn_y, spawn_z; + DVector3 spawn; DAngle SpawnAngle; if (mthing == NULL) @@ -4627,16 +4614,13 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) ( NULL != p->attacker ) && // don't respawn on damaging floors ( p->mo->Sector->damageamount < TELEFRAG_DAMAGE )) // this really should be a bit smarter... { - spawn_x = p->mo->_f_X(); - spawn_y = p->mo->_f_Y(); - spawn_z = p->mo->_f_Z(); - + spawn = p->mo->Pos(); SpawnAngle = p->mo->Angles.Yaw; } else { - spawn_x = mthing->_f_X(); - spawn_y = mthing->_f_Y(); + spawn.X = mthing->pos.X; + spawn.Y = mthing->pos.Y; // Allow full angular precision SpawnAngle = (double)mthing->angle; @@ -4646,21 +4630,21 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) } if (GetDefaultByType(p->cls)->flags & MF_SPAWNCEILING) - spawn_z = ONCEILINGZ; + spawn.Z = ONCEILINGZ; else if (GetDefaultByType(p->cls)->flags2 & MF2_SPAWNFLOAT) - spawn_z = FLOATRANDZ; + spawn.Z = FLOATRANDZ; else - spawn_z = ONFLOORZ; + spawn.Z = ONFLOORZ; } mobj = static_cast - (Spawn (p->cls, spawn_x, spawn_y, spawn_z, NO_REPLACE)); + (Spawn (p->cls, spawn, NO_REPLACE)); if (level.flags & LEVEL_USEPLAYERSTARTZ) { - if (spawn_z == ONFLOORZ) + if (spawn.Z == ONFLOORZ) mobj->AddZ(mthing->pos.Z); - else if (spawn_z == ONCEILINGZ) + else if (spawn.Z == ONCEILINGZ) mobj->AddZ(-mthing->pos.Z); P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); } @@ -4781,7 +4765,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) if (multiplayer) { - Spawn ("TeleportFog", mobj->Vec3Angle(20, mobj->Angles.Yaw, TELEFOGHEIGHT), ALLOW_REPLACE); + Spawn ("TeleportFog", mobj->Vec3Angle(20., mobj->Angles.Yaw, TELEFOGHEIGHT), ALLOW_REPLACE); } // "Fix" for one of the starts on exec.wad MAP01: If you start inside the ceiling, @@ -5115,7 +5099,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) else z = ONFLOORZ; - mobj = AActor::StaticSpawn (i, x, y, z, NO_REPLACE, true); + mobj = AActor::StaticSpawn (i, DVector3(FIXED2DBL(mthing->x), FIXED2DBL(mthing->y), z), NO_REPLACE, true); if (z == ONFLOORZ) { @@ -5222,7 +5206,8 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y if (!(flags & PF_NORANDOMZ)) z += pr_spawnpuff.Random2 () << 10; - puff = Spawn (pufftype, x, y, z, ALLOW_REPLACE); + DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); + puff = Spawn (pufftype, pos, ALLOW_REPLACE); if (puff == NULL) return NULL; if ((puff->flags4 & MF4_RANDOMIZE) && puff->tics > 0) @@ -5296,6 +5281,7 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AActor *originator) { + DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); AActor *th; PalEntry bloodcolor = originator->GetBloodColor(); PClassActor *bloodcls = originator->GetBloodType(); @@ -5308,7 +5294,7 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc if (bloodcls != NULL) { z += pr_spawnblood.Random2 () << 10; - th = Spawn (bloodcls, x, y, z, NO_REPLACE); // GetBloodType already performed the replacement + th = Spawn (bloodcls, pos, NO_REPLACE); // GetBloodType already performed the replacement th->Vel.Z = 2; th->Angles.Yaw = ANGLE2DBL(dir); // [NG] Applying PUFFGETSOWNER to the blood will make it target the owner @@ -5389,8 +5375,9 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc // //--------------------------------------------------------------------------- -void P_BloodSplatter (fixedvec3 pos, AActor *originator) +void P_BloodSplatter (fixedvec3 _pos, AActor *originator) { + DVector3 pos(FIXED2DBL(_pos.x), FIXED2DBL(_pos.y), FIXED2DBL(_pos.z)); PalEntry bloodcolor = originator->GetBloodColor(); PClassActor *bloodcls = originator->GetBloodType(1); @@ -5419,7 +5406,7 @@ void P_BloodSplatter (fixedvec3 pos, AActor *originator) } if (bloodtype >= 1) { - P_DrawSplash2 (40, pos.x, pos.y, pos.z, 0u - originator->__f_AngleTo(pos), 2, bloodcolor); + //P_DrawSplash2 (40, pos.X, pos.Y, pos.Z, -originator->AngleTo(pos), 2, bloodcolor); } } @@ -5429,8 +5416,9 @@ void P_BloodSplatter (fixedvec3 pos, AActor *originator) // //=========================================================================== -void P_BloodSplatter2 (fixedvec3 pos, AActor *originator) +void P_BloodSplatter2 (fixedvec3 _pos, AActor *originator) { + DVector3 pos(FIXED2DBL(_pos.x), FIXED2DBL(_pos.y), FIXED2DBL(_pos.z)); PalEntry bloodcolor = originator->GetBloodColor(); PClassActor *bloodcls = originator->GetBloodType(2); @@ -5443,8 +5431,8 @@ void P_BloodSplatter2 (fixedvec3 pos, AActor *originator) { AActor *mo; - pos.x += ((pr_splat()-128)<<11); - pos.y += ((pr_splat()-128)<<11); + pos.X += (pr_splat()-128) / 32.; + pos.Y += (pr_splat()-128) / 32.; mo = Spawn (bloodcls, pos, NO_REPLACE); // GetBloodType already performed the replacement mo->target = originator; @@ -5459,7 +5447,7 @@ void P_BloodSplatter2 (fixedvec3 pos, AActor *originator) } if (bloodtype >= 1) { - P_DrawSplash2 (100, pos.x, pos.y, pos.z, 0u - originator->__f_AngleTo(pos), 2, bloodcolor); + //P_DrawSplash2 (100, pos.x, pos.y, pos.z, 0u - originator->__f_AngleTo(pos), 2, bloodcolor); } } @@ -5474,10 +5462,10 @@ void P_RipperBlood (AActor *mo, AActor *bleeder) PalEntry bloodcolor = bleeder->GetBloodColor(); PClassActor *bloodcls = bleeder->GetBloodType(); - fixed_t xo = (pr_ripperblood.Random2() << 12); - fixed_t yo = (pr_ripperblood.Random2() << 12); - fixed_t zo = (pr_ripperblood.Random2() << 12); - fixedvec3 pos = mo->Vec3Offset(xo, yo, zo); + double xo = pr_ripperblood.Random2() / 16.; + double yo = pr_ripperblood.Random2() / 16.; + double zo = pr_ripperblood.Random2() / 16.; + DVector3 pos = mo->Vec3Offset(xo, yo, zo); int bloodtype = cl_bloodtype; @@ -5506,7 +5494,7 @@ void P_RipperBlood (AActor *mo, AActor *bleeder) } if (bloodtype >= 1) { - P_DrawSplash2 (28, pos.x, pos.y, pos.z, 0, 0, bloodcolor); + //P_DrawSplash2 (28, pos.X, pos.Y, pos.Z, 0, 0, bloodcolor); } } @@ -5562,6 +5550,7 @@ bool P_HitWater (AActor * thing, sector_t * sec, fixed_t x, fixed_t y, fixed_t z if (z > compare_z) return false; } + DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); #if 0 // needs some rethinking before activation @@ -5633,14 +5622,14 @@ foundone: if (smallsplash && splash->SmallSplash) { - mo = Spawn (splash->SmallSplash, x, y, z, ALLOW_REPLACE); + mo = Spawn (splash->SmallSplash, pos, ALLOW_REPLACE); if (mo) mo->Floorclip += FIXED2DBL(splash->SmallSplashClip); } else { if (splash->SplashChunk) { - mo = Spawn (splash->SplashChunk, x, y, z, ALLOW_REPLACE); + mo = Spawn (splash->SplashChunk, pos, ALLOW_REPLACE); mo->target = thing; if (splash->ChunkXVelShift != 255) { @@ -5654,7 +5643,7 @@ foundone: } if (splash->SplashBase) { - mo = Spawn (splash->SplashBase, x, y, z, ALLOW_REPLACE); + mo = Spawn (splash->SplashBase, pos, ALLOW_REPLACE); } if (thing->player && !splash->NoAlert && alert) { @@ -5928,7 +5917,8 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, z -= source->_f_floorclip(); } - AActor *th = Spawn (type, x, y, z, ALLOW_REPLACE); + DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); + AActor *th = Spawn (type, pos, ALLOW_REPLACE); P_PlaySpawnSound(th, source); @@ -5988,7 +5978,7 @@ AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassAct { return NULL; } - AActor *th = Spawn (type, source->PosPlusZ(4*8*FRACUNIT), ALLOW_REPLACE); + AActor *th = Spawn (type, source->PosPlusZ(32.), ALLOW_REPLACE); P_PlaySpawnSound(th, source); th->target = owner; // record missile's originator @@ -6094,7 +6084,7 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, z -= source->_f_floorclip(); } - mo = Spawn (type, source->_f_X(), source->_f_Y(), z, ALLOW_REPLACE); + mo = Spawn (type, source->PosAtZ(FIXED2FLOAT(z)), ALLOW_REPLACE); P_PlaySpawnSound(mo, source); if (owner == NULL) owner = source; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 3c3bc91d9..08833a222 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3609,7 +3609,7 @@ void P_SetupLevel (const char *lumpname, int position) translationtables[TRANSLATION_LevelScripted].Clear(); // Initial height of PointOfView will be set by player think. - players[consoleplayer].viewz = -FLT_MAX; + players[consoleplayer].viewz = NO_VALUE; // Make sure all sounds are stopped before Z_FreeTags. S_Start (); diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 1f20af78a..5e97bff6d 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1036,22 +1036,19 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha, int linked lines[i].args[3] == 1) { // beware of overflows. - fixed_t x1 = fixed_t((SQWORD(line->v1->x) + SQWORD(line->v2->x)) >> 1); - fixed_t y1 = fixed_t((SQWORD(line->v1->y) + SQWORD(line->v2->y)) >> 1); - fixed_t x2 = fixed_t((SQWORD(lines[i].v1->x) + SQWORD(lines[i].v2->x)) >> 1); - fixed_t y2 = fixed_t((SQWORD(lines[i].v1->y) + SQWORD(lines[i].v2->y)) >> 1); - fixed_t z = linked ? line->frontsector->planes[plane].TexZ : 0; // the map's sector height defines the portal plane for linked portals + DVector3 pos1((line->v1->fX() + line->v2->fX()) / 2, (line->v1->fY() + line->v2->fY()) / 2, 0); + DVector3 pos2((lines[i].v1->fX() + lines[i].v2->fX()) / 2, (lines[i].v1->fY() + lines[i].v2->fY()) / 2, 0); + double z = linked ? line->frontsector->GetPlaneTexZF(plane) : 0; // the map's sector height defines the portal plane for linked portals fixed_t alpha = Scale (lines[i].args[4], OPAQUE, 255); - AStackPoint *anchor = Spawn(x1, y1, 0, NO_REPLACE); - AStackPoint *reference = Spawn(x2, y2, 0, NO_REPLACE); + AStackPoint *anchor = Spawn(pos1, NO_REPLACE); + AStackPoint *reference = Spawn(pos2, NO_REPLACE); reference->special1 = linked ? SKYBOX_LINKEDPORTAL : SKYBOX_PORTAL; anchor->special1 = SKYBOX_ANCHOR; // store the portal displacement in the unused scaleX/Y members of the portal reference actor. - anchor->Scale.X = -(reference->Scale.X = FIXED2DBL(x2 - x1)); - anchor->Scale.Y = -(reference->Scale.Y = FIXED2DBL(y2 - y1)); - anchor->specialf1 = reference->specialf1 = FIXED2FLOAT(z); + anchor->Scale = -(reference->Scale = pos2 - pos1); + anchor->specialf1 = reference->specialf1 = z; reference->Mate = anchor; anchor->Mate = reference; diff --git a/src/p_spec.h b/src/p_spec.h index 1148dfa6b..4b8643da1 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -924,19 +924,18 @@ enum TELF_KEEPHEIGHT = 16, }; -void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele = true, bool setTarget = false); //Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false). -inline void P_SpawnTeleportFog(AActor *mobj, const fixedvec3 &pos, bool beforeTele = true, bool setTarget = false) -{ - P_SpawnTeleportFog(mobj, pos.x, pos.y, pos.z, beforeTele, setTarget); -} -inline void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false) -{ - P_SpawnTeleportFog(mobj, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), beforeTele, setTarget); -} -inline void P_SpawnTeleportFog(AActor *mobj, double x, double y, double z, bool beforeTele = true, bool setTarget = false) +//Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false). +void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false); + +void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele = true, bool setTarget = false) = delete; +inline void P_SpawnTeleportFog(AActor *mobj, const fixedvec3 &pos, bool beforeTele = true, bool setTarget = false) = delete; +inline void P_SpawnTeleportFog(AActor *mobj, double x, double y, double z, bool beforeTele = true, bool setTarget = false) = delete; +/* { P_SpawnTeleportFog(mobj, FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), beforeTele, setTarget); } +*/ + 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 inline bool P_Teleport(AActor *thing, const DVector3 &pos, DAngle angle, int flags) { diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 577438c20..4340d13d5 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -78,7 +78,7 @@ void ATeleportFog::PostBeginPlay () // //========================================================================== -void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele, bool setTarget) +void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele, bool setTarget) { AActor *mo; if ((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType) == NULL) @@ -88,7 +88,7 @@ void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool befo } else { - mo = Spawn((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType), x, y, z, ALLOW_REPLACE); + mo = Spawn((beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType), pos, ALLOW_REPLACE); } if (mo != NULL && setTarget) @@ -103,7 +103,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i { bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING)); - fixedvec3 old; + DVector3 old; fixed_t aboveFloor; player_t *player; sector_t *destsect; @@ -111,7 +111,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i fixed_t floorheight, ceilingheight; double missilespeed = 0; - old = thing->_f_Pos(); + old = thing->Pos(); aboveFloor = thing->_f_Z() - thing->_f_floorz(); destsect = P_PointInSector (x, y); // killough 5/12/98: exclude voodoo dolls: @@ -194,7 +194,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i double fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; DVector2 vector = angle.ToVector(20); DVector2 fogpos = P_GetOffsetPosition(FIXED2DBL(x), FIXED2DBL(y), vector.X, vector.Y); - P_SpawnTeleportFog(thing, fogpos.X, fogpos.Y, thing->Z() + fogDelta, false, true); + P_SpawnTeleportFog(thing, DVector3(fogpos, thing->Z() + fogDelta), false, true); } if (thing->player) diff --git a/src/p_things.cpp b/src/p_things.cpp index 032ae9075..470282f60 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -125,19 +125,16 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog) { - fixed_t oldx, oldy, oldz; + DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); + DVector3 old = source->Pos(); - oldx = source->_f_X(); - oldy = source->_f_Y(); - oldz = source->_f_Z(); - - source->SetOrigin (x, y, z, true); + source->SetOrigin (pos, true); if (P_TestMobjLocation (source)) { if (fog) { - P_SpawnTeleportFog(source, x, y, z, false, true); - P_SpawnTeleportFog(source, oldx, oldy, oldz, true, true); + P_SpawnTeleportFog(source, pos, false, true); + P_SpawnTeleportFog(source, old, true, true); } source->ClearInterpolation(); if (source == players[consoleplayer].camera) @@ -148,7 +145,7 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog) } else { - source->SetOrigin (oldx, oldy, oldz, true); + source->SetOrigin (old, true); return false; } } @@ -221,7 +218,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam { do { - fixed_t z = spot->_f_Z(); + double z = spot->Z(); if (defflags3 & MF3_FLOORHUGGER) { z = ONFLOORZ; @@ -232,9 +229,9 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam } else if (z != ONFLOORZ) { - z -= spot->_f_floorclip(); + z -= spot->Floorclip; } - mobj = Spawn (kind, spot->_f_X(), spot->_f_Y(), z, ALLOW_REPLACE); + mobj = Spawn (kind, spot->PosAtZ(z), ALLOW_REPLACE); if (mobj) { diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 9aa48c147..032aa8bf5 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -57,7 +57,7 @@ bool P_CheckTickerPaused () ConsoleState == c_down || ConsoleState == c_falling) && !demoplayback && !demorecording - && players[consoleplayer].viewz != -FLT_MAX + && players[consoleplayer].viewz != NO_VALUE && wipegamestate == gamestate) { S_PauseSound (!(level.flags2 & LEVEL2_PAUSE_MUSIC_IN_MENUS), false); diff --git a/src/p_user.cpp b/src/p_user.cpp index 8a27c3ecb..1eee21935 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1650,7 +1650,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop) } self->flags &= ~MF_SOLID; - mo = (APlayerPawn *)Spawn (spawntype, self->PosPlusZ(48*FRACUNIT), NO_REPLACE); + mo = (APlayerPawn *)Spawn (spawntype, self->PosPlusZ(48.), NO_REPLACE); //mo->target = self; mo->Vel.X = pr_skullpop.Random2() / 128.; mo->Vel.Y = pr_skullpop.Random2() / 128.; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 100773e06..76d8e4956 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -2638,7 +2638,7 @@ CCMD (loopsound) } else { - AActor *icon = Spawn("SpeakerIcon", players[consoleplayer].mo->PosPlusZ(32*FRACUNIT), ALLOW_REPLACE); + AActor *icon = Spawn("SpeakerIcon", players[consoleplayer].mo->PosPlusZ(32.), ALLOW_REPLACE); if (icon != NULL) { S_Sound(icon, CHAN_BODY | CHAN_LOOP, id, 1.f, ATTN_IDLE); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 06be8952b..bebfce769 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -616,7 +616,7 @@ static void DoAttack (AActor *self, bool domelee, bool domissile, // This seemingly senseless code is needed for proper aiming. double add = MissileHeight + FIXED2FLOAT(self->GetBobOffset()) - 32; self->AddZ(add); - AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32*FRACUNIT), self, self->target, MissileType, false); + AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32.), self, self->target, MissileType, false); self->AddZ(-add); if (missile) @@ -1227,7 +1227,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) default: // same adjustment as above (in all 3 directions this time) - for better aiming! self->SetXYZ(self->Vec3Offset(x, y, z)); - missile = P_SpawnMissileXYZ(self->PosPlusZ(32*FRACUNIT), self, ref, ti, false); + missile = P_SpawnMissileXYZ(self->PosPlusZ(32.), self, ref, ti, false); self->SetXYZ(pos); break; @@ -1467,7 +1467,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) { // This seemingly senseless code is needed for proper aiming. self->_f_AddZ(spawnheight + self->GetBobOffset() - 32*FRACUNIT); - AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32*FRACUNIT), self, self->target, ti, false); + AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32.), self, self->target, ti, false); self->_f_AddZ(-(spawnheight + self->GetBobOffset() - 32*FRACUNIT)); if (missile) @@ -2378,7 +2378,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) PARAM_ACTION_PROLOGUE; PARAM_CLASS_OPT (missile, AActor) { missile = PClass::FindActor("Unknown"); } PARAM_FIXED_OPT (distance) { distance = 0; } - PARAM_FIXED_OPT (zheight) { zheight = 0; } + PARAM_FLOAT_OPT (zheight) { zheight = 0; } PARAM_BOOL_OPT (useammo) { useammo = true; } PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; } @@ -2414,7 +2414,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem) } } - AActor *mo = Spawn( missile, self->_f_Vec3Angle(distance, self->_f_angle(), -self->_f_floorclip() + self->GetBobOffset() + zheight), ALLOW_REPLACE); + AActor *mo = Spawn( missile, self->Vec3Angle(distance, self->Angles.Yaw, -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 @@ -2431,9 +2431,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) { PARAM_ACTION_PROLOGUE; PARAM_CLASS (missile, AActor); - PARAM_FIXED_OPT (xofs) { xofs = 0; } - PARAM_FIXED_OPT (yofs) { yofs = 0; } - PARAM_FIXED_OPT (zofs) { zofs = 0; } + PARAM_FLOAT_OPT (xofs) { xofs = 0; } + PARAM_FLOAT_OPT (yofs) { yofs = 0; } + PARAM_FLOAT_OPT (zofs) { zofs = 0; } PARAM_FLOAT_OPT (xvel) { xvel = 0; } PARAM_FLOAT_OPT (yvel) { yvel = 0; } PARAM_FLOAT_OPT (zvel) { zvel = 0; } @@ -2456,7 +2456,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) ACTION_RETURN_BOOL(true); } - fixedvec2 pos; + DVector2 pos; if (!(flags & SIXF_ABSOLUTEANGLE)) { @@ -2473,7 +2473,7 @@ 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(fixed_t(xofs * c + yofs * s), fixed_t(xofs * s - yofs*c)); + pos = self->Vec2Offset(xofs * c + yofs * s, xofs * s - yofs*c); } if (!(flags & SIXF_ABSOLUTEVELOCITY)) @@ -2484,7 +2484,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx) xvel = newxvel; } - AActor *mo = Spawn(missile, pos.x, pos.y, self->_f_Z() - self->_f_floorclip() + self->GetBobOffset() + zofs, ALLOW_REPLACE); + AActor *mo = Spawn(missile, DVector3(pos, self->Z() - self->Floorclip + self->GetBobOffset() + zofs), ALLOW_REPLACE); bool res = InitSpawnedItem(self, mo, flags); if (res) { @@ -2542,7 +2542,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade) AActor *bo; bo = Spawn(missile, - self->PosPlusZ(-self->_f_floorclip() + self->GetBobOffset() + zheight + 35*FRACUNIT + (self->player? FLOAT2FIXED(self->player->crouchoffset) : 0)), + self->PosPlusZ(-self->Floorclip + self->GetBobOffset() + zheight + 35 + (self->player? self->player->crouchoffset : 0.)), ALLOW_REPLACE); if (bo) { @@ -2936,9 +2936,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) for (i = 0; i < GetDefaultByType(debris)->health; i++) { - fixed_t xo = ((pr_spawndebris() - 128) << 12); - fixed_t yo = ((pr_spawndebris() - 128) << 12); - fixed_t zo = (pr_spawndebris()*self->_f_height() / 256 + self->GetBobOffset()); + double xo = (pr_spawndebris() - 128) / 16.; + double yo = (pr_spawndebris() - 128) / 16.; + double zo = pr_spawndebris()*self->Height / 256 + self->GetBobOffset(); mo = Spawn(debris, self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { @@ -3435,7 +3435,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) PARAM_INT_OPT(flags) { flags = RSF_FOG; } bool oktorespawn = false; - fixedvec3 pos = self->_f_Pos(); + DVector3 pos = self->Pos(); self->flags |= MF_SOLID; self->Height = self->GetDefault()->Height; @@ -3445,11 +3445,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) if (flags & RSF_TELEFRAG) { // [KS] DIE DIE DIE DIE erm *ahem* =) - oktorespawn = P_TeleportMove(self, self->_f_Pos(), true, false); + oktorespawn = P_TeleportMove(self, self->Pos(), true, false); } else { - oktorespawn = P_CheckPosition(self, self->_f_X(), self->_f_Y(), true); + oktorespawn = P_CheckPosition(self, self->Pos(), true); } if (oktorespawn) @@ -3487,7 +3487,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) if (flags & RSF_FOG) { P_SpawnTeleportFog(self, pos, true, true); - P_SpawnTeleportFog(self, self->_f_Pos(), false, true); + P_SpawnTeleportFog(self, self->Pos(), false, true); } if (self->CountsAsKill()) { From f60eac8dc09d0bbf207674606e6bc4cb8b44b1cd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 23 Mar 2016 12:21:52 +0100 Subject: [PATCH 03/12] - floatified FMapThing, dropoffz and GetBobOffset --- src/actor.h | 21 ++++++++-- src/b_move.cpp | 2 +- src/compatibility.cpp | 4 +- src/doomdata.h | 6 +-- src/edata.cpp | 6 +-- src/p_acs.cpp | 18 ++++----- src/p_buildmap.cpp | 10 ++--- src/p_checkposition.h | 6 ++- src/p_enemy.cpp | 47 +++++++++++----------- src/p_map.cpp | 44 ++++++++++---------- src/p_mobj.cpp | 60 +++++++++++++--------------- src/p_setup.cpp | 18 ++++----- src/p_slopes.cpp | 50 +++++++++++------------ src/p_things.cpp | 2 +- src/p_udmf.cpp | 6 +-- src/r_defs.h | 5 +++ src/r_things.cpp | 2 +- src/thingdef/thingdef_codeptr.cpp | 29 +++++++------- src/thingdef/thingdef_properties.cpp | 2 +- wadsrc/static/actors/actor.txt | 2 +- 20 files changed, 177 insertions(+), 163 deletions(-) diff --git a/src/actor.h b/src/actor.h index 6c283b03c..c37adf5e7 100644 --- a/src/actor.h +++ b/src/actor.h @@ -742,7 +742,18 @@ public: // What species am I? virtual FName GetSpecies(); - fixed_t GetBobOffset(fixed_t ticfrac=0) const + double GetBobOffset(fixed_t ticfrac = 0) const + { + if (!(flags2 & MF2_FLOATBOB)) + { + return 0; + } + return BobSin(FloatBobPhase + level.maptime + FIXED2FLOAT(ticfrac)); + } + + + + fixed_t _f_GetBobOffset(fixed_t ticfrac=0) const { if (!(flags2 & MF2_FLOATBOB)) { @@ -1123,6 +1134,7 @@ public: struct sector_t *Sector; subsector_t * subsector; double floorz, ceilingz; // closest together of contacted secs + double dropoffz; // killough 11/98: the lowest floor over all contacted Sectors. inline fixed_t _f_ceilingz() { @@ -1132,8 +1144,11 @@ public: { return FLOAT2FIXED(floorz); } + inline fixed_t _f_dropoffz() + { + return FLOAT2FIXED(dropoffz); + } - fixed_t dropoffz; // killough 11/98: the lowest floor over all contacted Sectors. struct sector_t *floorsector; FTextureID floorpic; // contacted sec floorpic @@ -1275,7 +1290,7 @@ public: FSoundIDNoInit WallBounceSound; FSoundIDNoInit CrushPainSound; - fixed_t MaxDropOffHeight; + double MaxDropOffHeight; double MaxStepHeight; fixed_t _f_MaxStepHeight() diff --git a/src/b_move.cpp b/src/b_move.cpp index f5eba7ea7..a879ef3d2 100644 --- a/src/b_move.cpp +++ b/src/b_move.cpp @@ -297,7 +297,7 @@ bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm if ( !(thing->flags&(MF_DROPOFF|MF_FLOAT)) - && tm._f_floorz() - tm.dropoffz > thing->MaxDropOffHeight ) + && tm.floorz - tm.dropoffz > thing->MaxDropOffHeight ) return false; // don't stand over a dropoff } diff --git a/src/compatibility.cpp b/src/compatibility.cpp index a440ac088..8157506fd 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -312,7 +312,7 @@ void ParseCompatibility() sc.MustGetNumber(); CompatParams.Push(sc.Number); sc.MustGetFloat(); - CompatParams.Push(FLOAT2FIXED(sc.Float)); + CompatParams.Push(int(sc.Float*256)); // do not use full fixed here so that it can eventually handle larger levels } else if (sc.Compare("setsectortag")) { @@ -545,7 +545,7 @@ void SetCompatibilityParams() // When this is called, the things haven't been spawned yet so we can alter the position inside the MapThings array. if ((unsigned)CompatParams[i+1] < MapThingsConverted.Size()) { - MapThingsConverted[CompatParams[i+1]].z = CompatParams[i+2]; + MapThingsConverted[CompatParams[i+1]].pos.Z = CompatParams[i+2]/256.; } i += 3; break; diff --git a/src/doomdata.h b/src/doomdata.h index dc70d0ccf..9c86e4f3c 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -346,9 +346,7 @@ struct FDoomEdEntry; struct FMapThing { int thingid; - fixed_t x; - fixed_t y; - fixed_t z; + DVector3 pos; short angle; WORD SkillFilter; WORD ClassFilter; @@ -433,7 +431,7 @@ struct FPlayerStart FPlayerStart() { } FPlayerStart(const FMapThing *mthing, int pnum) - : pos(FIXED2DBL(mthing->x), FIXED2DBL(mthing->y), FIXED2DBL(mthing->z)), + : pos(mthing->pos), angle(mthing->angle), type(pnum) { } diff --git a/src/edata.cpp b/src/edata.cpp index 746528575..8176e6a98 100644 --- a/src/edata.cpp +++ b/src/edata.cpp @@ -92,7 +92,7 @@ struct EDMapthing int recordnum; int tid; int type; - fixed_t height; + double height; int args[5]; WORD skillfilter; DWORD flags; @@ -585,7 +585,7 @@ static void parseMapthing(FScanner &sc) { sc.CheckString("="); sc.MustGetFloat(); // no idea if Eternity allows fractional numbers. Better be safe and do it anyway. - mt.height = FLOAT2FIXED(sc.Float); + mt.height = sc.Float; } else if (sc.Compare("options")) { @@ -682,7 +682,7 @@ void ProcessEDMapthing(FMapThing *mt, int recordnum) mt->thingid = emt->tid; mt->EdNum = emt->type; mt->info = DoomEdMap.CheckKey(mt->EdNum); - mt->z = emt->height; + mt->pos.Z = emt->height; memcpy(mt->args, emt->args, sizeof(mt->args)); mt->SkillFilter = emt->skillfilter; mt->flags = emt->flags; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 8a302c1d7..3d9f2ba7b 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4768,15 +4768,15 @@ static int SetCVar(AActor *activator, const char *cvarname, int value, bool is_s return 1; } -static bool DoSpawnDecal(AActor *actor, const FDecalTemplate *tpl, int flags, angle_t angle, fixed_t zofs, fixed_t distance) +static bool DoSpawnDecal(AActor *actor, const FDecalTemplate *tpl, int flags, DAngle angle, double zofs, double distance) { if (!(flags & SDF_ABSANGLE)) { - angle += actor->_f_angle(); + angle += actor->Angles.Yaw; } return NULL != ShootDecal(tpl, actor, actor->Sector, actor->X(), actor->Y(), - actor->Center() - actor->Floorclip + actor->GetBobOffset() + FIXED2DBL(zofs), - DAngle(ANGLE2DBL(angle)), FIXED2DBL(distance), !!(flags & SDF_PERMANENT)); + actor->Center() - actor->Floorclip + actor->GetBobOffset() + zofs, + angle, distance, !!(flags & SDF_PERMANENT)); } static void SetActorAngle(AActor *activator, int tid, int angle, bool interpolate) @@ -5674,9 +5674,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) if (tpl != NULL) { int flags = (argCount > 2) ? args[2] : 0; - angle_t angle = (argCount > 3) ? (args[3] << FRACBITS) : 0; - fixed_t zoffset = (argCount > 4) ? (args[4] << FRACBITS) : 0; - fixed_t distance = (argCount > 5) ? (args[5] << FRACBITS) : 64*FRACUNIT; + DAngle angle = ACSToAngle((argCount > 3) ? args[3] : 0); + int zoffset = (argCount > 4) ? args[4]: 0; + int distance = (argCount > 5) ? args[5] : 64; if (args[0] == 0) { @@ -8702,11 +8702,11 @@ scriptwait: } else if (pcd == PCD_GETACTORZ) { - STACK(1) = actor->_f_Z() + actor->GetBobOffset(); + STACK(1) = DoubleToACS(actor->Z() + actor->GetBobOffset()); } else { - STACK(1) = pcd == PCD_GETACTORX ? actor->_f_X() : pcd == PCD_GETACTORY ? actor->_f_Y() : actor->_f_Z(); + STACK(1) = DoubleToACS(pcd == PCD_GETACTORX ? actor->X() : pcd == PCD_GETACTORY ? actor->Y() : actor->Z()); } } break; diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 25691aa3e..b676c8398 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -697,9 +697,9 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, for (int i = 0; i < numsprites; ++i) { mapthings[count].thingid = 0; - mapthings[count].x = (sprites[i].x << 12); - mapthings[count].y = -(sprites[i].y << 12); - mapthings[count].z = (bsectors[sprites[i].sectnum].floorZ - sprites[i].z) << 8; + mapthings[count].pos.X = sprites[i].x / 16.; + mapthings[count].pos.Y = -sprites[i].y / 16.; + mapthings[count].pos.Z = (bsectors[sprites[i].sectnum].floorZ - sprites[i].z) / 256.; mapthings[count].angle = (((2048-sprites[i].ang) & 2047) * 360) >> 11; mapthings[count].ClassFilter = 0xffff; mapthings[count].SkillFilter = 0xffff; @@ -786,8 +786,8 @@ static void CreateStartSpot (fixed_t *pos, FMapThing *start) short angle = LittleShort(*(WORD *)(&pos[3])); FMapThing mt = { 0, }; - mt.x = LittleLong(pos[0])<<12; - mt.y = (-LittleLong(pos[1]))<<12; + mt.pos.X = LittleLong(pos[0]) / 16.; + mt.pos.Y = -LittleLong(pos[1]) / 16.; mt.angle = short(Scale((2048-angle)&2047, 360, 2048)); mt.info = DoomEdMap.CheckKey(1); mt.EdNum = 1; diff --git a/src/p_checkposition.h b/src/p_checkposition.h index 0950efd66..713bc79b7 100644 --- a/src/p_checkposition.h +++ b/src/p_checkposition.h @@ -21,7 +21,7 @@ struct FCheckPosition sector_t *sector; double floorz; double ceilingz; - fixed_t dropoffz; + double dropoffz; FTextureID floorpic; int floorterrain; sector_t *floorsector; @@ -55,6 +55,10 @@ struct FCheckPosition { return FLOAT2FIXED(floorz); } + inline fixed_t _f_dropoffz() + { + return FLOAT2FIXED(dropoffz); + } }; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 77808344b..a75aa891b 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -879,7 +879,7 @@ void P_NewChaseDir(AActor * actor) } // Try to move away from a dropoff - if (actor->_f_floorz() - actor->dropoffz > actor->MaxDropOffHeight && + if (actor->floorz - actor->dropoffz > actor->MaxDropOffHeight && actor->Z() <= actor->floorz && !(actor->flags & MF_DROPOFF) && !(actor->flags2 & MF2_ONMOBJ) && !(actor->flags & MF_FLOAT) && !(i_compatflags & COMPATF_DROPOFF)) @@ -888,8 +888,8 @@ void P_NewChaseDir(AActor * actor) FBlockLinesIterator it(box); line_t *line; - fixed_t deltax = 0; - fixed_t deltay = 0; + double deltax = 0; + double deltay = 0; while ((line = it.Next())) { if (line->backsector && // Ignore one-sided linedefs @@ -899,31 +899,31 @@ void P_NewChaseDir(AActor * actor) box.Bottom() < line->bbox[BOXTOP] && box.BoxOnLineSide(line) == -1) { - fixed_t front = line->frontsector->floorplane.ZatPoint(actor->PosRelative(line)); - fixed_t back = line->backsector->floorplane.ZatPoint(actor->PosRelative(line)); - angle_t angle; + double front = line->frontsector->floorplane.ZatPointF(actor->PosRelative(line)); + double back = line->backsector->floorplane.ZatPointF(actor->PosRelative(line)); + DAngle angle; // The monster must contact one of the two floors, // and the other must be a tall dropoff. - if (back == actor->_f_Z() && front < actor->_f_Z() - actor->MaxDropOffHeight) + if (back == actor->Z() && front < actor->Z() - actor->MaxDropOffHeight) { - angle = R_PointToAngle2(0,0,line->dx,line->dy); // front side dropoff + angle = line->Delta().Angle(); // front side dropoff } - else if (front == actor->_f_Z() && back < actor->_f_Z() - actor->MaxDropOffHeight) + else if (front == actor->Z() && back < actor->Z() - actor->MaxDropOffHeight) { - angle = R_PointToAngle2(line->dx,line->dy,0,0); // back side dropoff + angle = line->Delta().Angle() + 180.; // back side dropoff } else continue; // Move away from dropoff at a standard speed. // Multiple contacted linedefs are cumulative (e.g. hanging over corner) - deltax -= finesine[angle >> ANGLETOFINESHIFT]*32; - deltay += finecosine[angle >> ANGLETOFINESHIFT]*32; + deltax -= 32 * angle.Sin(); + deltay += 32 * angle.Cos(); } } - if (deltax || deltay) + if (deltax != 0 || deltay != 0) { // [Graf Zahl] I have changed P_TryMove to only apply this logic when // being called from here. AVOIDINGDROPOFF activates the code that @@ -933,7 +933,7 @@ void P_NewChaseDir(AActor * actor) // use different dropoff movement logic in P_TryMove actor->flags5|=MF5_AVOIDINGDROPOFF; - P_DoNewChaseDir(actor, deltax, deltay); + P_DoNewChaseDir(actor, FLOAT2FIXED(deltax), FLOAT2FIXED(deltay)); actor->flags5&=~MF5_AVOIDINGDROPOFF; // If moving away from dropoff, set movecount to 1 so that @@ -2861,30 +2861,29 @@ void A_Face (AActor *self, AActor *other, angle_t _max_turn, angle_t _max_pitch, // disabled and is so by default. if (max_pitch <= 180.) { - fixedvec2 pos = self->_f_Vec2To(other); - DVector2 dist(pos.x, pos.y); + DVector2 dist = self->Vec2To(other); // Positioning ala missile spawning, 32 units above foot level - fixed_t source_z = self->_f_Z() + 32*FRACUNIT + self->GetBobOffset(); - fixed_t target_z = other->_f_Z() + 32*FRACUNIT + other->GetBobOffset(); + double source_z = self->Z() + 32 + self->GetBobOffset(); + double target_z = other->Z() + 32 + other->GetBobOffset(); // If the target z is above the target's head, reposition to the middle of // its body. - if (target_z >= other->_f_Top()) + if (target_z >= other->Top()) { - target_z = other->_f_Z() + (other->_f_height() / 2); + target_z = other->Center(); } //Note there is no +32*FRACUNIT on purpose. This is for customization sake. //If one doesn't want this behavior, just don't use FAF_BOTTOM. if (flags & FAF_BOTTOM) - target_z = other->_f_Z() + other->GetBobOffset(); + target_z = other->Z() + other->GetBobOffset(); if (flags & FAF_MIDDLE) - target_z = other->_f_Z() + (other->_f_height() / 2) + other->GetBobOffset(); + target_z = other->Center() + other->GetBobOffset(); if (flags & FAF_TOP) - target_z = other->_f_Z() + (other->_f_height()) + other->GetBobOffset(); + target_z = other->Top() + other->GetBobOffset(); - target_z += z_add; + target_z += FIXED2FLOAT(z_add); double dist_z = target_z - source_z; double ddist = g_sqrt(dist.X*dist.X + dist.Y*dist.Y + dist_z*dist_z); diff --git a/src/p_map.cpp b/src/p_map.cpp index 0bd03b868..851cc45f5 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -260,7 +260,7 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines tmf.touchmidtex = open.touchmidtex; tmf.abovemidtex = open.abovemidtex; if (ffcf_verbose) Printf(" Adjust floorz to %f\n", FIXED2FLOAT(open.bottom)); - if (tmf._f_floorz() > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown(); + if (tmf.floorz > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown(); } else if (open.bottom == tmf._f_floorz()) { @@ -268,11 +268,11 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines tmf.abovemidtex |= open.abovemidtex; } - if (open.lowfloor < tmf.dropoffz && open.lowfloor > FIXED_MIN) + if (open.lowfloor < tmf._f_dropoffz() && open.lowfloor > FIXED_MIN) { - tmf.dropoffz = open.lowfloor; + tmf.dropoffz = FIXED2DBL(open.lowfloor); if (ffcf_verbose) Printf(" Adjust dropoffz to %f\n", FIXED2FLOAT(open.bottom)); - if (tmf._f_floorz() > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown(); + if (tmf.floorz > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown(); } } return true; @@ -292,8 +292,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) F3DFloor *ffc, *fff; tmf.ceilingz = FIXED2DBL(sec->NextHighestCeilingAt(tmf.x, tmf.y, tmf.z, tmf.z + tmf.thing->_f_height(), flags, &tmf.ceilingsector, &ffc)); - tmf.dropoffz = sec->NextLowestFloorAt(tmf.x, tmf.y, tmf.z, flags, tmf.thing->_f_MaxStepHeight(), &tmf.floorsector, &fff); - tmf.floorz = FIXED2DBL(tmf.dropoffz); + tmf.floorz = tmf.dropoffz = FIXED2DBL(sec->NextLowestFloorAt(tmf.x, tmf.y, tmf.z, flags, tmf.thing->_f_MaxStepHeight(), &tmf.floorsector, &fff)); if (fff) { @@ -364,7 +363,7 @@ void P_FindFloorCeiling(AActor *actor, int flags) PIT_FindFloorCeiling(mit, cres, mit.Box(), tmf, flags|cres.portalflags); } - if (tmf.touchmidtex) tmf.dropoffz = tmf._f_floorz(); + if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; bool usetmf = !(flags & FFCF_ONLYSPAWNPOS) || (tmf.abovemidtex && (tmf.floorz <= actor->Z())); @@ -445,7 +444,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra } thing->_f_SetZ(savedz); - if (tmf.touchmidtex) tmf.dropoffz = tmf._f_floorz(); + if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; FMultiBlockThingsIterator mit2(grouplist, x, y, z, thing->_f_height(), thing->_f_radius(), false, sector); FMultiBlockThingsIterator::CheckResult cres2; @@ -965,9 +964,9 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec tm.abovemidtex |= open.abovemidtex; } - if (open.lowfloor < tm.dropoffz) + if (open.lowfloor < tm._f_dropoffz()) { - tm.dropoffz = open.lowfloor; + tm.dropoffz = FIXED2FLOAT(open.lowfloor); } } @@ -1084,8 +1083,8 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera ret = true; } - if (open.lowfloor - zofs < tm.dropoffz) - tm.dropoffz = open.lowfloor - zofs; + if (open.lowfloor - zofs < tm._f_dropoffz()) + tm.dropoffz = FIXED2FLOAT(open.lowfloor - zofs); } tm.thing->_f_AddZ(-zofs); lp->backsector = sec; @@ -1224,7 +1223,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // [RH] Let monsters walk on actors as well as floors if ((tm.thing->flags3 & MF3_ISMONSTER) && - topz >= tm._f_floorz() && topz <= tm.thing->_f_Z() + tm.thing->_f_MaxStepHeight()) + topz >= tm.floorz && topz <= tm.thing->Z() + tm.thing->MaxStepHeight) { // The commented-out if is an attempt to prevent monsters from walking off a // thing further than they would walk off a ledge. I can't think of an easy @@ -1625,8 +1624,7 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo else { // With noclip2, we must ignore 3D floors and go right to the uppermost ceiling and lowermost floor. - tm.dropoffz = newsec->_f_LowestFloorAt(x, y, &tm.floorsector); - tm.floorz = FIXED2DBL(tm.dropoffz); + tm.floorz = tm.dropoffz = FIXED2FLOAT(newsec->_f_LowestFloorAt(x, y, &tm.floorsector)); tm.ceilingz = FIXED2DBL(newsec->_f_HighestCeilingAt(x, y, &tm.ceilingsector)); tm.floorpic = tm.floorsector->GetTexture(sector_t::floor); tm.floorterrain = tm.floorsector->GetTerrain(sector_t::floor); @@ -1727,7 +1725,7 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo fixed_t thingdropoffz = tm._f_floorz(); //bool onthing = (thingdropoffz != tmdropoffz); - tm.floorz = FIXED2DBL(tm.dropoffz); + tm.floorz = tm.dropoffz; bool good = true; @@ -1760,11 +1758,11 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo } if (tm.touchmidtex) { - tm.dropoffz = tm._f_floorz(); + tm.dropoffz = tm.floorz; } else if (tm.stepthing != NULL) { - tm.dropoffz = thingdropoffz; + tm.dropoffz = FIXED2FLOAT(thingdropoffz); } return (thing->BlockingMobj = thingblocker) == NULL; @@ -2111,7 +2109,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, thing->Vel.Z = -8; goto pushline; } - else if (thing->Z() < tm.floorz && tm._f_floorz() - tm.dropoffz > thing->MaxDropOffHeight) + else if (thing->Z() < tm.floorz && tm.floorz - tm.dropoffz > thing->MaxDropOffHeight) { thing->Vel.Z = 8; goto pushline; @@ -2167,7 +2165,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } if (dropoff == 2 && // large jump down (e.g. dogs) - (tm._f_floorz() - tm.dropoffz > 128 * FRACUNIT || thing->target == NULL || thing->target->_f_Z() >tm.dropoffz)) + (tm.floorz - tm.dropoffz > 128. || thing->target == NULL || thing->target->Z() >tm.dropoffz)) { dropoff = false; } @@ -2186,7 +2184,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, floorz = MAX(thing->Z(), tm.floorz); } - if (FLOAT2FIXED(floorz) - tm.dropoffz > thing->MaxDropOffHeight && + if (floorz - tm.dropoffz > thing->MaxDropOffHeight && !(thing->flags2 & MF2_BLASTED) && !missileCheck) { // Can't move over a dropoff unless it's been blasted // [GZ] Or missile-spawned @@ -2199,7 +2197,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { // special logic to move a monster off a dropoff // this intentionally does not check for standing on things. - if (thing->_f_floorz() - tm._f_floorz() > thing->MaxDropOffHeight || + if (thing->floorz - tm.floorz > thing->MaxDropOffHeight || thing->dropoffz - tm.dropoffz > thing->MaxDropOffHeight) { thing->flags6 &= ~MF6_INTRYMOVE; @@ -3105,7 +3103,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov pos.x += xmove; pos.y += ymove; - if (sec->floorplane.ZatPoint(pos) >= actor->_f_Z() - actor->_f_MaxStepHeight()) + if (sec->floorplane.ZatPointF(pos) >= actor->Z() - actor->MaxStepHeight) { dopush = false; break; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 6cdfbb640..9f894f0f0 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -369,7 +369,7 @@ void AActor::Serialize(FArchive &arc) << SeeState << MeleeState << MissileState - << MaxDropOffHeight + << MaxDropOffHeight << MaxStepHeight << BounceFlags << bouncefactor @@ -2208,13 +2208,13 @@ explode: // killough 8/11/98: add bouncers // killough 9/15/98: add objects falling off ledges // killough 11/98: only include bouncers hanging off ledges - if ((mo->flags & MF_CORPSE) || (mo->BounceFlags & BOUNCE_MBF && mo->_f_Z() > mo->dropoffz) || (mo->flags6 & MF6_FALLING)) + if ((mo->flags & MF_CORPSE) || (mo->BounceFlags & BOUNCE_MBF && mo->Z() > mo->dropoffz) || (mo->flags6 & MF6_FALLING)) { // Don't stop sliding if halfway off a step with some velocity - if (mo->_f_velx() > FRACUNIT/4 || mo->_f_velx() < -FRACUNIT/4 || mo->_f_vely() > FRACUNIT/4 || mo->_f_vely() < -FRACUNIT/4) + if (fabs(mo->Vel.X) > 0.25 || fabs(mo->Vel.Y) > 0.25) { - if (mo->_f_floorz() > mo->Sector->floorplane.ZatPoint(mo)) + if (mo->floorz > mo->Sector->floorplane.ZatPointF(mo)) { - if (mo->dropoffz != mo->_f_floorz()) // 3DMidtex or other special cases that must be excluded + if (mo->dropoffz != mo->floorz) // 3DMidtex or other special cases that must be excluded { unsigned i; for(i=0;iSector->e->XFloor.ffloors.Size();i++) @@ -3743,7 +3743,7 @@ void AActor::Tick () const sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - if (floorplane.ZatPoint (PosRelative(node->m_sector)) >= _f_Z() - _f_MaxStepHeight()) + if (floorplane.ZatPointF (PosRelative(node->m_sector)) >= Z() - MaxStepHeight) { dopush = false; break; @@ -4192,8 +4192,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a actor->LinkToWorld (SpawningMapThing); actor->ClearInterpolation(); - actor->floorz = actor->Sector->floorplane.ZatPoint(pos); - actor->dropoffz = FLOAT2FIXED(actor->floorz); // killough 11/98: for tracking dropoffs + actor->dropoffz = actor->floorz = actor->Sector->floorplane.ZatPoint(pos); actor->ceilingz = actor->Sector->ceilingplane.ZatPoint(pos); // The z-coordinate needs to be set once before calling P_FindFloorCeiling @@ -4824,7 +4823,6 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) PClassActor *i; int mask; AActor *mobj; - fixed_t x, y, z; if (mthing->EdNum == 0 || mthing->EdNum == -1) return NULL; @@ -4835,9 +4833,8 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) if (mentry == NULL) { // [RH] Don't die if the map tries to spawn an unknown thing - Printf ("Unknown type %i at (%i, %i)\n", - mthing->EdNum, - mthing->x>>FRACBITS, mthing->y>>FRACBITS); + Printf("Unknown type %i at (%.1f, %.1f)\n", + mthing->EdNum, mthing->pos.X, mthing->pos.Y); mentry = DoomEdMap.CheckKey(0); if (mentry == NULL) // we need a valid entry for the rest of this function so if we can't find a default, let's exit right away. { @@ -4878,8 +4875,8 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) { polyspawns_t *polyspawn = new polyspawns_t; polyspawn->next = polyspawns; - polyspawn->x = mthing->x; - polyspawn->y = mthing->y; + polyspawn->x = FLOAT2FIXED(mthing->pos.X); + polyspawn->y = FLOAT2FIXED(mthing->pos.Y); polyspawn->angle = mthing->angle; polyspawn->type = mentry->Special; polyspawns = polyspawn; @@ -5013,7 +5010,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) } else { - P_PointInSector (mthing->x, mthing->y)->seqType = type; + P_PointInSector (mthing->pos)->seqType = type; } return NULL; } @@ -5034,8 +5031,8 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) if (gameinfo.flags & GI_SHAREWARE) return NULL; - Printf ("%s at (%i, %i) has no frames\n", - i->TypeName.GetChars(), mthing->x>>FRACBITS, mthing->y>>FRACBITS); + Printf ("%s at (%.1f, %.1f) has no frames\n", + i->TypeName.GetChars(), mthing->pos.X, mthing->pos.Y); i = PClass::FindActor("Unknown"); assert(i->IsKindOf(RUNTIME_CLASS(PClassActor))); } @@ -5089,30 +5086,29 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) } // spawn it - x = mthing->x; - y = mthing->y; + double sz; if (info->flags & MF_SPAWNCEILING) - z = ONCEILINGZ; + sz = ONCEILINGZ; else if (info->flags2 & MF2_SPAWNFLOAT) - z = FLOATRANDZ; + sz = FLOATRANDZ; else - z = ONFLOORZ; + sz = ONFLOORZ; - mobj = AActor::StaticSpawn (i, DVector3(FIXED2DBL(mthing->x), FIXED2DBL(mthing->y), z), NO_REPLACE, true); + mobj = AActor::StaticSpawn (i, DVector3(mthing->pos, sz), NO_REPLACE, true); - if (z == ONFLOORZ) + if (sz == ONFLOORZ) { - mobj->_f_AddZ(mthing->z); + mobj->AddZ(mthing->pos.Z); if ((mobj->flags2 & MF2_FLOATBOB) && (ib_compatflags & BCOMPATF_FLOATBOB)) { - mobj->specialf1 = FIXED2DBL(mthing->z); + mobj->specialf1 = mthing->pos.Z; } } - else if (z == ONCEILINGZ) - mobj->_f_AddZ(-mthing->z); + else if (sz == ONCEILINGZ) + mobj->AddZ(-mthing->pos.Z); - mobj->SpawnPoint = { FIXED2DBL(mthing->x), FIXED2DBL(mthing->y),FIXED2DBL(mthing->z) }; + mobj->SpawnPoint = mthing->pos; mobj->SpawnAngle = mthing->angle; mobj->SpawnFlags = mthing->flags; if (mthing->FloatbobPhase >= 0 && mthing->FloatbobPhase < 64) mobj->FloatBobPhase = mthing->FloatbobPhase; @@ -5884,7 +5880,7 @@ AActor *P_SpawnMissile (AActor *source, AActor *dest, PClassActor *type, AActor { return NULL; } - return P_SpawnMissileXYZ (source->_f_X(), source->_f_Y(), source->_f_Z() + 32*FRACUNIT + source->GetBobOffset(), + return P_SpawnMissileXYZ (source->_f_X(), source->_f_Y(), source->_f_Z() + 32*FRACUNIT + source->_f_GetBobOffset(), source, dest, type, true, owner); } @@ -6015,7 +6011,7 @@ AActor *P_SpawnMissileAngle (AActor *source, PClassActor *type, { return NULL; } - return P_SpawnMissileAngleZSpeed (source, source->_f_Z() + 32*FRACUNIT + source->GetBobOffset(), + return P_SpawnMissileAngleZSpeed (source, source->_f_Z() + 32*FRACUNIT + source->_f_GetBobOffset(), type, angle, vz, GetDefaultSpeed (type)); } @@ -6066,7 +6062,7 @@ AActor *P_SpawnMissileAngleSpeed (AActor *source, PClassActor *type, { return NULL; } - return P_SpawnMissileAngleZSpeed (source, source->_f_Z() + 32*FRACUNIT + source->GetBobOffset(), + return P_SpawnMissileAngleZSpeed (source, source->_f_Z() + 32*FRACUNIT + source->_f_GetBobOffset(), type, angle, vz, speed); } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 08833a222..067075ee7 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1671,8 +1671,8 @@ AActor *SpawnMapThing(int index, FMapThing *mt, int position) AActor *spawned = P_SpawnMapThing(mt, position); if (dumpspawnedthings) { - Printf("%5d: (%5d, %5d, %5d), doomednum = %5d, flags = %04x, type = %s\n", - index, mt->x>>FRACBITS, mt->y>>FRACBITS, mt->z>>FRACBITS, mt->EdNum, mt->flags, + Printf("%5d: (%5f, %5f, %5f), doomednum = %5d, flags = %04x, type = %s\n", + index, mt->pos.X, mt->pos.Y, mt->pos.Z, mt->EdNum, mt->flags, spawned? spawned->GetClass()->TypeName.GetChars() : "(none)"); } T_AddSpawnedThing(spawned); @@ -1765,8 +1765,8 @@ void P_LoadThings (MapData * map) mti[i].health = 1; mti[i].FloatbobPhase = -1; - mti[i].x = LittleShort(mt->x) << FRACBITS; - mti[i].y = LittleShort(mt->y) << FRACBITS; + mti[i].pos.X = LittleShort(mt->x); + mti[i].pos.Y = LittleShort(mt->y); mti[i].angle = LittleShort(mt->angle); mti[i].EdNum = LittleShort(mt->type); mti[i].info = DoomEdMap.CheckKey(mti[i].EdNum); @@ -1838,9 +1838,9 @@ void P_LoadThings2 (MapData * map) memset (&mti[i], 0, sizeof(mti[i])); mti[i].thingid = LittleShort(mth[i].thingid); - mti[i].x = LittleShort(mth[i].x)< &spots, TAr if (mentry != NULL && mentry->Type == NULL && mentry->Special >= SMT_PolyAnchor && mentry->Special <= SMT_PolySpawnHurt) { FNodeBuilder::FPolyStart newvert; - newvert.x = MapThingsConverted[i].x; - newvert.y = MapThingsConverted[i].y; + newvert.x = FLOAT2FIXED(MapThingsConverted[i].pos.X); + newvert.y = FLOAT2FIXED(MapThingsConverted[i].pos.Y); newvert.polynum = MapThingsConverted[i].angle; if (mentry->Special == SMT_PolyAnchor) { diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index 97cf2fb57..0265a1514 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -277,7 +277,7 @@ void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, const int *oldvertextable) { - TMap vt_heights[2]; + TMap vt_heights[2]; FMapThing *mt; bool vt_found = false; @@ -289,15 +289,15 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, { for (int i = 0; i < numvertexes; i++) { - if (vertexes[i].x == mt->x && vertexes[i].y == mt->y) + if (vertexes[i].fX() == mt->pos.X && vertexes[i].fY() == mt->pos.Y) { if (mt->info->Special == SMT_VertexFloorZ) { - vt_heights[0][i] = mt->z; + vt_heights[0][i] = mt->pos.Z; } else { - vt_heights[1][i] = mt->z; + vt_heights[1][i] = mt->pos.Z; } vt_found = true; } @@ -345,25 +345,20 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, vi3 = (sec->lines[1]->v1 == sec->lines[0]->v1 || sec->lines[1]->v1 == sec->lines[0]->v2)? int(sec->lines[1]->v2 - vertexes) : int(sec->lines[1]->v1 - vertexes); - vt1.X = FIXED2DBL(vertexes[vi1].x); - vt1.Y = FIXED2DBL(vertexes[vi1].y); - vt2.X = FIXED2DBL(vertexes[vi2].x); - vt2.Y = FIXED2DBL(vertexes[vi2].y); - vt3.X = FIXED2DBL(vertexes[vi3].x); - vt3.Y = FIXED2DBL(vertexes[vi3].y); + vt1 = DVector3(vertexes[vi1].fPos(), 0); + vt2 = DVector3(vertexes[vi2].fPos(), 0); + vt3 = DVector3(vertexes[vi3].fPos(), 0); for(int j=0; j<2; j++) { - fixed_t *h1 = vt_heights[j].CheckKey(vi1); - fixed_t *h2 = vt_heights[j].CheckKey(vi2); - fixed_t *h3 = vt_heights[j].CheckKey(vi3); - fixed_t z3; + double *h1 = vt_heights[j].CheckKey(vi1); + double *h2 = vt_heights[j].CheckKey(vi2); + double *h3 = vt_heights[j].CheckKey(vi3); if (h1==NULL && h2==NULL && h3==NULL) continue; - vt1.Z = FIXED2DBL(h1? *h1 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling)); - vt2.Z = FIXED2DBL(h2? *h2 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling)); - z3 = h3? *h3 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling); - vt3.Z = FIXED2DBL(z3); + vt1.Z = h1? *h1 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling); + vt2.Z = h2? *h2 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling); + vt3.Z = h3? *h3 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling); if (P_PointOnLineSidePrecise(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) { @@ -401,7 +396,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, srcplane->ic = DivScale32 (1, srcplane->c); srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].x, srcplane->b, vertexes[vi3].y, - srcplane->c, z3); + srcplane->c, FLOAT2FIXED(vt3.Z)); } } } @@ -422,14 +417,12 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldve if (mt->info != NULL && mt->info->Type == NULL && (mt->info->Special >= SMT_SlopeFloorPointLine && mt->info->Special <= SMT_VavoomCeiling)) { - fixed_t x, y, z; + DVector3 pos = mt->pos; secplane_t *refplane; sector_t *sec; bool ceiling; - x = mt->x; - y = mt->y; - sec = P_PointInSector (x, y); + sec = P_PointInSector (mt->pos); if (mt->info->Special == SMT_SlopeCeilingPointLine || mt->info->Special == SMT_VavoomCeiling || mt->info->Special == SMT_SetCeilingSlope) { refplane = &sec->ceilingplane; @@ -440,7 +433,12 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldve refplane = &sec->floorplane; ceiling = false; } - z = refplane->ZatPoint (x, y) + (mt->z); + pos.Z = refplane->ZatPoint (mt->pos) + mt->pos.Z; + + fixed_t x = FLOAT2FIXED(pos.X); + fixed_t y = FLOAT2FIXED(pos.Y); + fixed_t z = FLOAT2FIXED(pos.Z); + if (mt->info->Special <= SMT_SlopeCeilingPointLine) { // SlopeFloorPointLine and SlopCeilingPointLine P_SlopeLineToPoint (mt->args[0], x, y, z, ceiling); @@ -451,7 +449,7 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldve } else { // VavoomFloor and VavoomCeiling - P_VavoomSlope(sec, mt->thingid, x, y, mt->z, ceiling); + P_VavoomSlope(sec, mt->thingid, x, y, FLOAT2FIXED(mt->pos.Z), ceiling); } mt->EdNum = 0; } @@ -462,7 +460,7 @@ void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldve if (mt->info != NULL && mt->info->Type == NULL && (mt->info->Special == SMT_CopyFloorPlane || mt->info->Special == SMT_CopyCeilingPlane)) { - P_CopyPlane (mt->args[0], mt->x, mt->y, mt->info->Special == SMT_CopyCeilingPlane); + P_CopyPlane (mt->args[0], FLOAT2FIXED(mt->pos.X), FLOAT2FIXED(mt->pos.Y), mt->info->Special == SMT_CopyCeilingPlane); mt->EdNum = 0; } } diff --git a/src/p_things.cpp b/src/p_things.cpp index 470282f60..206b713f5 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -792,7 +792,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, } if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB)) { - caller->_f_AddZ(reference->GetBobOffset()); + caller->_f_AddZ(reference->_f_GetBobOffset()); } } return true; diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 89b5b9737..365dbb76b 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -487,15 +487,15 @@ public: break; case NAME_X: - th->x = CheckFixed(key); + th->pos.X = CheckFloat(key); break; case NAME_Y: - th->y = CheckFixed(key); + th->pos.Y = CheckFloat(key); break; case NAME_Height: - th->z = CheckFixed(key); + th->pos.Z = CheckFloat(key); break; case NAME_Angle: diff --git a/src/r_defs.h b/src/r_defs.h index 01150afd0..dedb49336 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -105,6 +105,11 @@ struct vertex_t return FIXED2DBL(y); } + DVector2 fPos() + { + return{ fX(), fY() }; + } + bool operator== (const vertex_t &other) { return x == other.x && y == other.y; diff --git a/src/r_things.cpp b/src/r_things.cpp index ac1a7725f..fa5145001 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -770,7 +770,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor fixedvec3 pos = thing->InterpolatedPosition(r_TicFrac); fx = pos.x; fy = pos.y; - fz = pos.z + thing->GetBobOffset(r_TicFrac); + fz = pos.z + thing->_f_GetBobOffset(r_TicFrac); tex = NULL; voxel = NULL; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index bebfce769..86f6f4cf6 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -614,7 +614,7 @@ static void DoAttack (AActor *self, bool domelee, bool domissile, else if (domissile && MissileType != NULL) { // This seemingly senseless code is needed for proper aiming. - double add = MissileHeight + FIXED2FLOAT(self->GetBobOffset()) - 32; + double add = MissileHeight + self->GetBobOffset() - 32; self->AddZ(add); AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32.), self, self->target, MissileType, false); self->AddZ(-add); @@ -1197,8 +1197,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) { PARAM_ACTION_PROLOGUE; PARAM_CLASS (ti, AActor); - PARAM_FIXED_OPT (spawnheight) { spawnheight = 32*FRACUNIT; } - PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; } + PARAM_FLOAT_OPT (Spawnheight) { Spawnheight = 32; } + PARAM_FLOAT_OPT (Spawnofs_xy) { Spawnofs_xy = 0; } PARAM_DANGLE_OPT(Angle) { Angle = 0.; } PARAM_INT_OPT (flags) { flags = 0; } PARAM_DANGLE_OPT(Pitch) { Pitch = 0.; } @@ -1215,12 +1215,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) { if (ti) { - 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? FLOAT2FIXED(self->player->crouchoffset) : 0); + DAngle angle = self->Angles.Yaw - 90; + double x = Spawnofs_xy * angle.Cos(); + double y = Spawnofs_xy * angle.Sin(); + double z = Spawnheight + self->GetBobOffset() - 32 + (self->player? self->player->crouchoffset : 0.); - fixedvec3 pos = self->_f_Pos(); + DVector3 pos = self->Pos(); switch (aimmode) { case 0: @@ -1232,12 +1232,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) break; case 1: - missile = P_SpawnMissileXYZ(self->Vec3Offset(x, y, self->GetBobOffset() + spawnheight), self, ref, ti, false); + missile = P_SpawnMissileXYZ(self->Vec3Offset(x, y, self->GetBobOffset() + Spawnheight), self, ref, ti, false); break; case 2: - self->SetXYZ(self->Vec3Offset(x, y, 0)); - missile = P_SpawnMissileAngleZSpeed(self, self->_f_Z() + self->GetBobOffset() + spawnheight, ti, self->_f_angle(), 0, GetDefaultByType(ti)->_f_speed(), self, false); + self->SetXYZ(self->Vec3Offset(x, y, 0.)); + missile = P_SpawnMissileAngleZSpeed(self, self->Z() + self->GetBobOffset() + Spawnheight, ti, self->Angles.Yaw, 0, GetDefaultByType(ti)->Speed, self, false); self->SetXYZ(pos); flags |= CMF_ABSOLUTEPITCH; @@ -1443,7 +1443,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) { PARAM_ACTION_PROLOGUE; PARAM_CLASS (ti, AActor); - PARAM_FIXED (spawnheight); + PARAM_FLOAT (spawnheight); PARAM_INT (damage); PARAM_SOUND_OPT (meleesound) { meleesound = 0; } PARAM_NAME_OPT (damagetype) { damagetype = NAME_Melee; } @@ -1466,9 +1466,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack) else if (ti) { // This seemingly senseless code is needed for proper aiming. - self->_f_AddZ(spawnheight + self->GetBobOffset() - 32*FRACUNIT); + double add = spawnheight + self->GetBobOffset() - 32; + self->AddZ(add); AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32.), self, self->target, ti, false); - self->_f_AddZ(-(spawnheight + self->GetBobOffset() - 32*FRACUNIT)); + self->AddZ(-add); if (missile) { diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index ebc89dc4a..8c2a664e2 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1256,7 +1256,7 @@ DEFINE_PROPERTY(maxstepheight, F, Actor) //========================================================================== DEFINE_PROPERTY(maxdropoffheight, F, Actor) { - PROP_FIXED_PARM(i, 0); + PROP_DOUBLE_PARM(i, 0); defaults->MaxDropOffHeight = i; } diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index aeeaec813..d416cf40a 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -184,7 +184,7 @@ ACTOR Actor native //: Thinker action native A_StopSoundEx(coerce name slot); action native A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); action native state A_Jump(int chance = 256, state label, ...); - action native A_CustomMissile(class missiletype, float spawnheight = 32, int spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0, int ptr = AAPTR_TARGET); + action native A_CustomMissile(class missiletype, float spawnheight = 32, float spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0, int ptr = AAPTR_TARGET); action native A_CustomBulletAttack(float/*angle*/ spread_xy, float/*angle*/ spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", float range = 0, int flags = 0, int ptr = AAPTR_TARGET); action native A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, int aim = 0, float maxdiff = 0, class pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270); action native state A_JumpIfHealthLower(int health, state label, int ptr_selector = AAPTR_DEFAULT); From 7c87479eea5f655dc3dd1e6ee3716f0294350eff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 23 Mar 2016 13:31:12 +0100 Subject: [PATCH 04/12] - parameter rework of several spawning functions. --- src/p_acs.cpp | 2 +- src/p_effect.cpp | 18 +++--- src/p_effect.h | 2 +- src/p_local.h | 26 ++++----- src/p_map.cpp | 19 ++++--- src/p_mobj.cpp | 93 +++++++++++++++---------------- src/p_spec.cpp | 2 +- src/p_things.cpp | 5 +- src/p_udmf.cpp | 22 +++----- src/r_defs.h | 2 +- src/s_sound.h | 4 ++ src/thingdef/thingdef_codeptr.cpp | 7 +-- 12 files changed, 94 insertions(+), 108 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 3d9f2ba7b..a03039541 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -8685,7 +8685,7 @@ scriptwait: bool result = false; AActor *actor = SingleActorFromTID (STACK(5), activator); if (actor != NULL) - result = P_MoveThing(actor, STACK(4), STACK(3), STACK(2), !!STACK(1)); + result = P_MoveThing(actor, DVector3(ACSToDouble(STACK(4)), ACSToDouble(STACK(3)), ACSToDouble(STACK(2))), !!STACK(1)); sp -= 4; STACK(1) = result; } diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 5de7cb523..3814d35d8 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -493,11 +493,9 @@ void P_RunEffect (AActor *actor, int effects) { // Grenade trail - fixedvec3 pos = actor->_f_Vec3Angle(-actor->_f_radius() * 2, moveangle.BAMs(), - fixed_t(-(actor->_f_height() >> 3) * (actor->Vel.Z) + (2 * actor->_f_height()) / 3)); + DVector3 pos = actor->Vec3Angle(-actor->radius * 2, moveangle, -actor->Height * actor->Vel.Z / 8 + actor->Height * (2. / 3)); - P_DrawSplash2 (6, pos.x, pos.y, pos.z, - moveangle.BAMs() + ANG180, 2, 2); + P_DrawSplash2 (6, pos, moveangle + 180, 2, 2); } if (effects & FX_FOUNTAINMASK) { @@ -582,7 +580,7 @@ void P_DrawSplash (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, in } } -void P_DrawSplash2 (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int updown, int kind) +void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, int kind) { int color1, color2, zvel, zspread, zadd; @@ -626,16 +624,16 @@ void P_DrawSplash2 (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, i p->vel.z = M_Random () * zvel; p->accz = -FRACUNIT/22; if (kind) { - an = (angle + ((M_Random() - 128) << 23)) >> ANGLETOFINESHIFT; + an = (angle.BAMs() + ((M_Random() - 128) << 23)) >> ANGLETOFINESHIFT; p->vel.x = (M_Random () * finecosine[an]) >> 11; p->vel.y = (M_Random () * finesine[an]) >> 11; p->accx = p->vel.x >> 4; p->accy = p->vel.y >> 4; } - p->z = z + (M_Random () + zadd - 128) * zspread; - an = (angle + ((M_Random() - 128) << 22)) >> ANGLETOFINESHIFT; - p->x = x + ((M_Random () & 31)-15)*finecosine[an]; - p->y = y + ((M_Random () & 31)-15)*finesine[an]; + p->z = FLOAT2FIXED(pos.Z) + (M_Random () + zadd - 128) * zspread; + an = (angle.BAMs() + ((M_Random() - 128) << 22)) >> ANGLETOFINESHIFT; + p->x = FLOAT2FIXED(pos.X) + ((M_Random () & 31)-15)*finecosine[an]; + p->y = FLOAT2FIXED(pos.X) + ((M_Random () & 31)-15)*finesine[an]; } } diff --git a/src/p_effect.h b/src/p_effect.h index 3990fa80c..9bab44a81 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -91,5 +91,5 @@ void P_RunEffect (AActor *actor, int effects); void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, angle_t angle = 0, int duration = 35, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270); void P_DrawSplash (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int kind); -void P_DrawSplash2 (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int updown, int kind); +void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, int kind); void P_DisconnectEffect (AActor *actor); diff --git a/src/p_local.h b/src/p_local.h index e4ad4e44f..17af47908 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -138,22 +138,15 @@ enum EPuffFlags PF_NORANDOMZ = 16 }; -AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y, fixed_t z, angle_t hitdir, angle_t particledir, int updown, int flags = 0, AActor *vict = NULL); +AActor *P_SpawnPuff(AActor *source, PClassActor *pufftype, const DVector3 &pos, DAngle hitdir, DAngle particledir, int updown, int flags = 0, AActor *vict = NULL); inline AActor *P_SpawnPuff(AActor *source, PClassActor *pufftype, const fixedvec3 &pos, angle_t hitdir, angle_t particledir, int updown, int flags = 0, AActor *vict = NULL) { - return P_SpawnPuff(source, pufftype, pos.x, pos.y, pos.z, hitdir, particledir, updown, flags, vict); + DVector3 _pos(FIXED2DBL(pos.x), FIXED2DBL(pos.y), FIXED2DBL(pos.z)); + return P_SpawnPuff(source, pufftype, _pos, ANGLE2DBL(hitdir), ANGLE2DBL(particledir), updown, flags, vict); } -inline AActor *P_SpawnPuff(AActor *source, PClassActor *pufftype, const DVector3 &pos, DAngle hitdir, DAngle particledir, int updown, int flags = 0, AActor *vict = NULL) -{ - return P_SpawnPuff(source, pufftype, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), hitdir.BAMs(), particledir.BAMs(), updown, flags, vict); -} -void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AActor *originator); -inline void P_SpawnBlood(const fixedvec3 &pos, angle_t dir, int damage, AActor *originator) -{ - P_SpawnBlood(pos.x, pos.y, pos.z, dir, damage, originator); -} -void P_BloodSplatter (fixedvec3 pos, AActor *originator); -void P_BloodSplatter2 (fixedvec3 pos, AActor *originator); +void P_SpawnBlood (const DVector3 &pos, DAngle angle, int damage, AActor *originator); +void P_BloodSplatter (const DVector3 &pos, AActor *originator, DAngle hitangle); +void P_BloodSplatter2 (const DVector3 &pos, AActor *originator, DAngle hitangle); void P_RipperBlood (AActor *mo, AActor *bleeder); int P_GetThingFloorType (AActor *thing); void P_ExplodeMissile (AActor *missile, line_t *explodeline, AActor *target); @@ -219,7 +212,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i 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); +bool P_MoveThing(AActor *source, const DVector3 &pos, bool fog); bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog); int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type); void P_Thing_SetVelocity(AActor *actor, const DVector3 &vec, bool add, bool setbob); @@ -390,10 +383,11 @@ void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile ver void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff); // hitscan version void P_TraceBleed (int damage, AActor *target); // random direction version bool P_HitFloor (AActor *thing); -bool P_HitWater (AActor *thing, sector_t *sec, fixed_t splashx = FIXED_MIN, fixed_t splashy = FIXED_MIN, fixed_t splashz=FIXED_MIN, bool checkabove = false, bool alert = true, bool force = false); +bool P_HitWater (AActor *thing, sector_t *sec, const DVector3 &pos, bool checkabove = false, bool alert = true, bool force = false); inline bool P_HitWater(AActor *thing, sector_t *sec, const fixedvec3 &pos, bool checkabove = false, bool alert = true, bool force = false) { - return P_HitWater(thing, sec, pos.x, pos.y, pos.z, checkabove, alert, force); + DVector3 fpos(FIXED2DBL(pos.x), FIXED2DBL(pos.y), FIXED2DBL(pos.z)); + return P_HitWater(thing, sec, fpos, checkabove, alert, force); } void P_CheckSplash(AActor *self, double distance); void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z = 0, int color1 = 0, int color2 = 0, double maxdiff = 0, int flags = 0, PClassActor *puff = NULL, angle_t angleoffset = 0, angle_t pitchoffset = 0, fixed_t distance = 8192*FRACUNIT, int duration = 0, double sparsity = 1.0, double drift = 1.0, PClassActor *spawnclass = NULL, int SpiralOffset = 270); // [RH] Shoot a railgun diff --git a/src/p_map.cpp b/src/p_map.cpp index 851cc45f5..f4188e8d1 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1507,7 +1507,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch !(tm.thing->flags3 & MF3_BLOODLESSIMPACT) && (pr_checkthing() < 192)) { - P_BloodSplatter(tm.thing->_f_Pos(), thing); + P_BloodSplatter(tm.thing->Pos(), thing, tm.thing->AngleTo(thing)); } if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) { @@ -4234,7 +4234,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, if (trace.HitType != TRACE_HitWall || trace.Line->special != Line_Horizon) { fixedvec2 pos = P_GetOffsetPosition(trace.HitPos.x, trace.HitPos.y, -trace.HitVector.x * 4, -trace.HitVector.y * 4); - puff = P_SpawnPuff(t1, pufftype, pos.x, pos.y, trace.HitPos.z - trace.HitVector.z * 4, trace.SrcAngleToTarget, + puff = P_SpawnPuff(t1, pufftype, { pos.x, pos.y, trace.HitPos.z - trace.HitVector.z * 4 }, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 0, puffFlags); puff->radius = 1/65536.; } @@ -4292,6 +4292,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, bleedpos.y = ofs.y; bleedpos.z -= -10 * trace.HitVector.z; } + DVector3 bleedposf(FIXED2DBL(bleedpos.x), FIXED2DBL(bleedpos.y), FIXED2DBL(bleedpos.z)); // Spawn bullet puffs or blood spots, depending on target type. if ((puffDefaults != NULL && puffDefaults->flags3 & MF3_PUFFONACTORS) || @@ -4343,7 +4344,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, !(trace.Actor->flags & MF_NOBLOOD) && !(trace.Actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) { - P_SpawnBlood(bleedpos, trace.SrcAngleToTarget, newdam > 0 ? newdam : damage, trace.Actor); + P_SpawnBlood(bleedposf, ANGLE2DBL(trace.SrcAngleToTarget), newdam > 0 ? newdam : damage, trace.Actor); } if (damage) @@ -4355,11 +4356,11 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, { if (axeBlood) { - P_BloodSplatter2(bleedpos, trace.Actor); + P_BloodSplatter2(bleedposf, trace.Actor, ANGLE2DBL(trace.SrcAngleToTarget)); } if (pr_lineattack() < 192) { - P_BloodSplatter(bleedpos, trace.Actor); + P_BloodSplatter(bleedposf, trace.Actor, ANGLE2DBL(trace.SrcAngleToTarget)); } } } @@ -4794,7 +4795,8 @@ 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); + DVector3 h(FIXED2DBL(hitpos.x), FIXED2DBL(hitpos.y), FIXED2DBL(hitpos.z)); + P_SpawnBlood(h, ANGLE2DBL(hitangle), newdam > 0 ? newdam : damage, hitactor); P_TraceBleed(newdam > 0 ? newdam : damage, hitpos, hitactor, source->_f_angle(), pitch); } } @@ -5646,11 +5648,10 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos) if (!(cl_bloodtype <= 1)) mo->renderflags |= RF_INVISIBLE; } - angle_t an; - an = (M_Random() - 128) << 24; + DAngle an = (M_Random() - 128) * (360./256); if (cl_bloodtype >= 1) { - P_DrawSplash2(32, thing->_f_X(), thing->_f_Y(), thing->_f_Z() + thing->_f_height() / 2, an, 2, bloodcolor); + P_DrawSplash2(32, thing->PosPlusZ(thing->Height/2), an, 2, bloodcolor); } } if (thing->CrushPainSound != 0 && !S_GetSoundPlayingInfo(thing, thing->CrushPainSound)) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 9f894f0f0..b5e58b0aa 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4111,7 +4111,7 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) // the water flags. if (boomwaterlevel == 0 && waterlevel != 0 && dosplash) { - P_HitWater(this, Sector, FIXED_MIN, FIXED_MIN, FLOAT2FIXED(fh), true); + P_HitWater(this, Sector, PosAtZ(fh), true); } boomwaterlevel = waterlevel; if (reset) @@ -5195,15 +5195,15 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) // P_SpawnPuff // -AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y, fixed_t z, angle_t hitdir, angle_t particledir, int updown, int flags, AActor *vict) +AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, const DVector3 &pos, DAngle hitdir, DAngle particledir, int updown, int flags, AActor *vict) { AActor *puff; + double z = 0; if (!(flags & PF_NORANDOMZ)) - z += pr_spawnpuff.Random2 () << 10; + z = pr_spawnpuff.Random2() / 64.; - DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); - puff = Spawn (pufftype, pos, ALLOW_REPLACE); + puff = Spawn(pufftype, pos + Vector3(0, 0, z), ALLOW_REPLACE); if (puff == NULL) return NULL; if ((puff->flags4 & MF4_RANDOMIZE) && puff->tics > 0) @@ -5225,7 +5225,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->Angles.Yaw = ANGLE2DBL(hitdir + ANGLE_180); + puff->Angles.Yaw = hitdir + 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 @@ -5250,7 +5250,7 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y { if (cl_pufftype && updown != 3 && (puff->flags4 & MF4_ALLOWPARTICLES)) { - P_DrawSplash2 (32, x, y, z, particledir, updown, 1); + P_DrawSplash2 (32, pos, particledir, updown, 1); puff->renderflags |= RF_INVISIBLE; } @@ -5275,9 +5275,8 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, fixed_t x, fixed_t y // //--------------------------------------------------------------------------- -void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AActor *originator) +void P_SpawnBlood (const DVector3 &pos, DAngle dir, int damage, AActor *originator) { - DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); AActor *th; PalEntry bloodcolor = originator->GetBloodColor(); PClassActor *bloodcls = originator->GetBloodType(); @@ -5289,8 +5288,8 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc if (bloodcls != NULL) { - z += pr_spawnblood.Random2 () << 10; - th = Spawn (bloodcls, pos, NO_REPLACE); // GetBloodType already performed the replacement + double z = pr_spawnblood.Random2 () / 64.; + th = Spawn(bloodcls, pos + DVector3(0, 0, z), NO_REPLACE); // GetBloodType already performed the replacement th->Vel.Z = 2; th->Angles.Yaw = ANGLE2DBL(dir); // [NG] Applying PUFFGETSOWNER to the blood will make it target the owner @@ -5362,7 +5361,7 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc } if (bloodtype >= 1) - P_DrawSplash2 (40, x, y, z, dir, 2, bloodcolor); + P_DrawSplash2 (40, pos, ANGLE2DBL(dir), 2, bloodcolor); } //--------------------------------------------------------------------------- @@ -5371,9 +5370,8 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AAc // //--------------------------------------------------------------------------- -void P_BloodSplatter (fixedvec3 _pos, AActor *originator) +void P_BloodSplatter (const DVector3 &pos, AActor *originator, DAngle hitangle) { - DVector3 pos(FIXED2DBL(_pos.x), FIXED2DBL(_pos.y), FIXED2DBL(_pos.z)); PalEntry bloodcolor = originator->GetBloodColor(); PClassActor *bloodcls = originator->GetBloodType(1); @@ -5402,7 +5400,7 @@ void P_BloodSplatter (fixedvec3 _pos, AActor *originator) } if (bloodtype >= 1) { - //P_DrawSplash2 (40, pos.X, pos.Y, pos.Z, -originator->AngleTo(pos), 2, bloodcolor); + P_DrawSplash2 (40, pos, hitangle-180., 2, bloodcolor); } } @@ -5412,9 +5410,8 @@ void P_BloodSplatter (fixedvec3 _pos, AActor *originator) // //=========================================================================== -void P_BloodSplatter2 (fixedvec3 _pos, AActor *originator) +void P_BloodSplatter2 (const DVector3 &pos, AActor *originator, DAngle hitangle) { - DVector3 pos(FIXED2DBL(_pos.x), FIXED2DBL(_pos.y), FIXED2DBL(_pos.z)); PalEntry bloodcolor = originator->GetBloodColor(); PClassActor *bloodcls = originator->GetBloodType(2); @@ -5426,11 +5423,12 @@ void P_BloodSplatter2 (fixedvec3 _pos, AActor *originator) if (bloodcls != NULL) { AActor *mo; - - pos.X += (pr_splat()-128) / 32.; - pos.Y += (pr_splat()-128) / 32.; - mo = Spawn (bloodcls, pos, NO_REPLACE); // GetBloodType already performed the replacement + DVector2 add; + add.X = (pr_splat()-128) / 32.; + add.Y = (pr_splat()-128) / 32.; + + mo = Spawn (bloodcls, pos + add, NO_REPLACE); // GetBloodType already performed the replacement mo->target = originator; // colorize the blood! @@ -5443,7 +5441,7 @@ void P_BloodSplatter2 (fixedvec3 _pos, AActor *originator) } if (bloodtype >= 1) { - //P_DrawSplash2 (100, pos.x, pos.y, pos.z, 0u - originator->__f_AngleTo(pos), 2, bloodcolor); + P_DrawSplash2(40, pos, hitangle - 180., 2, bloodcolor); } } @@ -5490,7 +5488,7 @@ void P_RipperBlood (AActor *mo, AActor *bleeder) } if (bloodtype >= 1) { - //P_DrawSplash2 (28, pos.X, pos.Y, pos.Z, 0, 0, bloodcolor); + P_DrawSplash2(28, pos, bleeder->AngleTo(mo) + 180., 0, bloodcolor); } } @@ -5519,7 +5517,7 @@ int P_GetThingFloorType (AActor *thing) // Returns true if hit liquid and splashed, false if not. //--------------------------------------------------------------------------- -bool P_HitWater (AActor * thing, sector_t * sec, fixed_t x, fixed_t y, fixed_t z, bool checkabove, bool alert, bool force) +bool P_HitWater (AActor * thing, sector_t * sec, const DVector3 &pos, bool checkabove, bool alert, bool force) { if (thing->flags3 & MF3_DONTSPLASH) return false; @@ -5532,21 +5530,17 @@ bool P_HitWater (AActor * thing, sector_t * sec, fixed_t x, fixed_t y, fixed_t z int terrainnum; sector_t *hsec = NULL; - if (x == FIXED_MIN) x = thing->_f_X(); - if (y == FIXED_MIN) y = thing->_f_Y(); - if (z == FIXED_MIN) z = thing->_f_Z(); // don't splash above the object if (checkabove) { - fixed_t compare_z = thing->_f_Z() + (thing->_f_height() >> 1); + double compare_z = thing->Center(); // Missiles are typically small and fast, so they might // end up submerged by the move that calls P_HitWater. if (thing->flags & MF_MISSILE) - compare_z -= thing->_f_velz(); - if (z > compare_z) + compare_z -= thing->Vel.Z; + if (pos.Z > compare_z) return false; } - DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); #if 0 // needs some rethinking before activation @@ -5555,10 +5549,10 @@ bool P_HitWater (AActor * thing, sector_t * sec, fixed_t x, fixed_t y, fixed_t z // it is not guaranteed that all players have GL nodes loaded. if (!multiplayer && thing->subsector->sector != thing->subsector->render_sector) { - fixed_t zs = thing->subsector->sector->floorplane.ZatPoint(x, y); - fixed_t zr = thing->subsector->render_sector->floorplane.ZatPoint(x, y); + double zs = thing->subsector->sector->floorplane.ZatPoint(pos); + double zr = thing->subsector->render_sector->floorplane.ZatPoint(pos); - if (zs > zr && thing->z >= zs) return false; + if (zs > zr && thing->Z() >= zs) return false; } #endif @@ -5567,20 +5561,20 @@ bool P_HitWater (AActor * thing, sector_t * sec, fixed_t x, fixed_t y, fixed_t z { for (unsigned int i = 0; ie->XFloor.ffloors.Size(); i++) { - F3DFloor * rover = sec->e->XFloor.ffloors[i]; - if (!(rover->flags & FF_EXISTS)) continue; - fixed_t planez = rover->top.plane->ZatPoint(x, y); - if (z > planez - FRACUNIT / 2 && z < planez + FRACUNIT / 2) // allow minor imprecisions - { - if (rover->flags & (FF_SOLID | FF_SWIMMABLE)) + F3DFloor * rover = sec->e->XFloor.ffloors[i]; + if (!(rover->flags & FF_EXISTS)) continue; + double planez = rover->top.plane->ZatPoint(pos); + if (pos.Z > planez - 0.5 && pos.Z < planez + 0.5) // allow minor imprecisions { - terrainnum = rover->model->GetTerrain(rover->top.isceiling); - goto foundone; + if (rover->flags & (FF_SOLID | FF_SWIMMABLE)) + { + terrainnum = rover->model->GetTerrain(rover->top.isceiling); + goto foundone; + } } + planez = rover->bottom.plane->ZatPoint(pos); + if (planez < pos.Z && !(planez < thing->floorz)) return false; } - planez = rover->bottom.plane->ZatPoint(x, y); - if (planez < z && !(planez < thing->_f_floorz())) return false; - } } hsec = sec->GetHeightSec(); if (force || hsec == NULL || !(hsec->MoreFlags & SECF_CLIPFAKEPLANES)) @@ -5601,13 +5595,13 @@ foundone: return Terrains[terrainnum].IsLiquid; // don't splash when touching an underwater floor - if (thing->waterlevel>=1 && z<=thing->_f_floorz()) return Terrains[terrainnum].IsLiquid; + if (thing->waterlevel >= 1 && pos.Z <= thing->floorz) return Terrains[terrainnum].IsLiquid; plane = hsec != NULL? &sec->heightsec->floorplane : &sec->floorplane; // Don't splash for living things with small vertical velocities. // There are levels where the constant splashing from the monsters gets extremely annoying - if (((thing->flags3&MF3_ISMONSTER || thing->player) && thing->_f_velz() >= -6*FRACUNIT) && !force) + if (((thing->flags3&MF3_ISMONSTER || thing->player) && thing->Vel.Z >= -6) && !force) return Terrains[terrainnum].IsLiquid; splash = &Splashes[splashnum]; @@ -5654,7 +5648,7 @@ foundone: } else { - S_Sound (x, y, z, CHAN_ITEM, smallsplash ? + S_Sound (pos, CHAN_ITEM, smallsplash ? splash->SmallSplashSound : splash->NormalSplashSound, 1, ATTN_IDLE); } @@ -5736,7 +5730,8 @@ void P_CheckSplash(AActor *self, double distance) // a separate parameter for that so this would get in the way of proper // behavior. fixedvec3 pos = self->PosRelative(floorsec); - P_HitWater (self, floorsec, pos.x, pos.y, self->_f_floorz(), false, false); + pos.z = self->_f_floorz(); + P_HitWater (self, floorsec, pos, false, false); } } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 5e97bff6d..ba2f7a766 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -476,7 +476,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) } if (sector->Flags & SECF_DMGTERRAINFX) { - P_HitWater(player->mo, player->mo->Sector, INT_MIN, INT_MIN, INT_MIN, false, true, true); + P_HitWater(player->mo, player->mo->Sector, player->mo->Pos(), false, true, true); } } } diff --git a/src/p_things.cpp b/src/p_things.cpp index 206b713f5..1866c079e 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -123,9 +123,8 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i // [BC] Added // [RH] Fixed -bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog) +bool P_MoveThing(AActor *source, const DVector3 &pos, bool fog) { - DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); DVector3 old = source->Pos(); source->SetOrigin (pos, true); @@ -164,7 +163,7 @@ bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog) if (source != NULL && target != NULL) { - return P_MoveThing(source, target->_f_X(), target->_f_Y(), target->_f_Z(), fog); + return P_MoveThing(source, target->Pos(), fog); } return false; } diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 365dbb76b..946e0000c 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1678,32 +1678,28 @@ public: { vt->x = vt->y = 0; vd->zCeiling = vd->zFloor = vd->flags = 0; - sc.MustGetStringName("{"); - while (!sc.CheckString("}")) + + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) { - sc.MustGetString(); - FName key = sc.String; - sc.MustGetStringName("="); - sc.MustGetString(); - FString value = sc.String; - sc.MustGetStringName(";"); - switch(key) + FName key = ParseKey(); + switch (key) { case NAME_X: - vt->x = FLOAT2FIXED(strtod(value, NULL)); + vt->x = CheckFixed(key); break; case NAME_Y: - vt->y = FLOAT2FIXED(strtod(value, NULL)); + vt->y = CheckFixed(key); break; case NAME_ZCeiling: - vd->zCeiling = FLOAT2FIXED(strtod(value, NULL)); + vd->zCeiling = CheckFloat(key); vd->flags |= VERTEXFLAG_ZCeilingEnabled; break; case NAME_ZFloor: - vd->zFloor = FLOAT2FIXED(strtod(value, NULL)); + vd->zFloor = CheckFloat(key); vd->flags |= VERTEXFLAG_ZFloorEnabled; break; diff --git a/src/r_defs.h b/src/r_defs.h index dedb49336..fac1379c3 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -88,7 +88,7 @@ enum }; struct vertexdata_t { - fixed_t zCeiling, zFloor; + double zCeiling, zFloor; DWORD flags; }; struct vertex_t diff --git a/src/s_sound.h b/src/s_sound.h index 59307b707..795232d1a 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -231,6 +231,10 @@ void S_SoundMinMaxDist (AActor *ent, int channel, FSoundID sfxid, float volume, void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, float volume, float attenuation); void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation); void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sfxid, float volume, float attenuation); +inline void S_Sound(const DVector3 &pos, int channel, FSoundID sfxid, float volume, float attenuation) +{ + S_Sound(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), channel, sfxid, volume, attenuation); +} // sound channels // channel 0 never willingly overrides diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 86f6f4cf6..05492306e 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -5095,8 +5095,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) // Compute position for spawning blood/puff angle = self->target->__f_AngleTo(self); - fixedvec3 bloodpos = self->target->_f_Vec3Angle(self->target->_f_radius(), angle, self->target->_f_height() >> 1); - + DVector3 BloodPos = self->target->Vec3Angle(self->target->radius, ANGLE2DBL(angle), self->target->Height/2); int damage = flags & WAF_NORANDOM ? maxdamage : (1 + (pr_cabullet() % maxdamage)); if (dist >= pointblank) @@ -5117,7 +5116,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) if ((0 && dpuff->flags3 & MF3_PUFFONACTORS) || !spawnblood) { spawnblood = false; - P_SpawnPuff(self, pufftype, bloodpos, angle, angle, 0); + P_SpawnPuff(self, pufftype, BloodPos, ANGLE2DBL(angle), ANGLE2DBL(angle), 0); } } else if (self->target->flags3 & MF3_GHOST) @@ -5127,7 +5126,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack) int newdam = P_DamageMobj(self->target, self, self, damage, mod, DMG_THRUSTLESS); if (spawnblood) { - P_SpawnBlood(bloodpos, angle, newdam > 0 ? newdam : damage, self->target); + P_SpawnBlood(BloodPos, ANGLE2DBL(angle), newdam > 0 ? newdam : damage, self->target); P_TraceBleed(newdam > 0 ? newdam : damage, self->target, self); } } From 0d1fbcf65fdc7b66140277343fba5c43728ea7a2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 23 Mar 2016 14:03:10 +0100 Subject: [PATCH 05/12] - flattened the following commits by Major Cooke: * Added falloff parameter to A_QuakeEx. - Treated just like A_Explode's 'fullradiusdamage' parameter, where the quake will fall off from this distance on out to the edge. Default is 0, which means no falloff. - Credits to MaxED and Michaelis for helping. * - Added HighPoint parameter to QuakeEx. - Allows fine tuning of where the quake's maximum or minimum occurs, in tics. This must be a range between [1, duration). - For up or down scaling quakes, this sets the quake to reach maximum sooner or start minimizing later. - For both, this indicates when the strongest will occur. Default is 0, or in the middle. The original commits were nearly impossible to find in the convoluted commit tree, so I think it's preferable to have one clean commit instead. --- src/g_shared/a_quake.cpp | 128 +++++++++++++++++++++++++----- src/g_shared/a_sharedglobal.h | 6 +- src/p_acs.cpp | 4 +- src/p_spec.h | 2 +- src/r_utility.cpp | 19 +++-- src/thingdef/thingdef_codeptr.cpp | 6 +- src/version.h | 2 +- wadsrc/static/actors/actor.txt | 2 +- 8 files changed, 131 insertions(+), 38 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 2e1c5fa16..c93c574a3 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -37,7 +37,7 @@ DEarthquake::DEarthquake() DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesound, int flags, - double waveSpeedX, double waveSpeedY, double waveSpeedZ) + double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint) : DThinker(STAT_EARTHQUAKE) { m_QuakeSFX = quakesound; @@ -54,6 +54,9 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in m_WaveSpeedX = (float)waveSpeedX; m_WaveSpeedY = (float)waveSpeedY; m_WaveSpeedZ = (float)waveSpeedZ; + m_Falloff = falloff << FRACBITS; + m_Highpoint = highpoint; + m_MiniCount = highpoint; } //========================================================================== @@ -97,6 +100,14 @@ void DEarthquake::Serialize (FArchive &arc) { arc << m_WaveSpeedX << m_WaveSpeedY << m_WaveSpeedZ; } + if (SaveVersion < 4534) + { + m_Falloff = m_Highpoint = m_MiniCount = 0; + } + else + { + arc << m_Falloff << m_Highpoint << m_MiniCount; + } } //========================================================================== @@ -122,6 +133,7 @@ void DEarthquake::Tick () { S_Sound (m_Spot, CHAN_BODY | CHAN_LOOP, m_QuakeSFX, 1, ATTN_NORM); } + if (m_DamageRadius > 0) { for (i = 0; i < MAXPLAYERS; i++) @@ -158,6 +170,8 @@ void DEarthquake::Tick () } } + if (m_MiniCount > 0) + m_MiniCount--; if (--m_Countdown == 0) { if (S_IsActorPlayingSomething(m_Spot, CHAN_BODY, m_QuakeSFX)) @@ -168,12 +182,18 @@ void DEarthquake::Tick () } } +//========================================================================== +// +// DEarthquake :: GetModWave +// +// QF_WAVE converts intensity into amplitude and unlocks a new property, the +// wave length. This is, in short, waves per second. Named waveMultiplier +// because that's as the name implies: adds more waves per second. +// +//========================================================================== + fixed_t DEarthquake::GetModWave(double waveMultiplier) const { - //QF_WAVE converts intensity into amplitude and unlocks a new property, the wave length. - //This is, in short, waves per second (full cycles, mind you, from 0 to 360.) - //Named waveMultiplier because that's as the name implies: adds more waves per second. - double time = m_Countdown - FIXED2DBL(r_TicFrac); return FLOAT2FIXED(sin(waveMultiplier * time * (M_PI * 2 / TICRATE))); } @@ -189,35 +209,96 @@ fixed_t DEarthquake::GetModWave(double waveMultiplier) const fixed_t DEarthquake::GetModIntensity(fixed_t intensity) const { assert(m_CountdownStart >= m_Countdown); + intensity += intensity; // always doubled if (m_Flags & (QF_SCALEDOWN | QF_SCALEUP)) { + // Adjustable maximums must use a range between 1 and m_CountdownStart to constrain between no quake and full quake. + bool check = !!(m_Highpoint > 0 && m_Highpoint < m_CountdownStart); + int divider = (check) ? m_Highpoint : m_CountdownStart; int scalar; + if ((m_Flags & (QF_SCALEDOWN | QF_SCALEUP)) == (QF_SCALEDOWN | QF_SCALEUP)) { - scalar = (m_Flags & QF_MAX) ? MAX(m_Countdown, m_CountdownStart - m_Countdown) - : MIN(m_Countdown, m_CountdownStart - m_Countdown); + if (check) + { + if (m_MiniCount > 0) + scalar = (m_Flags & QF_MAX) ? m_MiniCount : (m_Highpoint - m_MiniCount); + else + { + divider = m_CountdownStart - m_Highpoint; + scalar = (m_Flags & QF_MAX) ? (divider - m_Countdown) : m_Countdown; + } + } + else + { + // Defaults to middle of the road. + divider = m_CountdownStart; + scalar = (m_Flags & QF_MAX) ? MAX(m_Countdown, m_CountdownStart - m_Countdown) + : MIN(m_Countdown, m_CountdownStart - m_Countdown); + } + scalar = (scalar > divider) ? divider : scalar; if (m_Flags & QF_FULLINTENSITY) { scalar *= 2; } } - else if (m_Flags & QF_SCALEDOWN) + else { - scalar = m_Countdown; - } - else // QF_SCALEUP - { - scalar = m_CountdownStart - m_Countdown; - } - assert(m_CountdownStart > 0); - intensity = Scale(intensity, scalar, m_CountdownStart); + if (m_Flags & QF_SCALEDOWN) + { + scalar = m_Countdown; + } + else // QF_SCALEUP + { + scalar = m_CountdownStart - m_Countdown; + if (m_Highpoint > 0) + { + if ((m_Highpoint - m_MiniCount) < divider) + scalar = m_Highpoint - m_MiniCount; + else + scalar = divider; + } + } + scalar = (scalar > divider) ? divider : scalar; + } + assert(divider > 0); + intensity = Scale(intensity, scalar, divider); } return intensity; } +//========================================================================== +// +// DEarthquake :: GetFalloff +// +// Given the distance of the player from the quake, find the multiplier. +// Process everything as doubles, and output again as fixed_t (mainly +// because fixed_t was misbehaving here...) +// +//========================================================================== + +fixed_t DEarthquake::GetFalloff(fixed_t dist) const +{ + if ((dist < m_Falloff) || (m_Falloff >= m_TremorRadius) || (m_Falloff <= 0) || (m_TremorRadius - m_Falloff <= 0)) + { //Player inside the minimum falloff range, or safety check kicked in. + return FRACUNIT; + } + else if ((dist > m_Falloff) && (dist < m_TremorRadius)) + { //Player inside the radius, and outside the min distance for falloff. + fixed_t tremorsize = m_TremorRadius - m_Falloff; + fixed_t tremordist = dist - m_Falloff; + assert(tremorsize > 0); + return (FRACUNIT - FixedMul(FRACUNIT,tremordist) / tremorsize); + } + else + { //Shouldn't happen. + return FRACUNIT; + } +} + //========================================================================== // // DEarthquake::StaticGetQuakeIntensity @@ -247,12 +328,16 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger fixed_t dist = quake->m_Spot->AproxDistance (victim, true); if (dist < quake->m_TremorRadius) { + fixed_t falloff = quake->GetFalloff(dist); ++count; fixed_t x = quake->GetModIntensity(quake->m_IntensityX); fixed_t y = quake->GetModIntensity(quake->m_IntensityY); fixed_t z = quake->GetModIntensity(quake->m_IntensityZ); + + if (!(quake->m_Flags & QF_WAVE)) { + jiggers.Falloff = MAX(falloff, jiggers.Falloff); if (quake->m_Flags & QF_RELATIVE) { jiggers.RelIntensityX = MAX(x, jiggers.RelIntensityX); @@ -268,6 +353,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger } else { + jiggers.WFalloff = MAX(falloff, jiggers.WFalloff); fixed_t mx = FixedMul(x, quake->GetModWave(quake->m_WaveSpeedX)); fixed_t my = FixedMul(y, quake->GetModWave(quake->m_WaveSpeedY)); fixed_t mz = FixedMul(z, quake->GetModWave(quake->m_WaveSpeedZ)); @@ -304,7 +390,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, - double waveSpeedX, double waveSpeedY, double waveSpeedZ) + double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint) { AActor *center; bool res = false; @@ -318,7 +404,7 @@ bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, if (activator != NULL) { new DEarthquake(activator, intensityX, intensityY, intensityZ, duration, damrad, tremrad, - quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ); + quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint); return true; } } @@ -329,7 +415,7 @@ bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, { res = true; new DEarthquake(center, intensityX, intensityY, intensityZ, duration, damrad, tremrad, - quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ); + quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint); } } @@ -337,6 +423,6 @@ bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, } bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) -{ //Maintains original behavior by passing 0 to intensityZ, and flags. - return P_StartQuakeXYZ(activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0, 0, 0, 0); +{ //Maintains original behavior by passing 0 to intensityZ, flags, and everything else after QSFX. + return P_StartQuakeXYZ(activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0, 0, 0, 0, 0, 0); } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 1e59bf740..1d5fd4ba5 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -157,6 +157,7 @@ struct FQuakeJiggers int RelIntensityX, RelIntensityY, RelIntensityZ; int OffsetX, OffsetY, OffsetZ; int RelOffsetX, RelOffsetY, RelOffsetZ; + int Falloff, WFalloff; }; class DEarthquake : public DThinker @@ -166,7 +167,7 @@ class DEarthquake : public DThinker public: DEarthquake(AActor *center, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, - double waveSpeedX, double waveSpeedY, double waveSpeedZ); + double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint); void Serialize (FArchive &arc); void Tick (); @@ -178,9 +179,12 @@ public: int m_Flags; fixed_t m_IntensityX, m_IntensityY, m_IntensityZ; float m_WaveSpeedX, m_WaveSpeedY, m_WaveSpeedZ; + fixed_t m_Falloff; + int m_Highpoint, m_MiniCount; fixed_t GetModIntensity(int intensity) const; fixed_t GetModWave(double waveMultiplier) const; + fixed_t GetFalloff(fixed_t dist) const; static int StaticGetQuakeIntensities(AActor *viewer, FQuakeJiggers &jiggers); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 11b169e6a..fe10921d0 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -5747,7 +5747,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) argCount > 8 ? args[8] : 0, argCount > 9 ? FIXED2DBL(args[9]) : 1.0, argCount > 10 ? FIXED2DBL(args[10]) : 1.0, - argCount > 11 ? FIXED2DBL(args[11]) : 1.0 ); + argCount > 11 ? FIXED2DBL(args[11]) : 1.0, + argCount > 12 ? args[12] : 0, + argCount > 13 ? args[13] : 0); } case ACSF_SetLineActivation: diff --git a/src/p_spec.h b/src/p_spec.h index e3b1c05ad..83a50e252 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -944,7 +944,7 @@ void P_DoDeferedScripts (void); // // [RH] p_quake.c // -bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ); +bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint); bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); #endif diff --git a/src/r_utility.cpp b/src/r_utility.cpp index f4bd85a9a..a5a422426 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -896,10 +896,9 @@ void R_AddInterpolationPoint(const fixedvec3a &vec) // //========================================================================== -static fixed_t QuakePower(fixed_t factor, fixed_t intensity, fixed_t offset) +static fixed_t QuakePower(fixed_t factor, fixed_t intensity, fixed_t offset, fixed_t falloff, fixed_t wfalloff) { fixed_t randumb; - if (intensity == 0) { randumb = 0; @@ -908,7 +907,8 @@ static fixed_t QuakePower(fixed_t factor, fixed_t intensity, fixed_t offset) { randumb = pr_torchflicker(intensity * 2) - intensity; } - return FixedMul(factor, randumb + offset); + fixed_t rn2 = (FixedMul(wfalloff,offset) + FixedMul(falloff, randumb)); + return FixedMul(factor, rn2); } //========================================================================== @@ -1050,34 +1050,33 @@ void R_SetupFrame (AActor *actor) if ((jiggers.RelIntensityX | jiggers.RelOffsetX) != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityX, jiggers.RelOffsetX); + fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityX, jiggers.RelOffsetX, jiggers.Falloff, jiggers.WFalloff); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if ((jiggers.RelIntensityY | jiggers.RelOffsetY) != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityY, jiggers.RelOffsetY); + fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityY, jiggers.RelOffsetY, jiggers.Falloff, jiggers.WFalloff); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } // FIXME: Relative Z is not relative - // [MC]On it! Will be introducing pitch after QF_WAVE. if ((jiggers.RelIntensityZ | jiggers.RelOffsetZ) != 0) { - viewz += QuakePower(quakefactor, jiggers.RelIntensityZ, jiggers.RelOffsetZ); + viewz += QuakePower(quakefactor, jiggers.RelIntensityZ, jiggers.RelOffsetZ, jiggers.Falloff, jiggers.WFalloff); } if ((jiggers.IntensityX | jiggers.OffsetX) != 0) { - viewx += QuakePower(quakefactor, jiggers.IntensityX, jiggers.OffsetX); + viewx += QuakePower(quakefactor, jiggers.IntensityX, jiggers.OffsetX, jiggers.Falloff, jiggers.WFalloff); } if ((jiggers.IntensityY | jiggers.OffsetY) != 0) { - viewy += QuakePower(quakefactor, jiggers.IntensityY, jiggers.OffsetY); + viewy += QuakePower(quakefactor, jiggers.IntensityY, jiggers.OffsetY, jiggers.Falloff, jiggers.WFalloff); } if ((jiggers.IntensityZ | jiggers.OffsetZ) != 0) { - viewz += QuakePower(quakefactor, jiggers.IntensityZ, jiggers.OffsetZ); + viewz += QuakePower(quakefactor, jiggers.IntensityZ, jiggers.OffsetZ, jiggers.Falloff, jiggers.WFalloff); } } } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index c5081f57a..9a492130b 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4969,7 +4969,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Quake) // A_QuakeEx // // Extended version of A_Quake. Takes individual axis into account and can -// take a flag. +// take flags. //=========================================================================== DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_QuakeEx) @@ -4986,7 +4986,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_QuakeEx) PARAM_FLOAT_OPT(mulWaveX) { mulWaveX = 1.; } PARAM_FLOAT_OPT(mulWaveY) { mulWaveY = 1.; } PARAM_FLOAT_OPT(mulWaveZ) { mulWaveZ = 1.; } - P_StartQuakeXYZ(self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags, mulWaveX, mulWaveY, mulWaveZ); + PARAM_INT_OPT(falloff) { falloff = 0; } + PARAM_INT_OPT(highpoint) { highpoint = 0; } + P_StartQuakeXYZ(self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags, mulWaveX, mulWaveY, mulWaveZ, falloff, highpoint); return 0; } 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/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index aeeaec813..e4a9b152b 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -277,7 +277,7 @@ ACTOR Actor native //: Thinker action native A_SetUserArray(name varname, int index, int value); action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0); action native A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake"); - action native A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, float mulWaveX = 1, float mulWaveY = 1, float mulWaveZ = 1); + action native A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, float mulWaveX = 1, float mulWaveY = 1, float mulWaveZ = 1, int falloff = 0, int highpoint = 0); action native A_SetTics(int tics); action native A_SetDamageType(name damagetype); action native A_DropItem(class item, int dropamount = -1, int chance = 256); From b16e696157dc6ed9466e3b96d2a3b5e95221a101 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 10 Mar 2016 12:54:23 -0600 Subject: [PATCH 06/12] - Added offset and angle parameters to A_CheckBlock. - Includes 2 flags, affixed by CBF_: AbsolutePos, and AbsoluteAngle. - AbsolutePos: Absolute position of where to check. - AbsoluteAngle: Angle parameter is used as is, not added onto the actor's current angle. --- src/thingdef/thingdef_codeptr.cpp | 52 ++++++++++++++++++++++++++++-- wadsrc/static/actors/actor.txt | 2 +- wadsrc/static/actors/constants.txt | 2 ++ 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 9a492130b..6efbeb167 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -6696,14 +6696,20 @@ enum CBF CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self. CBF_DROPOFF = 1 << 5, //Check for dropoffs. CBF_NOACTORS = 1 << 6, //Don't check actors. + CBF_ABSOLUTEPOS = 1 << 7, //Absolute position for offsets. + CBF_ABSOLUTEANGLE = 1 << 8, //Absolute angle for offsets. }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) { PARAM_ACTION_PROLOGUE; PARAM_STATE(block) - PARAM_INT_OPT(flags) { flags = 0; } - PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } + PARAM_INT_OPT(flags) { flags = 0; } + PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } + PARAM_FIXED_OPT(xofs) { xofs = 0; } + PARAM_FIXED_OPT(yofs) { yofs = 0; } + PARAM_FIXED_OPT(zofs) { zofs = 0; } + PARAM_ANGLE_OPT(angle) { angle = 0; } AActor *mobj = COPY_AAPTR(self, ptr); @@ -6713,8 +6719,48 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) ACTION_RETURN_STATE(NULL); } + if (!(flags & CBF_ABSOLUTEANGLE)) + { + angle += self->angle; + } + + angle_t ang = angle >> ANGLETOFINESHIFT; + fixedvec3 oldpos = mobj->Pos(); + fixedvec3 pos; + + if (flags & CBF_ABSOLUTEPOS) + { + pos.x = xofs; + pos.y = yofs; + pos.z = zofs; + } + else + { + pos = mobj->Vec3Offset( + FixedMul(xofs, finecosine[ang]) + FixedMul(yofs, finesine[ang]), + FixedMul(xofs, finesine[ang]) - FixedMul(yofs, finecosine[ang]), + mobj->Z() + zofs); + } + + // Next, try checking the position based on the sensitivity desired. + // If checking for dropoffs, set the z so we can have maximum flexibility. + // Otherwise, set origin and set it back after testing. + + bool checker = false; + if (flags & CBF_DROPOFF) + { + mobj->SetZ(pos.z); + checker = P_CheckMove(mobj, pos.x, pos.y); + mobj->SetZ(oldpos.z); + } + else + { + mobj->SetOrigin(pos, true); + checker = P_TestMobjLocation(mobj); + mobj->SetOrigin(oldpos, true); + } + //Nothing to block it so skip the rest. - bool checker = (flags & CBF_DROPOFF) ? P_CheckMove(mobj, mobj->X(), mobj->Y()) : P_TestMobjLocation(mobj); if (checker) { ACTION_RETURN_STATE(NULL); diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index e4a9b152b..e3bb06fe7 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -317,7 +317,7 @@ ACTOR Actor native //: Thinker action native A_SetRipMax(int maximum); action native A_SetChaseThreshold(int threshold, bool def = false, int ptr = AAPTR_DEFAULT); action native state A_CheckProximity(state jump, class classname, float distance, int count = 1, int flags = 0, int ptr = AAPTR_DEFAULT); - action native state A_CheckBlock(state block, int flags = 0, int ptr = AAPTR_DEFAULT); + action native state A_CheckBlock(state block, int flags = 0, int ptr = AAPTR_DEFAULT, float xofs = 0, float yofs = 0, float zofs = 0, float angle = 0); action native state A_CheckSightOrRange(float distance, state label, bool two_dimension = false); action native state A_CheckRange(float distance, state label, bool two_dimension = false); action native bool A_FaceMovementDirection(float offset = 0, float anglelimit = 0, float pitchlimit = 0, int flags = 0, int ptr = AAPTR_DEFAULT); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 3060c2c2d..9ccb1fd6e 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -527,6 +527,8 @@ enum CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self. CBF_DROPOFF = 1 << 5, //Check for dropoffs. CBF_NOACTORS = 1 << 6, //Don't check actors. + CBF_ABSOLUTEPOS = 1 << 7, //Absolute position for offsets. + CBF_ABSOLUTEANGLE = 1 << 8, //Absolute angle for offsets. }; enum From 2dbd79cc8d768ffeba5158f202fedaf6fb713ebd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 23 Mar 2016 18:07:04 +0100 Subject: [PATCH 07/12] - floatified the return data from Trace(). --- src/d_net.cpp | 3 +- src/g_shared/a_action.cpp | 2 +- src/g_shared/a_bridge.cpp | 2 +- src/g_shared/a_decals.cpp | 8 +-- src/g_shared/a_quake.cpp | 2 +- src/g_shared/a_randomspawner.cpp | 2 +- src/g_shared/a_spark.cpp | 2 +- src/p_acs.cpp | 2 +- src/p_effect.cpp | 11 ++-- src/p_effect.h | 2 +- src/p_local.h | 6 +- src/p_map.cpp | 99 ++++++++++++++----------------- src/p_mobj.cpp | 2 +- src/p_trace.cpp | 46 +++++++------- src/p_trace.h | 16 ++--- src/r_utility.cpp | 6 +- src/thingdef/thingdef_codeptr.cpp | 2 +- 17 files changed, 105 insertions(+), 108 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 2ebb54377..763b09f22 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2382,8 +2382,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) { if (trace.HitType == TRACE_HitWall) { - DVector3 hp(FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z)); - DImpactDecal::StaticCreate (s, hp, trace.Line->sidedef[trace.Side], NULL); + DImpactDecal::StaticCreate (s, trace.HitPos, trace.Line->sidedef[trace.Side], NULL); } } } diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 50ff5bb90..0e333a46e 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -286,7 +286,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) // with no relation to the size of the self shattering. I think it should // base the number of shards on the size of the dead thing, so bigger // things break up into more shards than smaller things. - // An actor with _f_radius() 20 and height 64 creates ~40 chunks. + // An actor with radius 20 and height 64 creates ~40 chunks. numChunks = MAX(4, int(self->radius * self->Height)/32); i = (pr_freeze.Random2()) % (numChunks/4); for (i = MAX (24, numChunks + i); i >= 0; i--) diff --git a/src/g_shared/a_bridge.cpp b/src/g_shared/a_bridge.cpp index d8c2ccc9c..178f004ca 100644 --- a/src/g_shared/a_bridge.cpp +++ b/src/g_shared/a_bridge.cpp @@ -9,7 +9,7 @@ static FRandom pr_orbit ("Orbit"); // Custom bridge -------------------------------------------------------- /* - args[0]: Bridge _f_radius(), in mapunits + args[0]: Bridge radius, in mapunits args[1]: Bridge height, in mapunits args[2]: Amount of bridge balls (if 0: Doom bridge) args[3]: Rotation speed of bridge balls, in byte angle per seconds, sorta: diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 154347496..8b52240d0 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -777,20 +777,20 @@ DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t * { if (permanent) { - decal = new DBaseDecal(FIXED2DBL(trace.HitPos.z)); + decal = new DBaseDecal(trace.HitPos.Z); wall = trace.Line->sidedef[trace.Side]; - decal->StickToWall(wall, FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), trace.ffloor); + decal->StickToWall(wall, trace.HitPos.X, trace.HitPos.Y, trace.ffloor); tpl->ApplyToDecal(decal, wall); // Spread decal to nearby walls if it does not all fit on this one if (cl_spreaddecals) { - decal->Spread(tpl, wall, FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z), trace.ffloor); + decal->Spread(tpl, wall, trace.HitPos.X, trace.HitPos.Y, trace.HitPos.Z, trace.ffloor); } return decal; } else { - return DImpactDecal::StaticCreate(tpl, DVector3(FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z)), trace.Line->sidedef[trace.Side], NULL); + return DImpactDecal::StaticCreate(tpl, trace.HitPos, trace.Line->sidedef[trace.Side], NULL); } } return NULL; diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index af5bb039f..db8aadadf 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -144,7 +144,7 @@ void DEarthquake::Tick () fixed_t dist; dist = m_Spot->AproxDistance (victim, true); - // Check if in damage _f_radius() + // Check if in damage radius if (dist < m_DamageRadius && victim->Z() <= victim->floorz) { if (pr_quake() < 50) diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index 1f039bda8..ac162a241 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -151,7 +151,7 @@ class ARandomSpawner : public AActor { tracer = target->target; } - newmobj = P_SpawnMissileXYZ(_f_Pos(), target, target->target, cls, false); + newmobj = P_SpawnMissileXYZ(Pos(), target, target->target, cls, false); } else { diff --git a/src/g_shared/a_spark.cpp b/src/g_shared/a_spark.cpp index 557abe5a2..4bc9dc4c4 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, _f_X(), _f_Y(), _f_Z(), FLOAT2ANGLE(Angles.Yaw.Degrees), 1); + P_DrawSplash (args[0] ? args[0] : 32, Pos(), Angles.Yaw, 1); S_Sound (this, CHAN_AUTO, "world/spark", 1, ATTN_STATIC); } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index e024392e5..f3748ec93 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -5789,7 +5789,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) argCount > 8 ? args[8] : 0, argCount > 9 ? ACSToDouble(args[9]) : 1.0, argCount > 10 ? ACSToDouble(args[10]) : 1.0, - argCount > 11 ? ACSToDouble(args[11]) : 1.0 ); + argCount > 11 ? ACSToDouble(args[11]) : 1.0, argCount > 12 ? args[12] : 0, argCount > 13 ? args[13] : 0); } diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 3814d35d8..442d5fd4c 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -545,7 +545,7 @@ void P_RunEffect (AActor *actor, int effects) } } -void P_DrawSplash (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int kind) +void P_DrawSplash (int count, const DVector3 &pos, DAngle angle, int kind) { int color1, color2; @@ -562,7 +562,6 @@ void P_DrawSplash (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, in for (; count; count--) { particle_t *p = JitterParticle (10); - angle_t an; if (!p) break; @@ -573,10 +572,10 @@ void P_DrawSplash (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, in p->accz -= FRACUNIT/8; p->accx += (M_Random () - 128) * 8; p->accy += (M_Random () - 128) * 8; - p->z = z - M_Random () * 1024; - an = (angle + (M_Random() << 21)) >> ANGLETOFINESHIFT; - p->x = x + (M_Random () & 15)*finecosine[an]; - p->y = y + (M_Random () & 15)*finesine[an]; + p->z = FLOAT2FIXED(pos.Z) - M_Random () * 1024; + angle += M_Random() * (45./256); + p->x = FLOAT2FIXED(pos.X + (M_Random() & 15)*angle.Cos()); + p->y = FLOAT2FIXED(pos.Y + (M_Random() & 15)*angle.Sin()); } } diff --git a/src/p_effect.h b/src/p_effect.h index 9bab44a81..4d246af83 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -90,6 +90,6 @@ void P_RunEffects (void); void P_RunEffect (AActor *actor, int effects); void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, angle_t angle = 0, int duration = 35, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270); -void P_DrawSplash (int count, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int kind); +void P_DrawSplash (int count, const DVector3 &pos, DAngle angle, int kind); void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, int kind); void P_DisconnectEffect (AActor *actor); diff --git a/src/p_local.h b/src/p_local.h index 17af47908..bea8d9d20 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -374,6 +374,10 @@ inline void P_TraceBleed(int damage, const fixedvec3 &pos, AActor *target, angle { P_TraceBleed(damage, pos.x, pos.y, pos.z, target, angle, pitch); } +inline void P_TraceBleed(int damage, const DVector3 &pos, AActor *target, DAngle angle, DAngle pitch) +{ + P_TraceBleed(damage, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), target,angle.BAMs(), pitch.BAMs()); +} void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch); inline void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch) { @@ -407,7 +411,7 @@ bool P_CheckMissileSpawn(AActor *missile, double maxdist); void P_PlaySpawnSound(AActor *missile, AActor *spawner); // [RH] Position the chasecam -void P_AimCamera (AActor *t1, fixed_t &x, fixed_t &y, fixed_t &z, sector_t *&sec, bool &unlinked); +void P_AimCamera (AActor *t1, DVector3 &, sector_t *&sec, bool &unlinked); // [RH] Means of death enum diff --git a/src/p_map.cpp b/src/p_map.cpp index f4188e8d1..fb341f285 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4219,7 +4219,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, } if (puffDefaults != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) { // Spawn the puff anyway - puff = P_SpawnPuff(t1, pufftype, trace.HitPos, trace.SrcAngleToTarget, trace.SrcAngleToTarget, 2, puffFlags); + puff = P_SpawnPuff(t1, pufftype, trace.HitPos, trace.SrcAngleFromTarget, trace.SrcAngleFromTarget, 2, puffFlags); } else { @@ -4233,9 +4233,9 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, // position a bit closer for puffs if (trace.HitType != TRACE_HitWall || trace.Line->special != Line_Horizon) { - fixedvec2 pos = P_GetOffsetPosition(trace.HitPos.x, trace.HitPos.y, -trace.HitVector.x * 4, -trace.HitVector.y * 4); - puff = P_SpawnPuff(t1, pufftype, { pos.x, pos.y, trace.HitPos.z - trace.HitVector.z * 4 }, trace.SrcAngleToTarget, - trace.SrcAngleToTarget - ANGLE_90, 0, puffFlags); + DVector2 pos = P_GetOffsetPosition(trace.HitPos.X, trace.HitPos.Y, -trace.HitVector.X * 4, -trace.HitVector.Y * 4); + puff = P_SpawnPuff(t1, pufftype, DVector3(pos, trace.HitPos.Z - trace.HitVector.Z * 4), trace.SrcAngleFromTarget, + trace.SrcAngleFromTarget - 90, 0, puffFlags); puff->radius = 1/65536.; } @@ -4283,16 +4283,15 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, (t1->player->ReadyWeapon->WeaponFlags & WIF_AXEBLOOD)); // Hit a thing, so it could be either a puff or blood - fixedvec3 bleedpos = trace.HitPos; + DVector3 bleedpos = trace.HitPos; // position a bit closer for puffs/blood if using compatibility mode. if (i_compatflags & COMPATF_HITSCAN) { - fixedvec2 ofs = P_GetOffsetPosition(bleedpos.x, bleedpos.y, -10 * trace.HitVector.x, -10 * trace.HitVector.y); - bleedpos.x = ofs.x; - bleedpos.y = ofs.y; - bleedpos.z -= -10 * trace.HitVector.z; + DVector2 ofs = P_GetOffsetPosition(bleedpos.X, bleedpos.Y, -10 * trace.HitVector.X, -10 * trace.HitVector.Y); + bleedpos.X = ofs.X; + bleedpos.Y = ofs.Y; + bleedpos.Z -= -10 * trace.HitVector.Z; } - DVector3 bleedposf(FIXED2DBL(bleedpos.x), FIXED2DBL(bleedpos.y), FIXED2DBL(bleedpos.z)); // Spawn bullet puffs or blood spots, depending on target type. if ((puffDefaults != NULL && puffDefaults->flags3 & MF3_PUFFONACTORS) || @@ -4303,7 +4302,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, puffFlags |= PF_HITTHINGBLEED; // We must pass the unreplaced puff type here - puff = P_SpawnPuff(t1, pufftype, bleedpos, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 2, puffFlags | PF_HITTHING, trace.Actor); + puff = P_SpawnPuff(t1, pufftype, bleedpos, trace.SrcAngleFromTarget, trace.SrcAngleFromTarget - 90, 2, puffFlags | PF_HITTHING, trace.Actor); } // Allow puffs to inflict poison damage, so that hitscans can poison, too. @@ -4329,10 +4328,10 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, { // Since the puff is the damage inflictor we need it here // regardless of whether it is displayed or not. - puff = P_SpawnPuff(t1, pufftype, bleedpos, 0, 0, 2, puffFlags | PF_HITTHING | PF_TEMPORARY); + puff = P_SpawnPuff(t1, pufftype, bleedpos, 0., 0., 2, puffFlags | PF_HITTHING | PF_TEMPORARY); killPuff = true; } - newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags|DMG_USEANGLE, ANGLE2DBL(trace.SrcAngleToTarget)); + newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags|DMG_USEANGLE, trace.SrcAngleFromTarget); if (actualdamage != NULL) { *actualdamage = newdam; @@ -4344,7 +4343,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, !(trace.Actor->flags & MF_NOBLOOD) && !(trace.Actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) { - P_SpawnBlood(bleedposf, ANGLE2DBL(trace.SrcAngleToTarget), newdam > 0 ? newdam : damage, trace.Actor); + P_SpawnBlood(bleedpos, trace.SrcAngleFromTarget, newdam > 0 ? newdam : damage, trace.Actor); } if (damage) @@ -4356,23 +4355,22 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, { if (axeBlood) { - P_BloodSplatter2(bleedposf, trace.Actor, ANGLE2DBL(trace.SrcAngleToTarget)); + P_BloodSplatter2(bleedpos, trace.Actor, trace.SrcAngleFromTarget); } if (pr_lineattack() < 192) { - P_BloodSplatter(bleedposf, trace.Actor, ANGLE2DBL(trace.SrcAngleToTarget)); + P_BloodSplatter(bleedpos, trace.Actor, trace.SrcAngleFromTarget); } } } // [RH] Stick blood to walls - P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos, - trace.Actor, trace.SrcAngleToTarget, srcpitch); + P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos, trace.Actor, trace.SrcAngleFromTarget, ANGLE2DBL(srcpitch)); } } if (victim != NULL) { victim->linetarget = trace.Actor; - victim->angleFromSource = ANGLE2DBL(trace.SrcAngleToTarget); + victim->angleFromSource = trace.SrcAngleFromTarget; victim->unlinked = trace.unlinked; } } @@ -4380,7 +4378,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, { if (puff == NULL) { // Spawn puff just to get a mass for the splash - puff = P_SpawnPuff(t1, pufftype, trace.HitPos, 0, 0, 2, puffFlags | PF_HITTHING | PF_TEMPORARY); + puff = P_SpawnPuff(t1, pufftype, trace.HitPos, 0., 0., 2, puffFlags | PF_HITTHING | PF_TEMPORARY); killPuff = true; } SpawnDeepSplash(t1, trace, puff); @@ -4539,8 +4537,7 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an bloodcolor.a = 1; } - DVector3 hp(FIXED2DBL(bleedtrace.HitPos.x), FIXED2DBL(bleedtrace.HitPos.y), FIXED2DBL(bleedtrace.HitPos.z)); - DImpactDecal::StaticCreate(bloodType, hp, + DImpactDecal::StaticCreate(bloodType, bleedtrace.HitPos, bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor); } } @@ -4629,8 +4626,8 @@ void P_TraceBleed(int damage, AActor *target) struct SRailHit { AActor *HitActor; - fixedvec3 HitPos; - angle_t HitAngle; + DVector3 HitPos; + DAngle HitAngle; }; struct RailData { @@ -4665,13 +4662,13 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) SRailHit newhit; newhit.HitActor = res.Actor; newhit.HitPos = res.HitPos; - newhit.HitAngle = res.SrcAngleToTarget; + newhit.HitAngle = res.SrcAngleFromTarget; if (i_compatflags & COMPATF_HITSCAN) { - fixedvec2 ofs = P_GetOffsetPosition(newhit.HitPos.x, newhit.HitPos.y, -10 * res.HitVector.x, -10 * res.HitVector.y); - newhit.HitPos.x = ofs.x; - newhit.HitPos.y = ofs.y; - newhit.HitPos.z -= -10 * res.HitVector.z; + DVector2 ofs = P_GetOffsetPosition(newhit.HitPos.X, newhit.HitPos.Y, -10 * res.HitVector.X, -10 * res.HitVector.Y); + newhit.HitPos.X = ofs.X; + newhit.HitPos.Y = ofs.Y; + newhit.HitPos.Z -= -10 * res.HitVector.Z; } data->RailHits.Push(newhit); @@ -4759,8 +4756,8 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i int puffflags = PF_HITTHING; AActor *hitactor = rail_data.RailHits[i].HitActor; - fixedvec3 &hitpos = rail_data.RailHits[i].HitPos; - angle_t hitangle = rail_data.RailHits[i].HitAngle; + DVector3 &hitpos = rail_data.RailHits[i].HitPos; + DAngle hitangle = rail_data.RailHits[i].HitAngle; if ((hitactor->flags & MF_NOBLOOD) || (hitactor->flags2 & MF2_DORMANT || ((hitactor->flags2 & MF2_INVULNERABLE) && !(puffDefaults->flags3 & MF3_FOILINVUL)))) @@ -4778,7 +4775,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i } if (spawnpuff) { - P_SpawnPuff(source, puffclass, hitpos, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 1, puffflags, hitactor); + P_SpawnPuff(source, puffclass, hitpos, hitangle, hitangle - 90, 1, puffflags, hitactor); } int dmgFlagPass = DMG_INFLICTOR_IS_PUFF; @@ -4791,13 +4788,12 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i if (puffDefaults->flags3 & MF3_FOILINVUL) dmgFlagPass |= DMG_FOILINVUL; if (puffDefaults->flags7 & MF7_FOILBUDDHA) dmgFlagPass |= DMG_FOILBUDDHA; } - int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, dmgFlagPass|DMG_USEANGLE, ANGLE2DBL(hitangle)); + int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, dmgFlagPass|DMG_USEANGLE, hitangle); if (bleed) { - DVector3 h(FIXED2DBL(hitpos.x), FIXED2DBL(hitpos.y), FIXED2DBL(hitpos.z)); - P_SpawnBlood(h, ANGLE2DBL(hitangle), newdam > 0 ? newdam : damage, hitactor); - P_TraceBleed(newdam > 0 ? newdam : damage, hitpos, hitactor, source->_f_angle(), pitch); + P_SpawnBlood(hitpos, hitangle, newdam > 0 ? newdam : damage, hitactor); + P_TraceBleed(newdam > 0 ? newdam : damage, hitpos, hitactor, hitangle, ANGLE2DBL(pitch)); } } @@ -4808,7 +4804,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i if (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) { - puff = P_SpawnPuff(source, puffclass, trace.HitPos, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 1, 0); + puff = P_SpawnPuff(source, puffclass, trace.HitPos, trace.SrcAngleFromTarget, trace.SrcAngleFromTarget - 90, 1, 0); if (puff && (trace.Line != NULL) && (trace.Line->special == Line_Horizon) && !(puff->flags3 & MF3_SKYEXPLODE)) puff->Destroy(); } @@ -4823,7 +4819,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i AActor* puff = NULL; if (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) { - puff = P_SpawnPuff(source, puffclass, trace.HitPos, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 1, 0); + puff = P_SpawnPuff(source, puffclass, trace.HitPos, trace.SrcAngleFromTarget, trace.SrcAngleFromTarget - 90, 1, 0); if (puff && !(puff->flags3 & MF3_SKYEXPLODE) && (((trace.HitType == TRACE_HitFloor) && (puff->floorpic == skyflatnum)) || ((trace.HitType == TRACE_HitCeiling) && (puff->ceilingpic == skyflatnum)))) @@ -4846,9 +4842,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i } // Draw the slug's trail. - end.X = FIXED2DBL(trace.HitPos.x); - end.Y = FIXED2DBL(trace.HitPos.y); - end.Z = FIXED2DBL(trace.HitPos.z); + end = trace.HitPos; P_DrawRailTrail(source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->_f_angle() + angleoffset, duration, sparsity, drift, SpiralOffset); } @@ -4861,7 +4855,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i CVAR(Float, chase_height, -8.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) 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) +void P_AimCamera(AActor *t1, DVector3 &campos, sector_t *&CameraSector, bool &unlinked) { fixed_t distance = (fixed_t)(clamp(chase_dist, 0, 30000) * FRACUNIT); angle_t angle = (t1->_f_angle() - ANG180) >> ANGLETOFINESHIFT; @@ -4873,23 +4867,21 @@ void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camera vy = FixedMul(finecosine[pitch], finesine[angle]); vz = finesine[pitch]; + DVector3 vvec(vx, vy, vz); + vvec.MakeUnit(); + sz = t1->_f_Z() - t1->_f_floorclip() + t1->_f_height() + (fixed_t)(clamp(chase_height, -1000, 1000) * FRACUNIT); if (Trace(t1->_f_X(), t1->_f_Y(), sz, t1->Sector, vx, vy, vz, distance, 0, 0, NULL, trace) && - trace.Distance > 10 * FRACUNIT) + trace.Distance > 10) { // Position camera slightly in front of hit thing - fixed_t dist = trace.Distance - 5 * FRACUNIT; - CameraX = t1->_f_X() + FixedMul(vx, dist); - CameraY = t1->_f_Y() + FixedMul(vy, dist); - CameraZ = sz + FixedMul(vz, dist); + campos = t1->PosAtZ(FIXED2DBL(sz)) + vvec *(trace.Distance - 5); } else { - CameraX = trace.HitPos.x; - CameraY = trace.HitPos.y; - CameraZ = trace.HitPos.z; + campos = trace.HitPos; } CameraSector = trace.Sector; unlinked = trace.unlinked; @@ -6418,9 +6410,8 @@ void SpawnShootDecal(AActor *t1, const FTraceResults &trace) } if (decalbase != NULL) { - DVector3 hp(FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z)); DImpactDecal::StaticCreate(decalbase->GetDecal(), - hp, trace.Line->sidedef[trace.Side], trace.ffloor); + trace.HitPos, trace.Line->sidedef[trace.Side], trace.ffloor); } } @@ -6432,7 +6423,7 @@ void SpawnShootDecal(AActor *t1, const FTraceResults &trace) static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff) { - const fixedvec3 *hitpos; + const DVector3 *hitpos; if (trace.Crossed3DWater) { hitpos = &trace.Crossed3DWaterPos; @@ -6443,7 +6434,7 @@ static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff } else return; - P_HitWater(puff != NULL ? puff : t1, P_PointInSector(hitpos->x, hitpos->y), *hitpos); + P_HitWater(puff != NULL ? puff : t1, P_PointInSector(*hitpos), *hitpos); } //============================================================================= diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b5e58b0aa..33a318b41 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5203,7 +5203,7 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, const DVector3 &pos, if (!(flags & PF_NORANDOMZ)) z = pr_spawnpuff.Random2() / 64.; - puff = Spawn(pufftype, pos + Vector3(0, 0, z), ALLOW_REPLACE); + puff = Spawn(pufftype, pos + DVector3(0, 0, z), ALLOW_REPLACE); if (puff == NULL) return NULL; if ((puff->flags4 & MF4_RANDOMIZE) && puff->tics > 0) diff --git a/src/p_trace.cpp b/src/p_trace.cpp index bd011e5fc..9ac0f29ca 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -94,9 +94,9 @@ struct FTraceInfo void SetSourcePosition() { - Results->SrcFromTarget = { StartX, StartY, StartZ }; - Results->HitVector = { Vx, Vy, Vz }; - Results->SrcAngleToTarget = R_PointToAngle2(0, 0, Results->HitPos.x - StartX, Results->HitPos.y - StartY); + Results->SrcFromTarget = { FIXED2DBL(StartX), FIXED2DBL(StartY), FIXED2DBL(StartZ) }; + Results->HitVector = { FIXED2DBL(Vx), FIXED2DBL(Vy), FIXED2DBL(Vz) }; + Results->SrcAngleFromTarget = VecToAngle(Results->HitVector); } @@ -122,7 +122,7 @@ bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector, FTraceResults tempResult; memset(&tempResult, 0, sizeof(tempResult)); - tempResult.Fraction = tempResult.Distance = FIXED_MAX; + tempResult.Fraction = tempResult.Distance = NO_VALUE; ptflags = actorMask ? PT_ADDLINES|PT_ADDTHINGS|PT_COMPATIBLE : PT_ADDLINES; @@ -652,10 +652,10 @@ cont: if (Results->HitType == TRACE_HitWall) { - Results->HitPos = { hitx, hity, hitz }; + Results->HitPos = { FIXED2DBL(hitx), FIXED2DBL(hity), FIXED2DBL(hitz) }; SetSourcePosition(); - Results->Distance = dist; - Results->Fraction = in->frac; + Results->Distance = FIXED2DBL(dist); + Results->Fraction = FIXED2DBL(in->frac); Results->Line = in->d.line; Results->Side = lineside; } @@ -779,10 +779,10 @@ cont1: Results->HitType = TRACE_HitActor; - Results->HitPos = { hitx, hity, hitz }; + Results->HitPos = { FIXED2DBL(hitx), FIXED2DBL(hity), FIXED2DBL(hitz) }; SetSourcePosition(); - Results->Distance = dist; - Results->Fraction = in->frac; + Results->Distance = FIXED2DBL(dist); + Results->Fraction = FIXED2DBL(in->frac); Results->Actor = in->d.thing; if (TraceCallback != NULL) @@ -836,7 +836,7 @@ bool FTraceInfo::TraceTraverse (int ptflags) } // We have something closer in the storage for portal subtraces. - if (TempResults->HitType != TRACE_HitNone && in->frac > TempResults->Fraction) + if (TempResults->HitType != TRACE_HitNone && FIXED2DBL(in->frac) > TempResults->Fraction) { break; } @@ -859,7 +859,7 @@ bool FTraceInfo::TraceTraverse (int ptflags) // We still need to do a water check here or this may get missed on occasion if (Results->CrossedWater == NULL && CurSector->heightsec != NULL && - CurSector->heightsec->floorplane.ZatPoint(Results->HitPos) >= Results->HitPos.z) + CurSector->heightsec->floorplane.ZatPoint(Results->HitPos) >= Results->HitPos.Z) { // Save the result so that the water check doesn't destroy it. FTraceResults *res = Results; @@ -896,7 +896,7 @@ bool FTraceInfo::TraceTraverse (int ptflags) if (Results->CrossedWater == NULL && CurSector->heightsec != NULL && - CurSector->heightsec->floorplane.ZatPoint(Results->HitPos) >= Results->HitPos.z) + CurSector->heightsec->floorplane.ZatPoint(Results->HitPos) >= Results->HitPos.Z) { // Save the result so that the water check doesn't destroy it. FTraceResults *res = Results; @@ -913,12 +913,12 @@ bool FTraceInfo::TraceTraverse (int ptflags) if (Results->HitType == TRACE_HitNone && Results->Distance == 0) { Results->HitPos = { - StartX + FixedMul(Vx, MaxDist), - StartY + FixedMul(Vy, MaxDist), - StartZ + FixedMul(Vz, MaxDist) }; + FIXED2DBL(StartX + FixedMul(Vx, MaxDist)), + FIXED2DBL(StartY + FixedMul(Vy, MaxDist)), + FIXED2DBL(StartZ + FixedMul(Vz, MaxDist)) }; SetSourcePosition(); - Results->Distance = MaxDist; - Results->Fraction = FRACUNIT; + Results->Distance = FIXED2DBL(MaxDist); + Results->Fraction = 1.; } return Results->HitType != TRACE_HitNone; } @@ -944,12 +944,12 @@ bool FTraceInfo::CheckPlane (const secplane_t &plane) if (hitdist > EnterDist && hitdist < MaxDist) { Results->HitPos = { - StartX + FixedMul(Vx, hitdist), - StartY + FixedMul(Vy, hitdist), - StartZ + FixedMul(Vz, hitdist) }; + FIXED2DBL(StartX + FixedMul(Vx, hitdist)), + FIXED2DBL(StartY + FixedMul(Vy, hitdist)), + FIXED2DBL(StartZ + FixedMul(Vz, hitdist)) }; SetSourcePosition(); - Results->Distance = hitdist; - Results->Fraction = FixedDiv (hitdist, MaxDist); + Results->Distance = FIXED2DBL(hitdist); + Results->Fraction = FIXED2DBL(FixedDiv (hitdist, MaxDist)); return true; } } diff --git a/src/p_trace.h b/src/p_trace.h index 43203f035..47f56fd0e 100644 --- a/src/p_trace.h +++ b/src/p_trace.h @@ -65,13 +65,13 @@ struct FTraceResults { sector_t *Sector; FTextureID HitTexture; - fixedvec3 HitPos; - fixedvec3 HitVector; - fixedvec3 SrcFromTarget; - angle_t SrcAngleToTarget; + DVector3 HitPos; + DVector3 HitVector; + DVector3 SrcFromTarget; + DAngle SrcAngleFromTarget; - fixed_t Distance; - fixed_t Fraction; + double Distance; + double Fraction; AActor *Actor; // valid if hit an actor @@ -83,9 +83,9 @@ struct FTraceResults F3DFloor *ffloor; sector_t *CrossedWater; // For Boom-style, Transfer_Heights-based deep water - fixedvec3 CrossedWaterPos; // remember the position so that we can use it for spawning the splash + DVector3 CrossedWaterPos; // remember the position so that we can use it for spawning the splash F3DFloor *Crossed3DWater; // For 3D floor-based deep water - fixedvec3 Crossed3DWaterPos; + DVector3 Crossed3DWaterPos; void CopyIfCloser(FTraceResults *other) { diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 0282d79ea..3d945864f 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -966,7 +966,11 @@ void R_SetupFrame (AActor *actor) { sector_t *oldsector = R_PointInSubsector(iview->oviewx, iview->oviewy)->sector; // [RH] Use chasecam view - P_AimCamera (camera, iview->nviewx, iview->nviewy, iview->nviewz, viewsector, unlinked); + DVector3 campos; + P_AimCamera (camera, campos, viewsector, unlinked); + iview->nviewx = FLOAT2FIXED(campos.X); + iview->nviewy = FLOAT2FIXED(campos.Y); + iview->nviewz = FLOAT2FIXED(campos.Z); r_showviewer = true; // Interpolating this is a very complicated thing because nothing keeps track of the aim camera's movement, so whenever we detect a portal transition // it's probably best to just reset the interpolation for this move. diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 497f6e275..5ce83f757 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3843,7 +3843,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) if (trace.HitType == TRACE_HitActor || ((flags & CLOFF_JUMP_ON_MISS) && !lof_data.BadActor && trace.HitType != TRACE_HitNone)) { - if (minrange > 0 && trace.Distance < FLOAT2FIXED(minrange)) + if (minrange > 0 && trace.Distance < minrange) { ACTION_RETURN_STATE(NULL); } From 6557f3b8c834c62d4d640beee90c3c8d2de2b3b7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 23 Mar 2016 20:45:48 +0100 Subject: [PATCH 08/12] - floatified quake and weapon code --- src/b_bot.cpp | 2 +- src/b_think.cpp | 2 +- src/g_shared/a_pickups.h | 16 ++-- src/g_shared/a_quake.cpp | 135 ++++++++++----------------- src/g_shared/a_sharedglobal.h | 25 ++--- src/g_shared/a_weapons.cpp | 8 +- src/p_enemy.cpp | 2 +- src/p_pspr.cpp | 50 +++++----- src/p_pspr.h | 2 +- src/r_things.cpp | 8 +- src/r_utility.cpp | 51 +++++----- src/thingdef/thingdef_properties.cpp | 8 +- src/vectors.h | 10 +- 13 files changed, 140 insertions(+), 179 deletions(-) diff --git a/src/b_bot.cpp b/src/b_bot.cpp index 89b7b9471..3d6c916c6 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -269,7 +269,7 @@ void InitBotStuff() AWeapon *w = (AWeapon*)GetDefaultByType(cls); if (w != NULL) { - w->MoveCombatDist = botinits[i].movecombatdist; + w->MoveCombatDist = botinits[i].movecombatdist/65536.; w->WeaponFlags |= botinits[i].weaponflags; w->ProjectileType = PClass::FindActor(botinits[i].projectile); } diff --git a/src/b_think.cpp b/src/b_think.cpp index 0d02f76f8..dd6ce49aa 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -171,7 +171,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd) angle = player->mo->__f_AngleTo(enemy); if (player->ReadyWeapon == NULL || - player->mo->AproxDistance(enemy) > + player->mo->Distance2D(enemy) > player->ReadyWeapon->MoveCombatDist) { // If a monster, use lower speed (just for cooler apperance while strafing down doomed monster) diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 158c4130d..26b27e202 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -46,7 +46,7 @@ private: struct WeaponInfo { PClassWeapon *Type; - fixed_t Position; + int Position; }; void SetInitialPositions(); void Sort(); @@ -274,7 +274,7 @@ public: virtual void ReplaceClassRef(PClass *oldclass, PClass *newclass); int SlotNumber; - fixed_t SlotPriority; + int SlotPriority; }; class AWeapon : public AInventory @@ -288,18 +288,18 @@ public: int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon int AmmoUse1, AmmoUse2; // How much ammo to use with each shot int Kickback; - fixed_t YAdjust; // For viewing the weapon fullscreen + float YAdjust; // For viewing the weapon fullscreen (visual only so no need to be a double) FSoundIDNoInit UpSound, ReadySound; // Sounds when coming up and idle PClassWeapon *SisterWeaponType; // Another weapon to pick up with this one PClassActor *ProjectileType; // Projectile used by primary attack PClassActor *AltProjectileType; // Projectile used by alternate attack int SelectionOrder; // Lower-numbered weapons get picked first int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo - fixed_t MoveCombatDist; // Used by bots, but do they *really* need it? + double MoveCombatDist; // Used by bots, but do they *really* need it? int ReloadCounter; // For A_CheckForReload - int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) - fixed_t BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs. - fixed_t BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction. + int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double) + float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs. + float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction. // In-inventory instance variables TObjPtr Ammo1, Ammo2; @@ -395,7 +395,7 @@ public: bool TryPickup(AActor *&toucher); void Serialize(FArchive &arc); - fixed_t DropAmmoFactor; + double DropAmmoFactor; }; diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index db8aadadf..8668c2dd6 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -35,26 +35,22 @@ DEarthquake::DEarthquake() // //========================================================================== -DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int intensityZ, int duration, - int damrad, int tremrad, FSoundID quakesound, int flags, - double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint) - : DThinker(STAT_EARTHQUAKE) +DEarthquake::DEarthquake(AActor *center, int intensityX, int intensityY, int intensityZ, int duration, + int damrad, int tremrad, FSoundID quakesound, int flags, + double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint) + : DThinker(STAT_EARTHQUAKE) { m_QuakeSFX = quakesound; m_Spot = center; // Radii are specified in tile units (64 pixels) - m_DamageRadius = damrad << FRACBITS; - m_TremorRadius = tremrad << FRACBITS; - m_IntensityX = intensityX << FRACBITS; - m_IntensityY = intensityY << FRACBITS; - m_IntensityZ = intensityZ << FRACBITS; + m_DamageRadius = damrad; + m_TremorRadius = tremrad; + m_Intensity = DVector3(intensityX, intensityY, intensityZ); m_CountdownStart = duration; m_Countdown = duration; m_Flags = flags; - m_WaveSpeedX = (float)waveSpeedX; - m_WaveSpeedY = (float)waveSpeedY; - m_WaveSpeedZ = (float)waveSpeedZ; - m_Falloff = falloff << FRACBITS; + m_WaveSpeed = DVector3(waveSpeedX, waveSpeedY, waveSpeedZ); + m_Falloff = falloff; m_Highpoint = highpoint; m_MiniCount = highpoint; } @@ -68,46 +64,11 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in void DEarthquake::Serialize (FArchive &arc) { Super::Serialize (arc); - arc << m_Spot << m_IntensityX << m_Countdown + arc << m_Spot << m_Intensity << m_Countdown << m_TremorRadius << m_DamageRadius - << m_QuakeSFX; - if (SaveVersion < 4519) - { - m_IntensityY = m_IntensityX; - m_IntensityZ = 0; - m_Flags = 0; - } - else - { - arc << m_IntensityY << m_IntensityZ << m_Flags; - } - if (SaveVersion < 4520) - { - m_CountdownStart = 0; - } - else - { - arc << m_CountdownStart; - } - if (SaveVersion < 4521) - { - m_WaveSpeedX = m_WaveSpeedY = m_WaveSpeedZ = 0; - m_IntensityX <<= FRACBITS; - m_IntensityY <<= FRACBITS; - m_IntensityZ <<= FRACBITS; - } - else - { - arc << m_WaveSpeedX << m_WaveSpeedY << m_WaveSpeedZ; - } - if (SaveVersion < 4534) - { - m_Falloff = m_Highpoint = m_MiniCount = 0; - } - else - { - arc << m_Falloff << m_Highpoint << m_MiniCount; - } + << m_QuakeSFX << m_Flags << m_CountdownStart + << m_WaveSpeed + << m_Falloff << m_Highpoint << m_MiniCount; } //========================================================================== @@ -141,9 +102,9 @@ void DEarthquake::Tick () if (playeringame[i] && !(players[i].cheats & CF_NOCLIP)) { AActor *victim = players[i].mo; - fixed_t dist; + double dist; - dist = m_Spot->AproxDistance (victim, true); + dist = m_Spot->Distance2D(victim, true); // Check if in damage radius if (dist < m_DamageRadius && victim->Z() <= victim->floorz) { @@ -153,8 +114,8 @@ void DEarthquake::Tick () } // Thrust player around DAngle an = victim->Angles.Yaw + pr_quake(); - victim->Vel.X += FIXED2DBL(m_IntensityX) * an.Cos() * 0.5; - victim->Vel.Y += FIXED2DBL(m_IntensityY) * an.Sin() * 0.5; + victim->Vel.X += m_Intensity.X * an.Cos() * 0.5; + victim->Vel.Y += m_Intensity.Y * an.Sin() * 0.5; } } } @@ -182,10 +143,10 @@ void DEarthquake::Tick () // //========================================================================== -fixed_t DEarthquake::GetModWave(double waveMultiplier) const +double DEarthquake::GetModWave(double waveMultiplier) const { double time = m_Countdown - FIXED2DBL(r_TicFrac); - return FLOAT2FIXED(g_sin(waveMultiplier * time * (M_PI * 2 / TICRATE))); + return g_sin(waveMultiplier * time * (M_PI * 2 / TICRATE)); } //========================================================================== @@ -196,7 +157,7 @@ fixed_t DEarthquake::GetModWave(double waveMultiplier) const // //========================================================================== -fixed_t DEarthquake::GetModIntensity(fixed_t intensity) const +double DEarthquake::GetModIntensity(double intensity) const { assert(m_CountdownStart >= m_Countdown); @@ -255,7 +216,7 @@ fixed_t DEarthquake::GetModIntensity(fixed_t intensity) const scalar = (scalar > divider) ? divider : scalar; } assert(divider > 0); - intensity = Scale(intensity, scalar, divider); + intensity = intensity * scalar / divider; } return intensity; } @@ -265,27 +226,25 @@ fixed_t DEarthquake::GetModIntensity(fixed_t intensity) const // DEarthquake :: GetFalloff // // Given the distance of the player from the quake, find the multiplier. -// Process everything as doubles, and output again as fixed_t (mainly -// because fixed_t was misbehaving here...) // //========================================================================== -fixed_t DEarthquake::GetFalloff(fixed_t dist) const +double DEarthquake::GetFalloff(double dist) const { if ((dist < m_Falloff) || (m_Falloff >= m_TremorRadius) || (m_Falloff <= 0) || (m_TremorRadius - m_Falloff <= 0)) { //Player inside the minimum falloff range, or safety check kicked in. - return FRACUNIT; + return 1.; } else if ((dist > m_Falloff) && (dist < m_TremorRadius)) { //Player inside the radius, and outside the min distance for falloff. - fixed_t tremorsize = m_TremorRadius - m_Falloff; - fixed_t tremordist = dist - m_Falloff; + double tremorsize = m_TremorRadius - m_Falloff; + double tremordist = dist - m_Falloff; assert(tremorsize > 0); - return (FRACUNIT - FixedMul(FRACUNIT,tremordist) / tremorsize); + return (1. - tremordist) / tremorsize; } else { //Shouldn't happen. - return FRACUNIT; + return 1.; } } @@ -315,14 +274,14 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger { if (quake->m_Spot != NULL) { - fixed_t dist = quake->m_Spot->AproxDistance (victim, true); + double dist = quake->m_Spot->Distance2D (victim, true); if (dist < quake->m_TremorRadius) { - fixed_t falloff = quake->GetFalloff(dist); + double falloff = quake->GetFalloff(dist); ++count; - fixed_t x = quake->GetModIntensity(quake->m_IntensityX); - fixed_t y = quake->GetModIntensity(quake->m_IntensityY); - fixed_t z = quake->GetModIntensity(quake->m_IntensityZ); + double x = quake->GetModIntensity(quake->m_Intensity.X); + double y = quake->GetModIntensity(quake->m_Intensity.Y); + double z = quake->GetModIntensity(quake->m_Intensity.Z); if (!(quake->m_Flags & QF_WAVE)) @@ -330,23 +289,23 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger jiggers.Falloff = MAX(falloff, jiggers.Falloff); if (quake->m_Flags & QF_RELATIVE) { - jiggers.RelIntensityX = MAX(x, jiggers.RelIntensityX); - jiggers.RelIntensityY = MAX(y, jiggers.RelIntensityY); - jiggers.RelIntensityZ = MAX(z, jiggers.RelIntensityZ); + jiggers.RelIntensity.X = MAX(x, jiggers.RelIntensity.X); + jiggers.RelIntensity.Y = MAX(y, jiggers.RelIntensity.Y); + jiggers.RelIntensity.Z = MAX(z, jiggers.RelIntensity.Z); } else { - jiggers.IntensityX = MAX(x, jiggers.IntensityX); - jiggers.IntensityY = MAX(y, jiggers.IntensityY); - jiggers.IntensityZ = MAX(z, jiggers.IntensityZ); + jiggers.Intensity.X = MAX(x, jiggers.Intensity.X); + jiggers.Intensity.Y = MAX(y, jiggers.Intensity.Y); + jiggers.Intensity.Z = MAX(z, jiggers.Intensity.Z); } } else { jiggers.WFalloff = MAX(falloff, jiggers.WFalloff); - fixed_t mx = FixedMul(x, quake->GetModWave(quake->m_WaveSpeedX)); - fixed_t my = FixedMul(y, quake->GetModWave(quake->m_WaveSpeedY)); - fixed_t mz = FixedMul(z, quake->GetModWave(quake->m_WaveSpeedZ)); + double mx = x * quake->GetModWave(quake->m_WaveSpeed.X); + double my = y * quake->GetModWave(quake->m_WaveSpeed.Y); + double mz = z * quake->GetModWave(quake->m_WaveSpeed.Z); // [RH] This only gives effect to the last sine quake. I would // prefer if some way was found to make multiples coexist @@ -355,15 +314,15 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger // relative phases. if (quake->m_Flags & QF_RELATIVE) { - jiggers.RelOffsetX = mx; - jiggers.RelOffsetY = my; - jiggers.RelOffsetZ = mz; + jiggers.RelOffset.X = mx; + jiggers.RelOffset.Y = my; + jiggers.RelOffset.Z = mz; } else { - jiggers.OffsetX = mx; - jiggers.OffsetY = my; - jiggers.OffsetZ = mz; + jiggers.Offset.X = mx; + jiggers.Offset.Y = my; + jiggers.Offset.Z = mz; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index c65c0992d..6776fa814 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -154,11 +154,12 @@ enum struct FQuakeJiggers { - int IntensityX, IntensityY, IntensityZ; - int RelIntensityX, RelIntensityY, RelIntensityZ; - int OffsetX, OffsetY, OffsetZ; - int RelOffsetX, RelOffsetY, RelOffsetZ; - int Falloff, WFalloff; + DVector3 Intensity; + DVector3 RelIntensity; + DVector3 Offset; + DVector3 RelOffset; + double Falloff; + double WFalloff; }; class DEarthquake : public DThinker @@ -173,19 +174,19 @@ public: void Serialize (FArchive &arc); void Tick (); TObjPtr m_Spot; - fixed_t m_TremorRadius, m_DamageRadius; + double m_TremorRadius, m_DamageRadius; int m_Countdown; int m_CountdownStart; FSoundID m_QuakeSFX; int m_Flags; - fixed_t m_IntensityX, m_IntensityY, m_IntensityZ; - float m_WaveSpeedX, m_WaveSpeedY, m_WaveSpeedZ; - fixed_t m_Falloff; + DVector3 m_Intensity; + DVector3 m_WaveSpeed; + double m_Falloff; int m_Highpoint, m_MiniCount; - fixed_t GetModIntensity(int intensity) const; - fixed_t GetModWave(double waveMultiplier) const; - fixed_t GetFalloff(fixed_t dist) const; + double GetModIntensity(double intensity) const; + double GetModWave(double waveMultiplier) const; + double GetFalloff(double dist) const; static int StaticGetQuakeIntensities(AActor *viewer, FQuakeJiggers &jiggers); diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 5e00d9025..d0d566fee 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -41,7 +41,7 @@ IMPLEMENT_CLASS(PClassWeapon) PClassWeapon::PClassWeapon() { SlotNumber = -1; - SlotPriority = FIXED_MAX; + SlotPriority = INT_MAX; } void PClassWeapon::DeriveData(PClass *newclass) @@ -762,8 +762,8 @@ bool AWeaponGiver::TryPickup(AActor *&toucher) // If DropAmmoFactor is non-negative, modify the given ammo amounts. if (DropAmmoFactor > 0) { - weap->AmmoGive1 = FixedMul(weap->AmmoGive1, DropAmmoFactor); - weap->AmmoGive2 = FixedMul(weap->AmmoGive2, DropAmmoFactor); + weap->AmmoGive1 = int(weap->AmmoGive1 * DropAmmoFactor); + weap->AmmoGive2 = int(weap->AmmoGive2 * DropAmmoFactor); } weap->BecomeItem(); } @@ -984,7 +984,7 @@ void FWeaponSlot::Sort() for (i = 1; i < (int)Weapons.Size(); ++i) { - fixed_t pos = Weapons[i].Position; + int pos = Weapons[i].Position; PClassWeapon *type = Weapons[i].Type; for (j = i - 1; j >= 0 && Weapons[j].Position > pos; --j) { diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index a75aa891b..64161014c 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -3130,7 +3130,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount) } else if (inv->IsKindOf (RUNTIME_CLASS(AWeaponGiver))) { - static_cast(inv)->DropAmmoFactor = dropammofactor; + static_cast(inv)->DropAmmoFactor = FIXED2DBL(dropammofactor); inv->ItemFlags |= flagmask; } else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon))) diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 7b1dbc50d..ed578dd8e 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -367,12 +367,12 @@ void P_DropWeapon (player_t *player) // //============================================================================ -void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y) +void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y) { - static fixed_t curbob; + static float curbob; AWeapon *weapon; - fixed_t bobtarget; + float bobtarget; weapon = player->ReadyWeapon; @@ -384,26 +384,26 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y) // [XA] Get the current weapon's bob properties. int bobstyle = weapon->BobStyle; - int bobspeed = (weapon->BobSpeed * 128) >> 16; - fixed_t rangex = weapon->BobRangeX; - fixed_t rangey = weapon->BobRangeY; + float BobSpeed = (weapon->BobSpeed * 128); + float Rangex = weapon->BobRangeX; + float Rangey = weapon->BobRangeY; // Bob the weapon based on movement speed. - int angle = (bobspeed*35/TICRATE*level.time)&FINEMASK; + FAngle angle = (BobSpeed * 35 / TICRATE*level.time) * (360.f / 8192.f); // [RH] Smooth transitions between bobbing and not-bobbing frames. // This also fixes the bug where you can "stick" a weapon off-center by // shooting it when it's at the peak of its swing. - bobtarget = (player->WeaponState & WF_WEAPONBOBBING) ? FLOAT2FIXED(player->bob) : 0; + bobtarget = float((player->WeaponState & WF_WEAPONBOBBING) ? player->bob : 0.); if (curbob != bobtarget) { - if (abs (bobtarget - curbob) <= 1*FRACUNIT) + if (fabsf (bobtarget - curbob) <= 1) { curbob = bobtarget; } else { - fixed_t zoom = MAX (1*FRACUNIT, abs (curbob - bobtarget) / 40); + float zoom = MAX (1.f, fabsf (curbob - bobtarget) / 40); if (curbob > bobtarget) { curbob -= zoom; @@ -417,38 +417,38 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y) if (curbob != 0) { - fixed_t bobx = fixed_t(player->bob * rangex); - fixed_t boby = fixed_t(player->bob * rangey); - switch (bobstyle) + float bobx = float(player->bob * Rangex); + float boby = float(player->bob * Rangey); + switch (level.levelnum)//bobstyle) { case AWeapon::BobNormal: - *x = FixedMul(bobx, finecosine[angle]); - *y = FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]); + *x = bobx * angle.Cos(); + *y = boby * fabsf(angle.Sin()); break; case AWeapon::BobInverse: - *x = FixedMul(bobx, finecosine[angle]); - *y = boby - FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]); + *x = bobx*angle.Cos(); + *y = boby * (1.f - fabsf(angle.Sin())); break; case AWeapon::BobAlpha: - *x = FixedMul(bobx, finesine[angle]); - *y = FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]); + *x = bobx * angle.Sin(); + *y = boby * fabsf(angle.Sin()); break; case AWeapon::BobInverseAlpha: - *x = FixedMul(bobx, finesine[angle]); - *y = boby - FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]); + *x = bobx * angle.Sin(); + *y = boby * (1.f - fabsf(angle.Sin())); break; case AWeapon::BobSmooth: - *x = FixedMul(bobx, finecosine[angle]); - *y = (boby - FixedMul(boby, finecosine[angle*2 & (FINEANGLES-1)])) / 2; + *x = bobx*angle.Cos(); + *y = 0.5f * (boby * (1.f - fabsf((angle * 2).Cos()))); break; case AWeapon::BobInverseSmooth: - *x = FixedMul(bobx, finecosine[angle]); - *y = (FixedMul(boby, finecosine[angle*2 & (FINEANGLES-1)]) + boby) / 2; + *x = bobx*angle.Cos(); + *y = 0.5f * (boby * (1.f + fabsf((angle * 2).Cos()))); } } else diff --git a/src/p_pspr.h b/src/p_pspr.h index 2f19eb4e8..7045f96a5 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -87,7 +87,7 @@ void P_CalcSwing (player_t *player); void P_BringUpWeapon (player_t *player); void P_FireWeapon (player_t *player); void P_DropWeapon (player_t *player); -void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y); +void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y); DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0); void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch); diff --git a/src/r_things.cpp b/src/r_things.cpp index fa5145001..1e26d2f90 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1350,12 +1350,12 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ { if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) { - vis->texturemid -= weapon->YAdjust; + vis->texturemid -= FLOAT2FIXED(weapon->YAdjust); } else { vis->texturemid -= FixedMul (StatusBar->GetDisplacement (), - weapon->YAdjust); + FLOAT2FIXED(weapon->YAdjust)); } } } @@ -1575,7 +1575,7 @@ void R_DrawPlayerSprites () if (camera->player != NULL) { fixed_t centerhack = centeryfrac; - fixed_t ofsx, ofsy; + float ofsx, ofsy; centery = viewheight >> 1; centeryfrac = centery << FRACBITS; @@ -1590,7 +1590,7 @@ void R_DrawPlayerSprites () // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. if (psp->state && (i != ps_targetcenter || CrosshairImage == NULL)) { - R_DrawPSprite (psp, i, camera, FLOAT2FIXED(psp->sx) + ofsx, FLOAT2FIXED(psp->sy) + ofsy); + R_DrawPSprite (psp, i, camera, FLOAT2FIXED(psp->sx + ofsx), FLOAT2FIXED(psp->sy + ofsy)); } // [RH] Don't bob the targeter. if (i == ps_flash) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 3d945864f..3bc2db6cd 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -897,19 +897,18 @@ void R_AddInterpolationPoint(const fixedvec3a &vec) // //========================================================================== -static fixed_t QuakePower(fixed_t factor, fixed_t intensity, fixed_t offset, fixed_t falloff, fixed_t wfalloff) +static double QuakePower(double factor, double intensity, double offset, double falloff, double wfalloff) { - fixed_t randumb; + double randumb; if (intensity == 0) { randumb = 0; } else { - randumb = pr_torchflicker(intensity * 2) - intensity; + randumb = pr_torchflicker.GenRand_Real2() * (intensity * 2) - intensity; } - fixed_t rn2 = (FixedMul(wfalloff,offset) + FixedMul(falloff, randumb)); - return FixedMul(factor, rn2); + return factor * (wfalloff * offset + falloff * randumb); } //========================================================================== @@ -1046,42 +1045,44 @@ void R_SetupFrame (AActor *actor) if (!paused) { - FQuakeJiggers jiggers = { 0, }; + FQuakeJiggers jiggers; + memset(&jiggers, 0, sizeof(jiggers)); if (DEarthquake::StaticGetQuakeIntensities(camera, jiggers) > 0) { - fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); + double quakefactor = r_quakeintensity; + DAngle an; - if ((jiggers.RelIntensityX | jiggers.RelOffsetX) != 0) + if (jiggers.RelIntensity.X != 0 || jiggers.RelOffset.X != 0) { - int ang = (camera->_f_angle()) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityX, jiggers.RelOffsetX, jiggers.Falloff, jiggers.WFalloff); - viewx += FixedMul(finecosine[ang], power); - viewy += FixedMul(finesine[ang], power); + an = camera->Angles.Yaw; + double power = QuakePower(quakefactor, jiggers.RelIntensity.X, jiggers.RelOffset.X, jiggers.Falloff, jiggers.WFalloff); + viewx += FLOAT2FIXED(an.Cos() * power); + viewy += FLOAT2FIXED(an.Sin() * power); } - if ((jiggers.RelIntensityY | jiggers.RelOffsetY) != 0) + if (jiggers.RelIntensity.Y != 0 || jiggers.RelOffset.Y != 0) { - int ang = (camera->_f_angle() + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, jiggers.RelIntensityY, jiggers.RelOffsetY, jiggers.Falloff, jiggers.WFalloff); - viewx += FixedMul(finecosine[ang], power); - viewy += FixedMul(finesine[ang], power); + an = camera->Angles.Yaw + 90; + double power = QuakePower(quakefactor, jiggers.RelIntensity.Y, jiggers.RelOffset.Y, jiggers.Falloff, jiggers.WFalloff); + viewx += FLOAT2FIXED(an.Cos() * power); + viewy += FLOAT2FIXED(an.Sin() * power); } // FIXME: Relative Z is not relative - if ((jiggers.RelIntensityZ | jiggers.RelOffsetZ) != 0) + if (jiggers.RelIntensity.Z != 0 || jiggers.RelOffset.Z != 0) { - viewz += QuakePower(quakefactor, jiggers.RelIntensityZ, jiggers.RelOffsetZ, jiggers.Falloff, jiggers.WFalloff); + viewz += FLOAT2FIXED(QuakePower(quakefactor, jiggers.RelIntensity.Z, jiggers.RelOffset.Z, jiggers.Falloff, jiggers.WFalloff)); } - if ((jiggers.IntensityX | jiggers.OffsetX) != 0) + if (jiggers.Intensity.X != 0 || jiggers.Offset.X != 0) { - viewx += QuakePower(quakefactor, jiggers.IntensityX, jiggers.OffsetX, jiggers.Falloff, jiggers.WFalloff); + viewx += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.X, jiggers.Offset.X, jiggers.Falloff, jiggers.WFalloff)); } - if ((jiggers.IntensityY | jiggers.OffsetY) != 0) + if (jiggers.Intensity.Y != 0 || jiggers.Offset.Y != 0) { - viewy += QuakePower(quakefactor, jiggers.IntensityY, jiggers.OffsetY, jiggers.Falloff, jiggers.WFalloff); + viewy += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.Y, jiggers.Offset.Y, jiggers.Falloff, jiggers.WFalloff)); } - if ((jiggers.IntensityZ | jiggers.OffsetZ) != 0) + if (jiggers.Intensity.Z != 0 || jiggers.Offset.Z != 0) { - viewz += QuakePower(quakefactor, jiggers.IntensityZ, jiggers.OffsetZ, jiggers.Falloff, jiggers.WFalloff); + viewz += FLOAT2FIXED(QuakePower(quakefactor, jiggers.Intensity.Z, jiggers.Offset.Z, jiggers.Falloff, jiggers.WFalloff)); } } } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 8c2a664e2..4ac179305 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -2028,7 +2028,7 @@ DEFINE_CLASS_PROPERTY(upsound, S, Weapon) //========================================================================== DEFINE_CLASS_PROPERTY(yadjust, F, Weapon) { - PROP_FIXED_PARM(i, 0); + PROP_FLOAT_PARM(i, 0); defaults->YAdjust = i; } @@ -2056,7 +2056,7 @@ DEFINE_CLASS_PROPERTY(bobstyle, S, Weapon) //========================================================================== DEFINE_CLASS_PROPERTY(bobspeed, F, Weapon) { - PROP_FIXED_PARM(i, 0); + PROP_FLOAT_PARM(i, 0); defaults->BobSpeed = i; } @@ -2065,7 +2065,7 @@ DEFINE_CLASS_PROPERTY(bobspeed, F, Weapon) //========================================================================== DEFINE_CLASS_PROPERTY(bobrangex, F, Weapon) { - PROP_FIXED_PARM(i, 0); + PROP_FLOAT_PARM(i, 0); defaults->BobRangeX = i; } @@ -2074,7 +2074,7 @@ DEFINE_CLASS_PROPERTY(bobrangex, F, Weapon) //========================================================================== DEFINE_CLASS_PROPERTY(bobrangey, F, Weapon) { - PROP_FIXED_PARM(i, 0); + PROP_FLOAT_PARM(i, 0); defaults->BobRangeY = i; } diff --git a/src/vectors.h b/src/vectors.h index cbc221b1f..cc51f779f 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -1041,14 +1041,14 @@ struct TAngle return FLOAT2ANGLE(Degrees) >> 16; } - double Cos() const + vec_t Cos() const { - return g_cosdeg(Degrees); + return vec_t(g_cosdeg(Degrees)); } - double Sin() const + vec_t Sin() const { - return g_sindeg(Degrees); + return vec_t(g_sindeg(Degrees)); } double Tan() const @@ -1354,7 +1354,7 @@ typedef TVector2 FVector2; typedef TVector3 FVector3; typedef TRotator FRotator; typedef TMatrix3x3 FMatrix3x3; -//typedef TAngle FAngle; +typedef TAngle FAngle; typedef TVector2 DVector2; typedef TVector3 DVector3; From 4a7960232594fef677f4053df2b07d6b128e9b2b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 01:46:11 +0100 Subject: [PATCH 09/12] - floatification of g_shared. - rewrote FraggleScript's movecamera function because it was utterly incomprehensible. --- src/am_map.cpp | 5 +- src/fragglescript/t_func.cpp | 182 +++++------------------- src/fragglescript/t_oper.cpp | 3 +- src/g_level.h | 28 ++-- src/g_shared/a_armor.cpp | 8 +- src/g_shared/a_artifacts.h | 2 - src/g_shared/a_decals.cpp | 4 +- src/g_shared/a_pickups.cpp | 10 +- src/g_shared/a_quake.cpp | 2 +- src/g_shared/a_weapons.cpp | 4 +- src/g_shared/hudmessages.cpp | 34 +++-- src/g_shared/sbar.h | 11 +- src/g_shared/sbarinfo.cpp | 93 ++++++------ src/g_shared/sbarinfo.h | 9 +- src/g_shared/sbarinfo_commands.cpp | 72 +++++----- src/g_shared/shared_hud.cpp | 33 ++--- src/g_shared/shared_sbar.cpp | 54 +++---- src/g_skill.cpp | 84 +++++------ src/g_strife/strife_sbar.cpp | 4 +- src/intermission/intermission.cpp | 2 +- src/intermission/intermission_parse.cpp | 8 +- src/p_acs.cpp | 10 +- src/p_enemy.cpp | 16 +-- src/p_mobj.cpp | 4 +- src/p_trace.h | 9 ++ src/r_things.cpp | 3 +- src/r_utility.cpp | 2 + src/r_utility.h | 1 + src/thingdef/thingdef_parse.cpp | 2 +- src/vectors.h | 2 +- 30 files changed, 283 insertions(+), 418 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 2da1dee9c..7a556542a 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -957,10 +957,9 @@ void AM_StaticInit() // //============================================================================= -void AM_GetPosition(fixed_t &x, fixed_t &y) +DVector2 AM_GetPosition() { - x = (m_x + m_w/2) << FRACTOMAPBITS; - y = (m_y + m_h/2) << FRACTOMAPBITS; + return DVector2((m_x + m_w / 2) / MAPUNIT, (m_y + m_h / 2) / MAPUNIT); } //============================================================================= diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 40349d038..283f8d94f 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -69,6 +69,7 @@ #include "farchive.h" #include "p_setup.h" #include "p_spec.h" +#include "r_utility.h" #include "math/cmath.h" static FRandom pr_script("FScript"); @@ -1463,6 +1464,7 @@ void FParser::SF_SetCamera(void) if (t_argc < 4) newcamera->Angles.Pitch = 0.; else newcamera->Angles.Pitch = clamp(floatvalue(t_argv[3]), -50., 50.) * (20. / 32.); player->camera=newcamera; + R_ResetViewInterpolation(); } } @@ -3052,173 +3054,57 @@ void FParser::SF_SetWeapon() // // movecamera(camera, targetobj, targetheight, movespeed, targetangle, anglespeed) // +// This has been completely rewritten in a sane fashion, using actual vector math. +// //========================================================================== void FParser::SF_MoveCamera(void) { - fixed_t x, y, z; - fixed_t zdist, xydist, movespeed; - fixed_t xstep, ystep, zstep, targetheight; - angle_t anglespeed, anglestep, angledist, targetangle, bigangle, smallangle; - DAngle mobjangle; - - // I have to use floats for the math where angles are divided - // by fixed values. - double fangledist, fanglestep, fmovestep; - int angledir; - AActor* target; - int moved; - int quad1, quad2; - AActor * cam; - - angledir = moved = 0; - if (CheckArgs(6)) { - cam = actorvalue(t_argv[0]); - target = actorvalue(t_argv[1]); - if(!cam || !target) + AActor *cam = actorvalue(t_argv[0]); + AActor *target = actorvalue(t_argv[1]); + if(!cam || !target) { script_error("invalid target for camera\n"); return; } - DVector2 fdist = cam->Vec2To(target); - fixed_t distx = FLOAT2FIXED(fdist.X); - fixed_t disty = FLOAT2FIXED(fdist.Y); - fixed_t camx = FLOAT2FIXED(cam->X()); - fixed_t camy = FLOAT2FIXED(cam->Y()); - fixed_t camz = FLOAT2FIXED(cam->Z()); + double targetheight = floatvalue(t_argv[2]); + DVector3 campos = cam->Pos(); + DVector3 targpos = DVector3(target->Pos(), targetheight); + if (campos != targpos) + { + DVector3 movement = targpos - campos; + double movelen = movement.Length(); + double movespeed = floatvalue(t_argv[3]); + DVector3 movepos; + bool finished = (movespeed >= movelen); + if (finished) movepos = targpos; + else movepos = campos + movement.Resized(movespeed); - - targetheight = fixedvalue(t_argv[2]); - movespeed = fixedvalue(t_argv[3]); - targetangle = (angle_t)FixedToAngle(fixedvalue(t_argv[4])); - anglespeed = (angle_t)FixedToAngle(fixedvalue(t_argv[5])); - - // figure out how big one step will be - zdist = targetheight - camz; - - // Angle checking... - // 90 - // Q1|Q0 - //180--+--0 - // Q2|Q3 - // 270 - angle_t camangle = cam->Angles.Yaw.BAMs(); - quad1 = targetangle / ANG90; - 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 > camangle ? 1 : -1; - } - else - { - angle_t diff180 = (bigangle + ANG180) - (smallangle + ANG180); - - if(quad2 == 3 && quad1 == 0) + DAngle targetangle = floatvalue(t_argv[4]); + DAngle anglespeed = floatvalue(t_argv[5]); + DAngle diffangle = deltaangle(cam->Angles.Yaw, targetangle); + + if (movespeed > 0 && anglespeed == 0.) { - angledist = diff180; - angledir = 1; - } - else if(quad1 == 3 && quad2 == 0) - { - angledist = diff180; - angledir = -1; + if (!finished) targetangle = diffangle * movespeed / movelen; } else { - angledist = bigangle - smallangle; - if(angledist > ANG180) - { - angledist = diff180; - angledir = targetangle > camangle ? -1 : 1; - } - else - angledir = targetangle > camangle ? 1 : -1; + targetangle = cam->Angles.Yaw + anglespeed; } - } - - // set step variables based on distance and speed - mobjangle = cam->AngleTo(target); - xydist = FLOAT2FIXED(cam->Distance2D(target, true)); - - xstep = (fixed_t)(movespeed * mobjangle.Cos()); - ystep = (fixed_t)(movespeed * mobjangle.Sin()); - - if(xydist && movespeed) - zstep = FixedDiv(zdist, FixedDiv(xydist, movespeed)); - else - zstep = zdist > 0 ? movespeed : -movespeed; - - if(xydist && movespeed && !anglespeed) - { - fangledist = ((double)angledist / (ANG45/45)); - fmovestep = ((double)FixedDiv(xydist, movespeed) / FRACUNIT); - if(fmovestep) - fanglestep = fangledist / fmovestep; - else - fanglestep = 360; - - anglestep =(angle_t) (fanglestep * (ANG45/45)); - } - else - anglestep = anglespeed; - - if(abs(xstep) >= (abs(distx) - 1)) - x = camx + distx; - else - { - x = camx + xstep; - moved = 1; - } - - if(abs(ystep) >= (abs(disty) - 1)) - y = camy + disty; - else - { - y = camy + ystep; - moved = 1; - } - - if(abs(zstep) >= (abs(zdist) - 1)) - z = targetheight; - else - { - z = camz + zstep; - moved = 1; - } - - if(anglestep >= angledist) - cam->Angles.Yaw = ANGLE2DBL(targetangle); - else - { - if(angledir == 1) - { - cam->Angles.Yaw += ANGLE2DBL(anglestep); - moved = 1; - } - else if(angledir == -1) - { - cam->Angles.Yaw -= ANGLE2DBL(anglestep); - moved = 1; - } - } - cam->radius = 1 / 8192.; - cam->Height = 1 / 8192.; - if ((x != camx || y != camy) && !P_TryMove(cam, FIXED2FLOAT(x), FIXED2FLOAT(y), true)) - { - Printf("Illegal camera move to (%f, %f)\n", x/65536.f, y/65536.f); - return; + cam->radius = 1 / 8192.; + cam->Height = 1 / 8192.; + cam->SetOrigin(movepos, true); + t_return.value.i = 1; + } + else + { + t_return.value.i = 0; } - cam->SetZ(FIXED2FLOAT(z)); - t_return.type = svt_int; - t_return.value.i = moved; } } diff --git a/src/fragglescript/t_oper.cpp b/src/fragglescript/t_oper.cpp index c85bdf9c3..31673eb54 100644 --- a/src/fragglescript/t_oper.cpp +++ b/src/fragglescript/t_oper.cpp @@ -360,8 +360,7 @@ void FParser::OPmultiply(svalue_t &result,int start, int n, int stop) // haleyjd: 8-17 if(left.type == svt_fixed || right.type == svt_fixed) { - result.type = svt_fixed; - result.value.f = FixedMul(fixedvalue(left), fixedvalue(right)); + result.setDouble(floatvalue(left) * floatvalue(right)); } else { diff --git a/src/g_level.h b/src/g_level.h index 2468ff658..3b320bddb 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -545,30 +545,31 @@ void G_ClearHubInfo(); enum ESkillProperty { - SKILLP_AmmoFactor, - SKILLP_DropAmmoFactor, SKILLP_FastMonsters, SKILLP_Respawn, SKILLP_RespawnLimit, - SKILLP_Aggressiveness, SKILLP_DisableCheats, SKILLP_AutoUseHealth, SKILLP_SpawnFilter, SKILLP_EasyBossBrain, SKILLP_ACSReturn, - SKILLP_MonsterHealth, - SKILLP_FriendlyHealth, SKILLP_NoPain, - SKILLP_ArmorFactor, - SKILLP_HealthFactor, SKILLP_EasyKey, SKILLP_SlowMonsters, SKILLP_Infight, }; enum EFSkillProperty // floating point properties { + SKILLP_AmmoFactor, + SKILLP_DropAmmoFactor, + SKILLP_ArmorFactor, + SKILLP_HealthFactor, SKILLP_DamageFactor, + SKILLP_Aggressiveness, + SKILLP_MonsterHealth, + SKILLP_FriendlyHealth, }; + int G_SkillProperty(ESkillProperty prop); double G_SkillProperty(EFSkillProperty prop); const char * G_SkillName(); @@ -580,8 +581,11 @@ typedef TMap SkillActorReplacement; struct FSkillInfo { FName Name; - fixed_t AmmoFactor, DoubleAmmoFactor, DropAmmoFactor; + double AmmoFactor, DoubleAmmoFactor, DropAmmoFactor; double DamageFactor; + double ArmorFactor; + double HealthFactor; + bool FastMonsters; bool SlowMonsters; bool DisableCheats; @@ -591,7 +595,7 @@ struct FSkillInfo bool EasyKey; int RespawnCounter; int RespawnLimit; - fixed_t Aggressiveness; + double Aggressiveness; int SpawnFilter; int ACSReturn; FString MenuName; @@ -603,12 +607,10 @@ struct FSkillInfo FString TextColor; SkillActorReplacement Replace; SkillActorReplacement Replaced; - fixed_t MonsterHealth; - fixed_t FriendlyHealth; + double MonsterHealth; + double FriendlyHealth; bool NoPain; int Infighting; - fixed_t ArmorFactor; - fixed_t HealthFactor; FSkillInfo() {} FSkillInfo(const FSkillInfo &other) diff --git a/src/g_shared/a_armor.cpp b/src/g_shared/a_armor.cpp index 18ab0f0e0..8b911ce28 100644 --- a/src/g_shared/a_armor.cpp +++ b/src/g_shared/a_armor.cpp @@ -96,13 +96,13 @@ bool ABasicArmor::HandlePickup (AInventory *item) { ABasicArmorBonus *armor = static_cast(item); - armor->SaveAmount = FixedMul(armor->SaveAmount, G_SkillProperty(SKILLP_ArmorFactor)); + armor->SaveAmount = int(armor->SaveAmount * G_SkillProperty(SKILLP_ArmorFactor)); } else if (item->IsKindOf(RUNTIME_CLASS(ABasicArmorPickup)) && !(item->ItemFlags & IF_IGNORESKILL)) { ABasicArmorPickup *armor = static_cast(item); - armor->SaveAmount = FixedMul(armor->SaveAmount, G_SkillProperty(SKILLP_ArmorFactor)); + armor->SaveAmount = int(armor->SaveAmount * G_SkillProperty(SKILLP_ArmorFactor)); } if (Inventory != NULL) { @@ -216,7 +216,7 @@ AInventory *ABasicArmorPickup::CreateCopy (AActor *other) if (!(ItemFlags & IF_IGNORESKILL)) { - SaveAmount = FixedMul(SaveAmount, G_SkillProperty(SKILLP_ArmorFactor)); + SaveAmount = int(SaveAmount * G_SkillProperty(SKILLP_ArmorFactor)); } copy->SavePercent = SavePercent; @@ -298,7 +298,7 @@ AInventory *ABasicArmorBonus::CreateCopy (AActor *other) if (!(ItemFlags & IF_IGNORESKILL)) { - SaveAmount = FixedMul(SaveAmount, G_SkillProperty(SKILLP_ArmorFactor)); + SaveAmount = int(SaveAmount * G_SkillProperty(SKILLP_ArmorFactor)); } copy->SavePercent = SavePercent; diff --git a/src/g_shared/a_artifacts.h b/src/g_shared/a_artifacts.h index 747729423..9ed285ca5 100644 --- a/src/g_shared/a_artifacts.h +++ b/src/g_shared/a_artifacts.h @@ -91,8 +91,6 @@ protected: void DoEffect (); void EndEffect (); int AlterWeaponSprite (visstyle_t *vis); -// FRenderStyle OwnersNormalStyle; -// fixed_t OwnersNormalAlpha; }; class APowerIronFeet : public APowerup diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 8b52240d0..cdf3c2b2e 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -769,9 +769,7 @@ DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t * DBaseDecal *decal; side_t *wall; - Trace(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), sec, - FLOAT2FIXED(angle.Cos()), FLOAT2FIXED(angle.Sin()), 0, - FLOAT2FIXED(tracedist), 0, 0, NULL, trace, TRACE_NoSky); + Trace(DVector3(x,y,z), sec, DVector3(angle.ToVector(), 0), tracedist, 0, 0, NULL, trace, TRACE_NoSky); if (trace.HitType == TRACE_HitWall) { diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 7d579454e..6ad8e6e4a 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -141,7 +141,7 @@ bool AAmmo::HandlePickup (AInventory *item) if (!(item->ItemFlags & IF_IGNORESKILL)) { // extra ammo in baby mode and nightmare mode - receiving = FixedMul(receiving, G_SkillProperty(SKILLP_AmmoFactor)); + receiving = int(receiving * G_SkillProperty(SKILLP_AmmoFactor)); } int oldamount = Amount; @@ -193,7 +193,7 @@ AInventory *AAmmo::CreateCopy (AActor *other) // extra ammo in baby mode and nightmare mode if (!(ItemFlags&IF_IGNORESKILL)) { - amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor)); + amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor)); } if (GetClass()->ParentClass != RUNTIME_CLASS(AAmmo) && GetClass() != RUNTIME_CLASS(AAmmo)) @@ -298,7 +298,7 @@ bool P_GiveBody (AActor *actor, int num, int max) { if (player->health < max) { - num = FixedMul(num, G_SkillProperty(SKILLP_HealthFactor)); + num = int(num * G_SkillProperty(SKILLP_HealthFactor)); if (num < 1) num = 1; player->health += num; if (player->health > max) @@ -1853,7 +1853,7 @@ AInventory *ABackpackItem::CreateCopy (AActor *other) // extra ammo in baby mode and nightmare mode if (!(ItemFlags&IF_IGNORESKILL)) { - amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor)); + amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor)); } if (amount < 0) amount = 0; if (ammo == NULL) @@ -1916,7 +1916,7 @@ bool ABackpackItem::HandlePickup (AInventory *item) // extra ammo in baby mode and nightmare mode if (!(item->ItemFlags&IF_IGNORESKILL)) { - amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor)); + amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor)); } probe->Amount += amount; if (probe->Amount > probe->MaxAmount && !sv_unlimited_pickup) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 8668c2dd6..e16b7e480 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -145,7 +145,7 @@ void DEarthquake::Tick () double DEarthquake::GetModWave(double waveMultiplier) const { - double time = m_Countdown - FIXED2DBL(r_TicFrac); + double time = m_Countdown - r_TicFracF; return g_sin(waveMultiplier * time * (M_PI * 2 / TICRATE)); } diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index d0d566fee..9afa850bd 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -382,7 +382,7 @@ AAmmo *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount) // extra ammo in baby mode and nightmare mode if (!(this->ItemFlags&IF_IGNORESKILL)) { - amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor)); + amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor)); } ammo = static_cast(other->FindInventory (ammotype)); if (ammo == NULL) @@ -418,7 +418,7 @@ bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount) // extra ammo in baby mode and nightmare mode if (!(ItemFlags&IF_IGNORESKILL)) { - amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor)); + amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor)); } ammo->Amount += amount; if (ammo->Amount > ammo->MaxAmount && !sv_unlimited_pickup) diff --git a/src/g_shared/hudmessages.cpp b/src/g_shared/hudmessages.cpp index 3fea0f4c7..8f8100cdc 100644 --- a/src/g_shared/hudmessages.cpp +++ b/src/g_shared/hudmessages.cpp @@ -146,7 +146,7 @@ DHUDMessage::DHUDMessage (FFont *font, const char *text, float x, float y, int h Font = font; VisibilityFlags = 0; Style = STYLE_Translucent; - Alpha = FRACUNIT; + Alpha = 1.; ResetText (SourceText); } @@ -221,7 +221,7 @@ void DHUDMessage::Serialize (FArchive &arc) if (SaveVersion < 3824) { Style = STYLE_Translucent; - Alpha = FRACUNIT; + Alpha = 1.; } else { @@ -474,7 +474,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight) { screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_CleanNoMove, clean, - DTA_Alpha, Alpha, + DTA_AlphaF, Alpha, DTA_RenderStyle, Style, TAG_DONE); } @@ -483,7 +483,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight) screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_VirtualWidth, SCREENWIDTH/2, DTA_VirtualHeight, SCREENHEIGHT/2, - DTA_Alpha, Alpha, + DTA_AlphaF, Alpha, DTA_RenderStyle, Style, DTA_KeepRatio, true, TAG_DONE); @@ -498,7 +498,7 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight) DTA_ClipRight, ClipRight, DTA_ClipTop, ClipTop, DTA_ClipBottom, ClipBot, - DTA_Alpha, Alpha, + DTA_AlphaF, Alpha, DTA_RenderStyle, Style, TAG_DONE); } @@ -570,15 +570,14 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh } else { - fixed_t trans = -(Tics - FadeOutTics) * FRACUNIT / FadeOutTics; - trans = FixedMul(trans, Alpha); + float trans = float(Alpha * -(Tics - FadeOutTics) / FadeOutTics); if (hudheight == 0) { if (con_scaletext <= 1) { screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_CleanNoMove, clean, - DTA_Alpha, trans, + DTA_AlphaF, trans, DTA_RenderStyle, Style, TAG_DONE); } @@ -587,7 +586,7 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_VirtualWidth, SCREENWIDTH/2, DTA_VirtualHeight, SCREENHEIGHT/2, - DTA_Alpha, trans, + DTA_AlphaF, trans, DTA_RenderStyle, Style, DTA_KeepRatio, true, TAG_DONE); @@ -602,7 +601,7 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh DTA_ClipRight, ClipRight, DTA_ClipTop, ClipTop, DTA_ClipBottom, ClipBot, - DTA_Alpha, trans, + DTA_AlphaF, trans, DTA_RenderStyle, Style, TAG_DONE); } @@ -671,15 +670,14 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu { if (State == 0) { - fixed_t trans = Tics * FRACUNIT / FadeInTics; - trans = FixedMul(trans, Alpha); + float trans = float(Alpha * Tics / FadeInTics); if (hudheight == 0) { if (con_scaletext <= 1) { screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_CleanNoMove, clean, - DTA_Alpha, trans, + DTA_AlphaF, trans, DTA_RenderStyle, Style, TAG_DONE); } @@ -688,7 +686,7 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_VirtualWidth, SCREENWIDTH/2, DTA_VirtualHeight, SCREENHEIGHT/2, - DTA_Alpha, trans, + DTA_AlphaF, trans, DTA_RenderStyle, Style, DTA_KeepRatio, true, TAG_DONE); @@ -703,7 +701,7 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu DTA_ClipRight, ClipRight, DTA_ClipTop, ClipTop, DTA_ClipBottom, ClipBot, - DTA_Alpha, trans, + DTA_AlphaF, trans, DTA_RenderStyle, Style, TAG_DONE); } @@ -858,7 +856,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, DTA_CleanNoMove, clean, DTA_TextLen, LineVisible, - DTA_Alpha, Alpha, + DTA_AlphaF, Alpha, DTA_RenderStyle, Style, TAG_DONE); } @@ -869,7 +867,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in DTA_VirtualHeight, SCREENHEIGHT/2, DTA_KeepRatio, true, DTA_TextLen, LineVisible, - DTA_Alpha, Alpha, + DTA_AlphaF, Alpha, DTA_RenderStyle, Style, TAG_DONE); } @@ -883,7 +881,7 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in DTA_ClipRight, ClipRight, DTA_ClipTop, ClipTop, DTA_ClipBottom, ClipBot, - DTA_Alpha, Alpha, + DTA_AlphaF, Alpha, DTA_TextLen, LineVisible, DTA_RenderStyle, Style, TAG_DONE); diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index 3f91c2ee3..560a7500a 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -88,7 +88,7 @@ public: { Style = style; } - void SetAlpha(fixed_t alpha) + void SetAlpha(float alpha) { Alpha = alpha; } @@ -127,7 +127,7 @@ protected: EColorRange TextColor; FFont *Font; FRenderStyle Style; - fixed_t Alpha; + double Alpha; void CalcClipCoords(int hudheight); DHUDMessage () : SourceText(NULL) {} @@ -349,7 +349,7 @@ public: DHUDMessage *DetachMessage (uint32 id); void DetachAllMessages (); void ShowPlayerName (); - fixed_t GetDisplacement () { return Displacement; } + double GetDisplacement() { return Displacement; } int GetPlayer (); static void AddBlend (float r, float g, float b, float a, float v_blend[4]); @@ -380,7 +380,6 @@ protected: void UpdateRect (int x, int y, int width, int height) const; void DrawImage (FTexture *image, int x, int y, FRemapTable *translation=NULL) const; void DrawDimImage (FTexture *image, int x, int y, bool dimmed) const; - void DrawFadedImage (FTexture *image, int x, int y, fixed_t shade) const; void DrawPartialImage (FTexture *image, int wx, int ww) const; void DrINumber (signed int val, int x, int y, int imgBase=imgINumbers) const; @@ -407,8 +406,8 @@ public: bool Centering; bool FixedOrigin; bool CompleteBorder; - fixed_t CrosshairSize; - fixed_t Displacement; + double CrosshairSize; + double Displacement; enum { diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index 3cc4ccc42..eb2a41297 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -76,6 +76,7 @@ EXTERN_CVAR(Bool, vid_fps) EXTERN_CVAR(Bool, hud_scale) class DSBarInfo; +static double nulclip[] = { 0,0,0,0 }; //////////////////////////////////////////////////////////////////////////////// @@ -294,22 +295,22 @@ class SBarInfoMainBlock : public SBarInfoCommandFlowControl { public: SBarInfoMainBlock(SBarInfo *script) : SBarInfoCommandFlowControl(script), - alpha(OPAQUE), currentAlpha(OPAQUE), forceScaled(false), + alpha(1.), currentAlpha(1.), forceScaled(false), fullScreenOffsets(false) { SetTruth(true, NULL, NULL); } - int Alpha() const { return currentAlpha; } + double Alpha() const { return currentAlpha; } // Same as Draw but takes into account ForceScaled and temporarily sets the scaling if needed. - void DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, int alpha); + void DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha); // Silence hidden overload warning since this is a special use class. using SBarInfoCommandFlowControl::Draw; - void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, int xOffset, int yOffset, int alpha) + void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, int xOffset, int yOffset, double alpha) { this->xOffset = xOffset; this->yOffset = yOffset; - this->currentAlpha = FixedMul(this->alpha, alpha); + this->currentAlpha = this->alpha * alpha; SBarInfoCommandFlowControl::Draw(this, statusBar); } bool ForceScaled() const { return forceScaled; } @@ -334,7 +335,7 @@ class SBarInfoMainBlock : public SBarInfoCommandFlowControl } } sc.MustGetToken(TK_FloatConst); - alpha = fixed_t(OPAQUE * sc.Float); + alpha = sc.Float; } SBarInfoCommandFlowControl::Parse(sc, this->fullScreenOffsets); } @@ -343,8 +344,8 @@ class SBarInfoMainBlock : public SBarInfoCommandFlowControl int YOffset() const { return yOffset; } protected: - int alpha; - int currentAlpha; + double alpha; + double currentAlpha; bool forceScaled; bool fullScreenOffsets; int xOffset; @@ -698,24 +699,24 @@ void SBarInfo::ParseSBarInfo(int lump) popup.transition = Popup::TRANSITION_SLIDEINBOTTOM; sc.MustGetToken(','); sc.MustGetToken(TK_IntConst); - popup.speed = sc.Number; + popup.ispeed = sc.Number; } else if(sc.Compare("pushup")) { popup.transition = Popup::TRANSITION_PUSHUP; sc.MustGetToken(','); sc.MustGetToken(TK_IntConst); - popup.speed = sc.Number; + popup.ispeed = sc.Number; } else if(sc.Compare("fade")) { popup.transition = Popup::TRANSITION_FADE; sc.MustGetToken(','); sc.MustGetToken(TK_FloatConst); - popup.speed = fixed_t(FRACUNIT * (1.0 / (35.0 * sc.Float))); + popup.speed = 1.0 / (35.0 * sc.Float); sc.MustGetToken(','); sc.MustGetToken(TK_FloatConst); - popup.speed2 = fixed_t(FRACUNIT * (1.0 / (35.0 * sc.Float))); + popup.speed2 = 1.0 / (35.0 * sc.Float); } else sc.ScriptError("Unkown transition type: '%s'", sc.String); @@ -820,7 +821,7 @@ SBarInfo::~SBarInfo() //Popup Popup::Popup() : transition(TRANSITION_NONE), opened(false), moving(false), - height(320), width(200), speed(0), speed2(0), alpha(FRACUNIT), x(320), + height(320), width(200), ispeed(0), speed(0), speed2(0), alpha(1.), x(320), y(200), displacementX(0), displacementY(0) { } @@ -855,9 +856,9 @@ void Popup::tick() { int oldY = y; if(opened) - y -= clamp(height + (y - height), 1, speed); + y -= clamp(height + (y - height), 1, ispeed); else - y += clamp(height - y, 1, speed); + y += clamp(height - y, 1, ispeed); if(transition == TRANSITION_PUSHUP) displacementY += y - oldY; } @@ -870,11 +871,11 @@ void Popup::tick() if(moving) { if(opened) - alpha = clamp(alpha + speed, 0, OPAQUE); + alpha = clamp(alpha + speed, 0., 1.); else - alpha = clamp(alpha - speed2, 0, OPAQUE); + alpha = clamp(alpha - speed2, 0., 1.); } - if(alpha == 0 || alpha == OPAQUE) + if(alpha == 0 || alpha == 1.) moving = false; else moving = true; @@ -910,9 +911,9 @@ int Popup::getYOffset() return y; } -int Popup::getAlpha(int maxAlpha) +double Popup::getAlpha(double maxAlpha) { - return FixedMul(alpha, maxAlpha); + return alpha * maxAlpha; } int Popup::getXDisplacement() @@ -1057,9 +1058,9 @@ public: } if(currentPopup != POP_None && !script->huds[hud]->FullScreenOffsets()) - script->huds[hud]->Draw(NULL, this, script->popups[currentPopup-1].getXDisplacement(), script->popups[currentPopup-1].getYDisplacement(), FRACUNIT); + script->huds[hud]->Draw(NULL, this, script->popups[currentPopup-1].getXDisplacement(), script->popups[currentPopup-1].getYDisplacement(), 1.); else - script->huds[hud]->Draw(NULL, this, 0, 0, FRACUNIT); + script->huds[hud]->Draw(NULL, this, 0, 0, 1.); lastHud = hud; // Handle inventory bar drawing @@ -1073,7 +1074,7 @@ public: if(inventoryBar->NumCommands() == 0) CPlayer->inventorytics = 0; else - inventoryBar->DrawAux(NULL, this, 0, 0, FRACUNIT); + inventoryBar->DrawAux(NULL, this, 0, 0, 1.); } } @@ -1177,7 +1178,7 @@ public: } //draws an image with the specified flags - void DrawGraphic(FTexture* texture, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, int alpha, bool fullScreenOffsets, bool translate=false, bool dim=false, int offsetflags=0, bool alphaMap=false, int forceWidth=-1, int forceHeight=-1, fixed_t cx=0, fixed_t cy=0, fixed_t cr=0, fixed_t cb=0, bool clearDontDraw=false) const + void DrawGraphic(FTexture* texture, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, double Alpha, bool fullScreenOffsets, bool translate=false, bool dim=false, int offsetflags=0, bool alphaMap=false, int forceWidth=-1, int forceHeight=-1, const double *clip = nulclip, bool clearDontDraw=false) const { if (texture == NULL) return; @@ -1205,20 +1206,20 @@ public: dy += ST_Y - (Scaled ? script->resH : 200) + script->height; w = forceWidth < 0 ? texture->GetScaledWidthDouble() : forceWidth; h = forceHeight < 0 ? texture->GetScaledHeightDouble() : forceHeight; - double dcx = cx == 0 ? 0 : dx + ((double) cx / FRACUNIT) - texture->GetScaledLeftOffsetDouble(); - double dcy = cy == 0 ? 0 : dy + ((double) cy / FRACUNIT) - texture->GetScaledTopOffsetDouble(); - double dcr = cr == 0 ? INT_MAX : dx + w - ((double) cr / FRACUNIT) - texture->GetScaledLeftOffsetDouble(); - double dcb = cb == 0 ? INT_MAX : dy + h - ((double) cb / FRACUNIT) - texture->GetScaledTopOffsetDouble(); + double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetScaledLeftOffsetDouble(); + double dcy = clip[1] == 0 ? 0 : dy + clip[1] - texture->GetScaledTopOffsetDouble(); + double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetScaledLeftOffsetDouble(); + double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetScaledTopOffsetDouble(); if(Scaled) { - if(cx != 0 || cy != 0) + if(clip[0] != 0 || clip[1] != 0) { screen->VirtualToRealCoords(dcx, dcy, tmp, tmp, script->resW, script->resH, true); - if (cx == 0) dcx = 0; - if (cy == 0) dcy = 0; + if (clip[0] == 0) dcx = 0; + if (clip[1] == 0) dcy = 0; } - if(cr != 0 || cb != 0 || clearDontDraw) + if(clip[2] != 0 || clip[3] != 0 || clearDontDraw) screen->VirtualToRealCoords(dcr, dcb, tmp, tmp, script->resW, script->resH, true); screen->VirtualToRealCoords(dx, dy, w, h, script->resW, script->resH, true); } @@ -1245,7 +1246,7 @@ public: DTA_Translation, translate ? GetTranslation() : 0, DTA_ColorOverlay, dim ? DIM_OVERLAY : 0, DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM, - DTA_Alpha, alpha, + DTA_AlphaF, Alpha, DTA_AlphaChannel, alphaMap, DTA_FillColor, 0, TAG_DONE); @@ -1262,7 +1263,7 @@ public: DTA_Translation, translate ? GetTranslation() : 0, DTA_ColorOverlay, dim ? DIM_OVERLAY : 0, DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM, - DTA_Alpha, alpha, + DTA_AlphaF, Alpha, TAG_DONE); } } @@ -1298,12 +1299,12 @@ public: ry = SCREENHEIGHT + ry; // Check for clipping - if(cx != 0 || cy != 0 || cr != 0 || cb != 0) + if(clip[0] != 0 || clip[1] != 0 || clip[2] != 0 || clip[3] != 0) { - rcx = cx == 0 ? 0 : rx+((((double) cx/FRACUNIT) - texture->GetScaledLeftOffsetDouble())*xScale); - rcy = cy == 0 ? 0 : ry+((((double) cy/FRACUNIT) - texture->GetScaledTopOffsetDouble())*yScale); - rcr = cr == 0 ? INT_MAX : rx+w-((((double) cr/FRACUNIT) + texture->GetScaledLeftOffsetDouble())*xScale); - rcb = cb == 0 ? INT_MAX : ry+h-((((double) cb/FRACUNIT) + texture->GetScaledTopOffsetDouble())*yScale); + rcx = clip[0] == 0 ? 0 : rx+((clip[0] - texture->GetScaledLeftOffsetDouble())*xScale); + rcy = clip[1] == 0 ? 0 : ry+((clip[1] - texture->GetScaledTopOffsetDouble())*yScale); + rcr = clip[2] == 0 ? INT_MAX : rx+w-((clip[2] + texture->GetScaledLeftOffsetDouble())*xScale); + rcb = clip[3] == 0 ? INT_MAX : ry+h-((clip[3] + texture->GetScaledTopOffsetDouble())*yScale); } if(clearDontDraw) @@ -1322,7 +1323,7 @@ public: DTA_Translation, translate ? GetTranslation() : 0, DTA_ColorOverlay, dim ? DIM_OVERLAY : 0, DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM, - DTA_Alpha, alpha, + DTA_AlphaF, Alpha, DTA_AlphaChannel, alphaMap, DTA_FillColor, 0, TAG_DONE); @@ -1339,14 +1340,14 @@ public: DTA_Translation, translate ? GetTranslation() : 0, DTA_ColorOverlay, dim ? DIM_OVERLAY : 0, DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM, - DTA_Alpha, alpha, + DTA_AlphaF, Alpha, TAG_DONE); } } } } - void DrawString(FFont *font, const char* cstring, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, int alpha, bool fullScreenOffsets, EColorRange translation, int spacing=0, bool drawshadow=false, int shadowX=2, int shadowY=2) const + void DrawString(FFont *font, const char* cstring, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, double Alpha, bool fullScreenOffsets, EColorRange translation, int spacing=0, bool drawshadow=false, int shadowX=2, int shadowY=2) const { x += spacing; double ax = *x; @@ -1456,13 +1457,13 @@ public: } if(drawshadow) { - fixed_t salpha = fixed_t(alpha *HR_SHADOW); + double salpha = (Alpha *HR_SHADOW); double srx = rx + (shadowX*xScale); double sry = ry + (shadowY*yScale); screen->DrawTexture(character, srx, sry, DTA_DestWidthF, rw, DTA_DestHeightF, rh, - DTA_Alpha, salpha, + DTA_AlphaF, salpha, DTA_FillColor, 0, TAG_DONE); } @@ -1470,7 +1471,7 @@ public: DTA_DestWidthF, rw, DTA_DestHeightF, rh, DTA_Translation, remap, - DTA_Alpha, alpha, + DTA_AlphaF, Alpha, TAG_DONE); if(script->spacingCharacter == '\0') ax += width + spacing - (character->LeftOffset+1); @@ -1516,7 +1517,7 @@ DBaseStatusBar *CreateCustomStatusBar (int script) return new DSBarInfo(SBarInfoScript[script]); } -void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, int alpha) +void SBarInfoMainBlock::DrawAux(const SBarInfoMainBlock *block, DSBarInfo *statusBar, int xOffset, int yOffset, double alpha) { // Popups can also be forced to scale bool rescale = false; diff --git a/src/g_shared/sbarinfo.h b/src/g_shared/sbarinfo.h index 780cb433b..f5dcb4abd 100644 --- a/src/g_shared/sbarinfo.h +++ b/src/g_shared/sbarinfo.h @@ -61,9 +61,10 @@ struct Popup bool moving; int height; int width; - int speed; - int speed2; - int alpha; + int ispeed; + double speed; + double speed2; + double alpha; int x; int y; int displacementX; @@ -77,7 +78,7 @@ struct Popup bool isDoneMoving(); int getXOffset(); int getYOffset(); - int getAlpha(int maxAlpha=OPAQUE); + double getAlpha(double maxAlpha=1.); int getXDisplacement(); int getYDisplacement(); }; diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index d46e07499..262c49c81 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -48,7 +48,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl translatable(false), type(NORMAL_IMAGE), image(-1), maxwidth(-1), maxheight(-1), spawnScaleX(1.0f), spawnScaleY(1.0f), flags(0), applyscale(false), offset(static_cast (TOP|LEFT)), - texture(NULL), alpha(OPAQUE) + texture(NULL), alpha(1.) { } @@ -63,7 +63,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl int w = maxwidth, h = maxheight; // We must calculate this per frame in order to prevent glitches with cl_capfps true. - fixed_t frameAlpha = FixedMul(block->Alpha(), alpha); + double frameAlpha = block->Alpha() * alpha; if(flags & DI_DRAWINBOX) { @@ -234,7 +234,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); texture = NULL; - alpha = OPAQUE; + alpha = 1.; if (applyscale) { spawnScaleX = spawnScaleY = 1.0f; @@ -282,7 +282,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl if (harmor->Slots[armorType] > 0 && harmor->SlotsIncrement[armorType] > 0) { //combine the alpha values - alpha = int(alpha * MIN(1., harmor->Slots[armorType] / harmor->SlotsIncrement[armorType])); + alpha *= MIN(1., harmor->Slots[armorType] / harmor->SlotsIncrement[armorType]); texture = statusBar->Images[image]; } else @@ -350,7 +350,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl Offset offset; FTexture *texture; - int alpha; + double alpha; }; //////////////////////////////////////////////////////////////////////////////// @@ -641,7 +641,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage // Since we're not going to call our parent's tick() method, // be sure to set the alpha value properly. - alpha = FRACUNIT; + alpha = 1.; return; } CommandDrawImage::Tick(block, statusBar, hudChanged); @@ -1641,9 +1641,9 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra } else { - if(itemflash && itemflashFade) + if(itemflash && itemflashFade != 0) { - fixed_t flashAlpha = FixedMul(block->Alpha(), itemflashFade); + double flashAlpha = block->Alpha() * itemflashFade; statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgCURSOR], imgx-4, imgy+2, block->XOffset(), block->YOffset(), flashAlpha, block->FullScreenOffsets(), translatable, false, offset); } @@ -1736,7 +1736,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra artiflashTick--; if(itemflashFade > 0) { - itemflashFade -= FRACUNIT/14; + itemflashFade -= 1./14; if(itemflashFade < 0) itemflashFade = 0; } @@ -1747,7 +1747,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra CommandDrawNumber::Tick(block, statusBar, hudChanged); } - static void Flash() { artiflashTick = 4; itemflashFade = FRACUNIT*3/4; } + static void Flash() { artiflashTick = 4; itemflashFade = 0.75; } protected: bool alternateOnEmpty; bool artiflash; @@ -1755,10 +1755,10 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra bool itemflash; static int artiflashTick; - static fixed_t itemflashFade; + static double itemflashFade; }; int CommandDrawSelectedInventory::artiflashTick = 0; -int CommandDrawSelectedInventory::itemflashFade = FRACUNIT*3/4; +double CommandDrawSelectedInventory::itemflashFade = 0.75; void DSBarInfo::FlashItem(const PClass *itemtype) { @@ -2110,9 +2110,9 @@ class CommandDrawInventoryBar : public SBarInfoCommand { int spacing = GetCounterSpacing(statusBar); - int bgalpha = block->Alpha(); + double bgalpha = block->Alpha(); if(translucent) - bgalpha = fixed_t(block->Alpha() * HX_SHADOW); + bgalpha *= HX_SHADOW; AInventory *item; unsigned int i = 0; @@ -2492,10 +2492,10 @@ class CommandDrawBar : public SBarInfoCommand FTexture *fg = statusBar->Images[foreground]; FTexture *bg = (background != -1) ? statusBar->Images[background] : NULL; - fixed_t value = drawValue; + double value = drawValue; if(border != 0) { - value = FRACUNIT - value; //invert since the new drawing method requires drawing the bg on the fg. + value = 1. - value; //invert since the new drawing method requires drawing the bg on the fg. //Draw the whole foreground statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); @@ -2506,27 +2506,27 @@ class CommandDrawBar : public SBarInfoCommand if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight()) statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets()); else - statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, 0, 0, 0, 0, true); + statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, nulclip, true); } // {cx, cy, cr, cb} - fixed_t clip[4] = {0, 0, 0, 0}; + double Clip[4] = {0, 0, 0, 0}; - fixed_t sizeOfImage = (horizontal ? fg->GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2)<GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2); + Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value; // Draw background if(border != 0) { for(unsigned int i = 0;i < 4;i++) - clip[i] += border<GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight()) - statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3]); + statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip); else - statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3], true); + statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip, true); } else - statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, clip[0], clip[1], clip[2], clip[3]); + statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip); } void Parse(FScanner &sc, bool fullScreenOffsets) { @@ -2651,7 +2651,7 @@ class CommandDrawBar : public SBarInfoCommand } void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) { - fixed_t value = 0; + double value = 0; int max = 0; switch(type) { @@ -2791,9 +2791,7 @@ class CommandDrawBar : public SBarInfoCommand if(max != 0 && value > 0) { - value = (value << FRACBITS) / max; - if(value > FRACUNIT) - value = FRACUNIT; + value = MIN(value / max, 1.); } else value = 0; @@ -2802,14 +2800,14 @@ class CommandDrawBar : public SBarInfoCommand // [BL] Since we used a percentage (in order to get the most fluid animation) // we need to establish a cut off point so the last pixel won't hang as the animation slows if(pixel == -1 && statusBar->Images[foreground]) - pixel = MAX(1, FRACUNIT/statusBar->Images[foreground]->GetWidth()); + pixel = MAX(1., 1./statusBar->Images[foreground]->GetWidth()); - if(abs(drawValue - value) < pixel) + if(fabs(drawValue - value) < pixel) drawValue = value; - else if(value < drawValue) - drawValue -= clamp((drawValue - value) >> 2, 1, FixedDiv(interpolationSpeed<((value - drawValue) >> 2, 1, FixedDiv(interpolationSpeed<((drawValue - value) / 4, 1 / 65536., interpolationSpeed / 100.); + else if (drawValue < value) + drawValue += clamp((value - drawValue) / 4, 1 / 65536., interpolationSpeed / 100.); } else drawValue = value; @@ -2883,8 +2881,8 @@ class CommandDrawBar : public SBarInfoCommand SBarInfoCoordinate y; int interpolationSpeed; - fixed_t drawValue; - fixed_t pixel; + double drawValue; + double pixel; }; //////////////////////////////////////////////////////////////////////////////// @@ -3448,7 +3446,7 @@ class CommandAlpha : public SBarInfoMainBlock void Parse(FScanner &sc, bool fullScreenOffsets) { sc.MustGetToken(TK_FloatConst); - alpha = fixed_t(FRACUNIT * sc.Float); + alpha = sc.Float; // We don't want to allow all the options of a regular main block // so skip to the SBarInfoCommandFlowControl. diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 7a1e7da16..7169cb7db 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -116,7 +116,7 @@ static FTexture * invgems[4]; // Inventory arrows static int hudwidth, hudheight; // current width/height for HUD display static int statspace; -void AM_GetPosition(fixed_t & x, fixed_t & y); +DVector2 AM_GetPosition(); FTextureID GetHUDIcon(PClassInventory *cls) @@ -766,7 +766,7 @@ static void DrawInventory(player_t * CPlayer, int x,int y) if (AltIcon.Exists() && (rover->Icon.isValid() || AltIcon.isValid()) ) { - int trans = rover==CPlayer->mo->InvSel ? OPAQUE : 0x6666; + int trans = rover==CPlayer->mo->InvSel ? 0x10000 : 0x6666; DrawImageToBox(TexMan[AltIcon.isValid()? AltIcon : rover->Icon], x, y, 19, 25, trans); if (rover->Amount>1) @@ -818,23 +818,20 @@ static void DrawFrags(player_t * CPlayer, int x, int y) static void DrawCoordinates(player_t * CPlayer) { - fixed_t x; - fixed_t y; - fixed_t z; + DVector3 pos; char coordstr[18]; int h = SmallFont->GetHeight()+1; if (!map_point_coordinates || !automapactive) { - x=CPlayer->mo->_f_X(); - y=CPlayer->mo->_f_Y(); - z=CPlayer->mo->_f_Z(); + pos = CPlayer->mo->Pos(); } else { - AM_GetPosition(x,y); - z = P_PointInSector(x, y)->floorplane.ZatPoint(x, y); + DVector2 apos = AM_GetPosition(); + double z = P_PointInSector(apos)->floorplane.ZatPoint(apos); + pos = DVector3(apos, z); } int vwidth = con_scaletext==0? SCREENWIDTH : SCREENWIDTH/2; @@ -842,17 +839,17 @@ static void DrawCoordinates(player_t * CPlayer) int xpos = vwidth - SmallFont->StringWidth("X: -00000")-6; int ypos = 18; - mysnprintf(coordstr, countof(coordstr), "X: %d", x>>FRACBITS); + mysnprintf(coordstr, countof(coordstr), "X: %d", int(pos.X)); screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos, coordstr, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); - mysnprintf(coordstr, countof(coordstr), "Y: %d", y>>FRACBITS); + mysnprintf(coordstr, countof(coordstr), "Y: %d", int(pos.Y)); screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+h, coordstr, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); - mysnprintf(coordstr, countof(coordstr), "Z: %d", z>>FRACBITS); + mysnprintf(coordstr, countof(coordstr), "Z: %d", int(pos.Z)); screen->DrawText(SmallFont, hudcolor_xyco, xpos, ypos+2*h, coordstr, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, TAG_DONE); @@ -933,7 +930,7 @@ static void DrawTime() const int width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border const int height = SmallFont->GetHeight(); - DrawHudText(SmallFont, hud_timecolor, timeString, hudwidth - width, height, OPAQUE); + DrawHudText(SmallFont, hud_timecolor, timeString, hudwidth - width, height, 0x10000); } static bool IsAltHUDTextVisible() @@ -991,7 +988,7 @@ static void DrawLatency() const int width = SmallFont->GetCharWidth('0') * characterCount + 2; // small offset from screen's border const int height = SmallFont->GetHeight() * (ST_IsTimeVisible() ? 2 : 1); - DrawHudText(SmallFont, color, tempstr, hudwidth - width, height, OPAQUE); + DrawHudText(SmallFont, color, tempstr, hudwidth - width, height, 0x10000); } bool ST_IsLatencyVisible() @@ -1082,7 +1079,7 @@ void DrawHUD() { seconds = Tics2Seconds(level.totaltime); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); - DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, OPAQUE); + DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, 0x10000); bottom -= fonth; } @@ -1092,14 +1089,14 @@ void DrawHUD() { seconds = Tics2Seconds(level.time); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); - DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, OPAQUE); + DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, 0x10000); bottom -= fonth; } // Single level time for hubs seconds= Tics2Seconds(level.maptime); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); - DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, OPAQUE); + DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, 0x10000); } ST_FormatMapName(mapname); diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 736ba4af7..1a034345a 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -57,8 +57,8 @@ #include "../version.h" -#define XHAIRSHRINKSIZE (FRACUNIT/18) -#define XHAIRPICKUPSIZE (FRACUNIT*2+XHAIRSHRINKSIZE) +#define XHAIRSHRINKSIZE (1./18) +#define XHAIRPICKUPSIZE (2+XHAIRSHRINKSIZE) #define POWERUPICONSIZE 32 IMPLEMENT_POINTY_CLASS(DBaseStatusBar) @@ -233,7 +233,7 @@ DBaseStatusBar::DBaseStatusBar (int reltop, int hres, int vres) CompleteBorder = false; Centering = false; FixedOrigin = false; - CrosshairSize = FRACUNIT; + CrosshairSize = 1.; RelTop = reltop; memset(Messages, 0, sizeof(Messages)); Displacement = 0; @@ -287,7 +287,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) ::ST_Y = ST_Y; if (RelTop > 0) { - Displacement = ((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))*FRACUNIT/RelTop; + Displacement = double((ST_Y * VirticalResolution / SCREENHEIGHT) - (VirticalResolution - RelTop))/RelTop; } else { @@ -377,12 +377,12 @@ void DBaseStatusBar::Tick () } // If the crosshair has been enlarged, shrink it. - if (CrosshairSize > FRACUNIT) + if (CrosshairSize > 1.) { CrosshairSize -= XHAIRSHRINKSIZE; - if (CrosshairSize < FRACUNIT) + if (CrosshairSize < 1.) { - CrosshairSize = FRACUNIT; + CrosshairSize = 1.; } } } @@ -567,27 +567,6 @@ void DBaseStatusBar::DrawDimImage (FTexture *img, } } -//--------------------------------------------------------------------------- -// -// PROC DrawImage -// -// Draws a translucent image with the status bar's upper-left corner as the -// origin. -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::DrawFadedImage (FTexture *img, - int x, int y, fixed_t shade) const -{ - if (img != NULL) - { - screen->DrawTexture (img, x + ST_X, y + ST_Y, - DTA_Alpha, shade, - DTA_Bottom320x200, Scaled, - TAG_DONE); - } -} - //--------------------------------------------------------------------------- // // PROC DrawPartialImage @@ -1113,7 +1092,7 @@ void DBaseStatusBar::DrawCrosshair () static int palettecolor = 0; DWORD color; - fixed_t size; + double size; int w, h; // Don't draw the crosshair in chasecam mode @@ -1130,19 +1109,19 @@ void DBaseStatusBar::DrawCrosshair () if (crosshairscale) { - size = SCREENHEIGHT * FRACUNIT / 200; + size = SCREENHEIGHT / 200.; } else { - size = FRACUNIT; + size = 1.; } if (crosshairgrow) { - size = FixedMul (size, CrosshairSize); + size *= CrosshairSize; } - w = (CrosshairImage->GetWidth() * size) >> FRACBITS; - h = (CrosshairImage->GetHeight() * size) >> FRACBITS; + w = int(CrosshairImage->GetWidth() * size); + h = int(CrosshairImage->GetHeight() * size); if (crosshairhealth) { @@ -1255,7 +1234,6 @@ void DBaseStatusBar::Draw (EHudState state) { // Draw current coordinates int height = SmallFont->GetHeight(); char labels[3] = { 'X', 'Y', 'Z' }; - fixed_t *value; int i; int vwidth; @@ -1286,10 +1264,10 @@ void DBaseStatusBar::Draw (EHudState state) y -= height * 2; } - fixedvec3 pos = CPlayer->mo->_f_Pos(); - for (i = 2, value = &pos.z; i >= 0; y -= height, --value, --i) + DVector3 pos = CPlayer->mo->Pos(); + for (i = 2; i >= 0; y -= height, --i) { - mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS); + mysnprintf (line, countof(line), "%c: %d", labels[i], int(pos[i])); screen->DrawText (SmallFont, CR_GREEN, xpos, y, line, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight, diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 10d6a3ac7..44c2cef8c 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -59,10 +59,12 @@ void FMapInfoParser::ParseSkill () bool thisisdefault = false; bool acsreturnisset = false; - skill.AmmoFactor = FRACUNIT; - skill.DoubleAmmoFactor = 2*FRACUNIT; - skill.DropAmmoFactor = -1; + skill.AmmoFactor = 1.; + skill.DoubleAmmoFactor = 2.; + skill.DropAmmoFactor = -1.; skill.DamageFactor = 1.; + skill.ArmorFactor = 1.; + skill.HealthFactor = 1.; skill.FastMonsters = false; skill.SlowMonsters = false; skill.DisableCheats = false; @@ -71,7 +73,7 @@ void FMapInfoParser::ParseSkill () skill.AutoUseHealth = false; skill.RespawnCounter = 0; skill.RespawnLimit = 0; - skill.Aggressiveness = FRACUNIT; + skill.Aggressiveness = 1.; skill.SpawnFilter = 0; skill.ACSReturn = 0; skill.MustConfirm = false; @@ -79,12 +81,10 @@ void FMapInfoParser::ParseSkill () skill.TextColor = ""; skill.Replace.Clear(); skill.Replaced.Clear(); - skill.MonsterHealth = FRACUNIT; - skill.FriendlyHealth = FRACUNIT; + skill.MonsterHealth = 1.; + skill.FriendlyHealth = 1.; skill.NoPain = false; - skill.ArmorFactor = FRACUNIT; skill.Infighting = 0; - skill.HealthFactor = FRACUNIT; sc.MustGetString(); skill.Name = sc.String; @@ -97,19 +97,19 @@ void FMapInfoParser::ParseSkill () { ParseAssign(); sc.MustGetFloat (); - skill.AmmoFactor = FLOAT2FIXED(sc.Float); + skill.AmmoFactor = sc.Float; } else if (sc.Compare ("doubleammofactor")) { ParseAssign(); sc.MustGetFloat (); - skill.DoubleAmmoFactor = FLOAT2FIXED(sc.Float); + skill.DoubleAmmoFactor = sc.Float; } else if (sc.Compare ("dropammofactor")) { ParseAssign(); sc.MustGetFloat (); - skill.DropAmmoFactor = FLOAT2FIXED(sc.Float); + skill.DropAmmoFactor = sc.Float; } else if (sc.Compare ("damagefactor")) { @@ -157,7 +157,7 @@ void FMapInfoParser::ParseSkill () { ParseAssign(); sc.MustGetFloat (); - skill.Aggressiveness = FRACUNIT - FLOAT2FIXED(clamp(sc.Float, 0.,1.)); + skill.Aggressiveness = 1. - clamp(sc.Float, 0.,1.); } else if (sc.Compare("SpawnFilter")) { @@ -250,13 +250,13 @@ void FMapInfoParser::ParseSkill () { ParseAssign(); sc.MustGetFloat(); - skill.MonsterHealth = FLOAT2FIXED(sc.Float); + skill.MonsterHealth = sc.Float; } else if (sc.Compare("FriendlyHealth")) { ParseAssign(); sc.MustGetFloat(); - skill.FriendlyHealth = FLOAT2FIXED(sc.Float); + skill.FriendlyHealth = sc.Float; } else if (sc.Compare("NoPain")) { @@ -266,13 +266,13 @@ void FMapInfoParser::ParseSkill () { ParseAssign(); sc.MustGetFloat(); - skill.ArmorFactor = FLOAT2FIXED(sc.Float); + skill.ArmorFactor = sc.Float; } else if (sc.Compare("HealthFactor")) { ParseAssign(); sc.MustGetFloat(); - skill.HealthFactor = FLOAT2FIXED(sc.Float); + skill.HealthFactor = sc.Float; } else if (sc.Compare("NoInfighting")) { @@ -341,16 +341,6 @@ int G_SkillProperty(ESkillProperty prop) { switch(prop) { - case SKILLP_AmmoFactor: - if (dmflags2 & DF2_YES_DOUBLEAMMO) - { - return AllSkills[gameskill].DoubleAmmoFactor; - } - return AllSkills[gameskill].AmmoFactor; - - case SKILLP_DropAmmoFactor: - return AllSkills[gameskill].DropAmmoFactor; - case SKILLP_FastMonsters: return AllSkills[gameskill].FastMonsters || (dmflags & DF_FAST_MONSTERS); @@ -365,9 +355,6 @@ int G_SkillProperty(ESkillProperty prop) case SKILLP_RespawnLimit: return AllSkills[gameskill].RespawnLimit; - case SKILLP_Aggressiveness: - return AllSkills[gameskill].Aggressiveness; - case SKILLP_DisableCheats: return AllSkills[gameskill].DisableCheats; @@ -386,21 +373,9 @@ int G_SkillProperty(ESkillProperty prop) case SKILLP_ACSReturn: return AllSkills[gameskill].ACSReturn; - case SKILLP_MonsterHealth: - return AllSkills[gameskill].MonsterHealth; - - case SKILLP_FriendlyHealth: - return AllSkills[gameskill].FriendlyHealth; - case SKILLP_NoPain: return AllSkills[gameskill].NoPain; - case SKILLP_ArmorFactor: - return AllSkills[gameskill].ArmorFactor; - - case SKILLP_HealthFactor: - return AllSkills[gameskill].HealthFactor; - case SKILLP_Infight: // This property also needs to consider the level flags for the same info. if (level.flags2 & LEVEL2_TOTALINFIGHTING) return 1; @@ -425,9 +400,34 @@ double G_SkillProperty(EFSkillProperty prop) { switch (prop) { + case SKILLP_AmmoFactor: + if (dmflags2 & DF2_YES_DOUBLEAMMO) + { + return AllSkills[gameskill].DoubleAmmoFactor; + } + return AllSkills[gameskill].AmmoFactor; + + case SKILLP_DropAmmoFactor: + return AllSkills[gameskill].DropAmmoFactor; + + case SKILLP_ArmorFactor: + return AllSkills[gameskill].ArmorFactor; + + case SKILLP_HealthFactor: + return AllSkills[gameskill].HealthFactor; + case SKILLP_DamageFactor: return AllSkills[gameskill].DamageFactor; - break; + + case SKILLP_Aggressiveness: + return AllSkills[gameskill].Aggressiveness; + + case SKILLP_MonsterHealth: + return AllSkills[gameskill].MonsterHealth; + + case SKILLP_FriendlyHealth: + return AllSkills[gameskill].FriendlyHealth; + } } return 0; diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index dfdd9dbb5..bcdf624d7 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -576,7 +576,7 @@ private: int bars = (CurrentPop == POP_Status) ? imgINVPOP : imgINVPOP2; int back = (CurrentPop == POP_Status) ? imgINVPBAK : imgINVPBAK2; // Extrapolate the height of the popscreen for smoother movement - int height = clamp (PopHeight + FixedMul (r_TicFrac, PopHeightChange), -POP_HEIGHT, 0); + int height = clamp (PopHeight + int(r_TicFracF * PopHeightChange), -POP_HEIGHT, 0); xscale = CleanXfac; yscale = CleanYfac; @@ -627,7 +627,7 @@ private: if (KeyPopScroll > 0) { // Extrapolate the scroll position for smoother scrolling - int scroll = MAX (0,KeyPopScroll - FixedMul (r_TicFrac, 280/KEY_TIME)); + int scroll = MAX (0,KeyPopScroll - int(r_TicFracF * (280./KEY_TIME))); pos -= 10; leftcol = leftcol - 280 + scroll; } diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index 49e875195..5b78ebc51 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -262,7 +262,7 @@ void DIntermissionScreenFader::Drawer () { double factor = clamp(double(mTicker) / mDuration, 0., 1.); if (mType == FADE_In) factor = 1.0 - factor; - int color = MAKEARGB(xs_RoundToInt(factor*255), 0,0,0); + int color = MAKEARGB(int(factor*255), 0,0,0); if (screen->Begin2D(false)) { diff --git a/src/intermission/intermission_parse.cpp b/src/intermission/intermission_parse.cpp index e9ebd847e..b15b78e71 100644 --- a/src/intermission/intermission_parse.cpp +++ b/src/intermission/intermission_parse.cpp @@ -113,7 +113,7 @@ bool FIntermissionAction::ParseKey(FScanner &sc) if (!sc.CheckToken('-')) { sc.MustGetFloat(); - mDuration = xs_RoundToInt(sc.Float*TICRATE); + mDuration = int(sc.Float*TICRATE); } else { @@ -329,7 +329,7 @@ bool FIntermissionActionTextscreen::ParseKey(FScanner &sc) if (!sc.CheckToken('-')) { sc.MustGetFloat(); - mTextDelay = xs_RoundToInt(sc.Float*TICRATE); + mTextDelay = int(sc.Float*TICRATE); } else { @@ -438,7 +438,7 @@ bool FIntermissionActionScroller::ParseKey(FScanner &sc) if (!sc.CheckToken('-')) { sc.MustGetFloat(); - mScrollDelay = xs_RoundToInt(sc.Float*TICRATE); + mScrollDelay = int(sc.Float*TICRATE); } else { @@ -453,7 +453,7 @@ bool FIntermissionActionScroller::ParseKey(FScanner &sc) if (!sc.CheckToken('-')) { sc.MustGetFloat(); - mScrollTime = xs_RoundToInt(sc.Float*TICRATE); + mScrollTime = int(sc.Float*TICRATE); } else { diff --git a/src/p_acs.cpp b/src/p_acs.cpp index f3748ec93..ffb854575 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -7993,7 +7993,7 @@ scriptwait: float x = ACSToFloat(Stack[optstart-3]); float y = ACSToFloat(Stack[optstart-2]); float holdTime = ACSToFloat(Stack[optstart-1]); - fixed_t alpha; + float alpha; DHUDMessage *msg; if (type & HUDMSG_COLORSTRING) @@ -8008,13 +8008,13 @@ scriptwait: switch (type & 0xFF) { default: // normal - alpha = (optstart < sp) ? Stack[optstart] : OPAQUE; + alpha = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 1.f; msg = new DHUDMessage (activefont, work, x, y, hudwidth, hudheight, color, holdTime); break; case 1: // fade out { float fadeTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.5f; - alpha = (optstart < sp-1) ? Stack[optstart+1] : OPAQUE; + alpha = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 1.f; msg = new DHUDMessageFadeOut (activefont, work, x, y, hudwidth, hudheight, color, holdTime, fadeTime); } break; @@ -8022,7 +8022,7 @@ scriptwait: { float typeTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.05f; float fadeTime = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 0.5f; - alpha = (optstart < sp-2) ? Stack[optstart+2] : FRACUNIT; + alpha = (optstart < sp-2) ? ACSToFloat(Stack[optstart+2]) : 1.f; msg = new DHUDMessageTypeOnFadeOut (activefont, work, x, y, hudwidth, hudheight, color, typeTime, holdTime, fadeTime); } break; @@ -8030,7 +8030,7 @@ scriptwait: { float inTime = (optstart < sp) ? ACSToFloat(Stack[optstart]) : 0.5f; float outTime = (optstart < sp-1) ? ACSToFloat(Stack[optstart+1]) : 0.5f; - alpha = (optstart < sp-2) ? Stack[optstart+2] : OPAQUE; + alpha = (optstart < sp-2) ? ACSToFloat(Stack[optstart + 2]) : 1.f; msg = new DHUDMessageFadeInOut (activefont, work, x, y, hudwidth, hudheight, color, holdTime, inTime, outTime); } break; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 64161014c..e9e0e66d4 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -410,7 +410,7 @@ bool AActor::SuggestMissileAttack (fixed_t dist) if (flags4 & MF4_MISSILEMORE) dist >>= 1; if (flags4 & MF4_MISSILEEVENMORE) dist >>= 3; - int mmc = FixedMul(MinMissileChance, G_SkillProperty(SKILLP_Aggressiveness)); + int mmc = int(MinMissileChance * G_SkillProperty(SKILLP_Aggressiveness)); return pr_checkmissilerange() >= MIN (dist >> FRACBITS, mmc); } @@ -3097,11 +3097,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_ActiveAndUnblock) void ModifyDropAmount(AInventory *inv, int dropamount) { int flagmask = IF_IGNORESKILL; - fixed_t dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor); + double dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor); // Default drop amount is half of regular amount * regular ammo multiplication if (dropammofactor == -1) { - dropammofactor = FRACUNIT/2; + dropammofactor = 0.5; flagmask = 0; } @@ -3109,7 +3109,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount) { if (flagmask != 0 && inv->IsKindOf(RUNTIME_CLASS(AAmmo))) { - inv->Amount = FixedMul(dropamount, dropammofactor); + inv->Amount = int(dropamount * dropammofactor); inv->ItemFlags |= IF_IGNORESKILL; } else @@ -3123,21 +3123,21 @@ void ModifyDropAmount(AInventory *inv, int dropamount) int amount = static_cast(inv->GetClass())->DropAmount; if (amount <= 0) { - amount = MAX(1, FixedMul(inv->Amount, dropammofactor)); + amount = MAX(1, int(inv->Amount * dropammofactor)); } inv->Amount = amount; inv->ItemFlags |= flagmask; } else if (inv->IsKindOf (RUNTIME_CLASS(AWeaponGiver))) { - static_cast(inv)->DropAmmoFactor = FIXED2DBL(dropammofactor); + static_cast(inv)->DropAmmoFactor = dropammofactor; inv->ItemFlags |= flagmask; } else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon))) { // The same goes for ammo from a weapon. - static_cast(inv)->AmmoGive1 = FixedMul(static_cast(inv)->AmmoGive1, dropammofactor); - static_cast(inv)->AmmoGive2 = FixedMul(static_cast(inv)->AmmoGive2, dropammofactor); + static_cast(inv)->AmmoGive1 = int(static_cast(inv)->AmmoGive1 * dropammofactor); + static_cast(inv)->AmmoGive2 = int(static_cast(inv)->AmmoGive2 * dropammofactor); inv->ItemFlags |= flagmask; } else if (inv->IsKindOf (RUNTIME_CLASS(ADehackedPickup))) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 33a318b41..06cd8606c 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -6457,12 +6457,12 @@ int AActor::SpawnHealth() const } else if (flags & MF_FRIENDLY) { - int adj = FixedMul(defhealth, G_SkillProperty(SKILLP_FriendlyHealth)); + int adj = int(defhealth * G_SkillProperty(SKILLP_FriendlyHealth)); return (adj <= 0) ? 1 : adj; } else { - int adj = FixedMul(defhealth, G_SkillProperty(SKILLP_MonsterHealth)); + int adj = int(defhealth * G_SkillProperty(SKILLP_MonsterHealth)); return (adj <= 0) ? 1 : adj; } } diff --git a/src/p_trace.h b/src/p_trace.h index 47f56fd0e..01d308fd8 100644 --- a/src/p_trace.h +++ b/src/p_trace.h @@ -131,4 +131,13 @@ bool Trace (fixed_t x, fixed_t y, fixed_t z, sector_t *sector, DWORD traceFlags=0, ETraceStatus (*callback)(FTraceResults &res, void *)=NULL, void *callbackdata=NULL); +inline bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, double maxDist, + ActorFlags ActorMask, DWORD WallMask, AActor *ignore, FTraceResults &res, DWORD traceFlags = 0, + ETraceStatus(*callback)(FTraceResults &res, void *) = NULL, void *callbackdata = NULL) +{ + return Trace(FLOAT2FIXED(start.X), FLOAT2FIXED(start.Y), FLOAT2FIXED(start.Z), sector, + FLOAT2FIXED(direction.X), FLOAT2FIXED(direction.Y), FLOAT2FIXED(direction.Z), FLOAT2FIXED(maxDist), + ActorMask, WallMask, ignore, res, traceFlags, callback, callbackdata); +} + #endif //__P_TRACE_H__ diff --git a/src/r_things.cpp b/src/r_things.cpp index 1e26d2f90..580dad557 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1354,8 +1354,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ } else { - vis->texturemid -= FixedMul (StatusBar->GetDisplacement (), - FLOAT2FIXED(weapon->YAdjust)); + vis->texturemid -= FLOAT2FIXED(StatusBar->GetDisplacement () * weapon->YAdjust); } } } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 3bc2db6cd..c3229c14c 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -126,6 +126,7 @@ fixed_t viewsin, viewtansin; AActor *camera; // [RH] camera to draw from. doesn't have to be a player fixed_t r_TicFrac; // [RH] Fractional tic to render +double r_TicFracF; // same as floating point DWORD r_FrameTime; // [RH] Time this frame started drawing (in ms) bool r_NoInterpolate; bool r_showviewer; @@ -1010,6 +1011,7 @@ void R_SetupFrame (AActor *actor) { r_TicFrac = FRACUNIT; } + r_TicFracF = FIXED2DBL(r_TicFrac); R_InterpolateView (player, r_TicFrac, iview); diff --git a/src/r_utility.h b/src/r_utility.h index 0d4b4d023..dcfb31d65 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -34,6 +34,7 @@ extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard t extern int WidescreenRatio; extern fixed_t r_TicFrac; +extern double r_TicFracF; extern DWORD r_FrameTime; extern int extralight; extern unsigned int R_OldBlend; diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 4d64a6eb0..e0b19d19c 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -1284,7 +1284,7 @@ static void ParseDamageDefinition(FScanner &sc) { sc.MustGetFloat(); dtd.DefaultFactor = sc.Float; - if (dtd.DefaultFactor == 0) dtd.ReplaceFactor = true; // Multiply by 0 yields 0: FixedMul(damage, FixedMul(factor, 0)) is more wasteful than FixedMul(factor, 0) + if (dtd.DefaultFactor == 0) dtd.ReplaceFactor = true; } else if (sc.Compare("REPLACEFACTOR")) { diff --git a/src/vectors.h b/src/vectors.h index cc51f779f..af19d72b5 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -1031,7 +1031,7 @@ struct TAngle return FLOAT2ANGLE(Degrees); } - TVector2 ToVector(vec_t length) const + TVector2 ToVector(vec_t length = 1) const { return TVector2(length * Cos(), length * Sin()); } From eac0bfeaebe7f06d5c75f4d907a9bfc69be4c046 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 09:16:35 +0100 Subject: [PATCH 10/12] - removed fixed_t and associated utility macros from FraggleScript code. --- src/fragglescript/t_cmd.cpp | 2 +- src/fragglescript/t_func.cpp | 34 +++++++++++--------------------- src/fragglescript/t_oper.cpp | 19 ++++++++---------- src/fragglescript/t_parse.cpp | 3 +-- src/fragglescript/t_script.h | 12 ++++++----- src/fragglescript/t_variable.cpp | 12 +++++------ 6 files changed, 34 insertions(+), 48 deletions(-) diff --git a/src/fragglescript/t_cmd.cpp b/src/fragglescript/t_cmd.cpp index c5f77776f..1434870d1 100644 --- a/src/fragglescript/t_cmd.cpp +++ b/src/fragglescript/t_cmd.cpp @@ -165,7 +165,7 @@ void FS_EmulateCmd(char * string) else if (sc.Compare("viewheight")) { sc.MustGetFloat(); - double playerviewheight = sc.Float*FRACUNIT; + double playerviewheight = sc.Float; for(int i=0;i 2) speed = intvalue(t_argv[2]); else speed = 1; // 1= normal speed - EV_DoDoor(wait_time? DDoor::doorRaise:DDoor::doorOpen,NULL,NULL,sectag,2*FRACUNIT*clamp(speed,1,127),wait_time,0,0); + EV_DoDoor(wait_time ? DDoor::doorRaise : DDoor::doorOpen, NULL, NULL, sectag, 2. * clamp(speed, 1, 127), wait_time, 0, 0); } } @@ -2202,7 +2196,7 @@ void FParser::SF_CloseDoor(void) if(t_argc > 1) speed = intvalue(t_argv[1]); else speed = 1; // 1= normal speed - EV_DoDoor(DDoor::doorClose,NULL,NULL,sectag,2*FRACUNIT*clamp(speed,1,127),0,0,0); + EV_DoDoor(DDoor::doorClose, NULL, NULL, sectag, 2.*clamp(speed, 1, 127), 0, 0, 0); } } @@ -2416,12 +2410,10 @@ void FParser::SF_SetLineTexture(void) void FParser::SF_Max(void) { - fixed_t n1, n2; - if (CheckArgs(2)) { - n1 = fixedvalue(t_argv[0]); - n2 = fixedvalue(t_argv[1]); + auto n1 = fixedvalue(t_argv[0]); + auto n2 = fixedvalue(t_argv[1]); t_return.type = svt_fixed; t_return.value.f = (n1 > n2) ? n1 : n2; @@ -2437,12 +2429,10 @@ void FParser::SF_Max(void) void FParser::SF_Min(void) { - fixed_t n1, n2; - if (CheckArgs(1)) { - n1 = fixedvalue(t_argv[0]); - n2 = fixedvalue(t_argv[1]); + auto n1 = fixedvalue(t_argv[0]); + auto n2 = fixedvalue(t_argv[1]); t_return.type = svt_fixed; t_return.value.f = (n1 < n2) ? n1 : n2; @@ -2458,11 +2448,10 @@ void FParser::SF_Min(void) void FParser::SF_Abs(void) { - fixed_t n1; if (CheckArgs(1)) { - n1 = fixedvalue(t_argv[0]); + auto n1 = fixedvalue(t_argv[0]); t_return.type = svt_fixed; t_return.value.f = (n1 < 0) ? -n1 : n1; @@ -3877,10 +3866,9 @@ void FParser::SF_SetCorona(void) return; } - int num = t_argv[0].value.i; // which corona we want to modify - int what = t_argv[1].value.i; // what we want to modify (type, color, offset,...) - int ival = t_argv[2].value.i; // the value of what we modify - double fval = ((double) t_argv[2].value.f / FRACUNIT); + int num = intvalue(t_argv[0]); // which corona we want to modify + int what = intvalue(t_argv[1]); // what we want to modify (type, color, offset,...) + double val = floatvalue(t_argv[2]); // the value of what we modify /* switch (what) diff --git a/src/fragglescript/t_oper.cpp b/src/fragglescript/t_oper.cpp index 31673eb54..5a2092369 100644 --- a/src/fragglescript/t_oper.cpp +++ b/src/fragglescript/t_oper.cpp @@ -384,9 +384,9 @@ void FParser::OPdivide(svalue_t &result, int start, int n, int stop) // haleyjd: 8-17 if(left.type == svt_fixed || right.type == svt_fixed) { - fixed_t fr; + auto fr = fixedvalue(right); - if((fr = fixedvalue(right)) == 0) + if(fr == 0) script_error("divide by zero\n"); else { @@ -396,9 +396,9 @@ void FParser::OPdivide(svalue_t &result, int start, int n, int stop) } else { - int ir; + auto ir = intvalue(right); - if(!(ir = intvalue(right))) + if(!ir) script_error("divide by zero\n"); else { @@ -508,8 +508,7 @@ void FParser::OPincrement(svalue_t &result, int start, int n, int stop) } else { - result.value.f = fixedvalue(result) + FRACUNIT; - result.type = svt_fixed; + result.setDouble(floatvalue(result)+1); var->SetValue (result); } } @@ -534,8 +533,7 @@ void FParser::OPincrement(svalue_t &result, int start, int n, int stop) } else { - newvalue.type = svt_fixed; - newvalue.value.f = fixedvalue(result) + FRACUNIT; + newvalue.setDouble(floatvalue(result)+1); var->SetValue (newvalue); } } @@ -573,7 +571,7 @@ void FParser::OPdecrement(svalue_t &result, int start, int n, int stop) } else { - result.value.f = fixedvalue(result) - FRACUNIT; + result.setDouble(floatvalue(result)-1); result.type = svt_fixed; var->SetValue (result); } @@ -599,8 +597,7 @@ void FParser::OPdecrement(svalue_t &result, int start, int n, int stop) } else { - newvalue.type = svt_fixed; - newvalue.value.f = fixedvalue(result) - FRACUNIT; + newvalue.setDouble(floatvalue(result)-1); var->SetValue (newvalue); } } diff --git a/src/fragglescript/t_parse.cpp b/src/fragglescript/t_parse.cpp index 64dc3fb52..0b2f27680 100644 --- a/src/fragglescript/t_parse.cpp +++ b/src/fragglescript/t_parse.cpp @@ -567,8 +567,7 @@ void FParser::SimpleEvaluate(svalue_t &returnvar, int n) case number: if(strchr(Tokens[n], '.')) { - returnvar.type = svt_fixed; - returnvar.value.f = (fixed_t)(atof(Tokens[n]) * FRACUNIT); + returnvar.setDouble(atof(Tokens[n])); } else { diff --git a/src/fragglescript/t_script.h b/src/fragglescript/t_script.h index 0cbeb446f..39b0b93ee 100644 --- a/src/fragglescript/t_script.h +++ b/src/fragglescript/t_script.h @@ -82,15 +82,17 @@ enum // // //========================================================================== +typedef int fsfix; struct svalue_t { int type; + FString string; union { int i; - fixed_t f; // haleyjd: 8-17 + fsfix f; // haleyjd: 8-17 AActor *mobj; } value; @@ -113,7 +115,7 @@ struct svalue_t type = svt_int; } - void setFixed(fixed_t fp) + void setFixed(fsfix fp) { value.f = fp; type = svt_fixed; @@ -121,13 +123,13 @@ struct svalue_t void setDouble(double dp) { - value.f = FLOAT2FIXED(dp); + value.f = fsfix(dp/65536); type = svt_fixed; } }; int intvalue(const svalue_t & v); -fixed_t fixedvalue(const svalue_t & v); +fsfix fixedvalue(const svalue_t & v); double floatvalue(const svalue_t & v); const char *stringvalue(const svalue_t & v); AActor *actorvalue(const svalue_t &svalue); @@ -171,7 +173,7 @@ public: union value_t { SDWORD i; - fixed_t fixed; // haleyjd: fixed-point + fsfix fixed; // haleyjd: fixed-point // the following are only used in the global script so we don't need to bother with them // when serializing variables. diff --git a/src/fragglescript/t_variable.cpp b/src/fragglescript/t_variable.cpp index 09cdf950f..7fd39aa14 100644 --- a/src/fragglescript/t_variable.cpp +++ b/src/fragglescript/t_variable.cpp @@ -66,7 +66,7 @@ int intvalue(const svalue_t &v) { return (v.type == svt_string ? atoi(v.string) : - v.type == svt_fixed ? (int)(v.value.f / FRACUNIT) : + v.type == svt_fixed ? (int)(v.value.f / 65536.) : v.type == svt_mobj ? -1 : v.value.i ); } @@ -76,11 +76,11 @@ int intvalue(const svalue_t &v) // //========================================================================== -fixed_t fixedvalue(const svalue_t &v) +fsfix fixedvalue(const svalue_t &v) { return (v.type == svt_fixed ? v.value.f : - v.type == svt_string ? (fixed_t)(atof(v.string) * FRACUNIT) : - v.type == svt_mobj ? -1*FRACUNIT : v.value.i * FRACUNIT ); + v.type == svt_string ? (fsfix)(atof(v.string) * 65536.) : + v.type == svt_mobj ? -65536 : v.value.i * 65536 ); } //========================================================================== @@ -93,7 +93,7 @@ double floatvalue(const svalue_t &v) { return v.type == svt_string ? atof(v.string) : - v.type == svt_fixed ? FIXED2DBL(v.value.f) : + v.type == svt_fixed ? v.value.f * 65536. : v.type == svt_mobj ? -1. : (double)v.value.i; } @@ -118,7 +118,7 @@ const char *stringvalue(const svalue_t & v) case svt_fixed: { - double val = ((double)v.value.f) / FRACUNIT; + double val = v.value.f / 65536.; mysnprintf(buffer, countof(buffer), "%g", val); return buffer; } From c83ad9df6cd44bad3755be17a3c8626782119ac1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 11:30:11 +0100 Subject: [PATCH 11/12] - removed special treatment for not using stdint.h with MSVC. Current compiler versions have this file. - removed use of finesine for creating the player backdrop for the menu display. This mostly uses the code from the old 2.0 floating point version but fixes some of the constants in there which were not correct. --- src/basictypes.h | 11 ---- src/info.h | 2 +- src/menu/menu.cpp | 9 +-- src/menu/playerdisplay.cpp | 113 ++++++++++++++++++++++--------------- src/menu/readthis.cpp | 8 +-- src/tarray.h | 2 +- src/zstrformat.cpp | 6 +- 7 files changed, 79 insertions(+), 72 deletions(-) diff --git a/src/basictypes.h b/src/basictypes.h index 6c71fce9b..13be07b9f 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -1,16 +1,6 @@ #ifndef __BASICTYPES_H #define __BASICTYPES_H -#ifdef _MSC_VER -typedef __int8 SBYTE; -typedef unsigned __int8 BYTE; -typedef __int16 SWORD; -typedef unsigned __int16 WORD; -typedef __int32 SDWORD; -typedef unsigned __int32 uint32; -typedef __int64 SQWORD; -typedef unsigned __int64 QWORD; -#else #include typedef int8_t SBYTE; @@ -21,7 +11,6 @@ typedef int32_t SDWORD; typedef uint32_t uint32; typedef int64_t SQWORD; typedef uint64_t QWORD; -#endif typedef SDWORD int32; typedef float real32; diff --git a/src/info.h b/src/info.h index d6b3f5cf1..f0a08048c 100644 --- a/src/info.h +++ b/src/info.h @@ -37,7 +37,7 @@ #include #if !defined(_WIN32) #include // for intptr_t -#elif !defined(_MSC_VER) +#else #include // for mingw #endif diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 081a6e446..fb0ea80d7 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -78,7 +78,7 @@ FButtonStatus MenuButtons[NUM_MKEYS]; int MenuButtonTickers[NUM_MKEYS]; bool MenuButtonOrigin[NUM_MKEYS]; int BackbuttonTime; -fixed_t BackbuttonAlpha; +float BackbuttonAlpha; static bool MenuEnabled = true; @@ -274,7 +274,7 @@ void DMenu::Drawer () } else { - screen->DrawTexture(tex, x, y, DTA_CleanNoMove, true, DTA_Alpha, BackbuttonAlpha, TAG_DONE); + screen->DrawTexture(tex, x, y, DTA_CleanNoMove, true, DTA_AlphaF, BackbuttonAlpha, TAG_DONE); } } } @@ -680,12 +680,13 @@ void M_Ticker (void) } if (BackbuttonTime > 0) { - if (BackbuttonAlpha < OPAQUE) BackbuttonAlpha += OPAQUE/10; + if (BackbuttonAlpha < 1.f) BackbuttonAlpha += .1f; + if (BackbuttonAlpha > 1.f) BackbuttonAlpha = 1.f; BackbuttonTime--; } else { - if (BackbuttonAlpha > 0) BackbuttonAlpha -= OPAQUE/10; + if (BackbuttonAlpha > 0) BackbuttonAlpha -= .1f; if (BackbuttonAlpha < 0) BackbuttonAlpha = 0; } } diff --git a/src/menu/playerdisplay.cpp b/src/menu/playerdisplay.cpp index 5caf3ce42..c3d11a43a 100644 --- a/src/menu/playerdisplay.cpp +++ b/src/menu/playerdisplay.cpp @@ -35,8 +35,6 @@ #include "doomtype.h" #include "doomstat.h" #include "d_player.h" -#include "tables.h" -#include "m_fixed.h" #include "templates.h" #include "menu/menu.h" #include "colormatcher.h" @@ -59,6 +57,22 @@ struct FBackdropTexture : public FTexture { + enum + { + COS_SIZE = 256, + ANGLESHIFT = 24 + }; + + static constexpr uint32_t DEGREES(double v) + { + return uint32_t((v)*(0x40000000 / 90.0)); + } + + static double TORAD(uint32_t x) + { + return x*(M_PI / 0x80000000); + } + public: FBackdropTexture(); @@ -68,12 +82,13 @@ public: bool CheckModified(); protected: + uint32_t costab[COS_SIZE]; BYTE Pixels[144*160]; static const Span DummySpan[2]; int LastRenderTic; - angle_t time1, time2, time3, time4; - angle_t t1ang, t2ang, z1ang, z2ang; + uint32_t time1, time2, time3, time4; + uint32_t t1ang, t2ang, z1ang, z2ang; void Render(); }; @@ -171,14 +186,19 @@ FBackdropTexture::FBackdropTexture() WidthMask = 255; LastRenderTic = 0; - time1 = ANGLE_1*180; - time2 = ANGLE_1*56; - time3 = ANGLE_1*99; - time4 = ANGLE_1*1; - t1ang = ANGLE_90; + for (int i = 0; i < COS_SIZE; ++i) + { + costab[i] = uint32_t(cos(i * (M_PI / (COS_SIZE / 2))) * 65536); + } + + time1 = DEGREES(180); + time2 = DEGREES(56); + time3 = DEGREES(99); + time4 = DEGREES(1); + t1ang = DEGREES(90); t2ang = 0; z1ang = 0; - z2ang = ANGLE_90/2; + z2ang = DEGREES(45); } //============================================================================= @@ -248,22 +268,23 @@ void FBackdropTexture::Render() int x, y; - const angle_t a1add = ANGLE_1/2; - const angle_t a2add = ANGLE_MAX-ANGLE_1; - const angle_t a3add = ANGLE_1*5/7; - const angle_t a4add = ANGLE_MAX-ANGLE_1*4/3; + const DWORD a1add = DEGREES(0.5); + const DWORD a2add = DEGREES(359); + const DWORD a3add = DEGREES(5 / 7.f); + const DWORD a4add = DEGREES(358.66666); - const angle_t t1add = ANGLE_MAX-ANGLE_1*2; - const angle_t t2add = ANGLE_MAX-ANGLE_1*3+ANGLE_1/6; - const angle_t t3add = ANGLE_1*16/7; - const angle_t t4add = ANGLE_MAX-ANGLE_1*2/3; - const angle_t x1add = 5<>ANGLETOFINESHIFT]>>2)+FRACUNIT/2; - fixed_t z2 = (finecosine[z1ang>>ANGLETOFINESHIFT]>>2)+FRACUNIT*3/4; + double z1 = (cos(TORAD(z2ang)) / 4 + 0.5) * (0x8000000); + double z2 = (cos(TORAD(z1ang)) / 4 + 0.75) * (0x8000000); - tc = MulScale5 (finecosine[t1ang>>ANGLETOFINESHIFT], z1); - ts = MulScale5 (finesine[t1ang>>ANGLETOFINESHIFT], z1); - uc = MulScale5 (finecosine[t2ang>>ANGLETOFINESHIFT], z2); - us = MulScale5 (finesine[t2ang>>ANGLETOFINESHIFT], z2); - - ltx = -width/2*tc; - lty = -width/2*ts; - lux = -width/2*uc; - luy = -width/2*us; + tc = SDWORD(cos(TORAD(t1ang)) * z1); + ts = SDWORD(sin(TORAD(t1ang)) * z1); + uc = SDWORD(cos(TORAD(t2ang)) * z2); + us = SDWORD(sin(TORAD(t2ang)) * z2); + + ltx = -width / 2 * tc; + lty = -width / 2 * ts; + lux = -width / 2 * uc; + luy = -width / 2 * us; for (y = 0; y < height; ++y) { a1 = time1; a2 = time2; - c3 = finecosine[a3>>ANGLETOFINESHIFT]; - c4 = finecosine[a4>>ANGLETOFINESHIFT]; - tx = ltx - (y-height/2)*ts; - ty = lty + (y-height/2)*tc; - ux = lux - (y-height/2)*us; - uy = luy + (y-height/2)*uc; + c3 = SDWORD(cos(TORAD(a3)) * 65536.0); + c4 = SDWORD(cos(TORAD(a4)) * 65536.0); + tx = ltx - (y - height / 2)*ts; + ty = lty + (y - height / 2)*tc; + ux = lux - (y - height / 2)*us; + uy = luy + (y - height / 2)*uc; for (x = 0; x < width; ++x) { - c1 = finecosine[a1>>ANGLETOFINESHIFT]; - c2 = finecosine[a2>>ANGLETOFINESHIFT]; - from[x] = ((c1 + c2 + c3 + c4) >> (FRACBITS+3-7)) + 128 // plasma - + pattern1[(tx>>27)+((ty>>22)&992)] // rotozoomer 1 - + pattern2[(ux>>27)+((uy>>22)&992)]; // rotozoomer 2 + c1 = costab[a1 >> ANGLESHIFT]; + c2 = costab[a2 >> ANGLESHIFT]; + from[x] = ((c1 + c2 + c3 + c4) >> (16 + 3 - 7)) + 128 // plasma + + pattern1[(tx >> 27) + ((ty >> 22) & 992)] // rotozoomer 1 + + pattern2[(ux >> 27) + ((uy >> 22) & 992)]; // rotozoomer 2 tx += tc; ty += ts; ux += uc; diff --git a/src/menu/readthis.cpp b/src/menu/readthis.cpp index 82b20bf00..0aa3c2fcd 100644 --- a/src/menu/readthis.cpp +++ b/src/menu/readthis.cpp @@ -79,7 +79,7 @@ DReadThisMenu::DReadThisMenu(DMenu *parent) void DReadThisMenu::Drawer() { FTexture *tex = NULL, *prevpic = NULL; - fixed_t alpha; + double alpha; // Did the mapper choose a custom help page via MAPINFO? if ((level.info != NULL) && level.info->F1Pic.Len() != 0) @@ -99,12 +99,12 @@ void DReadThisMenu::Drawer() } screen->Dim(0, 1.0, 0,0, SCREENWIDTH, SCREENHEIGHT); - alpha = MIN (Scale (gametic - mInfoTic, OPAQUE, TICRATE/3), OPAQUE); - if (alpha < OPAQUE && prevpic != NULL) + alpha = MIN((gametic - mInfoTic) * (3. / TICRATE), 1.); + if (alpha < 1. && prevpic != NULL) { screen->DrawTexture (prevpic, 0, 0, DTA_Fullscreen, true, TAG_DONE); } - screen->DrawTexture (tex, 0, 0, DTA_Fullscreen, true, DTA_Alpha, alpha, TAG_DONE); + screen->DrawTexture (tex, 0, 0, DTA_Fullscreen, true, DTA_AlphaF, alpha, TAG_DONE); } diff --git a/src/tarray.h b/src/tarray.h index 7b9d5970b..8f370fcb9 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -42,7 +42,7 @@ #if !defined(_WIN32) #include // for intptr_t -#elif !defined(_MSC_VER) +#else #include // for mingw #endif diff --git a/src/zstrformat.cpp b/src/zstrformat.cpp index 63c179ca6..65ed889ae 100644 --- a/src/zstrformat.cpp +++ b/src/zstrformat.cpp @@ -92,12 +92,8 @@ #include "zstring.h" #include "gdtoa.h" -#ifndef _MSC_VER #include -#else -typedef unsigned __int64 uint64_t; -typedef signed __int64 int64_t; -#endif + /* * MAXEXPDIG is the maximum number of decimal digits needed to store a From 09d8b4af80713c4a176c4d4be0ab31deed724371 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 12:00:21 +0100 Subject: [PATCH 12/12] - changed I_GetTimeFrac to return a double instead of a fixed_t. --- src/posix/cocoa/i_timer.cpp | 6 +++--- src/posix/i_system.h | 2 +- src/posix/sdl/i_timer.cpp | 5 ++--- src/r_utility.cpp | 6 +++--- src/win32/i_system.cpp | 7 +++---- src/win32/i_system.h | 2 +- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/posix/cocoa/i_timer.cpp b/src/posix/cocoa/i_timer.cpp index b08a43139..901657eb9 100644 --- a/src/posix/cocoa/i_timer.cpp +++ b/src/posix/cocoa/i_timer.cpp @@ -186,7 +186,7 @@ unsigned int I_FPSTime() } -fixed_t I_GetTimeFrac(uint32* ms) +double I_GetTimeFrac(uint32* ms) { const uint32_t now = I_MSTime(); @@ -196,8 +196,8 @@ fixed_t I_GetTimeFrac(uint32* ms) } return 0 == s_ticStart - ? FRACUNIT - : clamp( (now - s_ticStart) * FRACUNIT * TICRATE / 1000, 0, FRACUNIT); + ? 1. + : clamp( (now - s_ticStart) * TICRATE / 1000., 0, 1); } diff --git a/src/posix/i_system.h b/src/posix/i_system.h index 391503602..0515f2d85 100644 --- a/src/posix/i_system.h +++ b/src/posix/i_system.h @@ -62,7 +62,7 @@ extern int (*I_WaitForTic) (int); // tic will never arrive (unless it's the current one). extern void (*I_FreezeTime) (bool frozen); -fixed_t I_GetTimeFrac (uint32 *ms); +double I_GetTimeFrac (uint32 *ms); // Return a seed value for the RNG. unsigned int I_MakeRNGSeed(); diff --git a/src/posix/sdl/i_timer.cpp b/src/posix/sdl/i_timer.cpp index 6255c8a96..fa08659a1 100644 --- a/src/posix/sdl/i_timer.cpp +++ b/src/posix/sdl/i_timer.cpp @@ -178,7 +178,7 @@ void I_SelectTimer() } // Returns the fractional amount of a tic passed since the most recent tic -fixed_t I_GetTimeFrac (uint32 *ms) +double I_GetTimeFrac (uint32 *ms) { DWORD now = SDL_GetTicks (); if (ms) *ms = TicStart + (1000 / TICRATE); @@ -188,8 +188,7 @@ fixed_t I_GetTimeFrac (uint32 *ms) } else { - fixed_t frac = clamp ((now - TicStart)*FRACUNIT*TICRATE/1000, 0, FRACUNIT); - return frac; + return clamp((now - TicStart) * TICRATE / 1000., 0, 1); } } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index c3229c14c..224648770 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -1006,12 +1006,12 @@ void R_SetupFrame (AActor *actor) iview->otic = nowtic; } - r_TicFrac = I_GetTimeFrac (&r_FrameTime); + r_TicFracF = I_GetTimeFrac (&r_FrameTime); if (cl_capfps || r_NoInterpolate) { - r_TicFrac = FRACUNIT; + r_TicFracF = 1.; } - r_TicFracF = FIXED2DBL(r_TicFrac); + r_TicFrac = FLOAT2FIXED(r_TicFracF); R_InterpolateView (player, r_TicFrac, iview); diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 0db4dd15e..ebf90e476 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -468,7 +468,7 @@ static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw // //========================================================================== -fixed_t I_GetTimeFrac(uint32 *ms) +double I_GetTimeFrac(uint32 *ms) { DWORD now = timeGetTime(); if (ms != NULL) @@ -478,12 +478,11 @@ fixed_t I_GetTimeFrac(uint32 *ms) DWORD step = TicNext - TicStart; if (step == 0) { - return FRACUNIT; + return 1.; } else { - fixed_t frac = clamp ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT); - return frac; + return clamp(double(now - TicStart) / step, 0, 1); } } diff --git a/src/win32/i_system.h b/src/win32/i_system.h index 179af4804..8e75b22a3 100644 --- a/src/win32/i_system.h +++ b/src/win32/i_system.h @@ -90,7 +90,7 @@ extern int (*I_WaitForTic) (int); // tic will never arrive (unless it's the current one). extern void (*I_FreezeTime) (bool frozen); -fixed_t I_GetTimeFrac (uint32 *ms); +double I_GetTimeFrac (uint32 *ms); // Return a seed value for the RNG. unsigned int I_MakeRNGSeed();