- g_shared refactored

This commit is contained in:
Christoph Oelckers 2016-01-19 13:26:05 +01:00
parent 9f78bcd1e6
commit 27aeb6a656
15 changed files with 111 additions and 122 deletions

View file

@ -262,14 +262,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
i = (pr_freeze.Random2()) % (numChunks/4); i = (pr_freeze.Random2()) % (numChunks/4);
for (i = MAX (24, numChunks + i); i >= 0; i--) for (i = MAX (24, numChunks + i); i >= 0; i--)
{ {
mo = Spawn("IceChunk", mo = Spawn("IceChunk", self->Vec3Offset(
self->x + (((pr_freeze()-128)*self->radius)>>7), (((pr_freeze()-128)*self->radius)>>7),
self->y + (((pr_freeze()-128)*self->radius)>>7), (((pr_freeze()-128)*self->radius)>>7),
self->z + (pr_freeze()*self->height/255), ALLOW_REPLACE); (pr_freeze()*self->height/255)), ALLOW_REPLACE);
if (mo) if (mo)
{ {
mo->SetState (mo->SpawnState + (pr_freeze()%3)); mo->SetState (mo->SpawnState + (pr_freeze()%3));
mo->velz = FixedDiv(mo->z - self->z, self->height)<<2; mo->velz = FixedDiv(mo->Z() - self->Z(), self->height)<<2;
mo->velx = pr_freeze.Random2 () << (FRACBITS-7); mo->velx = pr_freeze.Random2 () << (FRACBITS-7);
mo->vely = pr_freeze.Random2 () << (FRACBITS-7); mo->vely = pr_freeze.Random2 () << (FRACBITS-7);
CALL_ACTION(A_IceSetTics, mo); // set a random tic wait CALL_ACTION(A_IceSetTics, mo); // set a random tic wait
@ -279,11 +279,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
} }
if (self->player) if (self->player)
{ // attach the player's view to a chunk of ice { // attach the player's view to a chunk of ice
AActor *head = Spawn("IceChunkHead", self->x, self->y, AActor *head = Spawn("IceChunkHead", self->PosPlusZ(self->player->mo->ViewHeight), ALLOW_REPLACE);
self->z + self->player->mo->ViewHeight, ALLOW_REPLACE);
if (head != NULL) if (head != NULL)
{ {
head->velz = FixedDiv(head->z - self->z, self->height)<<2; head->velz = FixedDiv(head->Z() - self->Z(), self->height)<<2;
head->velx = pr_freeze.Random2 () << (FRACBITS-7); head->velx = pr_freeze.Random2 () << (FRACBITS-7);
head->vely = pr_freeze.Random2 () << (FRACBITS-7); head->vely = pr_freeze.Random2 () << (FRACBITS-7);
head->health = self->health; head->health = self->health;

View file

@ -965,7 +965,7 @@ void APowerFlight::InitEffect ()
Super::InitEffect(); Super::InitEffect();
Owner->flags2 |= MF2_FLY; Owner->flags2 |= MF2_FLY;
Owner->flags |= MF_NOGRAVITY; Owner->flags |= MF_NOGRAVITY;
if (Owner->z <= Owner->floorz) if (Owner->Z() <= Owner->floorz)
{ {
Owner->velz = 4*FRACUNIT; // thrust the player in the air a bit Owner->velz = 4*FRACUNIT; // thrust the player in the air a bit
} }
@ -1012,7 +1012,7 @@ void APowerFlight::EndEffect ()
if (!(Owner->flags7 & MF7_FLYCHEAT)) if (!(Owner->flags7 & MF7_FLYCHEAT))
{ {
if (Owner->z != Owner->floorz) if (Owner->Z() != Owner->floorz)
{ {
Owner->player->centering = true; Owner->player->centering = true;
} }
@ -1250,7 +1250,7 @@ void APowerSpeed::DoEffect ()
if (P_AproxDistance (Owner->velx, Owner->vely) <= 12*FRACUNIT) if (P_AproxDistance (Owner->velx, Owner->vely) <= 12*FRACUNIT)
return; return;
AActor *speedMo = Spawn<APlayerSpeedTrail> (Owner->x, Owner->y, Owner->z, NO_REPLACE); AActor *speedMo = Spawn<APlayerSpeedTrail> (Owner->Pos(), NO_REPLACE);
if (speedMo) if (speedMo)
{ {
speedMo->angle = Owner->angle; speedMo->angle = Owner->angle;

View file

@ -110,9 +110,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / (100 * FRACUNIT)); if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / (100 * FRACUNIT));
self->angle += rotationspeed; self->angle += rotationspeed;
self->x = self->target->x + rotationradius * finecosine[self->angle >> ANGLETOFINESHIFT]; self->SetOrigin(self->target->Vec3Angle(rotationradius, self->angle, 0), true);
self->y = self->target->y + rotationradius * finesine[self->angle >> ANGLETOFINESHIFT]; self->floorz = self->target->floorz;
self->z = self->target->z; self->ceilingz = self->target->ceilingz;
} }
@ -120,16 +120,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
{ {
angle_t startangle; angle_t startangle;
AActor *ball; AActor *ball;
fixed_t cx, cy, cz;
ACTION_PARAM_START(1); ACTION_PARAM_START(1);
ACTION_PARAM_CLASS(balltype, 0); ACTION_PARAM_CLASS(balltype, 0);
if (balltype == NULL) balltype = PClass::FindClass("BridgeBall"); if (balltype == NULL) balltype = PClass::FindClass("BridgeBall");
cx = self->x;
cy = self->y;
cz = self->z;
startangle = pr_orbit() << 24; startangle = pr_orbit() << 24;
// Spawn triad into world -- may be more than a triad now. // Spawn triad into world -- may be more than a triad now.
@ -137,7 +133,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit)
for (int i = 0; i < ballcount; i++) for (int i = 0; i < ballcount; i++)
{ {
ball = Spawn(balltype, cx, cy, cz, ALLOW_REPLACE); ball = Spawn(balltype, self->Pos(), ALLOW_REPLACE);
ball->angle = startangle + (ANGLE_45/32) * (256/ballcount) * i; ball->angle = startangle + (ANGLE_45/32) * (256/ballcount) * i;
ball->target = self; ball->target = self;
CALL_ACTION(A_BridgeOrbit, ball); CALL_ACTION(A_BridgeOrbit, ball);

View file

@ -176,11 +176,10 @@ void AAimingCamera::Tick ()
} }
if (MaxPitchChange) if (MaxPitchChange)
{ // Aim camera's pitch; use floats for precision { // Aim camera's pitch; use floats for precision
float dx = FIXED2FLOAT(x - tracer->x); TVector2<double> vect = tracer->Vec2To(this);
float dy = FIXED2FLOAT(y - tracer->y); double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2);
float dz = FIXED2FLOAT(z - tracer->z - tracer->height/2); double dist = vect.Length();
float dist = (float)sqrt (dx*dx + dy*dy); double ang = dist != 0.f ? atan2 (dz, dist) : 0;
float ang = dist != 0.f ? (float)atan2 (dz, dist) : 0;
int desiredpitch = (angle_t)(ang * 2147483648.f / PI); int desiredpitch = (angle_t)(ang * 2147483648.f / PI);
if (abs (desiredpitch - pitch) < MaxPitchChange) if (abs (desiredpitch - pitch) < MaxPitchChange)
{ {

View file

@ -36,17 +36,14 @@ void P_SpawnDirt (AActor *actor, fixed_t radius)
AActor *mo; AActor *mo;
angle_t angle; angle_t angle;
angle = pr_dirt()<<5; // <<24 >>19 fixedvec3 pos = actor->Vec3Angle(radius, pr_dirt() << 24, (pr_dirt() << 9) + FRACUNIT);
x = actor->x + FixedMul(radius,finecosine[angle]);
y = actor->y + FixedMul(radius,finesine[angle]);
z = actor->z + (pr_dirt()<<9) + FRACUNIT;
char fmt[8]; char fmt[8];
mysnprintf(fmt, countof(fmt), "Dirt%d", 1 + pr_dirt()%6); mysnprintf(fmt, countof(fmt), "Dirt%d", 1 + pr_dirt()%6);
dtype = PClass::FindClass(fmt); dtype = PClass::FindClass(fmt);
if (dtype) if (dtype)
{ {
mo = Spawn (dtype, x, y, z, ALLOW_REPLACE); mo = Spawn (dtype, pos, ALLOW_REPLACE);
if (mo) if (mo)
{ {
mo->velz = pr_dirt()<<10; mo->velz = pr_dirt()<<10;

View file

@ -91,7 +91,7 @@ DBaseDecal::DBaseDecal (int statnum, fixed_t z)
DBaseDecal::DBaseDecal (const AActor *basis) DBaseDecal::DBaseDecal (const AActor *basis)
: DThinker(STAT_DECAL), : DThinker(STAT_DECAL),
WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->z), ScaleX(basis->scaleX), ScaleY(basis->scaleY), WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->Z()), ScaleX(basis->scaleX), ScaleY(basis->scaleY),
Alpha(basis->alpha), AlphaColor(basis->fillcolor), Translation(basis->Translation), PicNum(basis->picnum), Alpha(basis->alpha), AlphaColor(basis->fillcolor), Translation(basis->Translation), PicNum(basis->picnum),
RenderFlags(basis->renderflags), RenderStyle(basis->RenderStyle) RenderFlags(basis->renderflags), RenderStyle(basis->RenderStyle)
{ {
@ -817,22 +817,22 @@ void ADecal::BeginPlay ()
{ {
if (!tpl->PicNum.Exists()) if (!tpl->PicNum.Exists())
{ {
Printf("Decal actor at (%d,%d) does not have a valid texture\n", x>>FRACBITS, y>>FRACBITS); Printf("Decal actor at (%d,%d) does not have a valid texture\n", X()>>FRACBITS, Y()>>FRACBITS);
} }
else else
{ {
// Look for a wall within 64 units behind the actor. If none can be // Look for a wall within 64 units behind the actor. If none can be
// found, then no decal is created, and this actor is destroyed // found, then no decal is created, and this actor is destroyed
// without effectively doing anything. // without effectively doing anything.
if (NULL == ShootDecal(tpl, this, Sector, x, y, z, angle + ANGLE_180, 64*FRACUNIT, true)) if (NULL == ShootDecal(tpl, this, Sector, X(), Y(), Z(), angle + ANGLE_180, 64*FRACUNIT, true))
{ {
DPrintf ("Could not find a wall to stick decal to at (%d,%d)\n", x>>FRACBITS, y>>FRACBITS); DPrintf ("Could not find a wall to stick decal to at (%d,%d)\n", X()>>FRACBITS, Y()>>FRACBITS);
} }
} }
} }
else else
{ {
DPrintf ("Decal actor at (%d,%d) does not have a good template\n", x>>FRACBITS, y>>FRACBITS); DPrintf ("Decal actor at (%d,%d) does not have a good template\n", X()>>FRACBITS, Y()>>FRACBITS);
} }
// This actor doesn't need to stick around anymore. // This actor doesn't need to stick around anymore.
Destroy(); Destroy();

View file

@ -25,10 +25,10 @@ void AFastProjectile::Tick ()
fixed_t zfrac; fixed_t zfrac;
int changexy; int changexy;
PrevX = x; PrevX = X();
PrevY = y; PrevY = Y();
PrevZ = z; PrevZ = Z();
fixed_t oldz = z; fixed_t oldz = Z();
PrevAngle = angle; PrevAngle = angle;
if (!(flags5 & MF5_NOTIMEFREEZE)) if (!(flags5 & MF5_NOTIMEFREEZE))
@ -57,7 +57,7 @@ void AFastProjectile::Tick ()
} }
// Handle movement // Handle movement
if (velx || vely || (z != floorz) || velz) if (velx || vely || (Z() != floorz) || velz)
{ {
xfrac = velx >> shift; xfrac = velx >> shift;
yfrac = vely >> shift; yfrac = vely >> shift;
@ -73,14 +73,14 @@ void AFastProjectile::Tick ()
tm.LastRipped = NULL; // [RH] Do rip damage each step, like Hexen tm.LastRipped = NULL; // [RH] Do rip damage each step, like Hexen
} }
if (!P_TryMove (this, x + xfrac,y + yfrac, true, NULL, tm)) if (!P_TryMove (this, X() + xfrac,Y() + yfrac, true, NULL, tm))
{ // Blocked move { // Blocked move
if (!(flags3 & MF3_SKYEXPLODE)) if (!(flags3 & MF3_SKYEXPLODE))
{ {
if (tm.ceilingline && if (tm.ceilingline &&
tm.ceilingline->backsector && tm.ceilingline->backsector &&
tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
z >= tm.ceilingline->backsector->ceilingplane.ZatPoint (x, y)) Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint (this))
{ {
// Hack to prevent missiles exploding against the sky. // Hack to prevent missiles exploding against the sky.
// Does not handle sky floors. // Does not handle sky floors.
@ -99,10 +99,10 @@ void AFastProjectile::Tick ()
return; return;
} }
} }
z += zfrac; AddZ(zfrac);
UpdateWaterLevel (oldz); UpdateWaterLevel (oldz);
oldz = z; oldz = Z();
if (z <= floorz) if (Z() <= floorz)
{ // Hit the floor { // Hit the floor
if (floorpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) if (floorpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE))
@ -113,12 +113,12 @@ void AFastProjectile::Tick ()
return; return;
} }
z = floorz; SetZ(floorz);
P_HitFloor (this); P_HitFloor (this);
P_ExplodeMissile (this, NULL, NULL); P_ExplodeMissile (this, NULL, NULL);
return; return;
} }
if (z + height > ceilingz) if (Top() > ceilingz)
{ // Hit the ceiling { // Hit the ceiling
if (ceilingpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) if (ceilingpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE))
@ -127,7 +127,7 @@ void AFastProjectile::Tick ()
return; return;
} }
z = ceilingz - height; SetZ(ceilingz - height);
P_ExplodeMissile (this, NULL, NULL); P_ExplodeMissile (this, NULL, NULL);
return; return;
} }
@ -160,7 +160,7 @@ void AFastProjectile::Effect()
FName name = (ENamedName) this->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None); FName name = (ENamedName) this->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None);
if (name != NAME_None) if (name != NAME_None)
{ {
fixed_t hitz = z-8*FRACUNIT; fixed_t hitz = Z()-8*FRACUNIT;
if (hitz < floorz) if (hitz < floorz)
{ {
@ -172,7 +172,7 @@ void AFastProjectile::Effect()
const PClass *trail = PClass::FindClass(name); const PClass *trail = PClass::FindClass(name);
if (trail != NULL) if (trail != NULL)
{ {
AActor *act = Spawn (trail, x, y, hitz, ALLOW_REPLACE); AActor *act = Spawn (trail, X(), Y(), hitz, ALLOW_REPLACE);
if (act != NULL) if (act != NULL)
{ {
act->angle = this->angle; act->angle = this->angle;

View file

@ -77,7 +77,7 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i
return false; return false;
} }
morphed = static_cast<APlayerPawn *>(Spawn (spawntype, actor->x, actor->y, actor->z, NO_REPLACE)); morphed = static_cast<APlayerPawn *>(Spawn (spawntype, actor->Pos(), NO_REPLACE));
EndAllPowerupEffects(actor->Inventory); EndAllPowerupEffects(actor->Inventory);
DObject::StaticPointerSubstitution (actor, morphed); DObject::StaticPointerSubstitution (actor, morphed);
if ((actor->tid != 0) && (style & MORPH_NEWTIDBEHAVIOUR)) if ((actor->tid != 0) && (style & MORPH_NEWTIDBEHAVIOUR))
@ -105,7 +105,7 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i
morphed->flags |= actor->flags & (MF_SHADOW|MF_NOGRAVITY); morphed->flags |= actor->flags & (MF_SHADOW|MF_NOGRAVITY);
morphed->flags2 |= actor->flags2 & MF2_FLY; morphed->flags2 |= actor->flags2 & MF2_FLY;
morphed->flags3 |= actor->flags3 & MF3_GHOST; morphed->flags3 |= actor->flags3 & MF3_GHOST;
AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->x, actor->y, actor->z + TELEFOGHEIGHT, ALLOW_REPLACE); AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->PosPlusZ(TELEFOGHEIGHT), ALLOW_REPLACE);
actor->player = NULL; actor->player = NULL;
actor->flags &= ~(MF_SOLID|MF_SHOOTABLE); actor->flags &= ~(MF_SOLID|MF_SHOOTABLE);
actor->flags |= MF_UNMORPHED; actor->flags |= MF_UNMORPHED;
@ -192,7 +192,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
} }
mo = barrier_cast<APlayerPawn *>(pmo->tracer); mo = barrier_cast<APlayerPawn *>(pmo->tracer);
mo->SetOrigin (pmo->x, pmo->y, pmo->z); mo->SetOrigin (pmo->Pos(), false);
mo->flags |= MF_SOLID; mo->flags |= MF_SOLID;
pmo->flags &= ~MF_SOLID; pmo->flags &= ~MF_SOLID;
if (!force && !P_TestMobjLocation (mo)) if (!force && !P_TestMobjLocation (mo))
@ -310,7 +310,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
AActor *eflash = NULL; AActor *eflash = NULL;
if (exit_flash != NULL) if (exit_flash != NULL)
{ {
eflash = Spawn(exit_flash, pmo->x + 20*finecosine[angle], pmo->y + 20*finesine[angle], pmo->z + TELEFOGHEIGHT, ALLOW_REPLACE); eflash = Spawn(exit_flash, pmo->Vec3Offset(20*finecosine[angle], 20*finesine[angle], TELEFOGHEIGHT), ALLOW_REPLACE);
if (eflash) eflash->target = mo; if (eflash) eflash->target = mo;
} }
mo->SetupWeaponSlots(); // Use original class's weapon slots. mo->SetupWeaponSlots(); // Use original class's weapon slots.
@ -381,7 +381,7 @@ bool P_MorphMonster (AActor *actor, const PClass *spawntype, int duration, int s
return false; return false;
} }
morphed = static_cast<AMorphedMonster *>(Spawn (spawntype, actor->x, actor->y, actor->z, NO_REPLACE)); morphed = static_cast<AMorphedMonster *>(Spawn (spawntype, actor->Pos(), NO_REPLACE));
DObject::StaticPointerSubstitution (actor, morphed); DObject::StaticPointerSubstitution (actor, morphed);
morphed->tid = actor->tid; morphed->tid = actor->tid;
morphed->angle = actor->angle; morphed->angle = actor->angle;
@ -410,7 +410,7 @@ bool P_MorphMonster (AActor *actor, const PClass *spawntype, int duration, int s
actor->flags &= ~(MF_SOLID|MF_SHOOTABLE); actor->flags &= ~(MF_SOLID|MF_SHOOTABLE);
actor->flags |= MF_UNMORPHED; actor->flags |= MF_UNMORPHED;
actor->renderflags |= RF_INVISIBLE; actor->renderflags |= RF_INVISIBLE;
AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->x, actor->y, actor->z + TELEFOGHEIGHT, ALLOW_REPLACE); AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->PosPlusZ(TELEFOGHEIGHT), ALLOW_REPLACE);
if (eflash) if (eflash)
eflash->target = morphed; eflash->target = morphed;
return true; return true;
@ -436,7 +436,7 @@ bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force)
return false; return false;
} }
actor = beast->UnmorphedMe; actor = beast->UnmorphedMe;
actor->SetOrigin (beast->x, beast->y, beast->z); actor->SetOrigin (beast->Pos(), false);
actor->flags |= MF_SOLID; actor->flags |= MF_SOLID;
beast->flags &= ~MF_SOLID; beast->flags &= ~MF_SOLID;
ActorFlags6 beastflags6 = beast->flags6; ActorFlags6 beastflags6 = beast->flags6;
@ -472,7 +472,7 @@ bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force)
DObject::StaticPointerSubstitution (beast, actor); DObject::StaticPointerSubstitution (beast, actor);
const PClass *exit_flash = beast->MorphExitFlash; const PClass *exit_flash = beast->MorphExitFlash;
beast->Destroy (); beast->Destroy ();
AActor *eflash = Spawn(exit_flash, beast->x, beast->y, beast->z + TELEFOGHEIGHT, ALLOW_REPLACE); AActor *eflash = Spawn(exit_flash, beast->PosPlusZ(TELEFOGHEIGHT), ALLOW_REPLACE);
if (eflash) if (eflash)
eflash->target = actor; eflash->target = actor;
return true; return true;

View file

@ -282,7 +282,7 @@ void APathFollower::Activate (AActor *activator)
if (CurrNode != NULL) if (CurrNode != NULL)
{ {
NewNode (); NewNode ();
SetOrigin (CurrNode->x, CurrNode->y, CurrNode->z); SetOrigin (CurrNode->Pos(), false);
Time = 0.f; Time = 0.f;
HoldTime = 0; HoldTime = 0;
bJustStepped = true; bJustStepped = true;
@ -302,9 +302,7 @@ void APathFollower::Tick ()
if (CurrNode->args[2]) if (CurrNode->args[2])
{ {
HoldTime = level.time + CurrNode->args[2] * TICRATE / 8; HoldTime = level.time + CurrNode->args[2] * TICRATE / 8;
x = CurrNode->x; SetXYZ(CurrNode->X(), CurrNode->Y(), CurrNode->Z());
y = CurrNode->y;
z = CurrNode->z;
} }
} }
@ -362,31 +360,33 @@ bool APathFollower::Interpolate ()
if ((args[2] & 8) && Time > 0.f) if ((args[2] & 8) && Time > 0.f)
{ {
dx = x; dx = X();
dy = y; dy = Y();
dz = z; dz = Z();
} }
if (CurrNode->Next==NULL) return false; if (CurrNode->Next==NULL) return false;
UnlinkFromWorld (); UnlinkFromWorld ();
fixed_t x, y, z;
if (args[2] & 1) if (args[2] & 1)
{ // linear { // linear
x = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->x), FIXED2FLOAT(CurrNode->Next->x))); x = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->X()), FIXED2FLOAT(CurrNode->Next->X())));
y = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->y), FIXED2FLOAT(CurrNode->Next->y))); y = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->Y()), FIXED2FLOAT(CurrNode->Next->Y())));
z = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->z), FIXED2FLOAT(CurrNode->Next->z))); z = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->Z()), FIXED2FLOAT(CurrNode->Next->Z())));
} }
else else
{ // spline { // spline
if (CurrNode->Next->Next==NULL) return false; if (CurrNode->Next->Next==NULL) return false;
x = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->x), FIXED2FLOAT(CurrNode->x), x = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->X()), FIXED2FLOAT(CurrNode->X()),
FIXED2FLOAT(CurrNode->Next->x), FIXED2FLOAT(CurrNode->Next->Next->x))); FIXED2FLOAT(CurrNode->Next->X()), FIXED2FLOAT(CurrNode->Next->Next->X())));
y = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->y), FIXED2FLOAT(CurrNode->y), y = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->Y()), FIXED2FLOAT(CurrNode->Y()),
FIXED2FLOAT(CurrNode->Next->y), FIXED2FLOAT(CurrNode->Next->Next->y))); FIXED2FLOAT(CurrNode->Next->Y()), FIXED2FLOAT(CurrNode->Next->Next->Y())));
z = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->z), FIXED2FLOAT(CurrNode->z), z = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->Z()), FIXED2FLOAT(CurrNode->Z()),
FIXED2FLOAT(CurrNode->Next->z), FIXED2FLOAT(CurrNode->Next->Next->z))); FIXED2FLOAT(CurrNode->Next->Z()), FIXED2FLOAT(CurrNode->Next->Next->Z())));
} }
SetXYZ(x, y, z);
LinkToWorld (); LinkToWorld ();
if (args[2] & 6) if (args[2] & 6)
@ -395,9 +395,9 @@ bool APathFollower::Interpolate ()
{ {
if (args[2] & 1) if (args[2] & 1)
{ // linear { // linear
dx = CurrNode->Next->x - CurrNode->x; dx = CurrNode->Next->X() - CurrNode->X();
dy = CurrNode->Next->y - CurrNode->y; dy = CurrNode->Next->Y() - CurrNode->Y();
dz = CurrNode->Next->z - CurrNode->z; dz = CurrNode->Next->Z() - CurrNode->Z();
} }
else if (Time > 0.f) else if (Time > 0.f)
{ // spline { // spline
@ -422,6 +422,7 @@ bool APathFollower::Interpolate ()
x -= dx; x -= dx;
y -= dy; y -= dy;
z -= dz; z -= dz;
SetXYZ(x, y, z);
} }
if (args[2] & 2) if (args[2] & 2)
{ // adjust yaw { // adjust yaw
@ -548,11 +549,11 @@ bool AActorMover::Interpolate ()
if (Super::Interpolate ()) if (Super::Interpolate ())
{ {
fixed_t savedz = tracer->z; fixed_t savedz = tracer->Z();
tracer->z = z; tracer->SetZ(Z());
if (!P_TryMove (tracer, x, y, true)) if (!P_TryMove (tracer, X(), Y(), true))
{ {
tracer->z = savedz; tracer->SetZ(savedz);
return false; return false;
} }
@ -589,9 +590,9 @@ void AActorMover::Activate (AActor *activator)
// Don't let the renderer interpolate between the actor's // Don't let the renderer interpolate between the actor's
// old position and its new position. // old position and its new position.
Interpolate (); Interpolate ();
tracer->PrevX = tracer->x; tracer->PrevX = tracer->X();
tracer->PrevY = tracer->y; tracer->PrevY = tracer->Y();
tracer->PrevZ = tracer->z; tracer->PrevZ = tracer->Z();
tracer->PrevAngle = tracer->angle; tracer->PrevAngle = tracer->angle;
} }
@ -667,15 +668,15 @@ bool AMovingCamera::Interpolate ()
if (Super::Interpolate ()) if (Super::Interpolate ())
{ {
angle = R_PointToAngle2 (x, y, tracer->x, tracer->y); angle = AngleTo(tracer, true);
if (args[2] & 4) if (args[2] & 4)
{ // Also aim camera's pitch; use floats for precision { // Also aim camera's pitch; use floats for precision
float dx = FIXED2FLOAT(x - tracer->x); double dx = FIXED2DBL(X() - tracer->X());
float dy = FIXED2FLOAT(y - tracer->y); double dy = FIXED2DBL(Y() - tracer->Y());
float dz = FIXED2FLOAT(z - tracer->z - tracer->height/2); double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2);
float dist = (float)sqrt (dx*dx + dy*dy); double dist = sqrt (dx*dx + dy*dy);
float ang = dist != 0.f ? (float)atan2 (dz, dist) : 0; double ang = dist != 0.f ? atan2 (dz, dist) : 0;
pitch = (angle_t)(ang * 2147483648.f / PI); pitch = (angle_t)(ang * 2147483648.f / PI);
} }

View file

@ -331,7 +331,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialDoomThing)
{ {
self->SetState (self->SpawnState); self->SetState (self->SpawnState);
S_Sound (self, CHAN_VOICE, "misc/spawn", 1, ATTN_IDLE); S_Sound (self, CHAN_VOICE, "misc/spawn", 1, ATTN_IDLE);
Spawn ("ItemFog", self->x, self->y, self->z, ALLOW_REPLACE); Spawn ("ItemFog", self->Pos(), ALLOW_REPLACE);
} }
} }
@ -351,19 +351,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
_y = self->SpawnPoint[1]; _y = self->SpawnPoint[1];
self->UnlinkFromWorld(); self->UnlinkFromWorld();
self->x = _x; self->SetXY(_x, _y);
self->y = _y;
self->LinkToWorld(true); self->LinkToWorld(true);
sec = self->Sector; sec = self->Sector;
self->z =
self->dropoffz = self->dropoffz =
self->floorz = sec->floorplane.ZatPoint(_x, _y); self->floorz = sec->floorplane.ZatPoint(_x, _y);
self->ceilingz = sec->ceilingplane.ZatPoint(_x, _y); self->ceilingz = sec->ceilingplane.ZatPoint(_x, _y);
self->SetZ(self->floorz);
P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS); P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS);
if (self->flags & MF_SPAWNCEILING) if (self->flags & MF_SPAWNCEILING)
{ {
self->z = self->ceilingz - self->height - self->SpawnPoint[2]; self->SetZ(self->ceilingz - self->height - self->SpawnPoint[2]);
} }
else if (self->flags2 & MF2_SPAWNFLOAT) else if (self->flags2 & MF2_SPAWNFLOAT)
{ {
@ -371,33 +370,33 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
if (space > 48*FRACUNIT) if (space > 48*FRACUNIT)
{ {
space -= 40*FRACUNIT; space -= 40*FRACUNIT;
self->z = ((space * pr_restore())>>8) + self->floorz + 40*FRACUNIT; self->SetZ(((space * pr_restore())>>8) + self->floorz + 40*FRACUNIT);
} }
else else
{ {
self->z = self->floorz; self->SetZ(self->floorz);
} }
} }
else else
{ {
self->z = self->SpawnPoint[2] + self->floorz; self->SetZ(self->SpawnPoint[2] + self->floorz);
} }
// Redo floor/ceiling check, in case of 3D floors // Redo floor/ceiling check, in case of 3D floors
P_FindFloorCeiling(self, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); P_FindFloorCeiling(self, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT);
if (self->z < self->floorz) if (self->Z() < self->floorz)
{ // Do not reappear under the floor, even if that's where we were for the { // Do not reappear under the floor, even if that's where we were for the
// initial spawn. // initial spawn.
self->z = self->floorz; self->SetZ(self->floorz);
} }
if ((self->flags & MF_SOLID) && (self->z + self->height > self->ceilingz)) if ((self->flags & MF_SOLID) && (self->Top() > self->ceilingz))
{ // Do the same for the ceiling. { // Do the same for the ceiling.
self->z = self->ceilingz - self->height; self->SetZ(self->ceilingz - self->height);
} }
// Do not interpolate from the position the actor was at when it was // Do not interpolate from the position the actor was at when it was
// picked up, in case that is different from where it is now. // picked up, in case that is different from where it is now.
self->PrevX = self->x; self->PrevX = self->X();
self->PrevY = self->y; self->PrevY = self->Y();
self->PrevZ = self->z; self->PrevZ = self->Z();
} }
int AInventory::StaticLastMessageTic; int AInventory::StaticLastMessageTic;
@ -728,8 +727,7 @@ AInventory *AInventory::CreateTossable ()
flags &= ~(MF_SPECIAL|MF_SOLID); flags &= ~(MF_SPECIAL|MF_SOLID);
return this; return this;
} }
copy = static_cast<AInventory *>(Spawn (GetClass(), Owner->x, copy = static_cast<AInventory *>(Spawn (GetClass(), Owner->Pos(), NO_REPLACE));
Owner->y, Owner->z, NO_REPLACE));
if (copy != NULL) if (copy != NULL)
{ {
copy->MaxAmount = MaxAmount; copy->MaxAmount = MaxAmount;
@ -994,7 +992,7 @@ void AInventory::Touch (AActor *toucher)
// This is the only situation when a pickup flash should ever play. // This is the only situation when a pickup flash should ever play.
if (PickupFlash != NULL && !ShouldStay()) if (PickupFlash != NULL && !ShouldStay())
{ {
Spawn(PickupFlash, x, y, z, ALLOW_REPLACE); Spawn(PickupFlash, Pos(), ALLOW_REPLACE);
} }
if (!(ItemFlags & IF_QUIET)) if (!(ItemFlags & IF_QUIET))
@ -1290,8 +1288,8 @@ bool AInventory::DoRespawn ()
if (state != NULL) spot = state->GetRandomSpot(SpawnPointClass); if (state != NULL) spot = state->GetRandomSpot(SpawnPointClass);
if (spot != NULL) if (spot != NULL)
{ {
SetOrigin (spot->x, spot->y, spot->z); SetOrigin (spot->Pos(), false);
z = floorz; SetZ(floorz);
} }
} }
return true; return true;

View file

@ -131,7 +131,7 @@ void DEarthquake::Tick ()
dist = m_Spot->AproxDistance (victim, true); dist = m_Spot->AproxDistance (victim, true);
// Check if in damage radius // Check if in damage radius
if (dist < m_DamageRadius && victim->z <= victim->floorz) if (dist < m_DamageRadius && victim->Z() <= victim->floorz)
{ {
if (pr_quake() < 50) if (pr_quake() < 50)
{ {

View file

@ -91,7 +91,7 @@ class ARandomSpawner : public AActor
// So now we can spawn the dropped item. // So now we can spawn the dropped item.
if (di == NULL || bouncecount >= MAX_RANDOMSPAWNERS_RECURSION) // Prevents infinite recursions if (di == NULL || bouncecount >= MAX_RANDOMSPAWNERS_RECURSION) // Prevents infinite recursions
{ {
Spawn("Unknown", x, y, z, NO_REPLACE); // Show that there's a problem. Spawn("Unknown", Pos(), NO_REPLACE); // Show that there's a problem.
Destroy(); Destroy();
return; return;
} }
@ -144,9 +144,9 @@ class ARandomSpawner : public AActor
if (this->flags & MF_MISSILE && target && target->target) // Attempting to spawn a missile. if (this->flags & MF_MISSILE && target && target->target) // Attempting to spawn a missile.
{ {
if ((tracer == NULL) && (flags2 & MF2_SEEKERMISSILE)) tracer = target->target; if ((tracer == NULL) && (flags2 & MF2_SEEKERMISSILE)) tracer = target->target;
newmobj = P_SpawnMissileXYZ(x, y, z, target, target->target, cls, false); newmobj = P_SpawnMissileXYZ(Pos(), target, target->target, cls, false);
} }
else newmobj = Spawn(cls, x, y, z, NO_REPLACE); else newmobj = Spawn(cls, Pos(), NO_REPLACE);
if (newmobj != NULL) if (newmobj != NULL)
{ {
// copy everything relevant // copy everything relevant
@ -179,7 +179,7 @@ class ARandomSpawner : public AActor
// Handle special altitude flags // Handle special altitude flags
if (newmobj->flags & MF_SPAWNCEILING) if (newmobj->flags & MF_SPAWNCEILING)
{ {
newmobj->z = newmobj->ceilingz - newmobj->height - SpawnPoint[2]; newmobj->SetZ(newmobj->ceilingz - newmobj->height - SpawnPoint[2]);
} }
else if (newmobj->flags2 & MF2_SPAWNFLOAT) else if (newmobj->flags2 & MF2_SPAWNFLOAT)
{ {
@ -187,9 +187,9 @@ class ARandomSpawner : public AActor
if (space > 48*FRACUNIT) if (space > 48*FRACUNIT)
{ {
space -= 40*FRACUNIT; space -= 40*FRACUNIT;
newmobj->z = MulScale8 (space, pr_randomspawn()) + newmobj->floorz + 40*FRACUNIT; newmobj->SetZ(MulScale8 (space, pr_randomspawn()) + newmobj->floorz + 40*FRACUNIT);
} }
newmobj->z += SpawnPoint[2]; newmobj->AddZ(SpawnPoint[2]);
} }
if (newmobj->flags & MF_MISSILE) if (newmobj->flags & MF_MISSILE)
P_CheckMissileSpawn(newmobj, 0); P_CheckMissileSpawn(newmobj, 0);

View file

@ -50,6 +50,6 @@ IMPLEMENT_CLASS (ASpark)
void ASpark::Activate (AActor *activator) void ASpark::Activate (AActor *activator)
{ {
Super::Activate (activator); Super::Activate (activator);
P_DrawSplash (args[0] ? args[0] : 32, x, y, z, angle, 1); P_DrawSplash (args[0] ? args[0] : 32, X(), Y(), Z(), angle, 1);
S_Sound (this, CHAN_AUTO, "world/spark", 1, ATTN_STATIC); S_Sound (this, CHAN_AUTO, "world/spark", 1, ATTN_STATIC);
} }

View file

@ -423,12 +423,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem)
return; return;
} }
AActor *spawned = Spawn(cls, self->x, self->y, self->z, ALLOW_REPLACE); AActor *spawned = Spawn(cls, self->Pos(), ALLOW_REPLACE);
if (spawned) if (spawned)
{ {
spawned->SetOrigin (spot->x, spot->y, spot->z); spawned->SetOrigin (spot->Pos(), false);
spawned->z = spawned->floorz; spawned->SetZ(spawned->floorz);
// We want this to respawn. // We want this to respawn.
if (!(self->flags & MF_DROPPED)) if (!(self->flags & MF_DROPPED))
{ {

View file

@ -1287,8 +1287,7 @@ void DBaseStatusBar::Draw (EHudState state)
} }
fixedvec3 pos = CPlayer->mo->Pos(); fixedvec3 pos = CPlayer->mo->Pos();
value = &pos.z; for (i = 2, value = &pos.z; i >= 0; y -= height, --value, --i)
for (i = 2, value = &CPlayer->mo->z; i >= 0; y -= height, --value, --i)
{ {
mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS); mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS);
screen->DrawText (SmallFont, CR_GREEN, xpos, y, line, screen->DrawText (SmallFont, CR_GREEN, xpos, y, line,