- fixed: The portal link table was not created when there were no sector portals.

- fixed: P_TryMove could loop endlessly over a list of static portals when there was an error during portal creation.
This commit is contained in:
Christoph Oelckers 2016-03-12 17:43:36 +01:00
parent f0192a2349
commit ae1571158c
4 changed files with 33 additions and 29 deletions

View file

@ -865,9 +865,9 @@ void gl_RenderModel(GLSprite * spr)
// [BB] Workaround for the missing pitch information. // [BB] Workaround for the missing pitch information.
if ( (smf->flags & MDL_PITCHFROMMOMENTUM) ) if ( (smf->flags & MDL_PITCHFROMMOMENTUM) )
{ {
const double x = static_cast<double>(spr->actor->velx); const double x = static_cast<double>(spr->actor->vel.x);
const double y = static_cast<double>(spr->actor->vely); const double y = static_cast<double>(spr->actor->vel.y);
const double z = static_cast<double>(spr->actor->velz); const double z = static_cast<double>(spr->actor->vel.z);
// [BB] Calculate the pitch using spherical coordinates. // [BB] Calculate the pitch using spherical coordinates.
if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180); if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180);

View file

@ -517,7 +517,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + thing->height + 2 * FRACUNIT) if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + thing->height + 2 * FRACUNIT)
{ {
// exclude vertically moving objects from this check. // exclude vertically moving objects from this check.
if (!(thing->velx == 0 && thing->vely == 0 && thing->velz != 0)) if (!(thing->vel.x == 0 && thing->vel.y == 0 && thing->vel.z != 0))
{ {
if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false)) if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false))
{ {

View file

@ -2287,9 +2287,12 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y,
{ {
fixed_t bestfrac = FIXED_MAX; fixed_t bestfrac = FIXED_MAX;
spechit_t besthit; spechit_t besthit;
int besthitnum;
// find the portal nearest to the crossing actor // find the portal nearest to the crossing actor
for (auto &spec : portalhit) for (unsigned i = 0; i < portalhit.Size();i++)
{ {
auto &spec = portalhit[i];
line_t *ld = spec.line; line_t *ld = spec.line;
if (ld->frontsector->PortalGroup != thing->Sector->PortalGroup) continue; // must be in the same group to be considered valid. if (ld->frontsector->PortalGroup != thing->Sector->PortalGroup) continue; // must be in the same group to be considered valid.
@ -2305,12 +2308,14 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y,
{ {
besthit = spec; besthit = spec;
bestfrac = frac; bestfrac = frac;
besthitnum = i;
} }
} }
} }
if (bestfrac < FIXED_MAX) if (bestfrac < FIXED_MAX)
{ {
portalhit.Delete(besthitnum);
line_t *ld = besthit.line; line_t *ld = besthit.line;
FLinePortal *port = ld->getPortal(); FLinePortal *port = ld->getPortal();
if (port->mType == PORTT_LINKED) if (port->mType == PORTT_LINKED)
@ -2370,7 +2375,10 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y,
} }
R_AddInterpolationPoint(hit); R_AddInterpolationPoint(hit);
} }
if (port->mType == PORTT_LINKED) continue; if (port->mType == PORTT_LINKED)
{
continue;
}
} }
break; break;
} }

View file

@ -933,7 +933,7 @@ void P_CreateLinkedPortals()
TThinkerIterator<AStackPoint> it; TThinkerIterator<AStackPoint> it;
AStackPoint *mo; AStackPoint *mo;
TArray<AStackPoint *> orgs; TArray<AStackPoint *> orgs;
int id = 0; int id = 1;
bool bogus = false; bool bogus = false;
while ((mo = it.Next())) while ((mo = it.Next()))
@ -952,36 +952,32 @@ void P_CreateLinkedPortals()
} }
} }
} }
if (orgs.Size() == 0) if (orgs.Size() != 0)
{ {
// Create the 0->0 translation which is always needed. for (int i = 0; i < numsectors; i++)
Displacements.Create(1);
return;
}
for (int i = 0; i < numsectors; i++)
{
for (int j = 0; j < 2; j++)
{ {
AActor *box = sectors[i].SkyBoxes[j]; for (int j = 0; j < 2; j++)
if (box != NULL && box->special1 == SKYBOX_LINKEDPORTAL)
{ {
secplane_t &plane = j == 0 ? sectors[i].floorplane : sectors[i].ceilingplane; AActor *box = sectors[i].SkyBoxes[j];
if (plane.a || plane.b) if (box != NULL && box->special1 == SKYBOX_LINKEDPORTAL)
{ {
// The engine cannot deal with portals on a sloped plane. secplane_t &plane = j == 0 ? sectors[i].floorplane : sectors[i].ceilingplane;
sectors[i].SkyBoxes[j] = NULL; if (plane.a || plane.b)
Printf("Portal on %s of sector %d is sloped and will be disabled\n", j==0? "floor":"ceiling", i); {
// The engine cannot deal with portals on a sloped plane.
sectors[i].SkyBoxes[j] = NULL;
Printf("Portal on %s of sector %d is sloped and will be disabled\n", j == 0 ? "floor" : "ceiling", i);
}
} }
} }
} }
}
// Group all sectors, starting at each portal origin. // Group all sectors, starting at each portal origin.
id = 1; for (unsigned i = 0; i < orgs.Size(); i++)
for (unsigned i = 0; i < orgs.Size(); i++) {
{ if (CollectSectors(id, orgs[i]->Sector)) id++;
if (CollectSectors(id, orgs[i]->Sector)) id++; if (CollectSectors(id, orgs[i]->Mate->Sector)) id++;
if (CollectSectors(id, orgs[i]->Mate->Sector)) id++; }
} }
for (unsigned i = 0; i < linePortals.Size(); i++) for (unsigned i = 0; i < linePortals.Size(); i++)
{ {