mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- moved setup code for Eternity-style skyboxes to p_spec.cpp and consolidated most of it with nearly identical parts of the stacked sector portal setup code.
This commit is contained in:
parent
918a2ed562
commit
7115590c1d
3 changed files with 89 additions and 120 deletions
|
@ -100,6 +100,20 @@ public:
|
|||
TObjPtr<ASkyViewpoint> Mate;
|
||||
};
|
||||
|
||||
// For an EE compatible linedef based definition.
|
||||
class ASkyCamCompat : public ASkyViewpoint
|
||||
{
|
||||
DECLARE_CLASS (ASkyCamCompat, ASkyViewpoint)
|
||||
|
||||
public:
|
||||
void BeginPlay ()
|
||||
{
|
||||
// Do not call the SkyViewpoint's super method because it would trash our setup
|
||||
AActor::BeginPlay();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class AStackPoint : public ASkyViewpoint
|
||||
{
|
||||
DECLARE_CLASS (AStackPoint, ASkyViewpoint)
|
||||
|
|
|
@ -83,95 +83,8 @@ void ASkyViewpoint::Destroy ()
|
|||
Super::Destroy();
|
||||
}
|
||||
|
||||
// For an RR compatible linedef based definition. This searches the viewpoint's sector
|
||||
// for a skybox line special, gets its tag and transfers the skybox to all tagged sectors.
|
||||
class ASkyCamCompat : public ASkyViewpoint
|
||||
{
|
||||
DECLARE_CLASS (ASkyCamCompat, ASkyViewpoint)
|
||||
|
||||
// skyboxify all tagged sectors
|
||||
// This involves changing their texture to the sky flat, because while
|
||||
// EE works with any texture for its skybox portals, ZDoom doesn't.
|
||||
void SkyboxifySector(sector_t *sector, int plane)
|
||||
{
|
||||
// plane: 0=floor, 1=ceiling, 2=both
|
||||
if (plane == 1 || plane == 2)
|
||||
{
|
||||
sector->CeilingSkyBox = this;
|
||||
sector->SetTexture(sector_t::ceiling, skyflatnum, false);
|
||||
}
|
||||
if (plane == 0 || plane == 2)
|
||||
{
|
||||
sector->FloorSkyBox = this;
|
||||
sector->SetTexture(sector_t::floor, skyflatnum, false);
|
||||
}
|
||||
}
|
||||
public:
|
||||
void BeginPlay ();
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS (ASkyCamCompat)
|
||||
|
||||
extern FTextureID skyflatnum;
|
||||
|
||||
void ASkyCamCompat::BeginPlay ()
|
||||
{
|
||||
if (Sector == NULL)
|
||||
{
|
||||
Printf("Sector not initialized for SkyCamCompat\n");
|
||||
Sector = P_PointInSector(x, y);
|
||||
}
|
||||
if (Sector)
|
||||
{
|
||||
line_t * refline = NULL;
|
||||
for (short i = 0; i < Sector->linecount; i++)
|
||||
{
|
||||
refline = Sector->lines[i];
|
||||
if (refline->special == Sector_SetPortal && refline->args[1] == 2)
|
||||
{
|
||||
// We found the setup linedef for this skybox, so let's use it for our init.
|
||||
int skybox_id = refline->args[0];
|
||||
|
||||
// Then, change the alpha
|
||||
alpha = refline->args[4];
|
||||
|
||||
FSectorTagIterator it(skybox_id);
|
||||
int secnum;
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
SkyboxifySector(§ors[secnum], refline->args[2]);
|
||||
}
|
||||
// and finally, check for portal copy linedefs
|
||||
for (int j=0;j<numlines;j++)
|
||||
{
|
||||
// Check if this portal needs to be copied to other sectors
|
||||
// This must be done here to ensure that it gets done only after the portal is set up
|
||||
if (lines[j].special == Sector_SetPortal &&
|
||||
lines[j].args[1] == 1 &&
|
||||
(lines[j].args[2] == refline->args[2] || lines[j].args[2] == 3) &&
|
||||
lines[j].args[3] == skybox_id)
|
||||
{
|
||||
if (lines[j].args[0] == 0)
|
||||
{
|
||||
SkyboxifySector(lines[j].frontsector, refline->args[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
FSectorTagIterator itr(lines[j].args[0]);
|
||||
int s;
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
SkyboxifySector(§ors[s], refline->args[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do not call the SkyViewpoint's super method because it would trash our setup
|
||||
AActor::BeginPlay();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
|
108
src/p_spec.cpp
108
src/p_spec.cpp
|
@ -62,6 +62,7 @@
|
|||
#include "farchive.h"
|
||||
#include "a_keys.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "r_sky.h"
|
||||
|
||||
// State.
|
||||
#include "r_state.h"
|
||||
|
@ -71,7 +72,6 @@
|
|||
#include "r_data/r_interpolate.h"
|
||||
|
||||
static FRandom pr_playerinspecialsector ("PlayerInSpecialSector");
|
||||
void P_SetupPortals();
|
||||
|
||||
EXTERN_CVAR(Bool, cl_predict_specials)
|
||||
|
||||
|
@ -986,7 +986,7 @@ void P_SetupPortals()
|
|||
}
|
||||
}
|
||||
|
||||
inline void SetPortal(sector_t *sector, int plane, AStackPoint *portal, fixed_t alpha)
|
||||
static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_t alpha)
|
||||
{
|
||||
// plane: 0=floor, 1=ceiling, 2=both
|
||||
if (plane > 0)
|
||||
|
@ -996,6 +996,8 @@ inline void SetPortal(sector_t *sector, int plane, AStackPoint *portal, fixed_t
|
|||
sector->CeilingSkyBox = portal;
|
||||
if (sector->GetAlpha(sector_t::ceiling) == OPAQUE)
|
||||
sector->SetAlpha(sector_t::ceiling, alpha);
|
||||
|
||||
if (!portal->bAlways) sector->SetTexture(sector_t::ceiling, skyflatnum);
|
||||
}
|
||||
}
|
||||
if (plane == 2 || plane == 0)
|
||||
|
@ -1006,6 +1008,42 @@ inline void SetPortal(sector_t *sector, int plane, AStackPoint *portal, fixed_t
|
|||
}
|
||||
if (sector->GetAlpha(sector_t::floor) == OPAQUE)
|
||||
sector->SetAlpha(sector_t::floor, alpha);
|
||||
|
||||
if (!portal->bAlways) sector->SetTexture(sector_t::floor, skyflatnum);
|
||||
}
|
||||
}
|
||||
|
||||
static void CopyPortal(int sectortag, int plane, ASkyViewpoint *origin, fixed_t alpha, bool tolines)
|
||||
{
|
||||
int s;
|
||||
FSectorTagIterator itr(sectortag);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
SetPortal(§ors[s], plane, origin, alpha);
|
||||
}
|
||||
|
||||
for (int j=0;j<numlines;j++)
|
||||
{
|
||||
// Check if this portal needs to be copied to other sectors
|
||||
// This must be done here to ensure that it gets done only after the portal is set up
|
||||
if (lines[j].special == Sector_SetPortal &&
|
||||
lines[j].args[1] == 1 &&
|
||||
(lines[j].args[2] == plane || lines[j].args[2] == 3) &&
|
||||
lines[j].args[3] == sectortag)
|
||||
{
|
||||
if (lines[j].args[0] == 0)
|
||||
{
|
||||
SetPortal(lines[j].frontsector, plane, origin, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
FSectorTagIterator itr(lines[j].args[0]);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
SetPortal(§ors[s], plane, origin, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1039,42 +1077,39 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha)
|
|||
reference->flags |= MF_JUSTATTACKED;
|
||||
anchor->flags |= MF_JUSTATTACKED;
|
||||
|
||||
int s;
|
||||
FSectorTagIterator itr(sectortag);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
SetPortal(§ors[s], plane, reference, alpha);
|
||||
}
|
||||
|
||||
for (int j=0;j<numlines;j++)
|
||||
{
|
||||
// Check if this portal needs to be copied to other sectors
|
||||
// This must be done here to ensure that it gets done only after the portal is set up
|
||||
if (lines[j].special == Sector_SetPortal &&
|
||||
lines[j].args[1] == 1 &&
|
||||
(lines[j].args[2] == plane || lines[j].args[2] == 3) &&
|
||||
lines[j].args[3] == sectortag)
|
||||
{
|
||||
if (lines[j].args[0] == 0)
|
||||
{
|
||||
SetPortal(lines[j].frontsector, plane, reference, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
FSectorTagIterator itr(lines[j].args[0]);
|
||||
while ((s = itr.Next()) >= 0)
|
||||
{
|
||||
SetPortal(§ors[s], plane, reference, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CopyPortal(sectortag, plane, reference, alpha, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This searches the viewpoint's sector
|
||||
// for a skybox line special, gets its tag and transfers the skybox to all tagged sectors.
|
||||
void P_SpawnSkybox(ASkyViewpoint *origin)
|
||||
{
|
||||
sector_t *Sector = origin->Sector;
|
||||
if (Sector == NULL)
|
||||
{
|
||||
Printf("Sector not initialized for SkyCamCompat\n");
|
||||
origin->Sector = Sector = P_PointInSector(origin->x, origin->y);
|
||||
}
|
||||
if (Sector)
|
||||
{
|
||||
line_t * refline = NULL;
|
||||
for (short i = 0; i < Sector->linecount; i++)
|
||||
{
|
||||
refline = Sector->lines[i];
|
||||
if (refline->special == Sector_SetPortal && refline->args[1] == 2)
|
||||
{
|
||||
// We found the setup linedef for this skybox, so let's use it for our init.
|
||||
CopyPortal(refline->args[0], refline->args[2], origin, 0, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// P_SetSectorDamage
|
||||
|
@ -1327,6 +1362,13 @@ void P_SpawnSpecials (void)
|
|||
P_SpawnFriction(); // phares 3/12/98: New friction model using linedefs
|
||||
P_SpawnPushers(); // phares 3/20/98: New pusher model using linedefs
|
||||
|
||||
TThinkerIterator<ASkyCamCompat> it2;
|
||||
ASkyCamCompat *pt2;
|
||||
while ((pt2 = it2.Next()))
|
||||
{
|
||||
P_SpawnSkybox(pt2);
|
||||
}
|
||||
|
||||
for (i = 0; i < numlines; i++)
|
||||
{
|
||||
switch (lines[i].special)
|
||||
|
|
Loading…
Reference in a new issue