- refactored sector portal data so that it does not rely on actors.

This is necessary because otherwise the level data cannot be serialized before the actors.
This commit is contained in:
Christoph Oelckers 2016-04-20 19:20:11 +02:00
commit 082042818b
23 changed files with 410 additions and 284 deletions

View file

@ -38,49 +38,42 @@
#include "p_lnspec.h"
#include "farchive.h"
#include "r_sky.h"
#include "portal.h"
// arg0 = Visibility*4 for this skybox
IMPLEMENT_POINTY_CLASS (ASkyViewpoint)
DECLARE_POINTER(Mate)
END_POINTERS
IMPLEMENT_CLASS (ASkyViewpoint)
// If this actor has no TID, make it the default sky box
void ASkyViewpoint::BeginPlay ()
{
Super::BeginPlay ();
if (tid == 0 && level.DefaultSkybox == NULL)
if (tid == 0 && sectorPortals[0].mSkybox == nullptr)
{
level.DefaultSkybox = this;
sectorPortals[0].mSkybox = this;
sectorPortals[0].mDestination = Sector;
}
special1 = SKYBOX_SKYVIEWPOINT;
}
void ASkyViewpoint::Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << bInSkybox << bAlways << Mate;
}
void ASkyViewpoint::Destroy ()
{
// remove all sector references to ourselves.
for (int i = 0; i <numsectors; i++)
for (int i = 0; i < numsectors; i++)
{
if (sectors[i].SkyBoxes[sector_t::floor] == this)
{
sectors[i].SkyBoxes[sector_t::floor] = NULL;
}
if (sectors[i].SkyBoxes[sector_t::ceiling] == this)
{
sectors[i].SkyBoxes[sector_t::ceiling] = NULL;
}
if (sectors[i].GetPortal(sector_t::floor)->mSkybox == this)
sectors[i].ClearPortal(sector_t::floor);
if (sectors[i].GetPortal(sector_t::ceiling)->mSkybox == this)
sectors[i].ClearPortal(sector_t::ceiling);
}
if (level.DefaultSkybox == this)
for (auto &s : sectorPortals)
{
level.DefaultSkybox = NULL;
if (s.mSkybox == this) s.mSkybox = 0;
// This is necessary to entirely disable EE-style skyboxes
// if their viewpoint gets deleted.
s.mFlags |= PORTSF_SKYFLATONLY;
}
Super::Destroy();
}
@ -90,10 +83,8 @@ void ASkyCamCompat::BeginPlay()
{
// Do not call the SkyViewpoint's super method because it would trash our setup
AActor::BeginPlay();
special1 = SKYBOX_SKYVIEWPOINT;
}
//---------------------------------------------------------------------------
// arg0 = tid of matching SkyViewpoint
@ -130,20 +121,18 @@ void ASkyPicker::PostBeginPlay ()
if (box == NULL && args[0] != 0)
{
Printf ("Can't find SkyViewpoint %d for sector %td\n",
args[0], Sector - sectors);
Printf ("Can't find SkyViewpoint %d for sector %td\n", args[0], Sector - sectors);
}
else
{
int boxindex = P_GetSkyboxPortal(box);
if (0 == (args[1] & 2))
{
Sector->SkyBoxes[sector_t::ceiling] = box;
if (box == NULL) Sector->MoreFlags |= SECF_NOCEILINGSKYBOX; // sector should ignore the level's default skybox
Sector->Portals[sector_t::ceiling] = boxindex;
}
if (0 == (args[1] & 1))
{
Sector->SkyBoxes[sector_t::floor] = box;
if (box == NULL) Sector->MoreFlags |= SECF_NOFLOORSKYBOX; // sector should ignore the level's default skybox
Sector->Portals[sector_t::floor] = boxindex;
}
}
Destroy ();
@ -160,9 +149,6 @@ void AStackPoint::BeginPlay ()
{
// Skip SkyViewpoint's initialization
AActor::BeginPlay ();
bAlways = true;
special1 = SKYBOX_STACKEDSECTORTHING;
}
//---------------------------------------------------------------------------