mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
- moved the tag manager into FLevelLocals
This commit is contained in:
parent
7e9340f3b7
commit
97495e1857
10 changed files with 51 additions and 78 deletions
|
@ -296,33 +296,6 @@ PClassActor *T_ClassType(const svalue_t &arg)
|
|||
return PClass::FindActor(stringvalue(arg));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Finds a sector from a tag. This has been extended to allow looking for
|
||||
// sectors directly by passing a negative value
|
||||
//
|
||||
//==========================================================================
|
||||
class FSSectorTagIterator : public FSectorTagIterator
|
||||
{
|
||||
public:
|
||||
FSSectorTagIterator(int tag)
|
||||
: FSectorTagIterator(tag)
|
||||
{
|
||||
if (tag < 0)
|
||||
{
|
||||
searchtag = INT_MIN;
|
||||
start = tag == -32768? 0 : -tag < (int)level.sectors.Size()? -tag : -1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline int T_FindFirstSectorFromTag(int tagnum)
|
||||
{
|
||||
FSSectorTagIterator it(tagnum);
|
||||
return it.Next();
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Get an ammo type
|
||||
|
@ -1518,7 +1491,7 @@ void FParser::SF_StartSectorSound(void)
|
|||
tagnum = intvalue(t_argv[0]);
|
||||
|
||||
int i=-1;
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
sector = &Level->sectors[i];
|
||||
|
@ -1555,7 +1528,7 @@ void FParser::SF_FloorHeight(void)
|
|||
|
||||
// set all sectors with tag
|
||||
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
auto &sec = Level->sectors[i];
|
||||
|
@ -1574,7 +1547,7 @@ void FParser::SF_FloorHeight(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
secnum = T_FindFirstSectorFromTag(tagnum);
|
||||
secnum = Level->FindFirstSectorFromTag(tagnum);
|
||||
if(secnum < 0)
|
||||
{
|
||||
script_error("sector not found with tagnum %i\n", tagnum);
|
||||
|
@ -1610,7 +1583,7 @@ void FParser::SF_MoveFloor(void)
|
|||
|
||||
// move all sectors with tag
|
||||
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
P_CreateFloor(&Level->sectors[secnum], DFloor::floorMoveToValue, NULL, platspeed, destheight, crush, 0, false, false);
|
||||
|
@ -1645,7 +1618,7 @@ void FParser::SF_CeilingHeight(void)
|
|||
dest = floatvalue(t_argv[1]);
|
||||
|
||||
// set all sectors with tag
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
auto &sec = Level->sectors[i];
|
||||
|
@ -1664,7 +1637,7 @@ void FParser::SF_CeilingHeight(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
secnum = T_FindFirstSectorFromTag(tagnum);
|
||||
secnum = Level->FindFirstSectorFromTag(tagnum);
|
||||
if(secnum < 0)
|
||||
{
|
||||
script_error("sector not found with tagnum %i\n", tagnum);
|
||||
|
@ -1702,7 +1675,7 @@ void FParser::SF_MoveCeiling(void)
|
|||
silent=t_argc>4 ? intvalue(t_argv[4]):1;
|
||||
|
||||
// move all sectors with tag
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
P_CreateCeiling(&Level->sectors[secnum], DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom);
|
||||
|
@ -1727,7 +1700,7 @@ void FParser::SF_LightLevel(void)
|
|||
tagnum = intvalue(t_argv[0]);
|
||||
|
||||
// argv is sector tag
|
||||
secnum = T_FindFirstSectorFromTag(tagnum);
|
||||
secnum = Level->FindFirstSectorFromTag(tagnum);
|
||||
|
||||
if(secnum < 0)
|
||||
{
|
||||
|
@ -1741,7 +1714,7 @@ void FParser::SF_LightLevel(void)
|
|||
int i = -1;
|
||||
|
||||
// set all sectors with tag
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
Level->sectors[i].SetLightLevel(intvalue(t_argv[1]));
|
||||
|
@ -1882,7 +1855,7 @@ void FParser::SF_FloorTexture(void)
|
|||
tagnum = intvalue(t_argv[0]);
|
||||
|
||||
// argv is sector tag
|
||||
secnum = T_FindFirstSectorFromTag(tagnum);
|
||||
secnum = Level->FindFirstSectorFromTag(tagnum);
|
||||
|
||||
if(secnum < 0)
|
||||
{ script_error("sector not found with tagnum %i\n", tagnum); return;}
|
||||
|
@ -1895,7 +1868,7 @@ void FParser::SF_FloorTexture(void)
|
|||
FTextureID picnum = TexMan.GetTextureID(t_argv[1].string, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
// set all sectors with tag
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
Level->sectors[i].SetTexture(sector_t::floor, picnum);
|
||||
|
@ -1934,7 +1907,7 @@ void FParser::SF_SectorColormap(void)
|
|||
tagnum = intvalue(t_argv[0]);
|
||||
|
||||
// argv is sector tag
|
||||
secnum = T_FindFirstSectorFromTag(tagnum);
|
||||
secnum = Level->FindFirstSectorFromTag(tagnum);
|
||||
|
||||
if(secnum < 0)
|
||||
{ script_error("sector not found with tagnum %i\n", tagnum); return;}
|
||||
|
@ -1945,7 +1918,7 @@ void FParser::SF_SectorColormap(void)
|
|||
{
|
||||
uint32_t cm = R_ColormapNumForName(t_argv[1].value.s);
|
||||
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
sectors[i].midmap=cm;
|
||||
|
@ -1972,7 +1945,7 @@ void FParser::SF_CeilingTexture(void)
|
|||
tagnum = intvalue(t_argv[0]);
|
||||
|
||||
// argv is sector tag
|
||||
secnum = T_FindFirstSectorFromTag(tagnum);
|
||||
secnum = Level->FindFirstSectorFromTag(tagnum);
|
||||
|
||||
if(secnum < 0)
|
||||
{ script_error("sector not found with tagnum %i\n", tagnum); return;}
|
||||
|
@ -1985,7 +1958,7 @@ void FParser::SF_CeilingTexture(void)
|
|||
FTextureID picnum = TexMan.GetTextureID(t_argv[1].string, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
// set all sectors with tag
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
Level->sectors[i].SetTexture(sector_t::ceiling, picnum);
|
||||
|
@ -3700,7 +3673,7 @@ void FParser::SF_SetColor(void)
|
|||
{
|
||||
tagnum = intvalue(t_argv[0]);
|
||||
|
||||
secnum = T_FindFirstSectorFromTag(tagnum);
|
||||
secnum = Level->FindFirstSectorFromTag(tagnum);
|
||||
|
||||
if(secnum < 0)
|
||||
{
|
||||
|
@ -3721,7 +3694,7 @@ void FParser::SF_SetColor(void)
|
|||
else return;
|
||||
|
||||
// set all sectors with tag
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
auto itr = Level->GetSectorTagIterator(tagnum);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
{
|
||||
Level->sectors[i].SetColor(color, 0);
|
||||
|
|
|
@ -103,6 +103,8 @@ struct FLevelData
|
|||
TArray<FPlayerStart> AllPlayerStarts;
|
||||
|
||||
FBehaviorContainer Behaviors;
|
||||
FTagManager tagManager;
|
||||
|
||||
};
|
||||
|
||||
struct FLevelLocals : public FLevelData
|
||||
|
@ -121,15 +123,15 @@ struct FLevelLocals : public FLevelData
|
|||
|
||||
FSectorTagIterator GetSectorTagIterator(int tag)
|
||||
{
|
||||
return FSectorTagIterator(tag);
|
||||
return FSectorTagIterator(tagManager, tag);
|
||||
}
|
||||
FSectorTagIterator GetSectorTagIterator(int tag, line_t *line)
|
||||
{
|
||||
return FSectorTagIterator(tag, line);
|
||||
return FSectorTagIterator(tagManager, tag, line);
|
||||
}
|
||||
FLineIdIterator GetLineIdIterator(int tag)
|
||||
{
|
||||
return FLineIdIterator(tag);
|
||||
return FLineIdIterator(tagManager, tag);
|
||||
}
|
||||
template<class T> TThinkerIterator<T> GetThinkerIterator(FName subtype = NAME_None)
|
||||
{
|
||||
|
|
|
@ -394,7 +394,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, ClearSectorTags)
|
|||
{
|
||||
PARAM_SELF_PROLOGUE(DLevelCompatibility);
|
||||
PARAM_INT(sector);
|
||||
tagManager.RemoveSectorTags(sector);
|
||||
self->Level->tagManager.RemoveSectorTags(sector);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddSectorTag)
|
|||
|
||||
if ((unsigned)sector < self->Level->sectors.Size())
|
||||
{
|
||||
tagManager.AddSectorTag(sector, tag);
|
||||
self->Level->tagManager.AddSectorTag(sector, tag);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, ClearLineIDs)
|
|||
{
|
||||
PARAM_SELF_PROLOGUE(DLevelCompatibility);
|
||||
PARAM_INT(line);
|
||||
tagManager.RemoveLineIDs(line);
|
||||
self->Level->tagManager.RemoveLineIDs(line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddLineID)
|
|||
|
||||
if ((unsigned)line < self->Level->lines.Size())
|
||||
{
|
||||
tagManager.AddLineID(line, tag);
|
||||
self->Level->tagManager.AddLineID(line, tag);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -583,7 +583,7 @@ void MapLoader::ProcessEDLinedef(line_t *ld, int recordnum)
|
|||
ld->flags = (ld->flags&~fmask) | eld->flags;
|
||||
ld->setAlpha(eld->alpha);
|
||||
memcpy(ld->args, eld->args, sizeof(ld->args));
|
||||
tagManager.AddLineID(Index(ld), eld->tag);
|
||||
Level->tagManager.AddLineID(Index(ld), eld->tag);
|
||||
}
|
||||
|
||||
void MapLoader::ProcessEDSector(sector_t *sec, int recordnum)
|
||||
|
|
|
@ -1111,7 +1111,7 @@ void MapLoader::LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
|
|||
ss->special = LittleShort(ms->special);
|
||||
else // [RH] Translate to new sector special
|
||||
ss->special = P_TranslateSectorSpecial (LittleShort(ms->special));
|
||||
tagManager.AddSectorTag(i, LittleShort(ms->tag));
|
||||
Level->tagManager.AddSectorTag(i, LittleShort(ms->tag));
|
||||
ss->thinglist = nullptr;
|
||||
ss->touching_thinglist = nullptr; // phares 3/14/98
|
||||
ss->sectorportal_thinglist = nullptr;
|
||||
|
@ -1529,7 +1529,7 @@ void MapLoader::SetLineID (int i, line_t *ld)
|
|||
}
|
||||
if (setid != -1)
|
||||
{
|
||||
tagManager.AddLineID(i, setid);
|
||||
Level->tagManager.AddLineID(i, setid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1753,7 +1753,7 @@ void MapLoader::LoadLineDefs (MapData * map)
|
|||
// do not assign the tag for Extradata lines.
|
||||
if (ld->special != Static_Init || (ld->args[1] != Init_EDLine && ld->args[1] != Init_EDSector))
|
||||
{
|
||||
tagManager.AddLineID(i, mld->tag);
|
||||
Level->tagManager.AddLineID(i, mld->tag);
|
||||
}
|
||||
#ifndef NO_EDATA
|
||||
if (ld->special == Static_Init && ld->args[1] == Init_EDLine)
|
||||
|
@ -2755,7 +2755,7 @@ void MapLoader::GroupLines (bool buildmap)
|
|||
{
|
||||
Printf ("Sector %i (tag %i) has no lines\n", i, Level->GetFirstSectorTag(Index(sector)));
|
||||
// 0 the sector's tag so that no specials can use it
|
||||
tagManager.RemoveSectorTags(i);
|
||||
Level->tagManager.RemoveSectorTags(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2810,7 +2810,7 @@ void MapLoader::GroupLines (bool buildmap)
|
|||
}
|
||||
|
||||
// killough 1/30/98: Create xref tables for tags
|
||||
tagManager.HashTags();
|
||||
Level->tagManager.HashTags();
|
||||
|
||||
if (!buildmap)
|
||||
{
|
||||
|
|
|
@ -856,7 +856,7 @@ public:
|
|||
|
||||
case NAME_Id:
|
||||
lineid = CheckInt(key);
|
||||
tagManager.AddLineID(index, lineid);
|
||||
Level->tagManager.AddLineID(index, lineid);
|
||||
continue;
|
||||
|
||||
case NAME_Sidefront:
|
||||
|
@ -1127,7 +1127,7 @@ public:
|
|||
// scan the string as long as valid numbers can be found
|
||||
while (sc.CheckNumber())
|
||||
{
|
||||
if (sc.Number != 0) tagManager.AddLineID(index, sc.Number);
|
||||
if (sc.Number != 0) Level->tagManager.AddLineID(index, sc.Number);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1513,7 +1513,7 @@ public:
|
|||
continue;
|
||||
|
||||
case NAME_Id:
|
||||
tagManager.AddSectorTag(index, CheckInt(key));
|
||||
Level->tagManager.AddSectorTag(index, CheckInt(key));
|
||||
continue;
|
||||
|
||||
default:
|
||||
|
@ -1908,7 +1908,7 @@ public:
|
|||
// scan the string as long as valid numbers can be found
|
||||
while (sc.CheckNumber())
|
||||
{
|
||||
if (sc.Number != 0) tagManager.AddSectorTag(index, sc.Number);
|
||||
if (sc.Number != 0) Level->tagManager.AddSectorTag(index, sc.Number);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -904,7 +904,7 @@ void MapLoader::Spawn3DFloors ()
|
|||
{
|
||||
if (line.args[1]&8)
|
||||
{
|
||||
tagManager.AddLineID(line.Index(), line.args[4]);
|
||||
Level->tagManager.AddLineID(line.Index(), line.args[4]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
#include "g_levellocals.h"
|
||||
#include "vm.h"
|
||||
|
||||
FTagManager tagManager;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -318,7 +316,7 @@ void FTagManager::DumpTags()
|
|||
|
||||
CCMD(dumptags)
|
||||
{
|
||||
tagManager.DumpTags();
|
||||
level.tagManager.DumpTags();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
12
src/p_tags.h
12
src/p_tags.h
|
@ -76,16 +76,15 @@ public: // The ones below are called by functions that cannot be declared as fri
|
|||
void DumpTags();
|
||||
};
|
||||
|
||||
extern FTagManager tagManager;
|
||||
|
||||
class FSectorTagIterator
|
||||
{
|
||||
friend struct FLevelLocals;
|
||||
protected:
|
||||
int searchtag;
|
||||
int start;
|
||||
FTagManager &tagManager;
|
||||
|
||||
FSectorTagIterator()
|
||||
FSectorTagIterator(FTagManager &tm) : tagManager(tm)
|
||||
{
|
||||
// For DSectorTagIterator
|
||||
}
|
||||
|
@ -110,13 +109,13 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
FSectorTagIterator(int tag)
|
||||
FSectorTagIterator(FTagManager &tm, int tag) : tagManager(tm)
|
||||
{
|
||||
Init(tag);
|
||||
}
|
||||
|
||||
// Special constructor for actions that treat tag 0 as 'back of activation line'
|
||||
FSectorTagIterator(int tag, line_t *line)
|
||||
FSectorTagIterator(FTagManager &tm, int tag, line_t *line) : tagManager(tm)
|
||||
{
|
||||
Init(tag, line);
|
||||
}
|
||||
|
@ -131,8 +130,9 @@ class FLineIdIterator
|
|||
protected:
|
||||
int searchtag;
|
||||
int start;
|
||||
FTagManager &tagManager;
|
||||
|
||||
FLineIdIterator(int id)
|
||||
FLineIdIterator(FTagManager &tm, int id) : tagManager(tm)
|
||||
{
|
||||
searchtag = id;
|
||||
start = tagManager.IDHashFirst[((unsigned int)id) % FTagManager::TAG_HASH_SIZE];
|
||||
|
|
|
@ -243,7 +243,7 @@ class DSectorTagIterator : public DObject, public FSectorTagIterator
|
|||
{
|
||||
DECLARE_ABSTRACT_CLASS(DSectorTagIterator, DObject);
|
||||
public:
|
||||
DSectorTagIterator(int tag, line_t *line)
|
||||
DSectorTagIterator(FTagManager &tm, int tag, line_t *line) : FSectorTagIterator(tm)
|
||||
{
|
||||
if (line == nullptr) Init(tag);
|
||||
else Init(tag, line);
|
||||
|
@ -254,7 +254,7 @@ IMPLEMENT_CLASS(DSectorTagIterator, true, false);
|
|||
|
||||
static DSectorTagIterator *CreateSTI(int tag, line_t *line)
|
||||
{
|
||||
return Create<DSectorTagIterator>(tag, line);
|
||||
return Create<DSectorTagIterator>(level.tagManager, tag, line);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DSectorTagIterator, Create, CreateSTI)
|
||||
|
@ -262,7 +262,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DSectorTagIterator, Create, CreateSTI)
|
|||
PARAM_PROLOGUE;
|
||||
PARAM_INT(tag);
|
||||
PARAM_POINTER(line, line_t);
|
||||
ACTION_RETURN_POINTER(Create<DSectorTagIterator>(tag, line));
|
||||
ACTION_RETURN_POINTER(CreateSTI(tag, line));
|
||||
}
|
||||
|
||||
int NextSTI(DSectorTagIterator *self)
|
||||
|
@ -299,8 +299,8 @@ class DLineIdIterator : public DObject, public FLineIdIterator
|
|||
{
|
||||
DECLARE_ABSTRACT_CLASS(DLineIdIterator, DObject);
|
||||
public:
|
||||
DLineIdIterator(int tag)
|
||||
: FLineIdIterator(tag)
|
||||
DLineIdIterator(FTagManager &tm, int tag)
|
||||
: FLineIdIterator(tm, tag)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -310,14 +310,14 @@ IMPLEMENT_CLASS(DLineIdIterator, true, false);
|
|||
|
||||
static DLineIdIterator *CreateLTI(int tag)
|
||||
{
|
||||
return Create<DLineIdIterator>(tag);
|
||||
return Create<DLineIdIterator>(level.tagManager, tag);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DLineIdIterator, Create, CreateLTI)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_INT(tag);
|
||||
ACTION_RETURN_POINTER(Create<DLineIdIterator>(tag));
|
||||
ACTION_RETURN_POINTER(CreateLTI(tag));
|
||||
}
|
||||
|
||||
int NextLTI(DLineIdIterator *self)
|
||||
|
|
Loading…
Reference in a new issue