diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index 3a8e8e5ec..ca57ad557 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -82,7 +82,7 @@ void AFastProjectile::Tick () if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline)) + Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 256ba010c..f66659df9 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -414,7 +414,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) // Move item back to its original location fixed_t _x, _y; - sector_t *sec; _x = self->SpawnPoint[0]; _y = self->SpawnPoint[1]; @@ -422,12 +421,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) self->UnlinkFromWorld(); self->SetXY(_x, _y); self->LinkToWorld(true); - sec = self->Sector; - self->dropoffz = - self->floorz = sec->floorplane.ZatPoint(_x, _y); - self->ceilingz = sec->ceilingplane.ZatPoint(_x, _y); - self->SetZ(self->floorz); - P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS | FFCF_NOPORTALS); // no pprtal checks here so that things get spawned in this sector. + self->SetZ(self->Sector->floorplane.ZatPoint(_x, _y)); + P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS | FFCF_NOPORTALS); // no portal checks here so that things get spawned in this sector. if (self->flags & MF_SPAWNCEILING) { @@ -450,10 +445,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) { self->SetZ(self->SpawnPoint[2] + self->floorz); } - // Redo floor/ceiling check, in case of 3D floors - // we need to get the actual floor and ceiling heights including portals here - self->floorz = sec->LowestFloorAt(self, &self->floorsector); - self->ceilingz = sec->HighestCeilingAt(self, &self->ceilingsector); + // Redo floor/ceiling check, in case of 3D floors and portals P_FindFloorCeiling(self, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); if (self->Z() < self->floorz) { // Do not reappear under the floor, even if that's where we were for the diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 9ffb17c27..47ac85d1f 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -558,7 +558,7 @@ bool P_Move (AActor *actor) else { // The monster just hit the floor, so trigger any actions. if (actor->floorsector->SecActTarget != NULL && - actor->floorz == actor->floorsector->floorplane.ZatPoint(actor->PosRelative(actor->floorsector)) + actor->floorz == actor->floorsector->floorplane.ZatPoint(actor->PosRelative(actor->floorsector))) { actor->floorsector->SecActTarget->TriggerAction(actor, SECSPAC_HitFloor); } diff --git a/src/p_map.cpp b/src/p_map.cpp index 1a17aa5b8..2b9faa03a 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -238,21 +238,24 @@ static bool PIT_FindFloorCeiling(line_t *ld, const FBoundingBox &box, FCheckPosi void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) { - sector_t *sec; - if (!(flags & FFCF_ONLYSPAWNPOS)) - { - sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector(tmf.x, tmf.y) : tmf.thing->Sector; + sector_t *sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector(tmf.x, tmf.y) : tmf.thing->Sector; - tmf.floorz = tmf.dropoffz = sec->LowestFloorAt(tmf.x, tmf.y, &tmf.floorsector); - tmf.ceilingz = sec->HighestCeilingAt(tmf.x, tmf.y, &tmf.ceilingsector); - tmf.floorpic = sec->GetTexture(sector_t::floor); - tmf.floorterrain = sec->GetTerrain(sector_t::floor); - tmf.ceilingpic = sec->GetTexture(sector_t::ceiling); + if (flags & FFCF_NOPORTALS) + { + tmf.thing->dropoffz = tmf.thing->floorz = sec->floorplane.ZatPoint(tmf.x, tmf.y); + tmf.thing->ceilingz = sec->ceilingplane.ZatPoint(tmf.x, tmf.y); + tmf.ceilingsector = tmf.floorsector = sec; } else { - sec = tmf.thing->Sector; + tmf.floorz = tmf.dropoffz = sec->LowestFloorAt(tmf.x, tmf.y, &tmf.floorsector); + tmf.ceilingz = sec->HighestCeilingAt(tmf.x, tmf.y, &tmf.ceilingsector); } + tmf.floorpic = tmf.floorsector->GetTexture(sector_t::floor); + tmf.floorterrain = tmf.floorsector->GetTerrain(sector_t::floor); + tmf.ceilingpic = tmf.ceilingsector->GetTexture(sector_t::ceiling); + + tmf.sector = sec; for (unsigned int i = 0; ie->XFloor.ffloors.Size(); i++) { @@ -299,21 +302,8 @@ void P_FindFloorCeiling(AActor *actor, int flags) { flags |= FFCF_3DRESTRICT; } - if (!(flags & FFCF_ONLYSPAWNPOS)) - { - P_GetFloorCeilingZ(tmf, flags); - } - else - { - tmf.ceilingsector = tmf.floorsector = actor->Sector; + P_GetFloorCeilingZ(tmf, flags); - tmf.floorz = tmf.dropoffz = actor->floorz; - tmf.ceilingz = actor->ceilingz; - tmf.floorpic = actor->floorpic; - tmf.floorterrain = actor->floorterrain; - tmf.ceilingpic = actor->ceilingpic; - P_GetFloorCeilingZ(tmf, flags); - } actor->floorz = tmf.floorz; actor->dropoffz = tmf.dropoffz; actor->ceilingz = tmf.ceilingz; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 53d7d14e9..12fdaf427 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -513,8 +513,6 @@ void AActor::SetOrigin (fixed_t ix, fixed_t iy, fixed_t iz, bool moving) SetXYZ(ix, iy, iz); if (moving) SetMovement(ix - X(), iy - Y(), iz - Z()); LinkToWorld (); - floorz = Sector->LowestFloorAt(ix, iy, &floorsector); - ceilingz = Sector->HighestCeilingAt(ix, iy, &ceilingsector); P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 60724bbe5..da5208b6a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3558,7 +3558,7 @@ void AActor::Tick () for (node = touching_sectorlist; node; node = node->m_tnext) { - const sector_t *sec = node->m_sector; + sector_t *sec = node->m_sector; fixed_t scrollx, scrolly; if (level.Scrolls != NULL) @@ -4172,8 +4172,6 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t // z-coordinate. if (!SpawningMapThing) { - actor->ceilingz = actor->Sector->HighestCeilingAt(actor, &actor->ceilingsector); - actor->dropoffz = actor->floorz = actor->Sector->LowestFloorAt(actor, &actor->floorsector); P_FindFloorCeiling(actor, FFCF_ONLYSPAWNPOS); } else diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 7e57cd0f8..6007963c6 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -2299,7 +2299,7 @@ void DPusher::Tick () continue; sector_t *hsec = sec->GetHeightSec(); - fixedvec2 pos = thing->PosRelative(sec); + fixedvec3 pos = thing->PosRelative(sec); if (m_Type == p_wind) { if (hsec == NULL) diff --git a/src/p_user.cpp b/src/p_user.cpp index 529420347..fbcf41238 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -769,10 +769,9 @@ void APlayerPawn::PostBeginPlay() // Voodoo dolls: restore original floorz/ceilingz logic if (player == NULL || player->mo != this) { - dropoffz = floorz = Sector->floorplane.ZatPoint(this); - ceilingz = Sector->ceilingplane.ZatPoint(this); - P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS); + P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS|FFCF_NOPORTALS); SetZ(floorz); + P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS); } else {