mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- wrapped all accesses to the sector tag into accessor functions, as preparation for allowing multiple tags per sector.
This commit is contained in:
parent
d7092f40a3
commit
238046655c
16 changed files with 61 additions and 44 deletions
|
@ -551,7 +551,7 @@ void SetCompatibilityParams()
|
|||
{
|
||||
if ((unsigned)CompatParams[i + 1] < (unsigned)numsectors)
|
||||
{
|
||||
sectors[CompatParams[i + 1]].tag = CompatParams[i + 2];
|
||||
sectors[CompatParams[i + 1]].SetTag(CompatParams[i + 2]);
|
||||
}
|
||||
i += 3;
|
||||
break;
|
||||
|
|
|
@ -1158,7 +1158,7 @@ void FParser::SF_ObjSector(void)
|
|||
}
|
||||
|
||||
t_return.type = svt_int;
|
||||
t_return.value.i = mo ? mo->Sector->tag : 0; // nullptr check
|
||||
t_return.value.i = mo ? mo->Sector->GetTag() : 0; // nullptr check
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -4291,7 +4291,7 @@ void FParser::SF_KillInSector()
|
|||
|
||||
while ((mo=it.Next()))
|
||||
{
|
||||
if (mo->flags3&MF3_ISMONSTER && mo->Sector->tag==tag) P_DamageMobj(mo, NULL, NULL, 1000000, NAME_Massacre);
|
||||
if (mo->flags3&MF3_ISMONSTER && mo->Sector->HasTag(tag)) P_DamageMobj(mo, NULL, NULL, 1000000, NAME_Massacre);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4388,19 +4388,9 @@ void FParser::SF_ChangeTag()
|
|||
{
|
||||
for (int secnum = -1; (secnum = P_FindSectorFromTag (t_argv[0].value.i, secnum)) >= 0; )
|
||||
{
|
||||
sectors[secnum].tag=t_argv[1].value.i;
|
||||
}
|
||||
|
||||
// Recreate the hash tables
|
||||
int i;
|
||||
|
||||
for (i=numsectors; --i>=0; ) sectors[i].firsttag = -1;
|
||||
for (i=numsectors; --i>=0; )
|
||||
{
|
||||
int j = (unsigned) sectors[i].tag % (unsigned) numsectors;
|
||||
sectors[i].nexttag = sectors[j].firsttag;
|
||||
sectors[j].firsttag = i;
|
||||
sectors[secnum].SetTag(t_argv[1].value.i);
|
||||
}
|
||||
sector_t::HashTags();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -636,7 +636,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain)
|
|||
}
|
||||
else if ((sec->special & 0xFF) == Scroll_StrifeCurrent)
|
||||
{
|
||||
int anglespeed = sec->tag - 100;
|
||||
int anglespeed = sec->GetTag() - 100;
|
||||
fixed_t speed = (anglespeed % 10) << (FRACBITS - 4);
|
||||
angle_t finean = (anglespeed / 10) << (32-3);
|
||||
finean >>= ANGLETOFINESHIFT;
|
||||
|
|
|
@ -3211,7 +3211,7 @@ do_count:
|
|||
if (actor->health > 0 &&
|
||||
(kind == NULL || actor->IsA (kind)))
|
||||
{
|
||||
if (actor->Sector->tag == tag || tag == -1)
|
||||
if (actor->Sector->HasTag(tag) || tag == -1)
|
||||
{
|
||||
// Don't count items in somebody's inventory
|
||||
if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) ||
|
||||
|
@ -3231,7 +3231,7 @@ do_count:
|
|||
if (actor->health > 0 &&
|
||||
(kind == NULL || actor->IsA (kind)))
|
||||
{
|
||||
if (actor->Sector->tag == tag || tag == -1)
|
||||
if (actor->Sector->HasTag(tag) || tag == -1)
|
||||
{
|
||||
// Don't count items in somebody's inventory
|
||||
if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) ||
|
||||
|
|
|
@ -572,7 +572,7 @@ static int P_FindSectorFromTagLinear (int tag, int start)
|
|||
{
|
||||
for (int i=start+1;i<numsectors;i++)
|
||||
{
|
||||
if (sectors[i].tag == tag) return i;
|
||||
if (sectors[i].HasTag(tag)) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -846,7 +846,7 @@ void EV_StopLightEffect (int tag)
|
|||
|
||||
while ((effect = iterator.Next()) != NULL)
|
||||
{
|
||||
if (effect->GetSector()->tag == tag)
|
||||
if (effect->GetSector()->HasTag(tag))
|
||||
{
|
||||
effect->Destroy();
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ static void RemoveTaggedSectors(extsector_t::linked::plane &scrollplane, int tag
|
|||
{
|
||||
for(int i = scrollplane.Sectors.Size()-1; i>=0; i--)
|
||||
{
|
||||
if (scrollplane.Sectors[i].Sector->tag == tag)
|
||||
if (scrollplane.Sectors[i].Sector->HasTag(tag))
|
||||
{
|
||||
scrollplane.Sectors.Delete(i);
|
||||
}
|
||||
|
|
|
@ -1266,7 +1266,7 @@ FUNC(LS_Thing_Destroy)
|
|||
while (actor)
|
||||
{
|
||||
AActor *temp = iterator.Next ();
|
||||
if (actor->flags & MF_SHOOTABLE && actor->Sector->tag == arg2)
|
||||
if (actor->flags & MF_SHOOTABLE && actor->Sector->HasTag(arg2))
|
||||
P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None);
|
||||
actor = temp;
|
||||
}
|
||||
|
@ -1279,7 +1279,7 @@ FUNC(LS_Thing_Destroy)
|
|||
while (actor)
|
||||
{
|
||||
AActor *temp = iterator.Next ();
|
||||
if (actor->flags & MF_SHOOTABLE && (arg2 == 0 || actor->Sector->tag == arg2))
|
||||
if (actor->flags & MF_SHOOTABLE && (arg2 == 0 || actor->Sector->HasTag(arg2)))
|
||||
P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None);
|
||||
actor = temp;
|
||||
}
|
||||
|
@ -2167,7 +2167,7 @@ static void SetScroller (int tag, DScroller::EScrollType type, fixed_t dx, fixed
|
|||
{
|
||||
if (scroller->IsType (type))
|
||||
{
|
||||
if (sectors[scroller->GetAffectee ()].tag == tag)
|
||||
if (sectors[scroller->GetAffectee ()].HasTag(tag))
|
||||
{
|
||||
i++;
|
||||
scroller->SetRate (dx, dy);
|
||||
|
|
|
@ -3437,7 +3437,7 @@ void AActor::Tick ()
|
|||
}
|
||||
else if (scrolltype == Scroll_StrifeCurrent)
|
||||
{ // Strife scroll special
|
||||
int anglespeed = sec->tag - 100;
|
||||
int anglespeed = sec->GetTag() - 100;
|
||||
fixed_t carryspeed = DivScale32 (anglespeed % 10, 16*CARRYFACTOR);
|
||||
angle_t fineangle = (anglespeed / 10) << (32-3);
|
||||
fineangle >>= ANGLETOFINESHIFT;
|
||||
|
|
|
@ -825,6 +825,36 @@ sector_t *sector_t::GetHeightSec() const
|
|||
}
|
||||
|
||||
|
||||
bool sector_t::HasTag(int checktag) const
|
||||
{
|
||||
return tag == checktag;
|
||||
}
|
||||
|
||||
void sector_t::SetTag(int tagnum, bool discardall)
|
||||
{
|
||||
tag = tagnum;
|
||||
}
|
||||
|
||||
int sector_t::GetTag() const
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
void sector_t::HashTags()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=numsectors; --i>=0; ) // Initially make all slots empty.
|
||||
sectors[i].firsttag = -1;
|
||||
for (i=numsectors; --i>=0; ) // Proceed from last to first sector
|
||||
{ // so that lower sectors appear first
|
||||
int j = (unsigned) sectors[i].tag % (unsigned) numsectors; // Hash func
|
||||
sectors[i].nexttag = sectors[j].firsttag; // Prepend sector to chain
|
||||
sectors[j].firsttag = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) const
|
||||
{
|
||||
bool copy = false;
|
||||
|
|
|
@ -1514,7 +1514,7 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
|
|||
else // [RH] Translate to new sector special
|
||||
ss->special = P_TranslateSectorSpecial (LittleShort(ms->special));
|
||||
ss->secretsector = !!(ss->special&SECRET_MASK);
|
||||
ss->tag = LittleShort(ms->tag);
|
||||
ss->SetTag(LittleShort(ms->tag));
|
||||
ss->thinglist = NULL;
|
||||
ss->touching_thinglist = NULL; // phares 3/14/98
|
||||
ss->seqType = defSeqType;
|
||||
|
@ -2495,7 +2495,7 @@ void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmaps
|
|||
|
||||
for (s = 0; s < numsectors; s++)
|
||||
{
|
||||
if (sectors[s].tag == tag)
|
||||
if (sectors[s].HasTag(tag))
|
||||
{
|
||||
if (!colorgood) color = sectors[s].ColorMap->Color;
|
||||
if (!foggood) fog = sectors[s].ColorMap->Fade;
|
||||
|
@ -3131,9 +3131,9 @@ static void P_GroupLines (bool buildmap)
|
|||
{
|
||||
if (sector->linecount == 0)
|
||||
{
|
||||
Printf ("Sector %i (tag %i) has no lines\n", i, sector->tag);
|
||||
Printf ("Sector %i (tag %i) has no lines\n", i, sector->GetTag());
|
||||
// 0 the sector's tag so that no specials can use it
|
||||
sector->tag = 0;
|
||||
sector->SetTag(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3309,18 +3309,10 @@ void P_LoadBehavior (MapData * map)
|
|||
// Hash the sector tags across the sectors and linedefs.
|
||||
static void P_InitTagLists ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=numsectors; --i>=0; ) // Initially make all slots empty.
|
||||
sectors[i].firsttag = -1;
|
||||
for (i=numsectors; --i>=0; ) // Proceed from last to first sector
|
||||
{ // so that lower sectors appear first
|
||||
int j = (unsigned) sectors[i].tag % (unsigned) numsectors; // Hash func
|
||||
sectors[i].nexttag = sectors[j].firsttag; // Prepend sector to chain
|
||||
sectors[j].firsttag = i;
|
||||
}
|
||||
sector_t::HashTags();
|
||||
|
||||
// killough 4/17/98: same thing, only for linedefs
|
||||
int i;
|
||||
|
||||
for (i=numlines; --i>=0; ) // Initially make all slots empty.
|
||||
lines[i].firstid = -1;
|
||||
|
|
|
@ -250,7 +250,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
|
|||
int count = 0;
|
||||
while ( (searcher = iterator.Next ()) )
|
||||
{
|
||||
if (tag == 0 || searcher->Sector->tag == tag)
|
||||
if (tag == 0 || searcher->Sector->HasTag(tag))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
|
|||
while (count > 0)
|
||||
{
|
||||
searcher = iterator.Next ();
|
||||
if (tag == 0 || searcher->Sector->tag == tag)
|
||||
if (tag == 0 || searcher->Sector->HasTag(tag))
|
||||
{
|
||||
count--;
|
||||
}
|
||||
|
|
|
@ -1316,7 +1316,7 @@ public:
|
|||
continue;
|
||||
|
||||
case NAME_Id:
|
||||
sec->tag = (short)CheckInt(key);
|
||||
sec->SetTag((short)CheckInt(key), false);
|
||||
continue;
|
||||
|
||||
default:
|
||||
|
|
|
@ -262,7 +262,7 @@ static int WriteSECTORS (FILE *file)
|
|||
uppercopy (ms.ceilingpic, GetTextureName (sectors[i].GetTexture(sector_t::ceiling)));
|
||||
ms.lightlevel = LittleShort((short)sectors[i].lightlevel);
|
||||
ms.special = LittleShort(sectors[i].special);
|
||||
ms.tag = LittleShort(sectors[i].tag);
|
||||
ms.tag = LittleShort(sectors[i].GetTag());
|
||||
fwrite (&ms, sizeof(ms), 1, file);
|
||||
}
|
||||
return numsectors * sizeof(ms);
|
||||
|
|
|
@ -304,7 +304,7 @@ void P_TranslateTeleportThings ()
|
|||
|
||||
while ( (dest = iterator.Next()) )
|
||||
{
|
||||
if (dest->Sector->tag == 0)
|
||||
if (dest->Sector->GetTag() == 0)
|
||||
{
|
||||
dest->tid = 1;
|
||||
dest->AddToHash ();
|
||||
|
|
|
@ -633,6 +633,11 @@ struct sector_t
|
|||
return pos == floor? floorplane:ceilingplane;
|
||||
}
|
||||
|
||||
bool HasTag(int checktag) const;
|
||||
void SetTag(int tagnum, bool discardall = true);
|
||||
int GetTag() const;
|
||||
static void HashTags();
|
||||
|
||||
bool PlaneMoving(int pos);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue