diff --git a/src/actor.h b/src/actor.h index 001f4698c0..6cbcaeb017 100644 --- a/src/actor.h +++ b/src/actor.h @@ -588,6 +588,36 @@ enum AMETA_BloodType3, // AxeBlood replacement type }; +struct fixedvec3 +{ + fixed_t x, y, z; + + operator FVector3() + { + return FVector3(FIXED2FLOAT(x), FIXED2FLOAT(y), FIXED2FLOAT(z)); + } + + operator TVector3() + { + return TVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); + } +}; + +struct fixedvec2 +{ + fixed_t x, y; + + operator FVector2() + { + return FVector2(FIXED2FLOAT(x), FIXED2FLOAT(y)); + } + + operator TVector2() + { + return TVector2(FIXED2DBL(x), FIXED2DBL(y)); + } +}; + struct FDropItem { FName Name; @@ -909,6 +939,35 @@ public: return R_PointToAngle2(myx, myy, other->x, other->y); } + fixedvec2 Vec2To(AActor *other) const + { + fixedvec2 ret = { other->x - x, other->y - y }; + return ret; + } + + fixedvec3 Vec3To(AActor *other) const + { + fixedvec3 ret = { other->x - x, other->y - y, other->z - z }; + return ret; + } + + fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy) const + { + fixedvec2 ret = { x + dx, y + dy }; + return ret; + } + + fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz) const + { + fixedvec3 ret = { x + dx, y + dy, z + dz }; + return ret; + } + + void Move(fixed_t dx, fixed_t dy, fixed_t dz) + { + SetOrigin(x + dx, y + dy, z + dz, true); + } + inline void SetFriendPlayer(player_t *player); bool IsVisibleToPlayer() const; @@ -1126,7 +1185,7 @@ public: void LinkToWorld (sector_t *sector); void UnlinkFromWorld (); void AdjustFloorClip (); - void SetOrigin (fixed_t x, fixed_t y, fixed_t z); + void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); bool InStateSequence(FState * newstate, FState * basestate); int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); @@ -1156,6 +1215,24 @@ public: bool HasSpecialDeathStates () const; + fixed_t X() const + { + return x; + } + fixed_t Y() const + { + return y; + } + fixed_t Z() const + { + return z; + } + void SetZ(fixed_t newz) + { + z = newz; + } + + // begin of GZDoom specific additions TArray > dynamiclights; void * lightassociations; @@ -1236,15 +1313,36 @@ inline AActor *Spawn (const PClass *type, fixed_t x, fixed_t y, fixed_t z, repla return AActor::StaticSpawn (type, x, y, z, allowreplacement); } +inline AActor *Spawn (const PClass *type, const fixedvec3 &pos, replace_t allowreplacement) +{ + return AActor::StaticSpawn (type, pos.x, pos.y, pos.z, 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 (const char *type, const fixedvec3 &pos, replace_t allowreplacement) +{ + return Spawn (type, pos.x, pos.y, pos.z, allowreplacement); +} + +inline AActor *Spawn (FName classname, const fixedvec3 &pos, replace_t allowreplacement) +{ + return Spawn (classname, pos.x, pos.y, pos.z, allowreplacement); +} + + template inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement) { return static_cast(AActor::StaticSpawn (RUNTIME_CLASS(T), x, y, z, allowreplacement)); } +template +inline T *Spawn (const fixedvec3 &pos, replace_t allowreplacement) +{ + return static_cast(AActor::StaticSpawn (RUNTIME_CLASS(T), pos.x, pos.y, pos.z, allowreplacement)); +} void PrintMiscActorInfo(AActor * query); diff --git a/src/am_map.cpp b/src/am_map.cpp index 606a65ae85..64d5420b0c 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -998,8 +998,8 @@ void AM_restoreScaleAndLoc () } else { - m_x = (players[consoleplayer].camera->x >> FRACTOMAPBITS) - m_w/2; - m_y = (players[consoleplayer].camera->y >> FRACTOMAPBITS)- m_h/2; + m_x = (players[consoleplayer].camera->X() >> FRACTOMAPBITS) - m_w/2; + m_y = (players[consoleplayer].camera->Y() >> FRACTOMAPBITS)- m_h/2; } m_x2 = m_x + m_w; m_y2 = m_y + m_h; @@ -1249,8 +1249,8 @@ void AM_initVariables () if (playeringame[pnum]) break; assert(pnum >= 0 && pnum < MAXPLAYERS); - m_x = (players[pnum].camera->x >> FRACTOMAPBITS) - m_w/2; - m_y = (players[pnum].camera->y >> FRACTOMAPBITS) - m_h/2; + m_x = (players[pnum].camera->X() >> FRACTOMAPBITS) - m_w/2; + m_y = (players[pnum].camera->Y() >> FRACTOMAPBITS) - m_h/2; AM_changeWindowLoc(); // for saving & restoring @@ -1571,25 +1571,25 @@ void AM_doFollowPlayer () fixed_t sx, sy; if (players[consoleplayer].camera != NULL && - (f_oldloc.x != players[consoleplayer].camera->x || - f_oldloc.y != players[consoleplayer].camera->y)) + (f_oldloc.x != players[consoleplayer].camera->X() || + f_oldloc.y != players[consoleplayer].camera->Y())) { - m_x = (players[consoleplayer].camera->x >> FRACTOMAPBITS) - m_w/2; - m_y = (players[consoleplayer].camera->y >> FRACTOMAPBITS) - m_h/2; + m_x = (players[consoleplayer].camera->X() >> FRACTOMAPBITS) - m_w/2; + m_y = (players[consoleplayer].camera->Y() >> FRACTOMAPBITS) - m_h/2; m_x2 = m_x + m_w; m_y2 = m_y + m_h; // do the parallax parchment scrolling. - sx = (players[consoleplayer].camera->x - f_oldloc.x) >> FRACTOMAPBITS; - sy = (f_oldloc.y - players[consoleplayer].camera->y) >> FRACTOMAPBITS; + sx = (players[consoleplayer].camera->X() - f_oldloc.x) >> FRACTOMAPBITS; + sy = (f_oldloc.y - players[consoleplayer].camera->Y()) >> FRACTOMAPBITS; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotate (&sx, &sy, players[consoleplayer].camera->angle - ANG90); } AM_ScrollParchment (sx, sy); - f_oldloc.x = players[consoleplayer].camera->x; - f_oldloc.y = players[consoleplayer].camera->y; + f_oldloc.x = players[consoleplayer].camera->X(); + f_oldloc.y = players[consoleplayer].camera->Y(); } } @@ -2612,8 +2612,8 @@ void AM_drawPlayers () mline_t *arrow; int numarrowlines; - pt.x = players[consoleplayer].camera->x >> FRACTOMAPBITS; - pt.y = players[consoleplayer].camera->y >> FRACTOMAPBITS; + pt.x = players[consoleplayer].camera->X() >> FRACTOMAPBITS; + pt.y = players[consoleplayer].camera->Y() >> FRACTOMAPBITS; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { angle = ANG90; @@ -2675,8 +2675,8 @@ void AM_drawPlayers () if (p->mo != NULL) { - pt.x = p->mo->x >> FRACTOMAPBITS; - pt.y = p->mo->y >> FRACTOMAPBITS; + pt.x = p->mo->X() >> FRACTOMAPBITS; + pt.y = p->mo->Y() >> FRACTOMAPBITS; angle = p->mo->angle; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) @@ -2707,8 +2707,8 @@ void AM_drawKeys () while ((key = it.Next()) != NULL) { - p.x = key->x >> FRACTOMAPBITS; - p.y = key->y >> FRACTOMAPBITS; + p.x = key->X() >> FRACTOMAPBITS; + p.y = key->Y() >> FRACTOMAPBITS; angle = key->angle; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) @@ -2752,8 +2752,8 @@ void AM_drawThings () { if (am_cheat > 0 || !(t->flags6 & MF6_NOTONAUTOMAP)) { - p.x = t->x >> FRACTOMAPBITS; - p.y = t->y >> FRACTOMAPBITS; + p.x = t->X() >> FRACTOMAPBITS; + p.y = t->Y() >> FRACTOMAPBITS; if (am_showthingsprites > 0 && t->sprite > 0) { @@ -2979,7 +2979,7 @@ void AM_drawAuthorMarkers () marked->subsector->flags & SSECF_DRAWN : marked->Sector->MoreFlags & SECF_DRAWN))) { - DrawMarker (tex, marked->x >> FRACTOMAPBITS, marked->y >> FRACTOMAPBITS, 0, + DrawMarker (tex, marked->X() >> FRACTOMAPBITS, marked->Y() >> FRACTOMAPBITS, 0, flip, mark->scaleX, mark->scaleY, mark->Translation, mark->alpha, mark->fillcolor, mark->RenderStyle); } diff --git a/src/b_func.cpp b/src/b_func.cpp index 9594d29d8b..cc8d9808a6 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -30,17 +30,17 @@ bool DBot::Reachable (AActor *rtarget) if (player->mo == rtarget) return false; - if ((rtarget->Sector->ceilingplane.ZatPoint (rtarget->x, rtarget->y) - - rtarget->Sector->floorplane.ZatPoint (rtarget->x, rtarget->y)) + if ((rtarget->Sector->ceilingplane.ZatPoint (rtarget) - + rtarget->Sector->floorplane.ZatPoint (rtarget)) < player->mo->height) //Where rtarget is, player->mo can't be. return false; sector_t *last_s = player->mo->Sector; - fixed_t last_z = last_s->floorplane.ZatPoint (player->mo->x, player->mo->y); + fixed_t last_z = last_s->floorplane.ZatPoint (player->mo); fixed_t estimated_dist = player->mo->AproxDistance(rtarget); bool reachable = true; - FPathTraverse it(player->mo->x+player->mo->velx, player->mo->y+player->mo->vely, rtarget->x, rtarget->y, PT_ADDLINES|PT_ADDTHINGS); + FPathTraverse it(player->mo->X()+player->mo->velx, player->mo->Y()+player->mo->vely, rtarget->X(), rtarget->Y(), PT_ADDLINES|PT_ADDTHINGS); intercept_t *in; while ((in = it.Next())) { @@ -96,7 +96,7 @@ bool DBot::Reachable (AActor *rtarget) thing = in->d.thing; if (thing == player->mo) //Can't reach self in this case. continue; - if (thing == rtarget && (rtarget->Sector->floorplane.ZatPoint (rtarget->x, rtarget->y) <= (last_z+MAXMOVEHEIGHT))) + if (thing == rtarget && (rtarget->Sector->floorplane.ZatPoint (rtarget) <= (last_z+MAXMOVEHEIGHT))) { return true; } @@ -219,7 +219,7 @@ void DBot::Dofire (ticcmd_t *cmd) shootmissile: dist = player->mo->AproxDistance (enemy); m = dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed; - bglobal.SetBodyAt (enemy->x + enemy->velx*m*2, enemy->y + enemy->vely*m*2, enemy->z, 1); + bglobal.SetBodyAt (enemy->X() + enemy->velx*m*2, enemy->Y() + enemy->vely*m*2, enemy->Z(), 1); angle = player->mo->AngleTo(bglobal.body1); if (Check_LOS (enemy, SHOOTFOV)) no_fire = false; @@ -427,7 +427,7 @@ void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum) { if (body1) { - body1->SetOrigin (x, y, z); + body1->SetOrigin (x, y, z, false); } else { @@ -438,7 +438,7 @@ void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum) { if (body2) { - body2->SetOrigin (x, y, z); + body2->SetOrigin (x, y, z, false); } else { @@ -459,16 +459,13 @@ 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->x, source->y, source->z + 4*8*FRACUNIT, NO_REPLACE); + AActor *th = Spawn ("CajunTrace", source->X(), source->Y(), source->Z() + 4*8*FRACUNIT, NO_REPLACE); th->target = source; // where it came from float speed = (float)th->Speed; - FVector3 velocity; - velocity[0] = FIXED2FLOAT(dest->x - source->x); - velocity[1] = FIXED2FLOAT(dest->y - source->y); - velocity[2] = FIXED2FLOAT(dest->z - source->z); + TVector3 velocity = source->Vec3To(dest); velocity.MakeUnit(); th->velx = FLOAT2FIXED(velocity[0] * speed); th->vely = FLOAT2FIXED(velocity[1] * speed); @@ -479,8 +476,8 @@ fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) while (dist < SAFE_SELF_MISDIST) { dist += th->Speed; - th->SetOrigin (th->x + th->velx, th->y + th->vely, th->z + th->velz); - if (!CleanAhead (th, th->x, th->y, cmd)) + th->Move(th->velx, th->vely, th->velz); + if (!CleanAhead (th, th->X(), th->Y(), cmd)) break; } th->Destroy (); @@ -494,9 +491,9 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) AActor *actor; int m; - bglobal.SetBodyAt (player->mo->x + FixedMul(player->mo->velx, 5*FRACUNIT), - player->mo->y + FixedMul(player->mo->vely, 5*FRACUNIT), - player->mo->z + (player->mo->height / 2), 2); + bglobal.SetBodyAt (player->mo->X() + FixedMul(player->mo->velx, 5*FRACUNIT), + player->mo->Y() + FixedMul(player->mo->vely, 5*FRACUNIT), + player->mo->Z() + (player->mo->height / 2), 2); actor = bglobal.body2; @@ -506,14 +503,14 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) //Predict. m = (((dist+1)/FRACUNIT) / GetDefaultByName("Rocket")->Speed); - bglobal.SetBodyAt (enemy->x + FixedMul(enemy->velx, (m+2*FRACUNIT)), - enemy->y + FixedMul(enemy->vely, (m+2*FRACUNIT)), ONFLOORZ, 1); + bglobal.SetBodyAt (enemy->X() + FixedMul(enemy->velx, (m+2*FRACUNIT)), + enemy->Y() + FixedMul(enemy->vely, (m+2*FRACUNIT)), ONFLOORZ, 1); //try the predicted location if (P_CheckSight (actor, bglobal.body1, SF_IGNOREVISIBILITY)) //See the predicted location, so give a test missile { FCheckPosition tm; - if (bglobal.SafeCheckPosition (player->mo, actor->x, actor->y, tm)) + if (bglobal.SafeCheckPosition (player->mo, actor->X(), actor->Y(), tm)) { if (bglobal.FakeFire (actor, bglobal.body1, cmd) >= SAFE_SELF_MISDIST) { diff --git a/src/b_move.cpp b/src/b_move.cpp index 5cacd56645..cee409265e 100644 --- a/src/b_move.cpp +++ b/src/b_move.cpp @@ -67,8 +67,8 @@ bool DBot::Move (ticcmd_t *cmd) if ((unsigned)player->mo->movedir >= 8) I_Error ("Weird bot movedir!"); - tryx = player->mo->x + 8*xspeed[player->mo->movedir]; - tryy = player->mo->y + 8*yspeed[player->mo->movedir]; + tryx = player->mo->X() + 8*xspeed[player->mo->movedir]; + tryy = player->mo->Y() + 8*yspeed[player->mo->movedir]; try_ok = bglobal.CleanAhead (player->mo, tryx, tryy, cmd); @@ -124,9 +124,6 @@ bool DBot::TryWalk (ticcmd_t *cmd) void DBot::NewChaseDir (ticcmd_t *cmd) { - fixed_t deltax; - fixed_t deltay; - dirtype_t d[3]; int tdir; @@ -145,19 +142,18 @@ void DBot::NewChaseDir (ticcmd_t *cmd) olddir = (dirtype_t)player->mo->movedir; turnaround = opposite[olddir]; - deltax = dest->x - player->mo->x; - deltay = dest->y - player->mo->y; + fixedvec2 delta = player->mo->Vec2To(dest); - if (deltax > 10*FRACUNIT) + if (delta.x > 10*FRACUNIT) d[1] = DI_EAST; - else if (deltax < -10*FRACUNIT) + else if (delta.x < -10*FRACUNIT) d[1] = DI_WEST; else d[1] = DI_NODIR; - if (deltay < -10*FRACUNIT) + if (delta.y < -10*FRACUNIT) d[2] = DI_SOUTH; - else if (deltay > 10*FRACUNIT) + else if (delta.y > 10*FRACUNIT) d[2] = DI_NORTH; else d[2] = DI_NODIR; @@ -165,14 +161,14 @@ void DBot::NewChaseDir (ticcmd_t *cmd) // try direct route if (d[1] != DI_NODIR && d[2] != DI_NODIR) { - player->mo->movedir = diags[((deltay<0)<<1)+(deltax>0)]; + player->mo->movedir = diags[((delta.y<0)<<1)+(delta.x>0)]; if (player->mo->movedir != turnaround && TryWalk(cmd)) return; } // try other directions if (pr_botnewchasedir() > 200 - || abs(deltay)>abs(deltax)) + || abs(delta.y)>abs(delta.x)) { tdir=d[1]; d[1]=d[2]; @@ -282,7 +278,7 @@ bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm if ( !(thing->flags & MF_TELEPORT) && - tm.ceilingz - thing->z < thing->height) + tm.ceilingz - thing->Z() < thing->height) return false; // mobj must lower itself to fit // jump out of water @@ -290,7 +286,7 @@ bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm // maxstep=37*FRACUNIT; if ( !(thing->flags & MF_TELEPORT) && - (tm.floorz - thing->z > maxstep ) ) + (tm.floorz - thing->Z() > maxstep ) ) return false; // too big a step up @@ -346,7 +342,7 @@ void DBot::Pitch (AActor *target) double aim; double diff; - diff = target->z - player->mo->z; + diff = target->Z() - player->mo->Z(); aim = atan(diff / (double)player->mo->AproxDistance(target)); player->mo->pitch = -(int)(aim * ANGLE_180/M_PI); } diff --git a/src/b_think.cpp b/src/b_think.cpp index ced5b4b4e0..de74c04dbe 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -303,8 +303,8 @@ void DBot::ThinkForMove (ticcmd_t *cmd) if (t_fight<(AFTERTICS/2)) player->mo->flags |= MF_DROPOFF; - oldx = player->mo->x; - oldy = player->mo->y; + oldx = player->mo->X(); + oldy = player->mo->Y(); } //BOT_WhatToGet diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 57290a98ae..3cfbf1c650 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -944,7 +944,7 @@ static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const cha { Printf ("%s at (%d,%d,%d)\n", mo->GetClass()->TypeName.GetChars(), - mo->x >> FRACBITS, mo->y >> FRACBITS, mo->z >> FRACBITS); + mo->X() >> FRACBITS, mo->Y() >> FRACBITS, mo->Z() >> FRACBITS); } } } @@ -1084,7 +1084,7 @@ CCMD(currentpos) { AActor *mo = players[consoleplayer].mo; Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", - FIXED2FLOAT(mo->x), FIXED2FLOAT(mo->y), FIXED2FLOAT(mo->z), mo->angle/float(ANGLE_1), FIXED2FLOAT(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); + FIXED2FLOAT(mo->X()), FIXED2FLOAT(mo->Y()), FIXED2FLOAT(mo->Z()), mo->angle/float(ANGLE_1), FIXED2FLOAT(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); } //----------------------------------------------------------------------------- diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index bc0acc6665..31ff05b649 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -3056,7 +3056,7 @@ bool ADehackedPickup::TryPickup (AActor *&toucher) { return false; } - RealPickup = static_cast(Spawn (type, x, y, z, NO_REPLACE)); + RealPickup = static_cast(Spawn (type, X(), Y(), Z(), NO_REPLACE)); if (RealPickup != NULL) { // The internally spawned item should never count towards statistics. diff --git a/src/d_net.cpp b/src/d_net.cpp index 780b893827..95061d0e1f 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2319,10 +2319,12 @@ void Net_DoCommand (int type, BYTE **stream, int player) else { const AActor *def = GetDefaultByType (typeinfo); - AActor *spawned = Spawn (typeinfo, - source->x + FixedMul (def->radius * 2 + source->radius, finecosine[source->angle>>ANGLETOFINESHIFT]), - source->y + FixedMul (def->radius * 2 + source->radius, finesine[source->angle>>ANGLETOFINESHIFT]), - source->z + 8 * FRACUNIT, ALLOW_REPLACE); + fixedvec3 spawnpos = source->Vec3Offset( + FixedMul (def->radius * 2 + source->radius, finecosine[source->angle>>ANGLETOFINESHIFT]), + FixedMul (def->radius * 2 + source->radius, finesine[source->angle>>ANGLETOFINESHIFT]), + 8 * FRACUNIT); + + AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE); if (spawned != NULL) { if (type == DEM_SUMMONFRIEND || type == DEM_SUMMONFRIEND2 || type == DEM_SUMMONMBF) @@ -2373,8 +2375,8 @@ void Net_DoCommand (int type, BYTE **stream, int player) s = ReadString (stream); - if (Trace (players[player].mo->x, players[player].mo->y, - players[player].mo->z + players[player].mo->height - (players[player].mo->height>>2), + if (Trace (players[player].mo->X(), players[player].mo->Y(), + players[player].mo->Z() + players[player].mo->height - (players[player].mo->height>>2), players[player].mo->Sector, vx, vy, vz, 172*FRACUNIT, 0, ML_BLOCKEVERYTHING, players[player].mo, trace, TRACE_NoSky)) diff --git a/src/g_game.cpp b/src/g_game.cpp index b7d10251b5..ca2233cdbf 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1176,7 +1176,7 @@ void G_Ticker () } if (players[i].mo) { - DWORD sum = rngsum + players[i].mo->x + players[i].mo->y + players[i].mo->z + DWORD sum = rngsum + players[i].mo->X() + players[i].mo->Y() + players[i].mo->Z() + players[i].mo->angle + players[i].mo->pitch; sum ^= players[i].health; consistancy[i][buf] = sum; @@ -1435,13 +1435,13 @@ bool G_CheckSpot (int playernum, FPlayerStart *mthing) if (!players[playernum].mo) { // first spawn of level, before corpses for (i = 0; i < playernum; i++) - if (players[i].mo && players[i].mo->x == x && players[i].mo->y == y) + if (players[i].mo && players[i].mo->X() == x && players[i].mo->Y() == y) return false; return true; } - oldz = players[playernum].mo->z; // [RH] Need to save corpse's z-height - players[playernum].mo->z = z; // [RH] Checks are now full 3-D + oldz = players[playernum].mo->Z(); // [RH] Need to save corpse's z-height + players[playernum].mo->SetZ(z); // [RH] Checks are now full 3-D // killough 4/2/98: fix bug where P_CheckPosition() uses a non-solid // corpse to detect collisions with other players in DM starts @@ -1453,7 +1453,7 @@ bool G_CheckSpot (int playernum, FPlayerStart *mthing) players[playernum].mo->flags |= MF_SOLID; i = P_CheckPosition(players[playernum].mo, x, y); players[playernum].mo->flags &= ~MF_SOLID; - players[playernum].mo->z = oldz; // [RH] Restore corpse's height + players[playernum].mo->SetZ(oldz); // [RH] Restore corpse's height if (!i) return false; diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 711bbd9607..247ccb03fd 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -1099,7 +1099,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_HideInCeiling) F3DFloor * rover = self->Sector->e->XFloor.ffloors[i]; if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - if ((foo = rover->bottom.plane->ZatPoint(self->x, self->y)) >= (self->z + self->height)) + if ((foo = rover->bottom.plane->ZatPoint(self)) >= (self->z + self->height)) { self->z = foo + 4*FRACUNIT; self->bouncecount = i; diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index 05f6367dc4..9f3ebb2723 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -628,7 +628,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) { sector_t *sec = self->Sector; - if (self->z == sec->floorplane.ZatPoint (self->x, self->y)) + if (self->z == sec->floorplane.ZatPoint(self)) { if (sec->special == Damage_InstantDeath) { diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index ab9c0aee71..3bab8f7e5e 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -580,7 +580,7 @@ void GiveSpawner (player_t *player, const PClass *type, int amount) } AInventory *item = static_cast - (Spawn (type, player->mo->x, player->mo->y, player->mo->z, NO_REPLACE)); + (Spawn (type, player->mo->X(), player->mo->Y(), player->mo->Z(), NO_REPLACE)); if (item != NULL) { if (amount > 0) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index c45e77855a..83dbbca3f5 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -334,13 +334,13 @@ void P_PlayerOnSpecial3DFloor(player_t* player) if(rover->flags & FF_SOLID) { // Player must be on top of the floor to be affected... - if(player->mo->z != rover->top.plane->ZatPoint(player->mo->x, player->mo->y)) continue; + if(player->mo->Z() != rover->top.plane->ZatPoint(player->mo)) continue; } else { //Water and DEATH FOG!!! heh - if (player->mo->z > rover->top.plane->ZatPoint(player->mo->x, player->mo->y) || - (player->mo->z + player->mo->height) < rover->bottom.plane->ZatPoint(player->mo->x, player->mo->y)) + if (player->mo->Z() > rover->top.plane->ZatPoint(player->mo) || + (player->mo->Z() + player->mo->height) < rover->bottom.plane->ZatPoint(player->mo)) continue; } @@ -375,7 +375,7 @@ bool P_CheckFor3DFloorHit(AActor * mo) if(rover->flags & FF_SOLID && rover->model->SecActTarget) { - if(mo->floorz == rover->top.plane->ZatPoint(mo->x, mo->y)) + if(mo->floorz == rover->top.plane->ZatPoint(mo)) { rover->model->SecActTarget->TriggerAction (mo, SECSPAC_HitFloor); return true; @@ -405,7 +405,7 @@ bool P_CheckFor3DCeilingHit(AActor * mo) if(rover->flags & FF_SOLID && rover->model->SecActTarget) { - if(mo->ceilingz == rover->bottom.plane->ZatPoint(mo->x, mo->y)) + if(mo->ceilingz == rover->bottom.plane->ZatPoint(mo)) { rover->model->SecActTarget->TriggerAction (mo, SECSPAC_HitCeiling); return true; @@ -755,7 +755,7 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li { fixed_t thingbot, thingtop; - thingbot = thing->z; + thingbot = thing->Z(); thingtop = thingbot + (thing->height==0? 1:thing->height); extsector_t::xfloor *xf[2] = {&linedef->frontsector->e->XFloor, &linedef->backsector->e->XFloor}; @@ -796,13 +796,13 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li lowestceilingpic = *rover->bottom.texture; } - if(ff_top > highestfloor && delta1 < delta2 && (!restrict || thing->z >= ff_top)) + if(ff_top > highestfloor && delta1 < delta2 && (!restrict || thing->Z() >= ff_top)) { highestfloor = ff_top; highestfloorpic = *rover->top.texture; highestfloorterrain = rover->model->GetTerrain(rover->top.isceiling); } - if(ff_top > lowestfloor[j] && ff_top <= thing->z + thing->MaxStepHeight) lowestfloor[j] = ff_top; + if(ff_top > lowestfloor[j] && ff_top <= thing->Z() + thing->MaxStepHeight) lowestfloor[j] = ff_top; } } diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index dbca50d105..3338956f32 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -276,7 +276,7 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & open.abovemidtex = false; if (P_GetMidTexturePosition(linedef, 0, &tt, &tb)) { - if (thing->z + (thing->height/2) < (tt + tb)/2) + if (thing->Z() + (thing->height/2) < (tt + tb)/2) { if (tb < open.top) { @@ -286,7 +286,7 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & } else { - if (tt > open.bottom && (!restrict || thing->z >= tt)) + if (tt > open.bottom && (!restrict || thing->Z() >= tt)) { open.bottom = tt; open.abovemidtex = true; @@ -295,7 +295,7 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & } // returns true if it touches the midtexture - return (abs(thing->z - tt) <= thing->MaxStepHeight); + return (abs(thing->Z() - tt) <= thing->MaxStepHeight); } } return false; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 6f136d98b7..6ce1cfd55d 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3441,12 +3441,12 @@ int DLevelScript::DoSpawnSpot (int type, int spot, int tid, int angle, bool forc while ( (aspot = iterator.Next ()) ) { - spawned += DoSpawn (type, aspot->x, aspot->y, aspot->z, tid, angle, force); + spawned += DoSpawn (type, aspot->X(), aspot->Y(), aspot->Z(), tid, angle, force); } } else if (activator != NULL) { - spawned += DoSpawn (type, activator->x, activator->y, activator->z, tid, angle, force); + spawned += DoSpawn (type, activator->X(), activator->Y(), activator->Z(), tid, angle, force); } return spawned; } @@ -3462,12 +3462,12 @@ int DLevelScript::DoSpawnSpotFacing (int type, int spot, int tid, bool force) while ( (aspot = iterator.Next ()) ) { - spawned += DoSpawn (type, aspot->x, aspot->y, aspot->z, tid, aspot->angle >> 24, force); + spawned += DoSpawn (type, aspot->X(), aspot->Y(), aspot->Z(), tid, aspot->angle >> 24, force); } } else if (activator != NULL) { - spawned += DoSpawn (type, activator->x, activator->y, activator->z, tid, activator->angle >> 24, force); + spawned += DoSpawn (type, activator->X(), activator->Y(), activator->Z(), tid, activator->angle >> 24, force); } return spawned; } @@ -4145,7 +4145,7 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b F3DFloor *ff = sec->e->XFloor.ffloors[i]; if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID) && - actor->z >= ff->top.plane->ZatPoint(actor->x, actor->y)) + actor->Z() >= ff->top.plane->ZatPoint(actor)) { // This floor is beneath our feet. secpic = *ff->top.texture; break; @@ -4158,14 +4158,14 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b } else { - fixed_t z = actor->z + actor->height; + fixed_t z = actor->Z() + actor->height; // Looking through planes from bottom to top for (i = numff-1; i >= 0; --i) { F3DFloor *ff = sec->e->XFloor.ffloors[i]; if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID) && - z <= ff->bottom.plane->ZatPoint(actor->x, actor->y)) + z <= ff->bottom.plane->ZatPoint(actor)) { // This floor is above our eyes. secpic = *ff->bottom.texture; break; @@ -4728,8 +4728,8 @@ static bool DoSpawnDecal(AActor *actor, const FDecalTemplate *tpl, int flags, an { angle += actor->angle; } - return NULL != ShootDecal(tpl, actor, actor->Sector, actor->x, actor->y, - actor->z + (actor->height>>1) - actor->floorclip + actor->GetBobOffset() + zofs, + return NULL != ShootDecal(tpl, actor, actor->Sector, actor->X(), actor->Y(), + actor->Z() + (actor->height>>1) - actor->floorclip + actor->GetBobOffset() + zofs, angle, distance, !!(flags & SDF_PERMANENT)); } @@ -8598,11 +8598,11 @@ scriptwait: } else if (pcd == PCD_GETACTORZ) { - STACK(1) = actor->z + actor->GetBobOffset(); + STACK(1) = actor->Z() + actor->GetBobOffset(); } else { - STACK(1) = (&actor->x)[pcd - PCD_GETACTORX]; + STACK(1) = pcd == PCD_GETACTORX ? actor->X() : pcd == PCD_GETACTORY ? actor->Y() : actor->Z(); } } break; diff --git a/src/p_effect.cpp b/src/p_effect.cpp index db31295219..0cd6d5c518 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -356,9 +356,10 @@ static void MakeFountain (AActor *actor, int color1, int color2) angle_t an = M_Random()<<(24-ANGLETOFINESHIFT); fixed_t out = FixedMul (actor->radius, M_Random()<<8); - particle->x = actor->x + FixedMul (out, finecosine[an]); - particle->y = actor->y + FixedMul (out, finesine[an]); - particle->z = actor->z + actor->height + FRACUNIT; + fixedvec3 pos = actor->Vec3Offset(FixedMul(out, finecosine[an]), FixedMul(out, finesine[an]), actor->height + FRACUNIT); + particle->x = pos.x; + particle->y = pos.y; + particle->z = pos.z; if (out < actor->radius/8) particle->velz += FRACUNIT*10/3; else @@ -395,9 +396,10 @@ void P_RunEffect (AActor *actor, int effects) { // Rocket trail - fixed_t backx = actor->x - FixedMul (finecosine[(moveangle)>>ANGLETOFINESHIFT], actor->radius*2); - fixed_t backy = actor->y - FixedMul (finesine[(moveangle)>>ANGLETOFINESHIFT], actor->radius*2); - fixed_t backz = actor->z - (actor->height>>3) * (actor->velz>>16) + (2*actor->height)/3; + + fixed_t backx = - FixedMul (finecosine[(moveangle)>>ANGLETOFINESHIFT], actor->radius*2); + fixed_t backy = - FixedMul (finesine[(moveangle)>>ANGLETOFINESHIFT], actor->radius*2); + fixed_t backz = - (actor->height>>3) * (actor->velz>>16) + (2*actor->height)/3; angle_t an = (moveangle + ANG90) >> ANGLETOFINESHIFT; int speed; @@ -405,9 +407,13 @@ void P_RunEffect (AActor *actor, int effects) particle = JitterParticle (3 + (M_Random() & 31)); if (particle) { fixed_t pathdist = M_Random()<<8; - particle->x = backx - FixedMul(actor->velx, pathdist); - particle->y = backy - FixedMul(actor->vely, pathdist); - particle->z = backz - FixedMul(actor->velz, pathdist); + fixedvec3 pos = actor->Vec3Offset( + backx - FixedMul(actor->velx, pathdist), + backy - FixedMul(actor->vely, pathdist), + backz - FixedMul(actor->velz, pathdist)); + particle->x = pos.x; + particle->y = pos.y; + particle->z = pos.z; speed = (M_Random () - 128) * (FRACUNIT/200); particle->velx += FixedMul (speed, finecosine[an]); particle->vely += FixedMul (speed, finesine[an]); @@ -420,9 +426,13 @@ void P_RunEffect (AActor *actor, int effects) particle_t *particle = JitterParticle (3 + (M_Random() & 31)); if (particle) { fixed_t pathdist = M_Random()<<8; - particle->x = backx - FixedMul(actor->velx, pathdist); - particle->y = backy - FixedMul(actor->vely, pathdist); - particle->z = backz - FixedMul(actor->velz, pathdist) + (M_Random() << 10); + fixedvec3 pos = actor->Vec3Offset( + backx - FixedMul(actor->velx, pathdist), + backy - FixedMul(actor->vely, pathdist), + backz - FixedMul(actor->velz, pathdist) + (M_Random() << 10)); + particle->x = pos.x; + particle->y = pos.y; + particle->z = pos.z; speed = (M_Random () - 128) * (FRACUNIT/200); particle->velx += FixedMul (speed, finecosine[an]); particle->vely += FixedMul (speed, finesine[an]); @@ -441,10 +451,12 @@ void P_RunEffect (AActor *actor, int effects) { // Grenade trail - P_DrawSplash2 (6, - actor->x - FixedMul (finecosine[(moveangle)>>ANGLETOFINESHIFT], actor->radius*2), - actor->y - FixedMul (finesine[(moveangle)>>ANGLETOFINESHIFT], actor->radius*2), - actor->z - (actor->height>>3) * (actor->velz>>16) + (2*actor->height)/3, + fixedvec3 pos = actor->Vec3Offset( + -FixedMul(finecosine[(moveangle) >> ANGLETOFINESHIFT], actor->radius * 2), + -FixedMul(finesine[(moveangle) >> ANGLETOFINESHIFT], actor->radius * 2), + -(actor->height >> 3) * (actor->velz >> 16) + (2 * actor->height) / 3); + + P_DrawSplash2 (6, pos.x, pos.y, pos.z, moveangle + ANG180, 2, 2); } if (effects & FX_FOUNTAINMASK) @@ -476,10 +488,11 @@ void P_RunEffect (AActor *actor, int effects) if (particle != NULL) { angle_t ang = M_Random () << (32-ANGLETOFINESHIFT-8); - particle->x = actor->x + FixedMul (actor->radius, finecosine[ang]); - particle->y = actor->y + FixedMul (actor->radius, finesine[ang]); + fixedvec3 pos = actor->Vec3Offset(FixedMul (actor->radius, finecosine[ang]), FixedMul (actor->radius, finesine[ang]), 0); + particle->x = pos.x; + particle->y = pos.y; + particle->z = pos.z; particle->color = *protectColors[M_Random() & 1]; - particle->z = actor->z; particle->velz = FRACUNIT; particle->accz = M_Random () << 7; particle->size = 1; @@ -619,8 +632,8 @@ void P_DrawRailTrail(AActor *source, const TVector3 &start, const TVecto double r; double dirz; - if (abs(mo->x - FLOAT2FIXED(start.X)) < 20 * FRACUNIT - && (mo->y - FLOAT2FIXED(start.Y)) < 20 * FRACUNIT) + if (abs(mo->X() - FLOAT2FIXED(start.X)) < 20 * FRACUNIT + && (mo->Y() - FLOAT2FIXED(start.Y)) < 20 * FRACUNIT) { // This player (probably) fired the railgun S_Sound (mo, CHAN_WEAPON, sound, 1, ATTN_NORM); } @@ -630,7 +643,7 @@ void P_DrawRailTrail(AActor *source, const TVector3 &start, const TVecto // Only consider sound in 2D (for now, anyway) // [BB] You have to divide by lengthsquared here, not multiply with it. - r = ((start.Y - FIXED2DBL(mo->y)) * (-dir.Y) - (start.X - FIXED2DBL(mo->x)) * (dir.X)) / lengthsquared; + r = ((start.Y - FIXED2DBL(mo->Y())) * (-dir.Y) - (start.X - FIXED2DBL(mo->X())) * (dir.X)) / lengthsquared; r = clamp(r, 0., 1.); dirz = dir.Z; @@ -832,9 +845,13 @@ void P_DisconnectEffect (AActor *actor) if (!p) break; - p->x = actor->x + ((M_Random()-128)<<9) * (actor->radius>>FRACBITS); - p->y = actor->y + ((M_Random()-128)<<9) * (actor->radius>>FRACBITS); - p->z = actor->z + (M_Random()<<8) * (actor->height>>FRACBITS); + fixedvec3 pos = actor->Vec3Offset( + ((M_Random()-128)<<9) * (actor->radius>>FRACBITS), + ((M_Random()-128)<<9) * (actor->radius>>FRACBITS), + (M_Random()<<8) * (actor->height>>FRACBITS)); + p->x = pos.x; + p->y = pos.y; + p->z = pos.z; p->accz -= FRACUNIT/4096; p->color = M_Random() < 128 ? maroon1 : maroon2; p->size = 4; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 7b7e27b2e3..77999c06eb 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -243,9 +243,9 @@ bool AActor::CheckMeleeRange () // [RH] Don't melee things too far above or below actor. if (!(flags5 & MF5_NOVERTICALMELEERANGE)) { - if (pl->z > z + height) + if (pl->Z() > Z() + height) return false; - if (pl->z + pl->height < z) + if (pl->Z() + pl->height < Z()) return false; } @@ -280,11 +280,11 @@ bool P_CheckMeleeRange2 (AActor *actor) { return false; } - if (mo->z > actor->z+actor->height) + if (mo->Z() > actor->Z()+actor->height) { // Target is higher than the attacker return false; } - else if (actor->z > mo->z+mo->height) + else if (actor->Z() > mo->Z()+mo->height) { // Attacker is higher return false; } @@ -434,7 +434,7 @@ bool P_Move (AActor *actor) // it difficult to thrust them vertically in a reasonable manner. // [GZ] Let jumping actors jump. if (!((actor->flags & MF_NOGRAVITY) || (actor->flags6 & MF6_CANJUMP)) - && actor->z > actor->floorz && !(actor->flags2 & MF2_ONMOBJ)) + && actor->Z() > actor->floorz && !(actor->flags2 & MF2_ONMOBJ)) { return false; } @@ -473,8 +473,8 @@ bool P_Move (AActor *actor) } } - tryx = (origx = actor->x) + (deltax = FixedMul (speed, xspeed[actor->movedir])); - tryy = (origy = actor->y) + (deltay = FixedMul (speed, yspeed[actor->movedir])); + tryx = (origx = actor->X()) + (deltax = FixedMul (speed, xspeed[actor->movedir])); + tryy = (origy = actor->Y()) + (deltay = FixedMul (speed, yspeed[actor->movedir])); // Like P_XYMovement this should do multiple moves if the step size is too large @@ -519,15 +519,14 @@ bool P_Move (AActor *actor) // so make it switchable if (nomonsterinterpolation) { - actor->PrevX = actor->x; - actor->PrevY = actor->y; - actor->PrevZ = actor->z; + actor->PrevX = actor->X(); + actor->PrevY = actor->Y(); + actor->PrevZ = actor->Z(); } if (try_ok && friction > ORIG_FRICTION) { - actor->x = origx; - actor->y = origy; + actor->SetOrigin(origx, origy, actor->Z(), false); movefactor *= FRACUNIT / ORIG_FRICTION_FACTOR / 4; actor->velx += FixedMul (deltax, movefactor); actor->vely += FixedMul (deltay, movefactor); @@ -538,22 +537,22 @@ bool P_Move (AActor *actor) // actually walking down a step. if (try_ok && !((actor->flags & MF_NOGRAVITY) || (actor->flags6 & MF6_CANJUMP)) - && actor->z > actor->floorz && !(actor->flags2 & MF2_ONMOBJ)) + && actor->Z() > actor->floorz && !(actor->flags2 & MF2_ONMOBJ)) { - if (actor->z <= actor->floorz + actor->MaxStepHeight) + if (actor->Y() <= actor->floorz + actor->MaxStepHeight) { - fixed_t savedz = actor->z; - actor->z = actor->floorz; + fixed_t savedz = actor->Z(); + actor->SetZ(actor->floorz); // Make sure that there isn't some other actor between us and // the floor we could get stuck in. The old code did not do this. if (!P_TestMobjZ(actor)) { - actor->z = savedz; + actor->SetZ(savedz); } else { // The monster just hit the floor, so trigger any actions. if (actor->floorsector->SecActTarget != NULL && - actor->floorz == actor->floorsector->floorplane.ZatPoint(actor->x, actor->y)) + actor->floorz == actor->floorsector->floorplane.ZatPoint(actor)) { actor->floorsector->SecActTarget->TriggerAction(actor, SECSPAC_HitFloor); } @@ -566,12 +565,12 @@ bool P_Move (AActor *actor) { if (((actor->flags6 & MF6_CANJUMP)||(actor->flags & MF_FLOAT)) && tm.floatok) { // must adjust height - fixed_t savedz = actor->z; + fixed_t savedz = actor->Z(); - if (actor->z < tm.floorz) - actor->z += actor->FloatSpeed; + if (actor->Z() < tm.floorz) + actor->SetZ(actor->Z() + actor->FloatSpeed); else - actor->z -= actor->FloatSpeed; + actor->SetZ(actor->Z() - actor->FloatSpeed); // [RH] Check to make sure there's nothing in the way of the float @@ -580,7 +579,7 @@ bool P_Move (AActor *actor) actor->flags |= MF_INFLOAT; return true; } - actor->z = savedz; + actor->SetZ(savedz); } if (!spechit.Size ()) @@ -812,28 +811,25 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) void P_NewChaseDir(AActor * actor) { - fixed_t deltax; - fixed_t deltay; + fixedvec2 delta; actor->strafecount = 0; if ((actor->flags5&MF5_CHASEGOAL || actor->goal == actor->target) && actor->goal!=NULL) { - deltax = actor->goal->x - actor->x; - deltay = actor->goal->y - actor->y; + delta = actor->Vec2To(actor->goal); } else if (actor->target != NULL) { - deltax = actor->target->x - actor->x; - deltay = actor->target->y - actor->y; + delta = actor->Vec2To(actor->target); if (!(actor->flags6 & MF6_NOFEAR)) { if ((actor->target->player != NULL && (actor->target->player->cheats & CF_FRIGHTENING)) || (actor->flags4 & MF4_FRIGHTENED)) { - deltax = -deltax; - deltay = -deltay; + delta.x = -delta.x; + delta.y = -delta.y; } } } @@ -847,11 +843,11 @@ void P_NewChaseDir(AActor * actor) // Try to move away from a dropoff if (actor->floorz - actor->dropoffz > actor->MaxDropOffHeight && - actor->z <= actor->floorz && !(actor->flags & MF_DROPOFF) && + actor->Z() <= actor->floorz && !(actor->flags & MF_DROPOFF) && !(actor->flags2 & MF2_ONMOBJ) && !(actor->flags & MF_FLOAT) && !(i_compatflags & COMPATF_DROPOFF)) { - FBoundingBox box(actor->x, actor->y, actor->radius); + FBoundingBox box(actor->X(), actor->Y(), actor->radius); FBlockLinesIterator it(box); line_t *line; @@ -866,18 +862,18 @@ void P_NewChaseDir(AActor * actor) box.Bottom() < line->bbox[BOXTOP] && box.BoxOnLineSide(line) == -1) { - fixed_t front = line->frontsector->floorplane.ZatPoint(actor->x,actor->y); - fixed_t back = line->backsector->floorplane.ZatPoint(actor->x,actor->y); + fixed_t front = line->frontsector->floorplane.ZatPoint(actor); + fixed_t back = line->backsector->floorplane.ZatPoint(actor); angle_t angle; // The monster must contact one of the two floors, // and the other must be a tall dropoff. - if (back == actor->z && front < actor->z - actor->MaxDropOffHeight) + if (back == actor->Z() && front < actor->Z() - actor->MaxDropOffHeight) { angle = R_PointToAngle2(0,0,line->dx,line->dy); // front side dropoff } - else if (front == actor->z && back < actor->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 } @@ -946,12 +942,12 @@ void P_NewChaseDir(AActor * actor) if (ismeleeattacker) { actor->strafecount = pr_enemystrafe() & 15; - deltax = -deltax, deltay = -deltay; + delta.x = -delta.x, delta.y = -delta.y; } } } - P_DoNewChaseDir(actor, deltax, deltay); + P_DoNewChaseDir(actor, delta.x, delta.y); // If strafing, set movecount to strafecount so that old Doom // logic still works the same, except in the strafing part @@ -983,7 +979,7 @@ void P_RandomChaseDir (AActor *actor) if (actor->flags & MF_FRIENDLY) { AActor *player; - fixed_t deltax, deltay; + fixedvec2 delta; dirtype_t d[3]; if (actor->FriendPlayer != 0) @@ -1005,19 +1001,18 @@ void P_RandomChaseDir (AActor *actor) { if (pr_newchasedir() & 1 || !P_CheckSight (actor, player)) { - deltax = player->x - actor->x; - deltay = player->y - actor->y; + delta = actor->Vec2To(player); - if (deltax>128*FRACUNIT) + if (delta.x>128*FRACUNIT) d[1]= DI_EAST; - else if (deltax<-128*FRACUNIT) + else if (delta.x<-128*FRACUNIT) d[1]= DI_WEST; else d[1]=DI_NODIR; - if (deltay<-128*FRACUNIT) + if (delta.y<-128*FRACUNIT) d[2]= DI_SOUTH; - else if (deltay>128*FRACUNIT) + else if (delta.y>128*FRACUNIT) d[2]= DI_NORTH; else d[2]=DI_NODIR; @@ -1025,13 +1020,13 @@ void P_RandomChaseDir (AActor *actor) // try direct route if (d[1] != DI_NODIR && d[2] != DI_NODIR) { - actor->movedir = diags[((deltay<0)<<1) + (deltax>0)]; + actor->movedir = diags[((delta.y<0)<<1) + (delta.x>0)]; if (actor->movedir != turnaround && P_TryWalk(actor)) return; } // try other directions - if (pr_newchasedir() > 200 || abs(deltay) > abs(deltax)) + if (pr_newchasedir() > 200 || abs(delta.y) > abs(delta.x)) { swapvalues (d[1], d[2]); } @@ -2474,8 +2469,8 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove) { // CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions. - fixed_t oldX = actor->x; - fixed_t oldY = actor->y; + fixed_t oldX = actor->X(); + fixed_t oldY = actor->Y(); FTextureID oldFloor = actor->floorpic; // chase towards player @@ -2526,11 +2521,12 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) if (self->movedir != DI_NODIR) { const fixed_t absSpeed = abs (self->Speed); - fixed_t viletryx = self->x + FixedMul (absSpeed, xspeed[self->movedir]); - fixed_t viletryy = self->y + FixedMul (absSpeed, yspeed[self->movedir]); + fixedvec2 viletry = self->Vec2Offset( + FixedMul (absSpeed, xspeed[self->movedir]), + FixedMul (absSpeed, yspeed[self->movedir]), true); AActor *corpsehit; - FBlockThingsIterator it(FBoundingBox(viletryx, viletryy, 32*FRACUNIT)); + FBlockThingsIterator it(FBoundingBox(viletry.x, viletry.y, 32*FRACUNIT)); while ((corpsehit = it.Next())) { FState *raisestate = corpsehit->GetRaiseState(); @@ -2539,8 +2535,8 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) // use the current actor's radius instead of the Arch Vile's default. fixed_t maxdist = corpsehit->GetDefault()->radius + self->radius; - if (abs(corpsehit->x - viletryx) > maxdist || - abs(corpsehit->y - viletryy) > maxdist) + if (abs(corpsehit->X() - viletry.x) > maxdist || + abs(corpsehit->Y() - viletry.y) > maxdist) continue; // not actually touching // Let's check if there are floors in between the archvile and its target sector_t *vilesec = self->Sector; @@ -2551,11 +2547,11 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) if (testsec) { fixed_t zdist1, zdist2; - if (P_Find3DFloor(testsec, corpsehit->x, corpsehit->y, corpsehit->z, false, true, zdist1) - != P_Find3DFloor(testsec, self->x, self->y, self->z, false, true, zdist2)) + if (P_Find3DFloor(testsec, corpsehit->X(), corpsehit->Y(), corpsehit->Z(), false, true, zdist1) + != P_Find3DFloor(testsec, self->X(), self->Y(), self->Z(), false, true, zdist2)) { // Not on same floor - if (vilesec == corpsec || abs(zdist1 - self->z) > self->height) + if (vilesec == corpsec || abs(zdist1 - self->Z()) > self->height) continue; } } @@ -2569,7 +2565,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) corpsehit->flags |= MF_SOLID; corpsehit->height = corpsehit->GetDefault()->height; - bool check = P_CheckPosition(corpsehit, corpsehit->x, corpsehit->y); + bool check = P_CheckPosition(corpsehit, corpsehit->X(), corpsehit->Y()); corpsehit->flags = oldflags; corpsehit->radius = oldradius; corpsehit->height = oldheight; @@ -2783,34 +2779,33 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a { // [DH] Don't need to do proper fixed->double conversion, since the // result is only used in a ratio. - double dist_x = other->x - self->x; - double dist_y = other->y - self->y; + fixedvec2 dist = self->Vec2To(other); // Positioning ala missile spawning, 32 units above foot level - fixed_t source_z = self->z + 32*FRACUNIT + self->GetBobOffset(); - fixed_t target_z = other->z + 32*FRACUNIT + other->GetBobOffset(); + fixed_t source_z = self->Z() + 32*FRACUNIT + self->GetBobOffset(); + fixed_t target_z = other->Z() + 32*FRACUNIT + other->GetBobOffset(); // If the target z is above the target's head, reposition to the middle of // its body. - if (target_z >= other->z + other->height) + if (target_z >= other->Z() + other->height) { - target_z = other->z + (other->height / 2); + target_z = other->Z() + (other->height / 2); } //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->z + other->GetBobOffset(); + target_z = other->Z() + other->GetBobOffset(); if (flags & FAF_MIDDLE) - target_z = other->z + (other->height / 2) + other->GetBobOffset(); + target_z = other->Z() + (other->height / 2) + other->GetBobOffset(); if (flags & FAF_TOP) - target_z = other->z + (other->height) + other->GetBobOffset(); + target_z = other->Z() + (other->height) + other->GetBobOffset(); if (!(flags & FAF_NODISTFACTOR)) target_z += pitch_offset; double dist_z = target_z - source_z; - double dist = sqrt(dist_x*dist_x + dist_y*dist_y + dist_z*dist_z); - int other_pitch = (int)rad2bam(asin(dist_z / dist)); + double ddist = sqrt(dist.x*dist.x + dist.y*dist.y + dist_z*dist_z); + int other_pitch = (int)rad2bam(asin(dist_z / ddist)); if (max_pitch != 0) { @@ -2922,9 +2917,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) if (linetarget == NULL) { // We probably won't hit the target, but aim at it anyway so we don't look stupid. - TVector2 xydiff(self->target->x - self->x, self->target->y - self->y); - double zdiff = (self->target->z + (self->target->height>>1)) - - (self->z + (self->height>>1) - self->floorclip); + TVector2 xydiff = self->Vec2To(self->target); + double zdiff = (self->target->Z() + (self->target->height>>1)) - + (self->Z() + (self->height>>1) - self->floorclip); self->pitch = int(atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI); } @@ -3072,7 +3067,7 @@ AInventory *P_DropItem (AActor *source, const PClass *type, int dropamount, int AActor *mo; fixed_t spawnz; - spawnz = source->z; + spawnz = source->Z(); if (!(i_compatflags & COMPATF_NOTOSSDROPS)) { int style = sv_dropstyle; @@ -3087,7 +3082,7 @@ AInventory *P_DropItem (AActor *source, const PClass *type, int dropamount, int spawnz += source->height / 2; } } - mo = Spawn (type, source->x, source->y, spawnz, ALLOW_REPLACE); + mo = Spawn (type, source->X(), source->Y(), spawnz, ALLOW_REPLACE); if (mo != NULL) { mo->flags |= MF_DROPPED; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 5534fb14ab..0c61b2d7df 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -84,7 +84,7 @@ FName MeansOfDeath; // void P_TouchSpecialThing (AActor *special, AActor *toucher) { - fixed_t delta = special->z - toucher->z; + fixed_t delta = special->Z() - toucher->Z(); // The pickup is at or above the toucher's feet OR // The pickup is below the toucher. @@ -1158,7 +1158,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, // If the origin and target are in exactly the same spot, choose a random direction. // (Most likely cause is from telefragging somebody during spawning because they // haven't moved from their spawn spot at all.) - if (origin->x == target->x && origin->y == target->y) + if (origin->X() == target->X() && origin->Y() == target->Y()) { ang = pr_kickbackdir.GenRand32(); } @@ -1184,7 +1184,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, // make fall forwards sometimes if ((damage < 40) && (damage > target->health) - && (target->z - origin->z > 64*FRACUNIT) + && (target->Z() - origin->Z() > 64*FRACUNIT) && (pr_damagemobj()&1) // [RH] But only if not too fast and not flying && thrust < 10*FRACUNIT diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 53090ef186..2592c930f6 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -148,7 +148,7 @@ FUNC(LS_Polyobj_MoveToSpot) FActorIterator iterator (arg2); AActor *spot = iterator.Next(); if (spot == NULL) return false; - return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->x, spot->y, false); + return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->X(), spot->Y(), false); } FUNC(LS_Polyobj_DoorSwing) @@ -199,7 +199,7 @@ FUNC(LS_Polyobj_OR_MoveToSpot) FActorIterator iterator (arg2); AActor *spot = iterator.Next(); if (spot == NULL) return false; - return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->x, spot->y, true); + return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->X(), spot->Y(), true); } FUNC(LS_Polyobj_Stop) @@ -3107,7 +3107,7 @@ FUNC(LS_GlassBreak) { glass = Spawn("GlassJunk", x, y, ONFLOORZ, ALLOW_REPLACE); - glass->z += 24 * FRACUNIT; + glass->SetZ(glass->z + 24 * FRACUNIT); glass->SetState (glass->SpawnState + (pr_glass() % glass->health)); an = pr_glass() << (32-8); glass->angle = an; diff --git a/src/p_map.cpp b/src/p_map.cpp index ce20c84303..78a17df109 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -52,6 +52,7 @@ #include "p_conversation.h" #include "r_data/r_translate.h" #include "g_level.h" +#include "r_sky.h" CVAR(Bool, cl_bloodsplats, true, CVAR_ARCHIVE) CVAR(Int, sv_smartaim, 0, CVAR_ARCHIVE | CVAR_SERVERINFO) @@ -592,8 +593,8 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_SWIMMABLE)) continue; - if (mo->z > rover->top.plane->ZatPoint(mo->x, mo->y) || - mo->z < rover->bottom.plane->ZatPoint(mo->x, mo->y)) + if (mo->z > rover->top.plane->ZatPoint(mo) || + mo->z < rover->bottom.plane->ZatPoint(mo)) continue; newfriction = secfriction(rover->model, rover->top.isceiling); @@ -622,13 +623,13 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) if (rover->flags & FF_SOLID) { // Must be standing on a solid floor - if (mo->z != rover->top.plane->ZatPoint(mo->x, mo->y)) continue; + if (mo->z != rover->top.plane->ZatPoint(mo)) continue; } else if (rover->flags & FF_SWIMMABLE) { // Or on or inside a swimmable floor (e.g. in shallow water) - if (mo->z > rover->top.plane->ZatPoint(mo->x, mo->y) || - (mo->z + mo->height) < rover->bottom.plane->ZatPoint(mo->x, mo->y)) + if (mo->z > rover->top.plane->ZatPoint(mo) || + (mo->z + mo->height) < rover->bottom.plane->ZatPoint(mo)) continue; } else @@ -649,9 +650,9 @@ int P_GetFriction(const AActor *mo, int *frictionfactor) } newfriction = secfriction(sec); if ((newfriction < friction || friction == ORIG_FRICTION) && - (mo->z <= sec->floorplane.ZatPoint(mo->x, mo->y) || + (mo->z <= sec->floorplane.ZatPoint(mo) || (sec->GetHeightSec() != NULL && - mo->z <= sec->heightsec->floorplane.ZatPoint(mo->x, mo->y)))) + mo->z <= sec->heightsec->floorplane.ZatPoint(mo)))) { friction = newfriction; movefactor = secmovefac(sec); @@ -1797,10 +1798,10 @@ static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, bool windo if (windowcheck && !(ib_compatflags & BCOMPATF_NOWINDOWCHECK) && line->backsector != NULL) { // Make sure this line actually blocks us and is not a window // or similar construct we are standing inside of. - fixed_t fzt = line->frontsector->ceilingplane.ZatPoint(mobj->x, mobj->y); - fixed_t fzb = line->frontsector->floorplane.ZatPoint(mobj->x, mobj->y); - fixed_t bzt = line->backsector->ceilingplane.ZatPoint(mobj->x, mobj->y); - fixed_t bzb = line->backsector->floorplane.ZatPoint(mobj->x, mobj->y); + fixed_t fzt = line->frontsector->ceilingplane.ZatPoint(mobj); + fixed_t fzb = line->frontsector->floorplane.ZatPoint(mobj); + fixed_t bzt = line->backsector->ceilingplane.ZatPoint(mobj); + fixed_t bzb = line->backsector->floorplane.ZatPoint(mobj); if (fzt >= mobj->z + mobj->height && bzt >= mobj->z + mobj->height && fzb <= mobj->z && bzb <= mobj->z) { @@ -1811,8 +1812,8 @@ static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, bool windo if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - fixed_t ff_bottom = rover->bottom.plane->ZatPoint(mobj->x, mobj->y); - fixed_t ff_top = rover->top.plane->ZatPoint(mobj->x, mobj->y); + fixed_t ff_bottom = rover->bottom.plane->ZatPoint(mobj); + fixed_t ff_top = rover->top.plane->ZatPoint(mobj); if (ff_bottom < mobj->z + mobj->height && ff_top > mobj->z) { @@ -2082,8 +2083,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { fixed_t eyez = oldz + viewheight; - oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint(thing->x, thing->y); - oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint(thing->x, thing->y); + oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint(thing); + oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint(thing); } // Borrowed from MBF: @@ -2742,14 +2743,14 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov } const secplane_t *plane = &actor->floorsector->floorplane; - fixed_t planezhere = plane->ZatPoint(actor->x, actor->y); + fixed_t planezhere = plane->ZatPoint(actor); for (unsigned int i = 0; ifloorsector->e->XFloor.ffloors.Size(); i++) { F3DFloor * rover = actor->floorsector->e->XFloor.ffloors[i]; if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - fixed_t thisplanez = rover->top.plane->ZatPoint(actor->x, actor->y); + fixed_t thisplanez = rover->top.plane->ZatPoint(actor); if (thisplanez>planezhere && thisplanez <= actor->z + actor->MaxStepHeight) { @@ -2767,7 +2768,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov F3DFloor * rover = actor->Sector->e->XFloor.ffloors[i]; if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - fixed_t thisplanez = rover->top.plane->ZatPoint(actor->x, actor->y); + fixed_t thisplanez = rover->top.plane->ZatPoint(actor); if (thisplanez>planezhere && thisplanez <= actor->z + actor->MaxStepHeight) { @@ -4293,6 +4294,8 @@ 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.X, trace.Y, trace.Z, (source->angle + angleoffset) - ANG90, 1, 0); + if (puff && (trace.Line != NULL) && (trace.Line->special == Line_Horizon) && !(puff->flags3 & MF3_SKYEXPLODE)) + puff->Destroy(); } if (puff != NULL && puffDefaults->flags7 & MF7_FORCEDECAL && puff->DecalGenerator) SpawnShootDecal(puff, trace); @@ -4306,6 +4309,12 @@ 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.X, trace.Y, trace.Z, (source->angle + angleoffset) - ANG90, 1, 0); + if (puff && !(puff->flags3 & MF3_SKYEXPLODE) && + (((trace.HitType == TRACE_HitFloor) && (puff->floorpic == skyflatnum)) || + ((trace.HitType == TRACE_HitCeiling) && (puff->ceilingpic == skyflatnum)))) + { + puff->Destroy(); + } } } if (thepuff != NULL) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 82907d10aa..1c7a205a19 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -585,7 +585,7 @@ sector_t *AActor::LinkToWorldForMapThing () return ssec->sector; } -void AActor::SetOrigin (fixed_t ix, fixed_t iy, fixed_t iz) +void AActor::SetOrigin (fixed_t ix, fixed_t iy, fixed_t iz, bool moving) { UnlinkFromWorld (); x = ix; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index bcaa778559..1c5105235c 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2077,7 +2077,7 @@ explode: if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - mo->z >= tm.ceilingline->backsector->ceilingplane.ZatPoint (mo->x, mo->y)) + mo->z >= tm.ceilingline->backsector->ceilingplane.ZatPoint(mo)) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. @@ -2161,7 +2161,7 @@ explode: { // Don't stop sliding if halfway off a step with some velocity if (mo->velx > FRACUNIT/4 || mo->velx < -FRACUNIT/4 || mo->vely > FRACUNIT/4 || mo->vely < -FRACUNIT/4) { - if (mo->floorz > mo->Sector->floorplane.ZatPoint (mo->x, mo->y)) + if (mo->floorz > mo->Sector->floorplane.ZatPoint(mo)) { if (mo->dropoffz != mo->floorz) // 3DMidtex or other special cases that must be excluded { @@ -2407,7 +2407,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { // Hit the floor if ((!mo->player || !(mo->player->cheats & CF_PREDICTING)) && mo->Sector->SecActTarget != NULL && - mo->Sector->floorplane.ZatPoint (mo->x, mo->y) == mo->floorz) + mo->Sector->floorplane.ZatPoint(mo) == mo->floorz) { // [RH] Let the sector do something to the actor mo->Sector->SecActTarget->TriggerAction (mo, SECSPAC_HitFloor); } @@ -2509,7 +2509,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { // hit the ceiling if ((!mo->player || !(mo->player->cheats & CF_PREDICTING)) && mo->Sector->SecActTarget != NULL && - mo->Sector->ceilingplane.ZatPoint (mo->x, mo->y) == mo->ceilingz) + mo->Sector->ceilingplane.ZatPoint(mo) == mo->ceilingz) { // [RH] Let the sector do something to the actor mo->Sector->SecActTarget->TriggerAction (mo, SECSPAC_HitCeiling); } @@ -2564,7 +2564,7 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh if (sec->heightsec != NULL && sec->SecActTarget != NULL) { sector_t *hs = sec->heightsec; - fixed_t waterz = hs->floorplane.ZatPoint (mo->x, mo->y); + fixed_t waterz = hs->floorplane.ZatPoint(mo); fixed_t newz; fixed_t viewheight; @@ -2599,7 +2599,7 @@ void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheigh if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) { - waterz = hs->ceilingplane.ZatPoint (mo->x, mo->y); + waterz = hs->ceilingplane.ZatPoint(mo); if (oldz <= waterz && newz > waterz) { // View went above fake ceiling sec->SecActTarget->TriggerAction (mo, SECSPAC_EyesAboveC); @@ -5493,7 +5493,7 @@ bool P_HitFloor (AActor *thing) // don't splash if landing on the edge above water/lava/etc.... for (m = thing->touching_sectorlist; m; m = m->m_tnext) { - if (thing->z == m->m_sector->floorplane.ZatPoint (thing->x, thing->y)) + if (thing->z == m->m_sector->floorplane.ZatPoint(thing)) { break; } @@ -5505,7 +5505,7 @@ bool P_HitFloor (AActor *thing) if (!(rover->flags & FF_EXISTS)) continue; if (rover->flags & (FF_SOLID|FF_SWIMMABLE)) { - if (rover->top.plane->ZatPoint(thing->x, thing->y) == thing->z) + if (rover->top.plane->ZatPoint(thing) == thing->z) { return P_HitWater (thing, m->m_sector); } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 1e91a13a0f..96300b24c6 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -433,7 +433,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) { // Falling, not all the way down yet? sector = player->mo->Sector; - if (player->mo->z != sector->floorplane.ZatPoint (player->mo->x, player->mo->y) + if (player->mo->z != sector->floorplane.ZatPoint(player->mo) && !player->mo->waterlevel) { return; @@ -510,7 +510,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type, if (!(flags & DAMAGE_PLAYERS) && actor->player != NULL) return; - if (!(flags & DAMAGE_IN_AIR) && actor->z != sec->floorplane.ZatPoint(actor->x, actor->y) && !actor->waterlevel) + if (!(flags & DAMAGE_IN_AIR) && actor->z != sec->floorplane.ZatPoint(actor) && !actor->waterlevel) return; if (protectClass != NULL) @@ -547,8 +547,8 @@ void P_SectorDamage(int tag, int amount, FName type, const PClass *protectClass, { next = actor->snext; // Only affect actors touching the 3D floor - fixed_t z1 = sec->floorplane.ZatPoint(actor->x, actor->y); - fixed_t z2 = sec->ceilingplane.ZatPoint(actor->x, actor->y); + fixed_t z1 = sec->floorplane.ZatPoint(actor); + fixed_t z2 = sec->ceilingplane.ZatPoint(actor); if (z2 < z1) { // Account for Vavoom-style 3D floors @@ -2318,7 +2318,7 @@ void DPusher::Tick () } else // special water sector { - ht = hsec->floorplane.ZatPoint (thing->x, thing->y); + ht = hsec->floorplane.ZatPoint(thing); if (thing->z > ht) // above ground { xspeed = m_Xmag; // full force @@ -2347,7 +2347,7 @@ void DPusher::Tick () { // special water sector floor = &hsec->floorplane; } - if (thing->z > floor->ZatPoint (thing->x, thing->y)) + if (thing->z > floor->ZatPoint(thing)) { // above ground xspeed = yspeed = 0; // no force } diff --git a/src/p_things.cpp b/src/p_things.cpp index 631f1be5e8..e8f9d60114 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -82,7 +82,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, } while (spot != NULL) { - mobj = Spawn (kind, spot->x, spot->y, spot->z, ALLOW_REPLACE); + mobj = Spawn (kind, spot->X(), spot->Y(), spot->Z(), ALLOW_REPLACE); if (mobj != NULL) { @@ -94,7 +94,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, mobj->angle = (angle != ANGLE_MAX ? angle : spot->angle); if (fog) { - P_SpawnTeleportFog(mobj, spot->x, spot->y, spot->z + TELEFOGHEIGHT, false, true); + P_SpawnTeleportFog(mobj, spot->X(), spot->Y(), spot->Z() + TELEFOGHEIGHT, false, true); } if (mobj->flags & MF_SPECIAL) mobj->flags |= MF_DROPPED; // Don't respawn @@ -165,7 +165,7 @@ bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog) if (source != NULL && target != NULL) { - return P_MoveThing(source, target->x, target->y, target->z, fog); + return P_MoveThing(source, target->X(), target->Y(), target->Z(), fog); } return false; } diff --git a/src/po_man.cpp b/src/po_man.cpp index 98fbbcbcb1..fb1d12519d 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1238,8 +1238,8 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) } // [BL] See if we hit below the floor/ceiling of the poly. else if(!performBlockingThrust && ( - mobj->z < ld->sidedef[!side]->sector->GetSecPlane(sector_t::floor).ZatPoint(mobj->x, mobj->y) || - mobj->z + mobj->height > ld->sidedef[!side]->sector->GetSecPlane(sector_t::ceiling).ZatPoint(mobj->x, mobj->y) + mobj->z < ld->sidedef[!side]->sector->GetSecPlane(sector_t::floor).ZatPoint(mobj) || + mobj->z + mobj->height > ld->sidedef[!side]->sector->GetSecPlane(sector_t::ceiling).ZatPoint(mobj) )) { performBlockingThrust = true; diff --git a/src/posix/cocoa/i_system.mm b/src/posix/cocoa/i_system.mm index f12ef18eb3..498498d946 100644 --- a/src/posix/cocoa/i_system.mm +++ b/src/posix/cocoa/i_system.mm @@ -338,23 +338,17 @@ int I_FindAttr(findstate_t* const fileinfo) } -static NSString* GetPasteboardStringType() -{ -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 - return NSStringPboardType; -#else // 10.6 or higher - return NSAppKitVersionNumber < AppKit10_6 - ? NSStringPboardType - : NSPasteboardTypeString; -#endif // before 10.6 -} - void I_PutInClipboard(const char* const string) { NSPasteboard* const pasteBoard = [NSPasteboard generalPasteboard]; - [pasteBoard clearContents]; - [pasteBoard setString:[NSString stringWithUTF8String:string] - forType:GetPasteboardStringType()]; + NSString* const stringType = NSStringPboardType; + NSArray* const types = [NSArray arrayWithObjects:stringType, nil]; + NSString* const content = [NSString stringWithUTF8String:string]; + + [pasteBoard declareTypes:types + owner:nil]; + [pasteBoard setString:content + forType:stringType]; } FString I_GetFromClipboard(bool returnNothing) @@ -365,7 +359,7 @@ FString I_GetFromClipboard(bool returnNothing) } NSPasteboard* const pasteBoard = [NSPasteboard generalPasteboard]; - NSString* const value = [pasteBoard stringForType:GetPasteboardStringType()]; + NSString* const value = [pasteBoard stringForType:NSStringPboardType]; return FString([value UTF8String]); } diff --git a/src/posix/cocoa/st_console.h b/src/posix/cocoa/st_console.h index 49b6e05470..6b6f018207 100644 --- a/src/posix/cocoa/st_console.h +++ b/src/posix/cocoa/st_console.h @@ -85,7 +85,6 @@ private: int m_netMaxPos; FConsoleWindow(); - ~FConsoleWindow(); void ExpandTextView(float height); diff --git a/src/posix/cocoa/st_console.mm b/src/posix/cocoa/st_console.mm index 342e251a3f..e952d22d6b 100644 --- a/src/posix/cocoa/st_console.mm +++ b/src/posix/cocoa/st_console.mm @@ -118,11 +118,6 @@ FConsoleWindow::FConsoleWindow() [m_window makeKeyAndOrderFront:nil]; } -FConsoleWindow::~FConsoleWindow() -{ - [m_window close]; -} - static FConsoleWindow* s_instance; diff --git a/src/r_defs.h b/src/r_defs.h index 915316b321..65b1ad0d41 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -279,6 +279,11 @@ struct secplane_t return FixedMul (ic, -d - DMulScale16 (a, v->x, b, v->y)); } + fixed_t ZatPoint (const AActor *ac) const + { + return FixedMul (ic, -d - DMulScale16 (a, ac->X(), b, ac->Y())); + } + // Returns the value of z at (x,y) if d is equal to dist fixed_t ZatPointDist (fixed_t x, fixed_t y, fixed_t dist) const { diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 552228557c..42e5c17b9f 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -961,8 +961,10 @@ void FWadCollection::RenameNerve () // // FixMacHexen // -// Rename unused high resolution font lumps because they are incorrectly -// treated as extended characters +// Discard all extra lumps in Mac version of Hexen IWAD (demo or full) +// to avoid any issues caused by names of these lumps, including: +// * Wrong height of small font +// * Broken life bar of mage class // //========================================================================== @@ -973,22 +975,51 @@ void FWadCollection::FixMacHexen() return; } - for (int i = GetFirstLump(IWAD_FILENUM), last = GetLastLump(IWAD_FILENUM); i <= last; ++i) + FileReader* const reader = GetFileReader(IWAD_FILENUM); + const long iwadSize = reader->GetLength(); + + static const long DEMO_SIZE = 13596228; + static const long FULL_SIZE = 21078584; + + if ( DEMO_SIZE != iwadSize + && FULL_SIZE != iwadSize) { - assert(IWAD_FILENUM == LumpInfo[i].wadnum); + return; + } - FResourceLump* const lump = LumpInfo[i].lump; - char* const name = lump->Name; + reader->Seek(0, SEEK_SET); - // Unwanted lumps are named like FONTA??1 + BYTE checksum[16]; + MD5Context md5; + md5.Update(reader, iwadSize); + md5.Final(checksum); - if (8 == strlen(name) - && MAKE_ID('F', 'O', 'N', 'T') == lump->dwName - && 'A' == name[4] && '1' == name[7] - && isdigit(name[5]) && isdigit(name[6])) - { - name[0] = '\0'; - } + static const BYTE HEXEN_DEMO_MD5[16] = + { + 0x92, 0x5f, 0x9f, 0x50, 0x00, 0xe1, 0x7d, 0xc8, + 0x4b, 0x0a, 0x6a, 0x3b, 0xed, 0x3a, 0x6f, 0x31 + }; + + static const BYTE HEXEN_FULL_MD5[16] = + { + 0xb6, 0x81, 0x40, 0xa7, 0x96, 0xf6, 0xfd, 0x7f, + 0x3a, 0x5d, 0x32, 0x26, 0xa3, 0x2b, 0x93, 0xbe + }; + + if ( 0 != memcmp(HEXEN_DEMO_MD5, checksum, sizeof checksum) + && 0 != memcmp(HEXEN_FULL_MD5, checksum, sizeof checksum)) + { + return; + } + + static const int EXTRA_LUMPS = 299; + + const int lastLump = GetLastLump(IWAD_FILENUM); + assert(GetFirstLump(IWAD_FILENUM) + 299 < lastLump); + + for (int i = lastLump - EXTRA_LUMPS + 1; i <= lastLump; ++i) + { + LumpInfo[i].lump->Name[0] = '\0'; } }