- removed most global references to the tag manager by routing most access to FLevelocals.

This commit is contained in:
Christoph Oelckers 2019-01-24 01:40:09 +01:00
commit 7e9340f3b7
33 changed files with 291 additions and 262 deletions

View file

@ -46,6 +46,7 @@
#include "p_spec.h"
#include "g_levellocals.h"
#include "actorinlines.h"
#include "maploader/maploader.h"
//==========================================================================
//
@ -200,105 +201,6 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag
}
}
//==========================================================================
//
// Creates all 3D floors defined by one linedef
//
//==========================================================================
static int P_Set3DFloor(line_t * line, int param, int param2, int alpha)
{
int s;
int flags;
int tag = line->args[0];
sector_t * sec = line->frontsector, *ss;
FSectorTagIterator itr(tag);
while ((s = itr.Next()) >= 0)
{
ss = &level.sectors[s];
if (param == 0)
{
flags = FF_EXISTS | FF_RENDERALL | FF_SOLID | FF_INVERTSECTOR;
alpha = 255;
for (auto l: sec->Lines)
{
if (l->special == Sector_SetContents && l->frontsector == sec)
{
alpha = clamp<int>(l->args[1], 0, 100);
if (l->args[2] & 1) flags &= ~FF_SOLID;
if (l->args[2] & 2) flags |= FF_SEETHROUGH;
if (l->args[2] & 4) flags |= FF_SHOOTTHROUGH;
if (l->args[2] & 8) flags |= FF_ADDITIVETRANS;
if (alpha != 100) flags |= FF_TRANSLUCENT;//|FF_BOTHPLANES|FF_ALLSIDES;
if (l->args[0])
{
// Yes, Vavoom's 3D-floor definitions suck!
// The content list changed in r1783 of Vavoom to be unified
// among all its supported games, so it has now ten different
// values instead of just five.
static uint32_t vavoomcolors[] = { VC_EMPTY,
VC_WATER, VC_LAVA, VC_NUKAGE, VC_SLIME, VC_HELLSLIME,
VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER };
flags |= FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_FLOOD;
l->frontsector->Colormap.FadeColor = vavoomcolors[l->args[0]] & VC_COLORMASK;
l->frontsector->Colormap.FogDensity = 0;
}
alpha = (alpha * 255) / 100;
break;
}
}
}
else if (param == 4)
{
flags = FF_EXISTS | FF_RENDERPLANES | FF_INVERTPLANES | FF_NOSHADE | FF_FIX;
if (param2 & 1) flags |= FF_SEETHROUGH; // marker for allowing missing texture checks
alpha = 255;
}
else
{
static const int defflags[] = { 0,
FF_SOLID,
FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_SHOOTTHROUGH | FF_SEETHROUGH,
FF_SHOOTTHROUGH | FF_SEETHROUGH,
};
flags = defflags[param & 3] | FF_EXISTS | FF_RENDERALL;
if (param & 4) flags |= FF_ALLSIDES | FF_BOTHPLANES;
if (param & 16) flags ^= FF_SEETHROUGH;
if (param & 32) flags ^= FF_SHOOTTHROUGH;
if (param2 & 1) flags |= FF_NOSHADE;
if (param2 & 2) flags |= FF_DOUBLESHADOW;
if (param2 & 4) flags |= FF_FOG;
if (param2 & 8) flags |= FF_THINFLOOR;
if (param2 & 16) flags |= FF_UPPERTEXTURE;
if (param2 & 32) flags |= FF_LOWERTEXTURE;
if (param2 & 64) flags |= FF_ADDITIVETRANS | FF_TRANSLUCENT;
// if flooding is used the floor must be non-solid and is automatically made shootthrough and seethrough
if ((param2 & 128) && !(flags & FF_SOLID)) flags |= FF_FLOOD | FF_SEETHROUGH | FF_SHOOTTHROUGH;
if (param2 & 512) flags |= FF_FADEWALLS;
if (param2&1024) flags |= FF_RESET;
FTextureID tex = line->sidedef[0]->GetTexture(side_t::top);
if (!tex.Exists() && alpha < 255)
{
alpha = -tex.GetIndex();
}
alpha = clamp(alpha, 0, 255);
if (alpha == 0) flags &= ~(FF_RENDERALL | FF_BOTHPLANES | FF_ALLSIDES);
else if (alpha != 255) flags |= FF_TRANSLUCENT;
}
P_Add3DFloor(ss, sec, line, flags, alpha);
}
// To be 100% safe this should be done even if the alpha by texture value isn't used.
if (!line->sidedef[0]->GetTexture(side_t::top).isValid())
line->sidedef[0]->SetTexture(side_t::top, FNullTextureID());
return 1;
}
//==========================================================================
//
// P_PlayerOnSpecial3DFloor
@ -876,31 +778,129 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li
}
}
//==========================================================================
//
// Creates all 3D floors defined by one linedef
//
//==========================================================================
int MapLoader::Set3DFloor(line_t * line, int param, int param2, int alpha)
{
int s;
int flags;
int tag = line->args[0];
sector_t * sec = line->frontsector, *ss;
auto itr = Level->GetSectorTagIterator(tag);
while ((s = itr.Next()) >= 0)
{
ss = &Level->sectors[s];
if (param == 0)
{
flags = FF_EXISTS | FF_RENDERALL | FF_SOLID | FF_INVERTSECTOR;
alpha = 255;
for (auto l: sec->Lines)
{
if (l->special == Sector_SetContents && l->frontsector == sec)
{
alpha = clamp<int>(l->args[1], 0, 100);
if (l->args[2] & 1) flags &= ~FF_SOLID;
if (l->args[2] & 2) flags |= FF_SEETHROUGH;
if (l->args[2] & 4) flags |= FF_SHOOTTHROUGH;
if (l->args[2] & 8) flags |= FF_ADDITIVETRANS;
if (alpha != 100) flags |= FF_TRANSLUCENT;//|FF_BOTHPLANES|FF_ALLSIDES;
if (l->args[0])
{
// Yes, Vavoom's 3D-floor definitions suck!
// The content list changed in r1783 of Vavoom to be unified
// among all its supported games, so it has now ten different
// values instead of just five.
static uint32_t vavoomcolors[] = { VC_EMPTY,
VC_WATER, VC_LAVA, VC_NUKAGE, VC_SLIME, VC_HELLSLIME,
VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER };
flags |= FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_FLOOD;
l->frontsector->Colormap.FadeColor = vavoomcolors[l->args[0]] & VC_COLORMASK;
l->frontsector->Colormap.FogDensity = 0;
}
alpha = (alpha * 255) / 100;
break;
}
}
}
else if (param == 4)
{
flags = FF_EXISTS | FF_RENDERPLANES | FF_INVERTPLANES | FF_NOSHADE | FF_FIX;
if (param2 & 1) flags |= FF_SEETHROUGH; // marker for allowing missing texture checks
alpha = 255;
}
else
{
static const int defflags[] = { 0,
FF_SOLID,
FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_SHOOTTHROUGH | FF_SEETHROUGH,
FF_SHOOTTHROUGH | FF_SEETHROUGH,
};
flags = defflags[param & 3] | FF_EXISTS | FF_RENDERALL;
if (param & 4) flags |= FF_ALLSIDES | FF_BOTHPLANES;
if (param & 16) flags ^= FF_SEETHROUGH;
if (param & 32) flags ^= FF_SHOOTTHROUGH;
if (param2 & 1) flags |= FF_NOSHADE;
if (param2 & 2) flags |= FF_DOUBLESHADOW;
if (param2 & 4) flags |= FF_FOG;
if (param2 & 8) flags |= FF_THINFLOOR;
if (param2 & 16) flags |= FF_UPPERTEXTURE;
if (param2 & 32) flags |= FF_LOWERTEXTURE;
if (param2 & 64) flags |= FF_ADDITIVETRANS | FF_TRANSLUCENT;
// if flooding is used the floor must be non-solid and is automatically made shootthrough and seethrough
if ((param2 & 128) && !(flags & FF_SOLID)) flags |= FF_FLOOD | FF_SEETHROUGH | FF_SHOOTTHROUGH;
if (param2 & 512) flags |= FF_FADEWALLS;
if (param2&1024) flags |= FF_RESET;
FTextureID tex = line->sidedef[0]->GetTexture(side_t::top);
if (!tex.Exists() && alpha < 255)
{
alpha = -tex.GetIndex();
}
alpha = clamp(alpha, 0, 255);
if (alpha == 0) flags &= ~(FF_RENDERALL | FF_BOTHPLANES | FF_ALLSIDES);
else if (alpha != 255) flags |= FF_TRANSLUCENT;
}
P_Add3DFloor(ss, sec, line, flags, alpha);
}
// To be 100% safe this should be done even if the alpha by texture value isn't used.
if (!line->sidedef[0]->GetTexture(side_t::top).isValid())
line->sidedef[0]->SetTexture(side_t::top, FNullTextureID());
return 1;
}
//==========================================================================
//
// Spawns 3D floors
//
//==========================================================================
void P_Spawn3DFloors (void)
void MapLoader::Spawn3DFloors ()
{
static int flagvals[] = {512, 2+512, 512+1024};
for (auto &line : level.lines)
for (auto &line : Level->lines)
{
switch(line.special)
{
case ExtraFloor_LightOnly:
if (line.args[1] < 0 || line.args[1] > 2) line.args[1] = 0;
if (line.args[0] != 0)
P_Set3DFloor(&line, 3, flagvals[line.args[1]], 0);
Set3DFloor(&line, 3, flagvals[line.args[1]], 0);
break;
case Sector_Set3DFloor:
// The flag high-byte/line id is only needed in Hexen format.
// UDMF can set both of these parameters without any restriction of the usable values.
// In Doom format the translators can take full integers for the tag and the line ID always is the same as the tag.
if (level.maptype == MAPTYPE_HEXEN)
if (Level->maptype == MAPTYPE_HEXEN)
{
if (line.args[1]&8)
{
@ -912,7 +912,7 @@ void P_Spawn3DFloors (void)
line.args[4]=0;
}
}
P_Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]);
Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]);
break;
default:
@ -922,7 +922,7 @@ void P_Spawn3DFloors (void)
line.args[0] = line.args[1] = line.args[2] = line.args[3] = line.args[4] = 0;
}
for (auto &sec : level.sectors)
for (auto &sec : Level->sectors)
{
P_Recalculate3DFloors(&sec);
}