- wrapped all line ID accesss just like sector tags

This commit is contained in:
Christoph Oelckers 2015-04-15 09:37:06 +02:00
parent 47543bb766
commit 902593198b
10 changed files with 99 additions and 40 deletions

View file

@ -4382,16 +4382,17 @@ void FParser::SF_SetLineTrigger()
FLineIdIterator itr(id);
while ((i = itr.Next()) >= 0)
{
if (t_argc==2) tag=lines[i].id;
if (t_argc == 2) tag = lines[i].GetMainId();
maplinedef_t mld;
mld.special=spec;
mld.tag=tag;
mld.flags=0;
mld.special = spec;
mld.tag = tag;
mld.flags = 0;
int f = lines[i].flags;
P_TranslateLineDef(&lines[i], &mld);
lines[i].id=tag;
lines[i].flags = (lines[i].flags & (ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_SPAC_MASK|ML_FIRSTSIDEONLY)) |
(f & ~(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_SPAC_MASK|ML_FIRSTSIDEONLY));
P_TranslateLineDef(&lines[i], &mld);
lines[i].ClearIds();
lines[i].SetMainId(tag);
lines[i].flags = (lines[i].flags & (ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)) |
(f & ~(ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY));
}
}

View file

@ -844,7 +844,7 @@ void P_Spawn3DFloors (void)
{
if (line->args[1]&8)
{
line->id = line->args[4];
line->SetMainId(line->args[4]);
}
else
{

View file

@ -167,7 +167,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
{
line_t *ln = sectors[sec].lines[line];
if (lineid != 0 && ln->id != lineid) continue;
if (lineid != 0 && !ln->HasId(lineid)) continue;
if (ln->frontsector == NULL || ln->backsector == NULL || !(ln->flags & ML_3DMIDTEX))
{

View file

@ -2063,7 +2063,7 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int
{
int wallnum = scroller->GetWallNum ();
if (wallnum >= 0 && sides[wallnum].linedef->id == id &&
if (wallnum >= 0 && sides[wallnum].linedef->HasId(id) &&
int(sides[wallnum].linedef->sidedef[sidechoice] - sides) == wallnum &&
Where == scroller->GetScrollParts())
{
@ -2082,7 +2082,7 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int
while ( (collect.Obj = iterator.Next ()) )
{
if ((collect.RefNum = ((DScroller *)collect.Obj)->GetWallNum ()) != -1 &&
sides[collect.RefNum].linedef->id == id &&
sides[collect.RefNum].linedef->HasId(id) &&
int(sides[collect.RefNum].linedef->sidedef[sidechoice] - sides) == collect.RefNum &&
Where == ((DScroller *)collect.Obj)->GetScrollParts())
{

View file

@ -859,6 +859,42 @@ void sector_t::HashTags()
}
}
void line_t::SetMainId(int newid)
{
id = newid;
}
int line_t::GetMainId() const
{
return id;
}
void line_t::ClearIds()
{
id = -1;
}
bool line_t::HasId(int checkid) const
{
return id == checkid;
}
void line_t::HashIds()
{
// 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;
for (i=numlines; --i>=0; ) // Proceed from last to first linedef
{ // so that lower linedefs appear first
int j = (unsigned) lines[i].id % (unsigned) numlines; // Hash func
lines[i].nextid = lines[j].firstid; // Prepend linedef to chain
lines[j].firstid = i;
}
}
bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) const
{

View file

@ -1920,40 +1920,40 @@ void P_SetLineID (line_t *ld)
case Line_SetIdentification:
if (!(level.flags2 & LEVEL2_HEXENHACK))
{
ld->id = ld->args[0] + 256 * ld->args[4];
ld->SetMainId(ld->args[0] + 256 * ld->args[4]);
ld->flags |= ld->args[1]<<16;
}
else
{
ld->id = ld->args[0];
ld->SetMainId(ld->args[0]);
}
ld->special = 0;
break;
case TranslucentLine:
ld->id = ld->args[0];
ld->SetMainId(ld->args[0]);
ld->flags |= ld->args[3]<<16;
break;
case Teleport_Line:
case Scroll_Texture_Model:
ld->id = ld->args[0];
ld->SetMainId(ld->args[0]);
break;
case Polyobj_StartLine:
ld->id = ld->args[3];
ld->SetMainId(ld->args[3]);
break;
case Polyobj_ExplicitLine:
ld->id = ld->args[4];
ld->SetMainId(ld->args[4]);
break;
case Plane_Align:
ld->id = ld->args[2];
ld->SetMainId(ld->args[2]);
break;
case Static_Init:
if (ld->args[1] == Init_SectorLink) ld->id = ld->args[0];
if (ld->args[1] == Init_SectorLink) ld->SetMainId(ld->args[0]);
break;
}
}
@ -2038,7 +2038,7 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
{
for (j = 0; j < numlines; j++)
{
if (lines[j].id == ld->args[0])
if (lines[j].HasId(ld->args[0]))
{
lines[j].Alpha = alpha;
if (additive)
@ -2233,7 +2233,7 @@ void P_LoadLineDefs2 (MapData * map)
ld->v1 = &vertexes[LittleShort(mld->v1)];
ld->v2 = &vertexes[LittleShort(mld->v2)];
ld->Alpha = FRACUNIT; // [RH] Opaque by default
ld->id = -1;
ld->ClearIds();
P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0]));
P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1]));
@ -3310,18 +3310,7 @@ void P_LoadBehavior (MapData * map)
static void P_InitTagLists ()
{
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;
for (i=numlines; --i>=0; ) // Proceed from last to first linedef
{ // so that lower linedefs appear first
int j = (unsigned) lines[i].id % (unsigned) numlines; // Hash func
lines[i].nextid = lines[j].firstid; // Prepend linedef to chain
lines[j].firstid = i;
}
line_t::HashIds();
}
void P_GetPolySpots (MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors)

View file

@ -279,11 +279,11 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType)
}
// some old WADs use this method to create walls that change the texture when shot.
else if (activationType == SPAC_Impact && // only for shootable triggers
(level.flags2 & LEVEL2_DUMMYSWITCHES) && // this is only a compatibility setting for an old hack!
(level.flags2 & LEVEL2_DUMMYSWITCHES) && // this is only a compatibility setting for an old hack!
!repeat && // only non-repeatable triggers
(special<Generic_Floor || special>Generic_Crusher) && // not for Boom's generalized linedefs
special && // not for lines without a special
line->args[0] == line->id && // Safety check: exclude edited UDMF linedefs or ones that don't map the tag to args[0]
line->HasId(line->args[0]) && // Safety check: exclude edited UDMF linedefs or ones that don't map the tag to args[0]
line->args[0] && // only if there's a tag (which is stored in the first arg)
P_FindFirstSectorFromTag (line->args[0]) == -1) // only if no sector is tagged to this linedef
{

View file

@ -780,7 +780,7 @@ public:
memset(ld, 0, sizeof(*ld));
ld->Alpha = FRACUNIT;
ld->id = -1;
ld->ClearIds();
ld->sidedef[0] = ld->sidedef[1] = NULL;
if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX;
if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX;
@ -813,7 +813,7 @@ public:
continue;
case NAME_Id:
ld->id = CheckInt(key);
ld->SetMainId(CheckInt(key));
continue;
case NAME_Sidefront:
@ -1040,6 +1040,19 @@ public:
break;
}
#if 0 // for later
if (if (namespace_bits & (Zd)) && !strnicmp(key.GetChars(), "Id", 2))
{
char *endp;
int num = strtol(key.GetChars(), &endp, 10);
if (num > 0 && *endp == NULL)
{
// only allow ID## with ## as a proper number
ld->SetId((short)CheckInt(key), false);
}
}
#endif
if (!strnicmp("user_", key.GetChars(), 5))
{
AddUserKey(key, UDMF_Line, index);
@ -1053,7 +1066,7 @@ public:
maplinedef_t mld;
memset(&mld, 0, sizeof(mld));
mld.special = ld->special;
mld.tag = ld->id;
mld.tag = ld->GetMainId();
P_TranslateLineDef(ld, &mld);
ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY));
}
@ -1497,6 +1510,18 @@ public:
default:
break;
}
#if 0 // for later
if (namespace_bits & (Zd)) && !strnicmp(key.GetChars(), "Id", 2))
{
char *endp;
int num = strtol(key.GetChars(), &endp, 10);
if (num > 0 && *endp == NULL)
{
// only allow ID## with ## as a proper number
sec->SetTag((short)CheckInt(key), false);
}
}
#endif
if (!strnicmp("user_", key.GetChars(), 5))
{

View file

@ -104,7 +104,8 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
// line also needs to have its ID set to the same as its tag.
// An external conversion program would need to do this more
// intelligently.
ld->id = tag;
ld->ClearIds();
ld->SetMainId(tag);
// 0 specials are never translated.
if (special == 0)

View file

@ -905,6 +905,13 @@ struct line_t
sector_t *frontsector, *backsector;
int validcount; // if == validcount, already checked
int locknumber; // [Dusk] lock number for special
void SetMainId(int newid);
int GetMainId() const;
void ClearIds();
bool HasId(int id) const;
static void HashIds();
};
// phares 3/14/98