This commit is contained in:
Christoph Oelckers 2015-04-16 18:08:23 +02:00
commit 45f893f8fc
36 changed files with 809 additions and 668 deletions

View file

@ -551,7 +551,8 @@ void SetCompatibilityParams()
{ {
if ((unsigned)CompatParams[i + 1] < (unsigned)numsectors) if ((unsigned)CompatParams[i + 1] < (unsigned)numsectors)
{ {
sectors[CompatParams[i + 1]].tag = CompatParams[i + 2]; sectors[CompatParams[i + 1]].ClearTags();
sectors[CompatParams[i + 1]].SetMainTag(CompatParams[i + 2]);
} }
i += 3; i += 3;
break; break;

View file

@ -67,6 +67,7 @@
#include "v_font.h" #include "v_font.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "farchive.h" #include "farchive.h"
#include "p_setup.h"
static FRandom pr_script("FScript"); static FRandom pr_script("FScript");
@ -312,18 +313,24 @@ static int T_GetPlayerNum(const svalue_t &arg)
// sectors directly by passing a negative value // sectors directly by passing a negative value
// //
//========================================================================== //==========================================================================
int T_FindSectorFromTag(int tagnum,int startsector) class FSSectorTagIterator : public FSectorTagIterator
{ {
if (tagnum<=0) public:
FSSectorTagIterator(int tag)
: FSectorTagIterator(tag)
{ {
if (startsector<0) if (tag < 0)
{ {
if (tagnum==-32768) return 0; searchtag = INT_MIN;
if (-tagnum<numsectors) return -tagnum; start = tag == -32768? 0 : -tag < numsectors? -tag : -1;
} }
return -1;
} }
return P_FindSectorFromTag(tagnum,startsector); };
inline int T_FindFirstSectorFromTag(int tagnum)
{
FSSectorTagIterator it(tagnum);
return it.Next();
} }
@ -1158,7 +1165,7 @@ void FParser::SF_ObjSector(void)
} }
t_return.type = svt_int; t_return.type = svt_int;
t_return.value.i = mo ? mo->Sector->tag : 0; // nullptr check t_return.value.i = mo ? mo->Sector->GetMainTag() : 0; // nullptr check
} }
//========================================================================== //==========================================================================
@ -1536,7 +1543,8 @@ void FParser::SF_StartSectorSound(void)
tagnum = intvalue(t_argv[0]); tagnum = intvalue(t_argv[0]);
int i=-1; int i=-1;
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
sector = &sectors[i]; sector = &sectors[i];
S_Sound(sector, CHAN_BODY, T_FindSound(stringvalue(t_argv[1])), 1.0f, ATTN_NORM); S_Sound(sector, CHAN_BODY, T_FindSound(stringvalue(t_argv[1])), 1.0f, ATTN_NORM);
@ -1595,7 +1603,8 @@ void FParser::SF_FloorHeight(void)
// set all sectors with tag // set all sectors with tag
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
if (sectors[i].floordata) continue; // don't move floors that are active! if (sectors[i].floordata) continue; // don't move floors that are active!
@ -1612,7 +1621,7 @@ void FParser::SF_FloorHeight(void)
} }
else else
{ {
secnum = T_FindSectorFromTag(tagnum, -1); secnum = T_FindFirstSectorFromTag(tagnum);
if(secnum < 0) if(secnum < 0)
{ {
script_error("sector not found with tagnum %i\n", tagnum); script_error("sector not found with tagnum %i\n", tagnum);
@ -1671,7 +1680,8 @@ void FParser::SF_MoveFloor(void)
// move all sectors with tag // move all sectors with tag
while ((secnum = T_FindSectorFromTag(tagnum, secnum)) >= 0) FSSectorTagIterator itr(tagnum);
while ((secnum = itr.Next()) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
// Don't start a second thinker on the same floor // Don't start a second thinker on the same floor
@ -1733,7 +1743,8 @@ void FParser::SF_CeilingHeight(void)
dest = fixedvalue(t_argv[1]); dest = fixedvalue(t_argv[1]);
// set all sectors with tag // set all sectors with tag
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
if (sectors[i].ceilingdata) continue; // don't move ceilings that are active! if (sectors[i].ceilingdata) continue; // don't move ceilings that are active!
@ -1750,7 +1761,7 @@ void FParser::SF_CeilingHeight(void)
} }
else else
{ {
secnum = T_FindSectorFromTag(tagnum, -1); secnum = T_FindFirstSectorFromTag(tagnum);
if(secnum < 0) if(secnum < 0)
{ {
script_error("sector not found with tagnum %i\n", tagnum); script_error("sector not found with tagnum %i\n", tagnum);
@ -1823,7 +1834,8 @@ void FParser::SF_MoveCeiling(void)
silent=t_argc>4 ? intvalue(t_argv[4]):1; silent=t_argc>4 ? intvalue(t_argv[4]):1;
// move all sectors with tag // move all sectors with tag
while ((secnum = T_FindSectorFromTag(tagnum, secnum)) >= 0) FSSectorTagIterator itr(tagnum);
while ((secnum = itr.Next()) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
@ -1851,7 +1863,7 @@ void FParser::SF_LightLevel(void)
tagnum = intvalue(t_argv[0]); tagnum = intvalue(t_argv[0]);
// argv is sector tag // argv is sector tag
secnum = T_FindSectorFromTag(tagnum, -1); secnum = T_FindFirstSectorFromTag(tagnum);
if(secnum < 0) if(secnum < 0)
{ {
@ -1865,7 +1877,8 @@ void FParser::SF_LightLevel(void)
int i = -1; int i = -1;
// set all sectors with tag // set all sectors with tag
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
sectors[i].SetLightLevel(intvalue(t_argv[1])); sectors[i].SetLightLevel(intvalue(t_argv[1]));
} }
@ -1984,7 +1997,8 @@ void FParser::SF_FadeLight(void)
destlevel = intvalue(t_argv[1]); destlevel = intvalue(t_argv[1]);
speed = t_argc>2 ? intvalue(t_argv[2]) : 1; speed = t_argc>2 ? intvalue(t_argv[2]) : 1;
for (i = -1; (i = P_FindSectorFromTag(sectag,i)) >= 0;) FSectorTagIterator it(sectag);
while ((i = it.Next()) >= 0)
{ {
if (!sectors[i].lightingdata) new DLightLevel(&sectors[i],destlevel,speed); if (!sectors[i].lightingdata) new DLightLevel(&sectors[i],destlevel,speed);
} }
@ -2006,7 +2020,7 @@ void FParser::SF_FloorTexture(void)
tagnum = intvalue(t_argv[0]); tagnum = intvalue(t_argv[0]);
// argv is sector tag // argv is sector tag
secnum = T_FindSectorFromTag(tagnum, -1); secnum = T_FindFirstSectorFromTag(tagnum);
if(secnum < 0) if(secnum < 0)
{ script_error("sector not found with tagnum %i\n", tagnum); return;} { script_error("sector not found with tagnum %i\n", tagnum); return;}
@ -2019,7 +2033,8 @@ void FParser::SF_FloorTexture(void)
FTextureID picnum = TexMan.GetTexture(t_argv[1].string, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); FTextureID picnum = TexMan.GetTexture(t_argv[1].string, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
// set all sectors with tag // set all sectors with tag
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
sectors[i].SetTexture(sector_t::floor, picnum); sectors[i].SetTexture(sector_t::floor, picnum);
} }
@ -2057,7 +2072,7 @@ void FParser::SF_SectorColormap(void)
tagnum = intvalue(t_argv[0]); tagnum = intvalue(t_argv[0]);
// argv is sector tag // argv is sector tag
secnum = T_FindSectorFromTag(tagnum, -1); secnum = T_FindFirstSectorFromTag(tagnum);
if(secnum < 0) if(secnum < 0)
{ script_error("sector not found with tagnum %i\n", tagnum); return;} { script_error("sector not found with tagnum %i\n", tagnum); return;}
@ -2068,7 +2083,8 @@ void FParser::SF_SectorColormap(void)
{ {
DWORD cm = R_ColormapNumForName(t_argv[1].value.s); DWORD cm = R_ColormapNumForName(t_argv[1].value.s);
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
sectors[i].midmap=cm; sectors[i].midmap=cm;
sectors[i].heightsec=&sectors[i]; sectors[i].heightsec=&sectors[i];
@ -2094,7 +2110,7 @@ void FParser::SF_CeilingTexture(void)
tagnum = intvalue(t_argv[0]); tagnum = intvalue(t_argv[0]);
// argv is sector tag // argv is sector tag
secnum = T_FindSectorFromTag(tagnum, -1); secnum = T_FindFirstSectorFromTag(tagnum);
if(secnum < 0) if(secnum < 0)
{ script_error("sector not found with tagnum %i\n", tagnum); return;} { script_error("sector not found with tagnum %i\n", tagnum); return;}
@ -2107,7 +2123,8 @@ void FParser::SF_CeilingTexture(void)
FTextureID picnum = TexMan.GetTexture(t_argv[1].string, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); FTextureID picnum = TexMan.GetTexture(t_argv[1].string, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
// set all sectors with tag // set all sectors with tag
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
sectors[i].SetTexture(sector_t::ceiling, picnum); sectors[i].SetTexture(sector_t::ceiling, picnum);
} }
@ -2210,9 +2227,6 @@ void FParser::SF_RunCommand(void)
// //
//========================================================================== //==========================================================================
// any linedef type
extern void P_TranslateLineDef (line_t *ld, maplinedef_t *mld);
void FParser::SF_LineTrigger() void FParser::SF_LineTrigger()
{ {
if (CheckArgs(1)) if (CheckArgs(1))
@ -2221,7 +2235,7 @@ void FParser::SF_LineTrigger()
maplinedef_t mld; maplinedef_t mld;
mld.special=intvalue(t_argv[0]); mld.special=intvalue(t_argv[0]);
mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0; mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0;
P_TranslateLineDef(&line, &mld); P_TranslateLineDef(&line, &mld, false);
P_ExecuteSpecial(line.special, NULL, Script->trigger, false, P_ExecuteSpecial(line.special, NULL, Script->trigger, false,
line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]); line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]);
} }
@ -2281,7 +2295,9 @@ void FParser::SF_SetLineBlocking(void)
{ {
blocking=blocks[blocking]; blocking=blocks[blocking];
int tag=intvalue(t_argv[0]); int tag=intvalue(t_argv[0]);
for (int i = -1; (i = P_FindLineFromID(tag, i)) >= 0;) FLineIdIterator itr(tag);
int i;
while ((i = itr.Next()) >= 0)
{ {
lines[i].flags = (lines[i].flags & ~(ML_BLOCKING | ML_BLOCKEVERYTHING)) | blocking; lines[i].flags = (lines[i].flags & ~(ML_BLOCKING | ML_BLOCKEVERYTHING)) | blocking;
} }
@ -2302,7 +2318,9 @@ void FParser::SF_SetLineMonsterBlocking(void)
int blocking = intvalue(t_argv[1]) ? ML_BLOCKMONSTERS : 0; int blocking = intvalue(t_argv[1]) ? ML_BLOCKMONSTERS : 0;
int tag=intvalue(t_argv[0]); int tag=intvalue(t_argv[0]);
for (int i = -1; (i = P_FindLineFromID(tag, i)) >= 0;) FLineIdIterator itr(tag);
int i;
while ((i = itr.Next()) >= 0)
{ {
lines[i].flags = (lines[i].flags & ~ML_BLOCKMONSTERS) | blocking; lines[i].flags = (lines[i].flags & ~ML_BLOCKMONSTERS) | blocking;
} }
@ -2357,7 +2375,8 @@ void FParser::SF_SetLineTexture(void)
texture = stringvalue(t_argv[3]); texture = stringvalue(t_argv[3]);
texturenum = TexMan.GetTexture(texture, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable); texturenum = TexMan.GetTexture(texture, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable);
for (i = -1; (i = P_FindLineFromID(tag, i)) >= 0;) FLineIdIterator itr(tag);
while ((i = itr.Next()) >= 0)
{ {
// bad sidedef, Hexen just SEGV'd here! // bad sidedef, Hexen just SEGV'd here!
if (lines[i].sidedef[side] != NULL) if (lines[i].sidedef[side] != NULL)
@ -2376,7 +2395,8 @@ void FParser::SF_SetLineTexture(void)
int sections = intvalue(t_argv[3]); int sections = intvalue(t_argv[3]);
// set all sectors with tag // set all sectors with tag
for (i = -1; (i = P_FindLineFromID(tag, i)) >= 0;) FLineIdIterator itr(tag);
while ((i = itr.Next()) >= 0)
{ {
side_t *sided = lines[i].sidedef[side]; side_t *sided = lines[i].sidedef[side];
if(sided != NULL) if(sided != NULL)
@ -4201,7 +4221,7 @@ void FParser::SF_SetColor(void)
{ {
tagnum = intvalue(t_argv[0]); tagnum = intvalue(t_argv[0]);
secnum = T_FindSectorFromTag(tagnum, -1); secnum = T_FindFirstSectorFromTag(tagnum);
if(secnum < 0) if(secnum < 0)
{ {
@ -4222,7 +4242,8 @@ void FParser::SF_SetColor(void)
else return; else return;
// set all sectors with tag // set all sectors with tag
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
sectors[i].ColorMap = GetSpecialLights (color, sectors[i].ColorMap->Fade, 0); sectors[i].ColorMap = GetSpecialLights (color, sectors[i].ColorMap->Fade, 0);
} }
@ -4291,7 +4312,7 @@ void FParser::SF_KillInSector()
while ((mo=it.Next())) 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);
} }
} }
} }
@ -4314,7 +4335,7 @@ void FParser::SF_SectorType(void)
tagnum = intvalue(t_argv[0]); tagnum = intvalue(t_argv[0]);
// argv is sector tag // argv is sector tag
secnum = T_FindSectorFromTag(tagnum, -1); secnum = T_FindFirstSectorFromTag(tagnum);
if(secnum < 0) if(secnum < 0)
{ script_error("sector not found with tagnum %i\n", tagnum); return;} { script_error("sector not found with tagnum %i\n", tagnum); return;}
@ -4327,7 +4348,8 @@ void FParser::SF_SectorType(void)
int spec = intvalue(t_argv[1]); int spec = intvalue(t_argv[1]);
// set all sectors with tag // set all sectors with tag
while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) FSSectorTagIterator itr(tagnum);
while ((i = itr.Next()) >= 0)
{ {
sectors[i].special = spec; sectors[i].special = spec;
} }
@ -4355,16 +4377,15 @@ void FParser::SF_SetLineTrigger()
id=intvalue(t_argv[0]); id=intvalue(t_argv[0]);
spec=intvalue(t_argv[1]); spec=intvalue(t_argv[1]);
if (t_argc>2) tag=intvalue(t_argv[2]); if (t_argc>2) tag=intvalue(t_argv[2]);
for (i = -1; (i = P_FindLineFromID (id, i)) >= 0; ) FLineIdIterator itr(id);
while ((i = itr.Next()) >= 0)
{ {
if (t_argc==2) tag=lines[i].id;
maplinedef_t mld; maplinedef_t mld;
mld.special = spec; mld.special = spec;
mld.tag = tag; mld.tag = tag;
mld.flags = 0; mld.flags = 0;
int f = lines[i].flags; int f = lines[i].flags;
P_TranslateLineDef(&lines[i], &mld); P_TranslateLineDef(&lines[i], &mld, false);
lines[i].id=tag;
lines[i].flags = (lines[i].flags & (ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)) | 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)); (f & ~(ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY));
@ -4375,33 +4396,13 @@ void FParser::SF_SetLineTrigger()
//========================================================================== //==========================================================================
// //
// new for GZDoom: Changes a sector's tag //
// (I only need this because MAP02 in RTC-3057 has some issues with the GL
// renderer that I can't fix without the scripts. But loading a FS on top on
// ACS still works so I can hack around it with this.)
// //
//========================================================================== //==========================================================================
void FParser::SF_ChangeTag() void FParser::SF_ChangeTag()
{ {
if (CheckArgs(2)) // Development garbage!
{
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;
}
}
} }

View file

@ -452,9 +452,9 @@ bool DFraggleThinker::wait_finished(DRunningScript *script)
case wt_tagwait: case wt_tagwait:
{ {
int secnum = -1; int secnum;
FSectorTagIterator itr(script->wait_data);
while ((secnum = P_FindSectorFromTag(script->wait_data, secnum)) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sector_t *sec = &sectors[secnum]; sector_t *sec = &sectors[secnum];
if(sec->floordata || sec->ceilingdata || sec->lightingdata) if(sec->floordata || sec->ceilingdata || sec->lightingdata)

View file

@ -1757,6 +1757,7 @@ IMPLEMENT_CLASS(APowerRegeneration)
void APowerRegeneration::DoEffect() void APowerRegeneration::DoEffect()
{ {
Super::DoEffect();
if (Owner != NULL && Owner->health > 0 && (level.time & 31) == 0) if (Owner != NULL && Owner->health > 0 && (level.time & 31) == 0)
{ {
if (P_GiveBody(Owner, Strength/FRACUNIT)) if (P_GiveBody(Owner, Strength/FRACUNIT))

View file

@ -119,7 +119,9 @@ void ASkyCamCompat::BeginPlay ()
// Finally, skyboxify all tagged sectors // Finally, skyboxify all tagged sectors
// This involves changing their texture to the sky flat, because while // This involves changing their texture to the sky flat, because while
// EE works with any texture for its skybox portals, ZDoom doesn't. // EE works with any texture for its skybox portals, ZDoom doesn't.
for (int secnum =-1; (secnum = P_FindSectorFromTag (skybox_id, secnum)) != -1; ) FSectorTagIterator it(skybox_id);
int secnum;
while ((secnum = it.Next()) >= 0)
{ {
// plane: 0=floor, 1=ceiling, 2=both // plane: 0=floor, 1=ceiling, 2=both
if (refline->args[2] == 1 || refline->args[2] == 2) if (refline->args[2] == 1 || refline->args[2] == 2)

View file

@ -636,7 +636,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain)
} }
else if ((sec->special & 0xFF) == Scroll_StrifeCurrent) else if ((sec->special & 0xFF) == Scroll_StrifeCurrent)
{ {
int anglespeed = sec->tag - 100; int anglespeed = sec->GetMainTag() - 100;
fixed_t speed = (anglespeed % 10) << (FRACBITS - 4); fixed_t speed = (anglespeed % 10) << (FRACBITS - 4);
angle_t finean = (anglespeed / 10) << (32-3); angle_t finean = (anglespeed / 10) << (32-3);
finean >>= ANGLETOFINESHIFT; finean >>= ANGLETOFINESHIFT;

View file

@ -429,7 +429,7 @@ void FGameConfigFile::DoKeySetup(const char *gamename)
{ "Bindings", &Bindings }, { "Bindings", &Bindings },
{ "DoubleBindings", &DoubleBindings }, { "DoubleBindings", &DoubleBindings },
{ "AutomapBindings", &AutomapBindings }, { "AutomapBindings", &AutomapBindings },
NULL, NULL { NULL, NULL }
}; };
const char *key, *value; const char *key, *value;

View file

@ -490,7 +490,7 @@ void P_Recalculate3DFloors(sector_t * sector)
// by the clipping code below. // by the clipping code below.
ffloors.Push(pick); ffloors.Push(pick);
} }
else if ((pick->flags&(FF_SWIMMABLE|FF_TRANSLUCENT) || (!(pick->flags&(FF_ALLSIDES|FF_BOTHPLANES)))) && pick->flags&FF_EXISTS) else if ((pick->flags&(FF_SWIMMABLE|FF_TRANSLUCENT) || (!(pick->flags&FF_RENDERALL))) && pick->flags&FF_EXISTS)
{ {
// We must check if this nonsolid segment gets clipped from the top by another 3D floor // We must check if this nonsolid segment gets clipped from the top by another 3D floor
if (solid != NULL && solid_bottom < height) if (solid != NULL && solid_bottom < height)

View file

@ -143,7 +143,9 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
if (tag == 0) if (tag == 0)
{ {
for(int line = -1; (line = P_FindLineFromID(lineid,line)) >= 0; ) FLineIdIterator itr(lineid);
int line;
while ((line = itr.Next()) >= 0)
{ {
line_t *ln = &lines[line]; line_t *ln = &lines[line];
@ -157,13 +159,15 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
} }
else else
{ {
for(int sec = -1; (sec = P_FindSectorFromTag(tag, sec)) >= 0; ) FSectorTagIterator it(tag);
int sec;
while ((sec = it.Next()) >= 0)
{ {
for (int line = 0; line < sectors[sec].linecount; line ++) for (int line = 0; line < sectors[sec].linecount; line ++)
{ {
line_t *ln = sectors[sec].lines[line]; 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)) if (ln->frontsector == NULL || ln->backsector == NULL || !(ln->flags & ML_3DMIDTEX))
{ {

View file

@ -1341,7 +1341,7 @@ DPlaneWatcher::DPlaneWatcher (AActor *it, line_t *line, int lineSide, bool ceili
{ {
int secnum; int secnum;
secnum = P_FindSectorFromTag (tag, -1); secnum = P_FindFirstSectorFromTag (tag);
if (secnum >= 0) if (secnum >= 0)
{ {
secplane_t plane; secplane_t plane;
@ -3211,7 +3211,7 @@ do_count:
if (actor->health > 0 && if (actor->health > 0 &&
(kind == NULL || actor->IsA (kind))) (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 // Don't count items in somebody's inventory
if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) || if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) ||
@ -3231,7 +3231,7 @@ do_count:
if (actor->health > 0 && if (actor->health > 0 &&
(kind == NULL || actor->IsA (kind))) (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 // Don't count items in somebody's inventory
if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) || if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) ||
@ -3268,7 +3268,8 @@ void DLevelScript::ChangeFlat (int tag, int name, bool floorOrCeiling)
flat = TexMan.GetTexture (flatname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); flat = TexMan.GetTexture (flatname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable);
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) FSectorTagIterator it(tag);
while ((secnum = it.Next()) >= 0)
{ {
int pos = floorOrCeiling? sector_t::ceiling : sector_t::floor; int pos = floorOrCeiling? sector_t::ceiling : sector_t::floor;
sectors[secnum].SetTexture(pos, flat); sectors[secnum].SetTexture(pos, flat);
@ -3299,7 +3300,8 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name)
texture = TexMan.GetTexture (texname, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable); texture = TexMan.GetTexture (texname, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable);
while ((linenum = P_FindLineFromID (lineid, linenum)) >= 0) FLineIdIterator itr(lineid);
while ((linenum = itr.Next()) >= 0)
{ {
side_t *sidedef; side_t *sidedef;
@ -4457,7 +4459,7 @@ int DLevelScript::SideFromID(int id, int side)
} }
else else
{ {
int line = P_FindLineFromID(id, -1); int line = P_FindFirstLineFromID(id);
if (line == -1) return -1; if (line == -1) return -1;
if (lines[line].sidedef[side] == NULL) return -1; if (lines[line].sidedef[side] == NULL) return -1;
return lines[line].sidedef[side]->Index; return lines[line].sidedef[side]->Index;
@ -4473,7 +4475,7 @@ int DLevelScript::LineFromID(int id)
} }
else else
{ {
return P_FindLineFromID(id, -1); return P_FindFirstLineFromID(id);
} }
} }
@ -4839,10 +4841,10 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const
return 0; // Not implemented yet return 0; // Not implemented yet
case ACSF_GetSectorUDMFInt: case ACSF_GetSectorUDMFInt:
return GetUDMFInt(UDMF_Sector, P_FindSectorFromTag(args[0], -1), FBehavior::StaticLookupString(args[1])); return GetUDMFInt(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), FBehavior::StaticLookupString(args[1]));
case ACSF_GetSectorUDMFFixed: case ACSF_GetSectorUDMFFixed:
return GetUDMFFixed(UDMF_Sector, P_FindSectorFromTag(args[0], -1), FBehavior::StaticLookupString(args[1])); return GetUDMFFixed(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), FBehavior::StaticLookupString(args[1]));
case ACSF_GetSideUDMFInt: case ACSF_GetSideUDMFInt:
return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), FBehavior::StaticLookupString(args[2])); return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), FBehavior::StaticLookupString(args[2]));
@ -5169,11 +5171,11 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const
int space = args[2] < CHAN_FLOOR || args[2] > CHAN_INTERIOR ? CHAN_FULLHEIGHT : args[2]; int space = args[2] < CHAN_FLOOR || args[2] > CHAN_INTERIOR ? CHAN_FULLHEIGHT : args[2];
if (seqname != NULL) if (seqname != NULL)
{ {
int secnum = -1; FSectorTagIterator it(args[0]);
int s;
while ((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0) while ((s = it.Next()) >= 0)
{ {
SN_StartSequence(&sectors[secnum], args[2], seqname, 0); SN_StartSequence(&sectors[s], args[2], seqname, 0);
} }
} }
} }
@ -5692,9 +5694,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_SetLineActivation: case ACSF_SetLineActivation:
if (argCount >= 2) if (argCount >= 2)
{ {
int line = -1; int line;
FLineIdIterator itr(args[0]);
while ((line = P_FindLineFromID(args[0], line)) >= 0) while ((line = itr.Next()) >= 0)
{ {
lines[line].activation = args[1]; lines[line].activation = args[1];
} }
@ -5704,7 +5706,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_GetLineActivation: case ACSF_GetLineActivation:
if (argCount > 0) if (argCount > 0)
{ {
int line = P_FindLineFromID(args[0], -1); int line = P_FindFirstLineFromID(args[0]);
return line >= 0 ? lines[line].activation : 0; return line >= 0 ? lines[line].activation : 0;
} }
break; break;
@ -5952,11 +5954,13 @@ int DLevelScript::RunScript ()
// Wait for tagged sector(s) to go inactive, then enter // Wait for tagged sector(s) to go inactive, then enter
// state running // state running
{ {
int secnum = -1; int secnum;
FSectorTagIterator it(statedata);
while ((secnum = P_FindSectorFromTag (statedata, secnum)) >= 0) while ((secnum = it.Next()) >= 0)
{
if (sectors[secnum].floordata || sectors[secnum].ceilingdata) if (sectors[secnum].floordata || sectors[secnum].ceilingdata)
return resultValue; return resultValue;
}
// If we got here, none of the tagged sectors were busy // If we got here, none of the tagged sectors were busy
state = SCRIPT_Running; state = SCRIPT_Running;
@ -7996,9 +8000,10 @@ scriptwait:
case PCD_SETLINEBLOCKING: case PCD_SETLINEBLOCKING:
{ {
int line = -1; int line;
while ((line = P_FindLineFromID (STACK(2), line)) >= 0) FLineIdIterator itr(STACK(2));
while ((line = itr.Next()) >= 0)
{ {
switch (STACK(1)) switch (STACK(1))
{ {
@ -8031,9 +8036,10 @@ scriptwait:
case PCD_SETLINEMONSTERBLOCKING: case PCD_SETLINEMONSTERBLOCKING:
{ {
int line = -1; int line;
while ((line = P_FindLineFromID (STACK(2), line)) >= 0) FLineIdIterator itr(STACK(2));
while ((line = itr.Next()) >= 0)
{ {
if (STACK(1)) if (STACK(1))
lines[line].flags |= ML_BLOCKMONSTERS; lines[line].flags |= ML_BLOCKMONSTERS;
@ -8058,7 +8064,8 @@ scriptwait:
arg0 = -FName(FBehavior::StaticLookupString(arg0)); arg0 = -FName(FBehavior::StaticLookupString(arg0));
} }
while ((linenum = P_FindLineFromID (STACK(7), linenum)) >= 0) FLineIdIterator itr(STACK(7));
while ((linenum = itr.Next()) >= 0)
{ {
line_t *line = &lines[linenum]; line_t *line = &lines[linenum];
line->special = specnum; line->special = specnum;
@ -8518,7 +8525,7 @@ scriptwait:
fixed_t z = 0; fixed_t z = 0;
if (tag != 0) if (tag != 0)
secnum = P_FindSectorFromTag (tag, -1); secnum = P_FindFirstSectorFromTag (tag);
else else
secnum = int(P_PointInSector (x, y) - sectors); secnum = int(P_PointInSector (x, y) - sectors);
@ -8540,7 +8547,7 @@ scriptwait:
case PCD_GETSECTORLIGHTLEVEL: case PCD_GETSECTORLIGHTLEVEL:
{ {
int secnum = P_FindSectorFromTag (STACK(1), -1); int secnum = P_FindFirstSectorFromTag (STACK(1));
int z = -1; int z = -1;
if (secnum >= 0) if (secnum >= 0)

View file

@ -510,9 +510,9 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
P_ActivateInStasisCeiling (tag); P_ActivateInStasisCeiling (tag);
} }
secnum = -1;
// affects all sectors with the same tag as the linedef // affects all sectors with the same tag as the linedef
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) FSectorTagIterator it(tag);
while ((secnum = it.Next()) >= 0)
{ {
rtn |= !!DCeiling::Create(&sectors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); rtn |= !!DCeiling::Create(&sectors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
} }

View file

@ -484,8 +484,8 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing,
else else
{ // [RH] Remote door { // [RH] Remote door
secnum = -1; FSectorTagIterator it(tag);
while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
// if the ceiling is already moving, don't start the door action // if the ceiling is already moving, don't start the door action
@ -812,7 +812,8 @@ bool EV_SlidingDoor (line_t *line, AActor *actor, int tag, int speed, int delay)
return false; return false;
} }
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) FSectorTagIterator it(tag);
while ((secnum = it.Next()) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
if (sec->ceilingdata != NULL) if (sec->ceilingdata != NULL)

View file

@ -290,28 +290,13 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
rtn = false; rtn = false;
// check if a manual trigger; if so do just the sector on the backside // check if a manual trigger; if so do just the sector on the backside
if (tag == 0) FSectorTagIterator it(tag, line);
{ while ((secnum = it.Next()) >= 0)
if (!line || !(sec = line->backsector))
return rtn;
secnum = (int)(sec-sectors);
goto manual_floor;
}
secnum = -1;
while (tag && (secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
manual_floor:
// ALREADY MOVING? IF SO, KEEP GOING... // ALREADY MOVING? IF SO, KEEP GOING...
if (sec->PlaneMoving(sector_t::floor)) if (sec->PlaneMoving(sector_t::floor))
{ {
// There was a test for 0/non-0 here, supposed to prevent 0-tags from executing "continue" and searching for unrelated sectors
// Unfortunately, the condition had been reversed, so that searches for tag-0 would continue,
// while numbered tags would abort (return false, even if some floors have been successfully triggered)
// All occurences of the condition (faulty or not) have been replaced by a looping condition: Looping only occurs if we're looking for a non-0 tag.
continue; continue;
} }
@ -545,9 +530,9 @@ manual_floor:
bool EV_FloorCrushStop (int tag) bool EV_FloorCrushStop (int tag)
{ {
int secnum = -1; int secnum;
FSectorTagIterator it(tag);
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sec = sectors + secnum; sector_t *sec = sectors + secnum;
@ -562,21 +547,6 @@ bool EV_FloorCrushStop (int tag)
return true; return true;
} }
//==========================================================================
//
// Linear tag search to emulate stair building from Doom.exe
//
//==========================================================================
static int P_FindSectorFromTagLinear (int tag, int start)
{
for (int i=start+1;i<numsectors;i++)
{
if (sectors[i].tag == tag) return i;
}
return -1;
}
//========================================================================== //==========================================================================
// //
// BUILD A STAIRCASE! // BUILD A STAIRCASE!
@ -591,7 +561,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
fixed_t stairsize, fixed_t speed, int delay, int reset, int igntxt, fixed_t stairsize, fixed_t speed, int delay, int reset, int igntxt,
int usespecials) int usespecials)
{ {
int secnum; int secnum = -1;
int osecnum; //jff 3/4/98 save old loop index int osecnum; //jff 3/4/98 save old loop index
int height; int height;
fixed_t stairstep; fixed_t stairstep;
@ -607,44 +577,27 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
sector_t* prev = NULL; sector_t* prev = NULL;
DFloor* floor; DFloor* floor;
bool manual = false;
if (speed == 0) if (speed == 0)
return false; return false;
persteptime = FixedDiv (stairsize, speed) >> FRACBITS; persteptime = FixedDiv (stairsize, speed) >> FRACBITS;
int (* FindSector) (int tag, int start) =
(i_compatflags & COMPATF_STAIRINDEX)? P_FindSectorFromTagLinear : P_FindSectorFromTag;
// check if a manual trigger, if so do just the sector on the backside // check if a manual trigger, if so do just the sector on the backside
if (tag == 0) FSectorTagIterator itr(tag, line);
{
if (!line || !(sec = line->backsector))
return rtn;
secnum = (int)(sec-sectors);
manual = true;
goto manual_stair;
}
// The compatibility mode doesn't work with a hashing algorithm. // The compatibility mode doesn't work with a hashing algorithm.
// It needs the original linear search method. This was broken in Boom. // It needs the original linear search method. This was broken in Boom.
bool compatible = tag != 0 && (i_compatflags & COMPATF_STAIRINDEX);
secnum = -1; while ((secnum = itr.NextCompat(compatible, secnum)) >= 0)
while ((secnum = FindSector (tag, secnum)) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
manual_stair:
// ALREADY MOVING? IF SO, KEEP GOING... // ALREADY MOVING? IF SO, KEEP GOING...
//jff 2/26/98 add special lockout condition to wait for entire //jff 2/26/98 add special lockout condition to wait for entire
//staircase to build before retriggering //staircase to build before retriggering
if (sec->PlaneMoving(sector_t::floor) || sec->stairlock) if (sec->PlaneMoving(sector_t::floor) || sec->stairlock)
{ {
if (!manual)
continue; continue;
else
return rtn;
} }
// new floor thinker // new floor thinker
@ -781,14 +734,6 @@ manual_stair:
// [RH] make sure the first sector doesn't point to a previous one, otherwise // [RH] make sure the first sector doesn't point to a previous one, otherwise
// it can infinite loop when the first sector stops moving. // it can infinite loop when the first sector stops moving.
sectors[osecnum].prevsec = -1; sectors[osecnum].prevsec = -1;
if (manual)
{
return rtn;
}
if (!(i_compatflags & COMPATF_STAIRINDEX))
{
secnum = osecnum; //jff 3/4/98 restore loop index
}
} }
return rtn; return rtn;
} }
@ -811,21 +756,13 @@ bool EV_DoDonut (int tag, line_t *line, fixed_t pillarspeed, fixed_t slimespeed)
vertex_t* spot; vertex_t* spot;
fixed_t height; fixed_t height;
secnum = -1;
rtn = false; rtn = false;
if (tag == 0) FSectorTagIterator itr(tag, line);
{ while ((secnum = itr.Next()) >= 0)
if (!line || !(s1 = line->backsector))
return rtn;
goto manual_donut;
}
while (tag && (secnum = P_FindSectorFromTag(tag,secnum)) >= 0)
{ {
s1 = &sectors[secnum]; // s1 is pillar's sector s1 = &sectors[secnum]; // s1 is pillar's sector
manual_donut:
// ALREADY MOVING? IF SO, KEEP GOING... // ALREADY MOVING? IF SO, KEEP GOING...
if (s1->PlaneMoving(sector_t::floor)) if (s1->PlaneMoving(sector_t::floor))
continue; // safe now, because we check that tag is non-0 in the looping condition [fdari] continue; // safe now, because we check that tag is non-0 in the looping condition [fdari]
@ -1042,19 +979,12 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
secnum = -1; secnum = -1;
rtn = false; rtn = false;
if (tag == 0) FSectorTagIterator itr(tag, line);
{
if (!line || !(sec = line->backsector))
return rtn;
goto manual_elevator;
}
// act on all sectors with the same tag as the triggering linedef // act on all sectors with the same tag as the triggering linedef
while (tag && (secnum = P_FindSectorFromTag (tag, secnum)) >= 0) // never loop for a non-0 tag (condition moved to beginning of loop) [FDARI] while ((secnum = itr.Next()) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
manual_elevator:
// If either floor or ceiling is already activated, skip it // If either floor or ceiling is already activated, skip it
if (sec->PlaneMoving(sector_t::floor) || sec->ceilingdata) //jff 2/22/98 if (sec->PlaneMoving(sector_t::floor) || sec->ceilingdata) //jff 2/22/98
continue; // the loop used to break at the end if tag were 0, but would miss that step if "continue" occured [FDARI] continue; // the loop used to break at the end if tag were 0, but would miss that step if "continue" occured [FDARI]
@ -1142,10 +1072,10 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag)
sector_t *sec; sector_t *sec;
sector_t *secm; sector_t *secm;
secnum = -1;
rtn = false; rtn = false;
// change all sectors with the same tag as the linedef // change all sectors with the same tag as the linedef
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) FSectorTagIterator it(tag);
while ((secnum = it.Next()) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
@ -1374,20 +1304,12 @@ bool EV_StartWaggle (int tag, line_t *line, int height, int speed, int offset,
bool retCode; bool retCode;
retCode = false; retCode = false;
sectorIndex = -1;
if (tag == 0) FSectorTagIterator itr(tag, line);
{
if (!line || !(sector = line->backsector))
return retCode;
goto manual_waggle;
}
while ((sectorIndex = itr.Next()) >= 0)
while (tag && (sectorIndex = P_FindSectorFromTag(tag, sectorIndex)) >= 0)
{ {
sector = &sectors[sectorIndex]; sector = &sectors[sectorIndex];
manual_waggle:
if ((!ceiling && sector->PlaneMoving(sector_t::floor)) || if ((!ceiling && sector->PlaneMoving(sector_t::floor)) ||
(ceiling && sector->PlaneMoving(sector_t::ceiling))) (ceiling && sector->PlaneMoving(sector_t::ceiling)))
{ // Already busy with another thinker { // Already busy with another thinker

View file

@ -189,9 +189,8 @@ DFlicker::DFlicker (sector_t *sector, int upper, int lower)
void EV_StartLightFlickering (int tag, int upper, int lower) void EV_StartLightFlickering (int tag, int upper, int lower)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag);
secnum = -1; while ((secnum = it.Next()) >= 0)
while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0)
{ {
new DFlicker (&sectors[secnum], upper, lower); new DFlicker (&sectors[secnum], upper, lower);
} }
@ -359,9 +358,8 @@ DStrobe::DStrobe (sector_t *sector, int utics, int ltics, bool inSync)
void EV_StartLightStrobing (int tag, int upper, int lower, int utics, int ltics) void EV_StartLightStrobing (int tag, int upper, int lower, int utics, int ltics)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag);
secnum = -1; while ((secnum = it.Next()) >= 0)
while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0)
{ {
sector_t *sec = &sectors[secnum]; sector_t *sec = &sectors[secnum];
if (sec->lightingdata) if (sec->lightingdata)
@ -374,9 +372,8 @@ void EV_StartLightStrobing (int tag, int upper, int lower, int utics, int ltics)
void EV_StartLightStrobing (int tag, int utics, int ltics) void EV_StartLightStrobing (int tag, int utics, int ltics)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag);
secnum = -1; while ((secnum = it.Next()) >= 0)
while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0)
{ {
sector_t *sec = &sectors[secnum]; sector_t *sec = &sectors[secnum];
if (sec->lightingdata) if (sec->lightingdata)
@ -396,16 +393,14 @@ void EV_StartLightStrobing (int tag, int utics, int ltics)
void EV_TurnTagLightsOff (int tag) void EV_TurnTagLightsOff (int tag)
{ {
int i;
int secnum; int secnum;
FSectorTagIterator it(tag);
// [RH] Don't do a linear search while ((secnum = it.Next()) >= 0)
for (secnum = -1; (secnum = P_FindSectorFromTag (tag, secnum)) >= 0; )
{ {
sector_t *sector = sectors + secnum; sector_t *sector = sectors + secnum;
int min = sector->lightlevel; int min = sector->lightlevel;
for (i = 0; i < sector->linecount; i++) for (int i = 0; i < sector->linecount; i++)
{ {
sector_t *tsec = getNextSector (sector->lines[i],sector); sector_t *tsec = getNextSector (sector->lines[i],sector);
if (!tsec) if (!tsec)
@ -427,10 +422,9 @@ void EV_TurnTagLightsOff (int tag)
void EV_LightTurnOn (int tag, int bright) void EV_LightTurnOn (int tag, int bright)
{ {
int secnum = -1; int secnum;
FSectorTagIterator it(tag);
// [RH] Don't do a linear search while ((secnum = it.Next()) >= 0)
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{ {
sector_t *sector = sectors + secnum; sector_t *sector = sectors + secnum;
int tbright = bright; //jff 5/17/98 search for maximum PER sector int tbright = bright; //jff 5/17/98 search for maximum PER sector
@ -480,15 +474,14 @@ void EV_LightTurnOn (int tag, int bright)
void EV_LightTurnOnPartway (int tag, fixed_t frac) void EV_LightTurnOnPartway (int tag, fixed_t frac)
{ {
int i;
frac = clamp<fixed_t> (frac, 0, FRACUNIT); frac = clamp<fixed_t> (frac, 0, FRACUNIT);
// Search all sectors for ones with same tag as activating line // Search all sectors for ones with same tag as activating line
i = -1; int secnum;
while ((i = P_FindSectorFromTag (tag, i)) >= 0) FSectorTagIterator it(tag);
while ((secnum = it.Next()) >= 0)
{ {
sector_t *temp, *sector = sectors + i; sector_t *temp, *sector = &sectors[secnum];
int j, bright = 0, min = sector->lightlevel; int j, bright = 0, min = sector->lightlevel;
for (j = 0; j < sector->linecount; ++j) for (j = 0; j < sector->linecount; ++j)
@ -520,9 +513,9 @@ void EV_LightTurnOnPartway (int tag, fixed_t frac)
void EV_LightChange (int tag, int value) void EV_LightChange (int tag, int value)
{ {
int secnum = -1; int secnum;
FSectorTagIterator it(tag);
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sectors[secnum].SetLightLevel(sectors[secnum].lightlevel + value); sectors[secnum].SetLightLevel(sectors[secnum].lightlevel + value);
} }
@ -681,8 +674,8 @@ void EV_StartLightGlowing (int tag, int upper, int lower, int tics)
lower = temp; lower = temp;
} }
secnum = -1; FSectorTagIterator it(tag);
while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sec = &sectors[secnum]; sector_t *sec = &sectors[secnum];
if (sec->lightingdata) if (sec->lightingdata)
@ -701,9 +694,8 @@ void EV_StartLightGlowing (int tag, int upper, int lower, int tics)
void EV_StartLightFading (int tag, int value, int tics) void EV_StartLightFading (int tag, int value, int tics)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag);
secnum = -1; while ((secnum = it.Next()) >= 0)
while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0)
{ {
sector_t *sec = &sectors[secnum]; sector_t *sec = &sectors[secnum];
if (sec->lightingdata) if (sec->lightingdata)
@ -846,7 +838,7 @@ void EV_StopLightEffect (int tag)
while ((effect = iterator.Next()) != NULL) while ((effect = iterator.Next()) != NULL)
{ {
if (effect->GetSector()->tag == tag) if (effect->GetSector()->HasTag(tag))
{ {
effect->Destroy(); effect->Destroy();
} }

View file

@ -278,7 +278,7 @@ static void RemoveTaggedSectors(extsector_t::linked::plane &scrollplane, int tag
{ {
for(int i = scrollplane.Sectors.Size()-1; i>=0; i--) 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); scrollplane.Sectors.Delete(i);
} }
@ -316,7 +316,9 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype)
if (movetype > 0) if (movetype > 0)
{ {
for(int sec = -1; (sec = P_FindSectorFromTag(tag, sec)) >= 0; ) int sec;
FSectorTagIterator itr(tag);
while ((sec = itr.Next()) >= 0)
{ {
// Don't attach to self! // Don't attach to self!
if (control != &sectors[sec]) if (control != &sectors[sec])
@ -346,7 +348,9 @@ void P_AddSectorLinksByID(sector_t *control, int id, INTBOOL ceiling)
{ {
extsector_t::linked::plane &scrollplane = ceiling? control->e->Linked.Ceiling : control->e->Linked.Floor; extsector_t::linked::plane &scrollplane = ceiling? control->e->Linked.Ceiling : control->e->Linked.Floor;
for(int line = -1; (line = P_FindLineFromID(id, line)) >= 0; ) FLineIdIterator itr(id);
int line;
while ((line = itr.Next()) >= 0)
{ {
line_t *ld = &lines[line]; line_t *ld = &lines[line];

View file

@ -1266,7 +1266,7 @@ FUNC(LS_Thing_Destroy)
while (actor) while (actor)
{ {
AActor *temp = iterator.Next (); 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); P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None);
actor = temp; actor = temp;
} }
@ -1279,7 +1279,7 @@ FUNC(LS_Thing_Destroy)
while (actor) while (actor)
{ {
AActor *temp = iterator.Next (); 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); P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None);
actor = temp; actor = temp;
} }
@ -1914,9 +1914,9 @@ FUNC(LS_Sector_ChangeSound)
if (!arg0) if (!arg0)
return false; return false;
secNum = -1;
rtn = false; rtn = false;
while ((secNum = P_FindSectorFromTag (arg0, secNum)) >= 0) FSectorTagIterator itr(arg0);
while ((secNum = itr.Next()) >= 0)
{ {
sectors[secNum].seqType = arg1; sectors[secNum].seqType = arg1;
rtn = true; rtn = true;
@ -1933,9 +1933,9 @@ FUNC(LS_Sector_ChangeFlags)
if (!arg0) if (!arg0)
return false; return false;
secNum = -1;
rtn = false; rtn = false;
while ((secNum = P_FindSectorFromTag (arg0, secNum)) >= 0) FSectorTagIterator itr(arg0);
while ((secNum = itr.Next()) >= 0)
{ {
sectors[secNum].Flags = (sectors[secNum].Flags | arg1) & ~arg2; sectors[secNum].Flags = (sectors[secNum].Flags | arg1) & ~arg2;
rtn = true; rtn = true;
@ -1969,10 +1969,11 @@ void AdjustPusher (int tag, int magnitude, int angle, DPusher::EPusher type)
} }
size_t numcollected = Collection.Size (); size_t numcollected = Collection.Size ();
int secnum = -1; int secnum;
// Now create pushers for any sectors that don't already have them. // Now create pushers for any sectors that don't already have them.
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) FSectorTagIterator itr(tag);
while ((secnum = itr.Next()) >= 0)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < numcollected; i++) for (i = 0; i < numcollected; i++)
@ -2020,9 +2021,9 @@ FUNC(LS_Sector_SetTranslucent)
{ {
if (arg0 != 0) if (arg0 != 0)
{ {
int secnum = -1; int secnum;
FSectorTagIterator itr(arg0);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sectors[secnum].SetAlpha(arg1, Scale(arg2, OPAQUE, 255)); sectors[secnum].SetAlpha(arg1, Scale(arg2, OPAQUE, 255));
sectors[secnum].ChangeFlags(arg1, ~PLANEF_ADDITIVE, arg3? PLANEF_ADDITIVE:0); sectors[secnum].ChangeFlags(arg1, ~PLANEF_ADDITIVE, arg3? PLANEF_ADDITIVE:0);
@ -2037,7 +2038,7 @@ FUNC(LS_Sector_SetLink)
{ {
if (arg0 != 0) // control tag == 0 is for static initialization and must not be handled here if (arg0 != 0) // control tag == 0 is for static initialization and must not be handled here
{ {
int control = P_FindSectorFromTag(arg0, -1); int control = P_FindFirstSectorFromTag(arg0);
if (control >= 0) if (control >= 0)
{ {
return P_AddSectorLinks(&sectors[control], arg1, arg2, arg3); return P_AddSectorLinks(&sectors[control], arg1, arg2, arg3);
@ -2062,7 +2063,7 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int
{ {
int wallnum = scroller->GetWallNum (); 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 && int(sides[wallnum].linedef->sidedef[sidechoice] - sides) == wallnum &&
Where == scroller->GetScrollParts()) Where == scroller->GetScrollParts())
{ {
@ -2081,7 +2082,7 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int
while ( (collect.Obj = iterator.Next ()) ) while ( (collect.Obj = iterator.Next ()) )
{ {
if ((collect.RefNum = ((DScroller *)collect.Obj)->GetWallNum ()) != -1 && 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 && int(sides[collect.RefNum].linedef->sidedef[sidechoice] - sides) == collect.RefNum &&
Where == ((DScroller *)collect.Obj)->GetScrollParts()) Where == ((DScroller *)collect.Obj)->GetScrollParts())
{ {
@ -2092,10 +2093,11 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int
} }
size_t numcollected = Collection.Size (); size_t numcollected = Collection.Size ();
int linenum = -1; int linenum;
// Now create scrollers for any walls that don't already have them. // Now create scrollers for any walls that don't already have them.
while ((linenum = P_FindLineFromID (id, linenum)) >= 0) FLineIdIterator itr(id);
while ((linenum = itr.Next()) >= 0)
{ {
if (lines[linenum].sidedef[sidechoice] != NULL) if (lines[linenum].sidedef[sidechoice] != NULL)
{ {
@ -2167,7 +2169,7 @@ static void SetScroller (int tag, DScroller::EScrollType type, fixed_t dx, fixed
{ {
if (scroller->IsType (type)) if (scroller->IsType (type))
{ {
if (sectors[scroller->GetAffectee ()].tag == tag) if (sectors[scroller->GetAffectee ()].HasTag(tag))
{ {
i++; i++;
scroller->SetRate (dx, dy); scroller->SetRate (dx, dy);
@ -2181,7 +2183,8 @@ static void SetScroller (int tag, DScroller::EScrollType type, fixed_t dx, fixed
} }
// Need to create scrollers for the sector(s) // Need to create scrollers for the sector(s)
for (i = -1; (i = P_FindSectorFromTag (tag, i)) >= 0; ) FSectorTagIterator itr(tag);
while ((i = itr.Next()) >= 0)
{ {
new DScroller (type, dx, dy, -1, i, 0); new DScroller (type, dx, dy, -1, i, 0);
} }
@ -2240,8 +2243,10 @@ FUNC(LS_Sector_SetDamage)
// problems by adding an unwanted constructor. // problems by adding an unwanted constructor.
// Since it doesn't really matter whether the type is translated // Since it doesn't really matter whether the type is translated
// here or in P_PlayerInSpecialSector I think it's the best solution. // here or in P_PlayerInSpecialSector I think it's the best solution.
int secnum = -1; FSectorTagIterator itr(arg0);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { int secnum;
while ((secnum = itr.Next()) >= 0)
{
sectors[secnum].damage = arg1; sectors[secnum].damage = arg1;
sectors[secnum].mod = arg2; sectors[secnum].mod = arg2;
} }
@ -2251,14 +2256,15 @@ FUNC(LS_Sector_SetDamage)
FUNC(LS_Sector_SetGravity) FUNC(LS_Sector_SetGravity)
// Sector_SetGravity (tag, intpart, fracpart) // Sector_SetGravity (tag, intpart, fracpart)
{ {
int secnum = -1;
float gravity; float gravity;
if (arg2 > 99) if (arg2 > 99)
arg2 = 99; arg2 = 99;
gravity = (float)arg1 + (float)arg2 * 0.01f; gravity = (float)arg1 + (float)arg2 * 0.01f;
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
sectors[secnum].gravity = gravity; sectors[secnum].gravity = gravity;
return true; return true;
@ -2267,9 +2273,9 @@ FUNC(LS_Sector_SetGravity)
FUNC(LS_Sector_SetColor) FUNC(LS_Sector_SetColor)
// Sector_SetColor (tag, r, g, b, desaturate) // Sector_SetColor (tag, r, g, b, desaturate)
{ {
int secnum = -1; FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sectors[secnum].SetColor(arg1, arg2, arg3, arg4); sectors[secnum].SetColor(arg1, arg2, arg3, arg4);
} }
@ -2280,9 +2286,9 @@ FUNC(LS_Sector_SetColor)
FUNC(LS_Sector_SetFade) FUNC(LS_Sector_SetFade)
// Sector_SetFade (tag, r, g, b) // Sector_SetFade (tag, r, g, b)
{ {
int secnum = -1; FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sectors[secnum].SetFade(arg1, arg2, arg3); sectors[secnum].SetFade(arg1, arg2, arg3);
} }
@ -2292,11 +2298,12 @@ FUNC(LS_Sector_SetFade)
FUNC(LS_Sector_SetCeilingPanning) FUNC(LS_Sector_SetCeilingPanning)
// Sector_SetCeilingPanning (tag, x-int, x-frac, y-int, y-frac) // Sector_SetCeilingPanning (tag, x-int, x-frac, y-int, y-frac)
{ {
int secnum = -1;
fixed_t xofs = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); fixed_t xofs = arg1 * FRACUNIT + arg2 * (FRACUNIT/100);
fixed_t yofs = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); fixed_t yofs = arg3 * FRACUNIT + arg4 * (FRACUNIT/100);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
{ {
sectors[secnum].SetXOffset(sector_t::ceiling, xofs); sectors[secnum].SetXOffset(sector_t::ceiling, xofs);
sectors[secnum].SetYOffset(sector_t::ceiling, yofs); sectors[secnum].SetYOffset(sector_t::ceiling, yofs);
@ -2307,11 +2314,12 @@ FUNC(LS_Sector_SetCeilingPanning)
FUNC(LS_Sector_SetFloorPanning) FUNC(LS_Sector_SetFloorPanning)
// Sector_SetFloorPanning (tag, x-int, x-frac, y-int, y-frac) // Sector_SetFloorPanning (tag, x-int, x-frac, y-int, y-frac)
{ {
int secnum = -1;
fixed_t xofs = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); fixed_t xofs = arg1 * FRACUNIT + arg2 * (FRACUNIT/100);
fixed_t yofs = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); fixed_t yofs = arg3 * FRACUNIT + arg4 * (FRACUNIT/100);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
{ {
sectors[secnum].SetXOffset(sector_t::floor, xofs); sectors[secnum].SetXOffset(sector_t::floor, xofs);
sectors[secnum].SetYOffset(sector_t::floor, yofs); sectors[secnum].SetYOffset(sector_t::floor, yofs);
@ -2322,7 +2330,6 @@ FUNC(LS_Sector_SetFloorPanning)
FUNC(LS_Sector_SetFloorScale) FUNC(LS_Sector_SetFloorScale)
// Sector_SetFloorScale (tag, x-int, x-frac, y-int, y-frac) // Sector_SetFloorScale (tag, x-int, x-frac, y-int, y-frac)
{ {
int secnum = -1;
fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100);
fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100);
@ -2331,7 +2338,9 @@ FUNC(LS_Sector_SetFloorScale)
if (yscale) if (yscale)
yscale = FixedDiv (FRACUNIT, yscale); yscale = FixedDiv (FRACUNIT, yscale);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
{ {
if (xscale) if (xscale)
sectors[secnum].SetXScale(sector_t::floor, xscale); sectors[secnum].SetXScale(sector_t::floor, xscale);
@ -2344,7 +2353,6 @@ FUNC(LS_Sector_SetFloorScale)
FUNC(LS_Sector_SetCeilingScale) FUNC(LS_Sector_SetCeilingScale)
// Sector_SetCeilingScale (tag, x-int, x-frac, y-int, y-frac) // Sector_SetCeilingScale (tag, x-int, x-frac, y-int, y-frac)
{ {
int secnum = -1;
fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100);
fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100);
@ -2353,7 +2361,9 @@ FUNC(LS_Sector_SetCeilingScale)
if (yscale) if (yscale)
yscale = FixedDiv (FRACUNIT, yscale); yscale = FixedDiv (FRACUNIT, yscale);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
{ {
if (xscale) if (xscale)
sectors[secnum].SetXScale(sector_t::ceiling, xscale); sectors[secnum].SetXScale(sector_t::ceiling, xscale);
@ -2366,14 +2376,14 @@ FUNC(LS_Sector_SetCeilingScale)
FUNC(LS_Sector_SetFloorScale2) FUNC(LS_Sector_SetFloorScale2)
// Sector_SetFloorScale2 (tag, x-factor, y-factor) // Sector_SetFloorScale2 (tag, x-factor, y-factor)
{ {
int secnum = -1;
if (arg1) if (arg1)
arg1 = FixedDiv (FRACUNIT, arg1); arg1 = FixedDiv (FRACUNIT, arg1);
if (arg2) if (arg2)
arg2 = FixedDiv (FRACUNIT, arg2); arg2 = FixedDiv (FRACUNIT, arg2);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
{ {
if (arg1) if (arg1)
sectors[secnum].SetXScale(sector_t::floor, arg1); sectors[secnum].SetXScale(sector_t::floor, arg1);
@ -2386,14 +2396,14 @@ FUNC(LS_Sector_SetFloorScale2)
FUNC(LS_Sector_SetCeilingScale2) FUNC(LS_Sector_SetCeilingScale2)
// Sector_SetFloorScale2 (tag, x-factor, y-factor) // Sector_SetFloorScale2 (tag, x-factor, y-factor)
{ {
int secnum = -1;
if (arg1) if (arg1)
arg1 = FixedDiv (FRACUNIT, arg1); arg1 = FixedDiv (FRACUNIT, arg1);
if (arg2) if (arg2)
arg2 = FixedDiv (FRACUNIT, arg2); arg2 = FixedDiv (FRACUNIT, arg2);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
{ {
if (arg1) if (arg1)
sectors[secnum].SetXScale(sector_t::ceiling, arg1); sectors[secnum].SetXScale(sector_t::ceiling, arg1);
@ -2406,11 +2416,12 @@ FUNC(LS_Sector_SetCeilingScale2)
FUNC(LS_Sector_SetRotation) FUNC(LS_Sector_SetRotation)
// Sector_SetRotation (tag, floor-angle, ceiling-angle) // Sector_SetRotation (tag, floor-angle, ceiling-angle)
{ {
int secnum = -1;
angle_t ceiling = arg2 * ANGLE_1; angle_t ceiling = arg2 * ANGLE_1;
angle_t floor = arg1 * ANGLE_1; angle_t floor = arg1 * ANGLE_1;
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
{ {
sectors[secnum].SetAngle(sector_t::floor, floor); sectors[secnum].SetAngle(sector_t::floor, floor);
sectors[secnum].SetAngle(sector_t::ceiling, ceiling); sectors[secnum].SetAngle(sector_t::ceiling, ceiling);
@ -2421,30 +2432,28 @@ FUNC(LS_Sector_SetRotation)
FUNC(LS_Line_AlignCeiling) FUNC(LS_Line_AlignCeiling)
// Line_AlignCeiling (lineid, side) // Line_AlignCeiling (lineid, side)
{ {
int line = P_FindLineFromID (arg0, -1);
bool ret = 0; bool ret = 0;
if (line < 0) FLineIdIterator itr(arg0);
I_Error ("Sector_AlignCeiling: Lineid %d is undefined", arg0); int line;
do while ((line = itr.Next()) >= 0)
{ {
ret |= P_AlignFlat (line, !!arg1, 1); ret |= P_AlignFlat (line, !!arg1, 1);
} while ( (line = P_FindLineFromID (arg0, line)) >= 0); }
return ret; return ret;
} }
FUNC(LS_Line_AlignFloor) FUNC(LS_Line_AlignFloor)
// Line_AlignFloor (lineid, side) // Line_AlignFloor (lineid, side)
{ {
int line = P_FindLineFromID (arg0, -1);
bool ret = 0; bool ret = 0;
if (line < 0) FLineIdIterator itr(arg0);
I_Error ("Sector_AlignFloor: Lineid %d is undefined", arg0); int line;
do while ((line = itr.Next()) >= 0)
{ {
ret |= P_AlignFlat (line, !!arg1, 0); ret |= P_AlignFlat (line, !!arg1, 0);
} while ( (line = P_FindLineFromID (arg0, line)) >= 0); }
return ret; return ret;
} }
@ -2456,7 +2465,9 @@ FUNC(LS_Line_SetTextureOffset)
if (arg0 == 0 || arg3 < 0 || arg3 > 1) if (arg0 == 0 || arg3 < 0 || arg3 > 1)
return false; return false;
for(int line = -1; (line = P_FindLineFromID (arg0, line)) >= 0; ) FLineIdIterator itr(arg0);
int line;
while ((line = itr.Next()) >= 0)
{ {
side_t *side = lines[line].sidedef[arg3]; side_t *side = lines[line].sidedef[arg3];
if (side != NULL) if (side != NULL)
@ -2507,7 +2518,9 @@ FUNC(LS_Line_SetTextureScale)
if (arg0 == 0 || arg3 < 0 || arg3 > 1) if (arg0 == 0 || arg3 < 0 || arg3 > 1)
return false; return false;
for(int line = -1; (line = P_FindLineFromID (arg0, line)) >= 0; ) FLineIdIterator itr(arg0);
int line;
while ((line = itr.Next()) >= 0)
{ {
side_t *side = lines[line].sidedef[arg3]; side_t *side = lines[line].sidedef[arg3];
if (side != NULL) if (side != NULL)
@ -2578,7 +2591,9 @@ FUNC(LS_Line_SetBlocking)
if (arg2 & 1) clearflags |= flagtrans[i]; if (arg2 & 1) clearflags |= flagtrans[i];
} }
for(int line = -1; (line = P_FindLineFromID (arg0, line)) >= 0; ) FLineIdIterator itr(arg0);
int line;
while ((line = itr.Next()) >= 0)
{ {
lines[line].flags = (lines[line].flags & ~clearflags) | setflags; lines[line].flags = (lines[line].flags & ~clearflags) | setflags;
} }
@ -2871,8 +2886,9 @@ FUNC(LS_SetPlayerProperty)
FUNC(LS_TranslucentLine) FUNC(LS_TranslucentLine)
// TranslucentLine (id, amount, type) // TranslucentLine (id, amount, type)
{ {
int linenum = -1; FLineIdIterator itr(arg0);
while ((linenum = P_FindLineFromID (arg0, linenum)) >= 0) int linenum;
while ((linenum = itr.Next()) >= 0)
{ {
lines[linenum].Alpha = Scale(clamp(arg1, 0, 255), FRACUNIT, 255); lines[linenum].Alpha = Scale(clamp(arg1, 0, 255), FRACUNIT, 255);
if (arg2 == 0) if (arg2 == 0)
@ -2997,10 +3013,11 @@ FUNC(LS_ForceField)
FUNC(LS_ClearForceField) FUNC(LS_ClearForceField)
// ClearForceField (tag) // ClearForceField (tag)
{ {
int secnum = -1;
bool rtn = false; bool rtn = false;
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) FSectorTagIterator itr(arg0);
int secnum;
while ((secnum = itr.Next()) >= 0)
{ {
sector_t *sec = &sectors[secnum]; sector_t *sec = &sectors[secnum];
rtn = true; rtn = true;

View file

@ -3437,7 +3437,7 @@ void AActor::Tick ()
} }
else if (scrolltype == Scroll_StrifeCurrent) else if (scrolltype == Scroll_StrifeCurrent)
{ // Strife scroll special { // Strife scroll special
int anglespeed = sec->tag - 100; int anglespeed = sec->GetMainTag() - 100;
fixed_t carryspeed = DivScale32 (anglespeed % 10, 16*CARRYFACTOR); fixed_t carryspeed = DivScale32 (anglespeed % 10, 16*CARRYFACTOR);
angle_t fineangle = (anglespeed / 10) << (32-3); angle_t fineangle = (anglespeed / 10) << (32-3);
fineangle >>= ANGLETOFINESHIFT; fineangle >>= ANGLETOFINESHIFT;

View file

@ -220,20 +220,11 @@ bool EV_DoPillar (DPillar::EPillar type, line_t *line, int tag,
bool rtn = false; bool rtn = false;
// check if a manual trigger; if so do just the sector on the backside // check if a manual trigger; if so do just the sector on the backside
if (tag == 0) FSectorTagIterator itr(tag, line);
{ while ((secnum = itr.Next()) >= 0)
if (!line || !(sec = line->backsector))
return rtn;
secnum = (int)(sec-sectors);
goto manual_pillar;
}
secnum = -1;
while (tag && (secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
manual_pillar:
if (sec->PlaneMoving(sector_t::floor) || sec->PlaneMoving(sector_t::ceiling)) if (sec->PlaneMoving(sector_t::floor) || sec->PlaneMoving(sector_t::ceiling))
continue; continue;

View file

@ -233,17 +233,8 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
fixed_t newheight = 0; fixed_t newheight = 0;
vertex_t *spot; vertex_t *spot;
// [RH] If tag is zero, use the sector on the back side if (tag != 0)
// of the activating line (if any).
if (!tag)
{ {
if (!line || !(sec = line->backsector))
return false;
secnum = (int)(sec - sectors);
manual = true;
goto manual_plat;
}
// Activate all <type> plats that are in_stasis // Activate all <type> plats that are in_stasis
switch (type) switch (type)
{ {
@ -256,19 +247,19 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
default: default:
break; break;
} }
}
secnum = -1;
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) // [RH] If tag is zero, use the sector on the back side
// of the activating line (if any).
FSectorTagIterator itr(tag, line);
while ((secnum = itr.Next()) >= 0)
{ {
sec = &sectors[secnum]; sec = &sectors[secnum];
manual_plat:
if (sec->PlaneMoving(sector_t::floor)) if (sec->PlaneMoving(sector_t::floor))
{ {
if (!manual)
continue; continue;
else
return false;
} }
// Find lowest & highest floors around sector // Find lowest & highest floors around sector
@ -406,8 +397,6 @@ manual_plat:
default: default:
break; break;
} }
if (manual)
return rtn;
} }
return rtn; return rtn;
} }

View file

@ -825,6 +825,77 @@ sector_t *sector_t::GetHeightSec() const
} }
bool sector_t::HasTag(int checktag) const
{
return tag == checktag;
}
void sector_t::SetMainTag(int tagnum)
{
tag = tagnum;
}
int sector_t::GetMainTag() const
{
return tag;
}
void sector_t::ClearTags()
{
tag = 0;
}
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;
}
}
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 bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) const
{ {
bool copy = false; bool copy = false;

View file

@ -96,7 +96,6 @@ CVAR (Bool, gennodes, false, CVAR_SERVERINFO|CVAR_GLOBALCONFIG);
CVAR (Bool, genglnodes, false, CVAR_SERVERINFO); CVAR (Bool, genglnodes, false, CVAR_SERVERINFO);
CVAR (Bool, showloadtimes, false, 0); CVAR (Bool, showloadtimes, false, 0);
static void P_InitTagLists ();
static void P_Shutdown (); static void P_Shutdown ();
bool P_IsBuildMap(MapData *map); bool P_IsBuildMap(MapData *map);
@ -1514,7 +1513,7 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
else // [RH] Translate to new sector special else // [RH] Translate to new sector special
ss->special = P_TranslateSectorSpecial (LittleShort(ms->special)); ss->special = P_TranslateSectorSpecial (LittleShort(ms->special));
ss->secretsector = !!(ss->special&SECRET_MASK); ss->secretsector = !!(ss->special&SECRET_MASK);
ss->tag = LittleShort(ms->tag); ss->SetMainTag(LittleShort(ms->tag));
ss->thinglist = NULL; ss->thinglist = NULL;
ss->touching_thinglist = NULL; // phares 3/14/98 ss->touching_thinglist = NULL; // phares 3/14/98
ss->seqType = defSeqType; ss->seqType = defSeqType;
@ -1920,40 +1919,40 @@ void P_SetLineID (line_t *ld)
case Line_SetIdentification: case Line_SetIdentification:
if (!(level.flags2 & LEVEL2_HEXENHACK)) 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; ld->flags |= ld->args[1]<<16;
} }
else else
{ {
ld->id = ld->args[0]; ld->SetMainId(ld->args[0]);
} }
ld->special = 0; ld->special = 0;
break; break;
case TranslucentLine: case TranslucentLine:
ld->id = ld->args[0]; ld->SetMainId(ld->args[0]);
ld->flags |= ld->args[3]<<16; ld->flags |= ld->args[3]<<16;
break; break;
case Teleport_Line: case Teleport_Line:
case Scroll_Texture_Model: case Scroll_Texture_Model:
ld->id = ld->args[0]; ld->SetMainId(ld->args[0]);
break; break;
case Polyobj_StartLine: case Polyobj_StartLine:
ld->id = ld->args[3]; ld->SetMainId(ld->args[3]);
break; break;
case Polyobj_ExplicitLine: case Polyobj_ExplicitLine:
ld->id = ld->args[4]; ld->SetMainId(ld->args[4]);
break; break;
case Plane_Align: case Plane_Align:
ld->id = ld->args[2]; ld->SetMainId(ld->args[2]);
break; break;
case Static_Init: 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; break;
} }
} }
@ -2038,7 +2037,7 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha)
{ {
for (j = 0; j < numlines; j++) for (j = 0; j < numlines; j++)
{ {
if (lines[j].id == ld->args[0]) if (lines[j].HasId(ld->args[0]))
{ {
lines[j].Alpha = alpha; lines[j].Alpha = alpha;
if (additive) if (additive)
@ -2146,11 +2145,10 @@ void P_LoadLineDefs (MapData * map)
// [RH] Translate old linedef special and flags to be // [RH] Translate old linedef special and flags to be
// compatible with the new format. // compatible with the new format.
P_TranslateLineDef (ld, mld); P_TranslateLineDef (ld, mld, true);
ld->v1 = &vertexes[LittleShort(mld->v1)]; ld->v1 = &vertexes[LittleShort(mld->v1)];
ld->v2 = &vertexes[LittleShort(mld->v2)]; ld->v2 = &vertexes[LittleShort(mld->v2)];
//ld->id = -1; ID has been assigned in P_TranslateLineDef
P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0])); P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0]));
P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1])); P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1]));
@ -2233,7 +2231,7 @@ void P_LoadLineDefs2 (MapData * map)
ld->v1 = &vertexes[LittleShort(mld->v1)]; ld->v1 = &vertexes[LittleShort(mld->v1)];
ld->v2 = &vertexes[LittleShort(mld->v2)]; ld->v2 = &vertexes[LittleShort(mld->v2)];
ld->Alpha = FRACUNIT; // [RH] Opaque by default 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[0], LittleShort(mld->sidenum[0]));
P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1])); P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1]));
@ -2495,7 +2493,7 @@ void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmaps
for (s = 0; s < numsectors; s++) for (s = 0; s < numsectors; s++)
{ {
if (sectors[s].tag == tag) if (sectors[s].HasTag(tag))
{ {
if (!colorgood) color = sectors[s].ColorMap->Color; if (!colorgood) color = sectors[s].ColorMap->Color;
if (!foggood) fog = sectors[s].ColorMap->Fade; if (!foggood) fog = sectors[s].ColorMap->Fade;
@ -3131,9 +3129,9 @@ static void P_GroupLines (bool buildmap)
{ {
if (sector->linecount == 0) 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->GetMainTag());
// 0 the sector's tag so that no specials can use it // 0 the sector's tag so that no specials can use it
sector->tag = 0; sector->ClearTags();
} }
else else
{ {
@ -3209,7 +3207,9 @@ static void P_GroupLines (bool buildmap)
// [RH] Moved this here // [RH] Moved this here
times[4].Clock(); times[4].Clock();
P_InitTagLists(); // killough 1/30/98: Create xref tables for tags // killough 1/30/98: Create xref tables for tags
sector_t::HashTags();
line_t::HashIds();
times[4].Unclock(); times[4].Unclock();
times[5].Clock(); times[5].Clock();
@ -3306,32 +3306,6 @@ 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;
}
// killough 4/17/98: same thing, only for linedefs
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;
}
}
void P_GetPolySpots (MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors) void P_GetPolySpots (MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors)
{ {
if (map->HasBehavior) if (map->HasBehavior)

View file

@ -115,7 +115,7 @@ struct line_t;
struct maplinedef_t; struct maplinedef_t;
void P_LoadTranslator(const char *lumpname); void P_LoadTranslator(const char *lumpname);
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld); void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, bool setlineid);
int P_TranslateSectorSpecial (int); int P_TranslateSectorSpecial (int);
int GetUDMFInt(int type, int index, const char *key); int GetUDMFInt(int type, int index, const char *key);

View file

@ -45,9 +45,10 @@
static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, bool slopeCeil) static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, bool slopeCeil)
{ {
int linenum = -1; int linenum;
while ((linenum = P_FindLineFromID (lineid, linenum)) != -1) FLineIdIterator itr(lineid);
while ((linenum = itr.Next()) >= 0)
{ {
const line_t *line = &lines[linenum]; const line_t *line = &lines[linenum];
sector_t *sec; sector_t *sec;
@ -123,7 +124,7 @@ static void P_CopyPlane (int tag, sector_t *dest, bool copyCeil)
int secnum; int secnum;
size_t planeofs; size_t planeofs;
secnum = P_FindSectorFromTag (tag, -1); secnum = P_FindFirstSectorFromTag (tag);
if (secnum == -1) if (secnum == -1)
{ {
return; return;

View file

@ -195,29 +195,48 @@ bool CheckIfExitIsGood (AActor *self, level_info_t *info)
// Find the next sector with a specified tag. // Find the next sector with a specified tag.
// Rewritten by Lee Killough to use chained hashing to improve speed // Rewritten by Lee Killough to use chained hashing to improve speed
int P_FindSectorFromTag (int tag, int start) int FSectorTagIterator::Next()
{ {
start = start >= 0 ? sectors[start].nexttag : int ret;
sectors[(unsigned) tag % (unsigned) numsectors].firsttag; if (searchtag == INT_MIN)
while (start >= 0 && sectors[start].tag != tag) {
start = sectors[start].nexttag; ret = start;
return start; start = -1;
} }
else
{
while (start != -1 && sectors[start].tag != searchtag) start = sectors[start].nexttag;
if (start == -1) return -1;
ret = start;
start = sectors[start].nexttag;
}
return ret;
}
int FSectorTagIterator::NextCompat(bool compat, int start)
{
if (!compat) return Next();
for (int i = start + 1; i < numsectors; i++)
{
if (sectors[i].HasTag(searchtag)) return i;
}
return -1;
}
// killough 4/16/98: Same thing, only for linedefs // killough 4/16/98: Same thing, only for linedefs
int P_FindLineFromID (int id, int start) int FLineIdIterator::Next()
{ {
start = start >= 0 ? lines[start].nextid : while (start != -1 && lines[start].id != searchtag) start = lines[start].nextid;
lines[(unsigned) id % (unsigned) numlines].firstid; if (start == -1) return -1;
while (start >= 0 && lines[start].id != id) int ret = start;
start = lines[start].nextid; start = lines[start].nextid;
return start; return ret;
} }
//============================================================================ //============================================================================
// //
// P_ActivateLine // P_ActivateLine
@ -264,9 +283,9 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType)
!repeat && // only non-repeatable triggers !repeat && // only non-repeatable triggers
(special<Generic_Floor || special>Generic_Crusher) && // not for Boom's generalized linedefs (special<Generic_Floor || special>Generic_Crusher) && // not for Boom's generalized linedefs
special && // not for lines without a special 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) line->args[0] && // only if there's a tag (which is stored in the first arg)
P_FindSectorFromTag (line->args[0], -1) == -1) // only if no sector is tagged to this linedef P_FindFirstSectorFromTag (line->args[0]) == -1) // only if no sector is tagged to this linedef
{ {
P_ChangeSwitchTexture (line->sidedef[0], repeat, special); P_ChangeSwitchTexture (line->sidedef[0], repeat, special);
line->special = 0; line->special = 0;
@ -657,9 +676,9 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type,
void P_SectorDamage(int tag, int amount, FName type, const PClass *protectClass, int flags) void P_SectorDamage(int tag, int amount, FName type, const PClass *protectClass, int flags)
{ {
int secnum = -1; FSectorTagIterator itr(tag);
int secnum;
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
AActor *actor, *next; AActor *actor, *next;
sector_t *sec = &sectors[secnum]; sector_t *sec = &sectors[secnum];
@ -884,12 +903,14 @@ DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor)
if (copyFloor) if (copyFloor)
{ {
for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) FSectorTagIterator itr(target);
while ((secnum = itr.Next()) >= 0)
sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING);
} }
else else
{ {
for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) FSectorTagIterator itr(target);
while ((secnum = itr.Next()) >= 0)
sectors[secnum].ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING); sectors[secnum].ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING);
} }
ChangeStatNum (STAT_LIGHTTRANSFER); ChangeStatNum (STAT_LIGHTTRANSFER);
@ -912,12 +933,14 @@ void DLightTransfer::DoTransfer (int level, int target, bool floor)
if (floor) if (floor)
{ {
for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) FSectorTagIterator itr(target);
while ((secnum = itr.Next()) >= 0)
sectors[secnum].SetPlaneLight(sector_t::floor, level); sectors[secnum].SetPlaneLight(sector_t::floor, level);
} }
else else
{ {
for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) FSectorTagIterator itr(target);
while ((secnum = itr.Next()) >= 0)
sectors[secnum].SetPlaneLight(sector_t::ceiling, level); sectors[secnum].SetPlaneLight(sector_t::ceiling, level);
} }
} }
@ -985,7 +1008,8 @@ DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, BYTE flags
wallflags = WALLF_ABSLIGHTING | WALLF_NOFAKECONTRAST; wallflags = WALLF_ABSLIGHTING | WALLF_NOFAKECONTRAST;
} }
for (linenum = -1; (linenum = P_FindLineFromID (target, linenum)) >= 0; ) FLineIdIterator itr(target);
while ((linenum = itr.Next()) >= 0)
{ {
if (flags & WLF_SIDE1 && lines[linenum].sidedef[0] != NULL) if (flags & WLF_SIDE1 && lines[linenum].sidedef[0] != NULL)
{ {
@ -1015,7 +1039,8 @@ void DWallLightTransfer::DoTransfer (short lightlevel, int target, BYTE flags)
{ {
int linenum; int linenum;
for (linenum = -1; (linenum = P_FindLineFromID (target, linenum)) >= 0; ) FLineIdIterator itr(target);
while ((linenum = itr.Next()) >= 0)
{ {
line_t *line = &lines[linenum]; line_t *line = &lines[linenum];
@ -1173,7 +1198,9 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha)
reference->flags |= MF_JUSTATTACKED; reference->flags |= MF_JUSTATTACKED;
anchor->flags |= MF_JUSTATTACKED; anchor->flags |= MF_JUSTATTACKED;
for (int s=-1; (s = P_FindSectorFromTag(sectortag,s)) >= 0;) int s;
FSectorTagIterator itr(sectortag);
while ((s = itr.Next()) >= 0)
{ {
SetPortal(&sectors[s], plane, reference, alpha); SetPortal(&sectors[s], plane, reference, alpha);
} }
@ -1193,7 +1220,8 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha)
} }
else else
{ {
for (int s=-1; (s = P_FindSectorFromTag(lines[j].args[0],s)) >= 0;) FSectorTagIterator itr(lines[j].args[0]);
while ((s = itr.Next()) >= 0)
{ {
SetPortal(&sectors[s], plane, reference, alpha); SetPortal(&sectors[s], plane, reference, alpha);
} }
@ -1374,6 +1402,7 @@ void P_SpawnSpecials (void)
// killough 3/7/98: // killough 3/7/98:
// support for drawn heights coming from different sector // support for drawn heights coming from different sector
case Transfer_Heights: case Transfer_Heights:
{
sec = lines[i].frontsector; sec = lines[i].frontsector;
if (lines[i].args[1] & 2) if (lines[i].args[1] & 2)
{ {
@ -1399,13 +1428,15 @@ void P_SpawnSpecials (void)
{ {
sec->MoreFlags |= SECF_NOFAKELIGHT; sec->MoreFlags |= SECF_NOFAKELIGHT;
} }
for (s = -1; (s = P_FindSectorFromTag(lines[i].args[0],s)) >= 0;) FSectorTagIterator itr(lines[i].args[0]);
while ((s = itr.Next()) >= 0)
{ {
sectors[s].heightsec = sec; sectors[s].heightsec = sec;
sec->e->FakeFloor.Sectors.Push(&sectors[s]); sec->e->FakeFloor.Sectors.Push(&sectors[s]);
sectors[s].AdjustFloorClip(); sectors[s].AdjustFloorClip();
} }
break; break;
}
// killough 3/16/98: Add support for setting // killough 3/16/98: Add support for setting
// floor lighting independently (e.g. lava) // floor lighting independently (e.g. lava)
@ -1459,7 +1490,8 @@ void P_SpawnSpecials (void)
case Init_Gravity: case Init_Gravity:
{ {
float grav = ((float)P_AproxDistance (lines[i].dx, lines[i].dy)) / (FRACUNIT * 100.0f); float grav = ((float)P_AproxDistance (lines[i].dx, lines[i].dy)) / (FRACUNIT * 100.0f);
for (s = -1; (s = P_FindSectorFromTag(lines[i].args[0],s)) >= 0;) FSectorTagIterator itr(lines[i].args[0]);
while ((s = itr.Next()) >= 0)
sectors[s].gravity = grav; sectors[s].gravity = grav;
} }
break; break;
@ -1470,7 +1502,8 @@ void P_SpawnSpecials (void)
case Init_Damage: case Init_Damage:
{ {
int damage = P_AproxDistance (lines[i].dx, lines[i].dy) >> FRACBITS; int damage = P_AproxDistance (lines[i].dx, lines[i].dy) >> FRACBITS;
for (s = -1; (s = P_FindSectorFromTag(lines[i].args[0],s)) >= 0;) FSectorTagIterator itr(lines[i].args[0]);
while ((s = itr.Next()) >= 0)
{ {
sectors[s].damage = damage; sectors[s].damage = damage;
sectors[s].mod = 0;//MOD_UNKNOWN; sectors[s].mod = 0;//MOD_UNKNOWN;
@ -1493,10 +1526,13 @@ void P_SpawnSpecials (void)
// or ceiling texture, to distinguish floor and ceiling sky. // or ceiling texture, to distinguish floor and ceiling sky.
case Init_TransferSky: case Init_TransferSky:
for (s = -1; (s = P_FindSectorFromTag(lines[i].args[0],s)) >= 0;) {
FSectorTagIterator itr(lines[i].args[0]);
while ((s = itr.Next()) >= 0)
sectors[s].sky = (i + 1) | PL_SKYFLAT; sectors[s].sky = (i + 1) | PL_SKYFLAT;
break; break;
} }
}
break; break;
} }
} }
@ -1756,7 +1792,7 @@ static void P_SpawnScrollers(void)
if (lines[i].special == Sector_CopyScroller) if (lines[i].special == Sector_CopyScroller)
{ {
// don't allow copying the scroller if the sector has the same tag as it would just duplicate it. // don't allow copying the scroller if the sector has the same tag as it would just duplicate it.
if (lines[i].args[0] != lines[i].frontsector->tag) if (lines[i].frontsector->HasTag(lines[i].args[0]))
{ {
copyscrollers.Push(i); copyscrollers.Push(i);
} }
@ -1832,7 +1868,9 @@ static void P_SpawnScrollers(void)
register int s; register int s;
case Scroll_Ceiling: case Scroll_Ceiling:
for (s=-1; (s = P_FindSectorFromTag (l->args[0],s)) >= 0;) {
FSectorTagIterator itr(l->args[0]);
while ((s = itr.Next()) >= 0)
{ {
new DScroller(DScroller::sc_ceiling, -dx, dy, control, s, accel); new DScroller(DScroller::sc_ceiling, -dx, dy, control, s, accel);
} }
@ -1846,11 +1884,13 @@ static void P_SpawnScrollers(void)
} }
} }
break; break;
}
case Scroll_Floor: case Scroll_Floor:
if (l->args[2] != 1) if (l->args[2] != 1)
{ // scroll the floor texture { // scroll the floor texture
for (s=-1; (s = P_FindSectorFromTag (l->args[0],s)) >= 0;) FSectorTagIterator itr(l->args[0]);
while ((s = itr.Next()) >= 0)
{ {
new DScroller (DScroller::sc_floor, -dx, dy, control, s, accel); new DScroller (DScroller::sc_floor, -dx, dy, control, s, accel);
} }
@ -1867,7 +1907,8 @@ static void P_SpawnScrollers(void)
if (l->args[2] > 0) if (l->args[2] > 0)
{ // carry objects on the floor { // carry objects on the floor
for (s=-1; (s = P_FindSectorFromTag (l->args[0],s)) >= 0;) FSectorTagIterator itr(l->args[0]);
while ((s = itr.Next()) >= 0)
{ {
new DScroller (DScroller::sc_carry, dx, dy, control, s, accel); new DScroller (DScroller::sc_carry, dx, dy, control, s, accel);
} }
@ -1886,10 +1927,15 @@ static void P_SpawnScrollers(void)
// killough 3/1/98: scroll wall according to linedef // killough 3/1/98: scroll wall according to linedef
// (same direction and speed as scrolling floors) // (same direction and speed as scrolling floors)
case Scroll_Texture_Model: case Scroll_Texture_Model:
for (s=-1; (s = P_FindLineFromID (l->args[0],s)) >= 0;) {
FLineIdIterator itr(l->args[0]);
while ((s = itr.Next()) >= 0)
{
if (s != i) if (s != i)
new DScroller(dx, dy, lines + s, control, accel); new DScroller(dx, dy, lines + s, control, accel);
}
break; break;
}
case Scroll_Texture_Offsets: case Scroll_Texture_Offsets:
// killough 3/2/98: scroll according to sidedef offsets // killough 3/2/98: scroll according to sidedef offsets
@ -2041,7 +2087,8 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag)
// higher friction value actually means 'less friction'. // higher friction value actually means 'less friction'.
movefactor = FrictionToMoveFactor(friction); movefactor = FrictionToMoveFactor(friction);
for (s = -1; (s = P_FindSectorFromTag (tag,s)) >= 0; ) FSectorTagIterator itr(tag);
while ((s = itr.Next()) >= 0)
{ {
// killough 8/28/98: // killough 8/28/98:
// //
@ -2153,7 +2200,7 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle,
int DPusher::CheckForSectorMatch (EPusher type, int tag) int DPusher::CheckForSectorMatch (EPusher type, int tag)
{ {
if (m_Type == type && sectors[m_Affectee].tag == tag) if (m_Type == type && sectors[m_Affectee].HasTag(tag))
return m_Affectee; return m_Affectee;
else else
return -1; return -1;
@ -2356,20 +2403,27 @@ static void P_SpawnPushers ()
switch (l->special) switch (l->special)
{ {
case Sector_SetWind: // wind case Sector_SetWind: // wind
for (s = -1; (s = P_FindSectorFromTag (l->args[0],s)) >= 0 ; ) {
FSectorTagIterator itr(l->args[0]);
while ((s = itr.Next()) >= 0)
new DPusher(DPusher::p_wind, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s); new DPusher(DPusher::p_wind, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s);
l->special = 0; l->special = 0;
break; break;
}
case Sector_SetCurrent: // current case Sector_SetCurrent: // current
for (s = -1; (s = P_FindSectorFromTag (l->args[0],s)) >= 0 ; ) {
FSectorTagIterator itr(l->args[0]);
while ((s = itr.Next()) >= 0)
new DPusher(DPusher::p_current, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s); new DPusher(DPusher::p_current, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s);
l->special = 0; l->special = 0;
break; break;
}
case PointPush_SetForce: // push/pull case PointPush_SetForce: // push/pull
if (l->args[0]) { // [RH] Find thing by sector if (l->args[0]) { // [RH] Find thing by sector
for (s = -1; (s = P_FindSectorFromTag (l->args[0], s)) >= 0 ; ) FSectorTagIterator itr(l->args[0]);
while ((s = itr.Next()) >= 0)
{ {
AActor *thing = P_GetPushThing (s); AActor *thing = P_GetPushThing (s);
if (thing) { // No MT_P* means no effect if (thing) { // No MT_P* means no effect

View file

@ -242,10 +242,66 @@ inline sector_t *getNextSector (line_t *line, const sector_t *sec)
line->frontsector; line->frontsector;
} }
class FSectorTagIterator
{
protected:
int searchtag;
int start;
int P_FindSectorFromTag (int tag, int start); public:
int P_FindLineFromID (int id, int start); FSectorTagIterator(int tag)
{
searchtag = tag;
start = sectors[(unsigned)tag % (unsigned)numsectors].firsttag;
}
// Special constructor for actions that treat tag 0 as 'back of activation line'
FSectorTagIterator(int tag, line_t *line)
{
if (tag == 0)
{
searchtag = INT_MIN;
start = (line == NULL || line->backsector == NULL)? -1 : (int)(line->backsector - sectors);
}
else
{
searchtag = tag;
start = sectors[(unsigned)tag % (unsigned)numsectors].firsttag;
}
}
int Next();
int NextCompat(bool compat, int secnum);
};
class FLineIdIterator
{
protected:
int searchtag;
int start;
public:
FLineIdIterator(int id)
{
searchtag = id;
start = lines[(unsigned) id % (unsigned) numlines].firstid;
}
int Next();
};
inline int P_FindFirstSectorFromTag(int tag)
{
FSectorTagIterator it(tag);
return it.Next();
}
inline int P_FindFirstLineFromID(int tag)
{
FLineIdIterator it(tag);
return it.Next();
}
// //
// P_LIGHTS // P_LIGHTS

View file

@ -250,7 +250,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
int count = 0; int count = 0;
while ( (searcher = iterator.Next ()) ) while ( (searcher = iterator.Next ()) )
{ {
if (tag == 0 || searcher->Sector->tag == tag) if (tag == 0 || searcher->Sector->HasTag(tag))
{ {
count++; count++;
} }
@ -289,7 +289,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
while (count > 0) while (count > 0)
{ {
searcher = iterator.Next (); searcher = iterator.Next ();
if (tag == 0 || searcher->Sector->tag == tag) if (tag == 0 || searcher->Sector->HasTag(tag))
{ {
count--; count--;
} }
@ -300,9 +300,10 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
if (tag != 0) if (tag != 0)
{ {
int secnum = -1; int secnum;
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) FSectorTagIterator itr(tag);
while ((secnum = itr.Next()) >= 0)
{ {
// Scanning the snext links of things in the sector will not work, because // Scanning the snext links of things in the sector will not work, because
// TeleportDests have MF_NOSECTOR set. So you have to search *everything*. // TeleportDests have MF_NOSECTOR set. So you have to search *everything*.
@ -423,7 +424,8 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidedef[1] == NULL) if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidedef[1] == NULL)
return false; return false;
for (i = -1; (i = P_FindLineFromID (id, i)) >= 0; ) FLineIdIterator itr(id);
while ((i = itr.Next()) >= 0)
{ {
if (line-lines == i) if (line-lines == i)
continue; continue;
@ -726,7 +728,8 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro
int secnum; int secnum;
secnum = -1; secnum = -1;
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) FSectorTagIterator itr(tag);
while ((secnum = itr.Next()) >= 0)
{ {
msecnode_t *node; msecnode_t *node;
const sector_t * const sec = &sectors[secnum]; const sector_t * const sec = &sectors[secnum];

View file

@ -722,6 +722,7 @@ public:
break; break;
default: default:
CHECK_N(Zd | Zdt)
if (0 == strnicmp("user_", key.GetChars(), 5)) if (0 == strnicmp("user_", key.GetChars(), 5))
{ // Custom user key - Sets an actor's user variable directly { // Custom user key - Sets an actor's user variable directly
FMapThingUserData ud; FMapThingUserData ud;
@ -753,7 +754,7 @@ public:
mld.flags = 0; mld.flags = 0;
mld.special = th->special; mld.special = th->special;
mld.tag = th->args[0]; mld.tag = th->args[0];
P_TranslateLineDef(&ld, &mld); P_TranslateLineDef(&ld, &mld, true);
th->special = ld.special; th->special = ld.special;
memcpy(th->args, ld.args, sizeof (ld.args)); memcpy(th->args, ld.args, sizeof (ld.args));
} }
@ -780,7 +781,7 @@ public:
memset(ld, 0, sizeof(*ld)); memset(ld, 0, sizeof(*ld));
ld->Alpha = FRACUNIT; ld->Alpha = FRACUNIT;
ld->id = -1; ld->ClearIds();
ld->sidedef[0] = ld->sidedef[1] = NULL; ld->sidedef[0] = ld->sidedef[1] = NULL;
if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX; if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX;
if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX; if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX;
@ -813,7 +814,7 @@ public:
continue; continue;
case NAME_Id: case NAME_Id:
ld->id = CheckInt(key); ld->SetMainId(CheckInt(key));
continue; continue;
case NAME_Sidefront: case NAME_Sidefront:
@ -1040,7 +1041,20 @@ public:
break; break;
} }
if (!strnicmp("user_", key.GetChars(), 5)) #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
ld->SetId((short)CheckInt(key), false);
}
}
#endif
if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5))
{ {
AddUserKey(key, UDMF_Line, index); AddUserKey(key, UDMF_Line, index);
} }
@ -1053,8 +1067,8 @@ public:
maplinedef_t mld; maplinedef_t mld;
memset(&mld, 0, sizeof(mld)); memset(&mld, 0, sizeof(mld));
mld.special = ld->special; mld.special = ld->special;
mld.tag = ld->id; mld.tag = ld->GetMainId();
P_TranslateLineDef(ld, &mld); P_TranslateLineDef(ld, &mld, false);
ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY)); ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY));
} }
if (passuse && (ld->activation & SPAC_Use)) if (passuse && (ld->activation & SPAC_Use))
@ -1226,7 +1240,7 @@ public:
break; break;
} }
if (!strnicmp("user_", key.GetChars(), 5)) if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5))
{ {
AddUserKey(key, UDMF_Side, index); AddUserKey(key, UDMF_Side, index);
} }
@ -1316,7 +1330,7 @@ public:
continue; continue;
case NAME_Id: case NAME_Id:
sec->tag = (short)CheckInt(key); sec->SetMainTag((short)CheckInt(key));
continue; continue;
default: default:
@ -1497,8 +1511,20 @@ public:
default: default:
break; 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)) if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5))
{ {
AddUserKey(key, UDMF_Sector, index); AddUserKey(key, UDMF_Sector, index);
} }

View file

@ -295,23 +295,23 @@ player_t::player_t()
respawn_time(0), respawn_time(0),
camera(0), camera(0),
air_finished(0), air_finished(0),
MUSINFOactor(0),
MUSINFOtics(-1),
crouching(0),
crouchdir(0),
Bot(0), Bot(0),
BlendR(0), BlendR(0),
BlendG(0), BlendG(0),
BlendB(0), BlendB(0),
BlendA(0), BlendA(0),
LogText(), LogText(),
crouching(0),
crouchdir(0),
crouchfactor(0), crouchfactor(0),
crouchoffset(0), crouchoffset(0),
crouchviewdelta(0), crouchviewdelta(0),
ConversationNPC(0), ConversationNPC(0),
ConversationPC(0), ConversationPC(0),
ConversationNPCAngle(0), ConversationNPCAngle(0),
ConversationFaceTalker(0), ConversationFaceTalker(0)
MUSINFOactor(0),
MUSINFOtics(-1)
{ {
memset (&cmd, 0, sizeof(cmd)); memset (&cmd, 0, sizeof(cmd));
memset (frags, 0, sizeof(frags)); memset (frags, 0, sizeof(frags));

View file

@ -262,7 +262,7 @@ static int WriteSECTORS (FILE *file)
uppercopy (ms.ceilingpic, GetTextureName (sectors[i].GetTexture(sector_t::ceiling))); uppercopy (ms.ceilingpic, GetTextureName (sectors[i].GetTexture(sector_t::ceiling)));
ms.lightlevel = LittleShort((short)sectors[i].lightlevel); ms.lightlevel = LittleShort((short)sectors[i].lightlevel);
ms.special = LittleShort(sectors[i].special); ms.special = LittleShort(sectors[i].special);
ms.tag = LittleShort(sectors[i].tag); ms.tag = LittleShort(sectors[i].GetMainTag());
fwrite (&ms, sizeof(ms), 1, file); fwrite (&ms, sizeof(ms), 1, file);
} }
return numsectors * sizeof(ms); return numsectors * sizeof(ms);

View file

@ -60,7 +60,7 @@ typedef enum
PushMany, PushMany,
} triggertype_e; } triggertype_e;
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, bool setid)
{ {
unsigned short special = (unsigned short) LittleShort(mld->special); unsigned short special = (unsigned short) LittleShort(mld->special);
short tag = LittleShort(mld->tag); short tag = LittleShort(mld->tag);
@ -100,11 +100,14 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld)
} }
flags = newflags; flags = newflags;
if (setid)
{
// For purposes of maintaining BOOM compatibility, each // For purposes of maintaining BOOM compatibility, each
// line also needs to have its ID set to the same as its tag. // line also needs to have its ID set to the same as its tag.
// An external conversion program would need to do this more // An external conversion program would need to do this more
// intelligently. // intelligently.
ld->id = tag; ld->SetMainId(tag);
}
// 0 specials are never translated. // 0 specials are never translated.
if (special == 0) if (special == 0)
@ -304,7 +307,7 @@ void P_TranslateTeleportThings ()
while ( (dest = iterator.Next()) ) while ( (dest = iterator.Next()) )
{ {
if (dest->Sector->tag == 0) if (dest->Sector->GetMainTag() == 0)
{ {
dest->tid = 1; dest->tid = 1;
dest->AddToHash (); dest->AddToHash ();

View file

@ -686,6 +686,12 @@ struct sector_t
return pos == floor? floorplane:ceilingplane; return pos == floor? floorplane:ceilingplane;
} }
bool HasTag(int checktag) const;
void SetMainTag(int tagnum);
int GetMainTag() const;
void ClearTags();
static void HashTags();
bool PlaneMoving(int pos); bool PlaneMoving(int pos);
@ -989,6 +995,13 @@ struct line_t
sector_t *frontsector, *backsector; sector_t *frontsector, *backsector;
int validcount; // if == validcount, already checked int validcount; // if == validcount, already checked
int locknumber; // [Dusk] lock number for special 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 // phares 3/14/98

View file

@ -168,7 +168,7 @@ bool FZipFile::Open(bool quiet)
if (centraldir == 0) if (centraldir == 0)
{ {
if (!quiet) Printf("\n%s: ZIP file corrupt!\n", Filename); if (!quiet) Printf(TEXTCOLOR_RED "\n%s: ZIP file corrupt!\n", Filename);
return false; return false;
} }
@ -180,7 +180,7 @@ bool FZipFile::Open(bool quiet)
if (info.NumEntries != info.NumEntriesOnAllDisks || if (info.NumEntries != info.NumEntriesOnAllDisks ||
info.FirstDisk != 0 || info.DiskNumber != 0) info.FirstDisk != 0 || info.DiskNumber != 0)
{ {
if (!quiet) Printf("\n%s: Multipart Zip files are not supported.\n", Filename); if (!quiet) Printf(TEXTCOLOR_RED "\n%s: Multipart Zip files are not supported.\n", Filename);
return false; return false;
} }
@ -188,9 +188,10 @@ bool FZipFile::Open(bool quiet)
Lumps = new FZipLump[NumLumps]; Lumps = new FZipLump[NumLumps];
// Load the entire central directory. Too bad that this contains variable length entries... // Load the entire central directory. Too bad that this contains variable length entries...
void *directory = malloc(LittleLong(info.DirectorySize)); int dirsize = LittleLong(info.DirectorySize);
void *directory = malloc(dirsize);
Reader->Seek(LittleLong(info.DirectoryOffset), SEEK_SET); Reader->Seek(LittleLong(info.DirectoryOffset), SEEK_SET);
Reader->Read(directory, LittleLong(info.DirectorySize)); Reader->Read(directory, dirsize);
char *dirptr = (char*)directory; char *dirptr = (char*)directory;
FZipLump *lump_p = Lumps; FZipLump *lump_p = Lumps;
@ -205,6 +206,13 @@ bool FZipFile::Open(bool quiet)
LittleShort(zip_fh->ExtraLength) + LittleShort(zip_fh->ExtraLength) +
LittleShort(zip_fh->CommentLength); LittleShort(zip_fh->CommentLength);
if (dirptr > ((char*)directory) + dirsize) // This directory entry goes beyond the end of the file.
{
free(directory);
if (!quiet) Printf(TEXTCOLOR_RED "\n%s: Central directory corrupted.", Filename);
return false;
}
// skip Directories // skip Directories
if (name[len - 1] == '/' && LittleLong(zip_fh->UncompressedSize) == 0) if (name[len - 1] == '/' && LittleLong(zip_fh->UncompressedSize) == 0)
{ {
@ -221,7 +229,7 @@ bool FZipFile::Open(bool quiet)
zip_fh->Method != METHOD_IMPLODE && zip_fh->Method != METHOD_IMPLODE &&
zip_fh->Method != METHOD_SHRINK) zip_fh->Method != METHOD_SHRINK)
{ {
if (!quiet) Printf("\n%s: '%s' uses an unsupported compression algorithm (#%d).\n", Filename, name.GetChars(), zip_fh->Method); if (!quiet) Printf(TEXTCOLOR_YELLOW "\n%s: '%s' uses an unsupported compression algorithm (#%d).\n", Filename, name.GetChars(), zip_fh->Method);
skipped++; skipped++;
continue; continue;
} }
@ -229,7 +237,7 @@ bool FZipFile::Open(bool quiet)
zip_fh->Flags = LittleShort(zip_fh->Flags); zip_fh->Flags = LittleShort(zip_fh->Flags);
if (zip_fh->Flags & ZF_ENCRYPTED) if (zip_fh->Flags & ZF_ENCRYPTED)
{ {
if (!quiet) Printf("\n%s: '%s' is encrypted. Encryption is not supported.\n", Filename, name.GetChars()); if (!quiet) Printf(TEXTCOLOR_YELLOW "\n%s: '%s' is encrypted. Encryption is not supported.\n", Filename, name.GetChars());
skipped++; skipped++;
continue; continue;
} }
@ -260,7 +268,7 @@ bool FZipFile::Open(bool quiet)
NumLumps -= skipped; NumLumps -= skipped;
free(directory); free(directory);
if (!quiet) Printf(", %d lumps\n", NumLumps); if (!quiet) Printf(TEXTCOLOR_NORMAL ", %d lumps\n", NumLumps);
PostProcessArchive(&Lumps[0], sizeof(FZipLump)); PostProcessArchive(&Lumps[0], sizeof(FZipLump));
return true; return true;

View file

@ -177,8 +177,8 @@ void FTextureManager::InitAnimated (void)
{ {
FMemLump animatedlump = Wads.ReadLump (lumpnum); FMemLump animatedlump = Wads.ReadLump (lumpnum);
int animatedlen = Wads.LumpLength(lumpnum); int animatedlen = Wads.LumpLength(lumpnum);
const char *animdefs = (const char *)animatedlump.GetMem(); const BYTE *animdefs = (const BYTE *)animatedlump.GetMem();
const char *anim_p; const BYTE *anim_p;
FTextureID pic1, pic2; FTextureID pic1, pic2;
int animtype; int animtype;
DWORD animspeed; DWORD animspeed;
@ -186,7 +186,7 @@ void FTextureManager::InitAnimated (void)
// Init animation // Init animation
animtype = FAnimDef::ANIM_Forward; animtype = FAnimDef::ANIM_Forward;
for (anim_p = animdefs; *anim_p != -1; anim_p += 23) for (anim_p = animdefs; *anim_p != 0xFF; anim_p += 23)
{ {
// make sure the current chunk of data is inside the lump boundaries. // make sure the current chunk of data is inside the lump boundaries.
if (anim_p + 22 >= animdefs + animatedlen) if (anim_p + 22 >= animdefs + animatedlen)
@ -196,8 +196,8 @@ void FTextureManager::InitAnimated (void)
if (*anim_p /* .istexture */ & 1) if (*anim_p /* .istexture */ & 1)
{ {
// different episode ? // different episode ?
if (!(pic1 = CheckForTexture (anim_p + 10 /* .startname */, FTexture::TEX_Wall, texflags)).Exists() || if (!(pic1 = CheckForTexture ((const char*)(anim_p + 10) /* .startname */, FTexture::TEX_Wall, texflags)).Exists() ||
!(pic2 = CheckForTexture (anim_p + 1 /* .endname */, FTexture::TEX_Wall, texflags)).Exists()) !(pic2 = CheckForTexture ((const char*)(anim_p + 1) /* .endname */, FTexture::TEX_Wall, texflags)).Exists())
continue; continue;
// [RH] Bit 1 set means allow decals on walls with this texture // [RH] Bit 1 set means allow decals on walls with this texture
@ -205,16 +205,16 @@ void FTextureManager::InitAnimated (void)
} }
else else
{ {
if (!(pic1 = CheckForTexture (anim_p + 10 /* .startname */, FTexture::TEX_Flat, texflags)).Exists() || if (!(pic1 = CheckForTexture ((const char*)(anim_p + 10) /* .startname */, FTexture::TEX_Flat, texflags)).Exists() ||
!(pic2 = CheckForTexture (anim_p + 1 /* .startname */, FTexture::TEX_Flat, texflags)).Exists()) !(pic2 = CheckForTexture ((const char*)(anim_p + 1) /* .startname */, FTexture::TEX_Flat, texflags)).Exists())
continue; continue;
} }
FTexture *tex1 = Texture(pic1); FTexture *tex1 = Texture(pic1);
FTexture *tex2 = Texture(pic2); FTexture *tex2 = Texture(pic2);
animspeed = (BYTE(anim_p[19]) << 0) | (BYTE(anim_p[20]) << 8) | animspeed = (anim_p[19] << 0) | (anim_p[20] << 8) |
(BYTE(anim_p[21]) << 16) | (BYTE(anim_p[22]) << 24); (anim_p[21] << 16) | (anim_p[22] << 24);
// SMMU-style swirly hack? Don't apply on already-warping texture // SMMU-style swirly hack? Don't apply on already-warping texture
if (animspeed > 65535 && tex1 != NULL && !tex1->bWarped) if (animspeed > 65535 && tex1 != NULL && !tex1->bWarped)
@ -242,7 +242,7 @@ void FTextureManager::InitAnimated (void)
if (pic1 == pic2) if (pic1 == pic2)
{ {
// This animation only has one frame. Skip it. (Doom aborted instead.) // This animation only has one frame. Skip it. (Doom aborted instead.)
Printf ("Animation %s in ANIMATED has only one frame\n", anim_p + 10); Printf ("Animation %s in ANIMATED has only one frame\n", (const char*)(anim_p + 10));
continue; continue;
} }
// [RH] Allow for backward animations as well as forward. // [RH] Allow for backward animations as well as forward.

View file

@ -70,6 +70,7 @@
#include "m_bbox.h" #include "m_bbox.h"
#include "r_data/r_translate.h" #include "r_data/r_translate.h"
#include "p_trace.h" #include "p_trace.h"
#include "p_setup.h"
#include "gstrings.h" #include "gstrings.h"
@ -4506,7 +4507,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Weave)
//=========================================================================== //===========================================================================
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld);
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect)
{ {
ACTION_PARAM_START(2); ACTION_PARAM_START(2);
@ -4520,7 +4520,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect)
if ((oldjunk.special = special)) // Linedef type if ((oldjunk.special = special)) // Linedef type
{ {
oldjunk.tag = tag; // Sector tag for linedef oldjunk.tag = tag; // Sector tag for linedef
P_TranslateLineDef(&junk, &oldjunk); // Turn into native type P_TranslateLineDef(&junk, &oldjunk, false); // Turn into native type
res = !!P_ExecuteSpecial(junk.special, NULL, self, false, junk.args[0], res = !!P_ExecuteSpecial(junk.special, NULL, self, false, junk.args[0],
junk.args[1], junk.args[2], junk.args[3], junk.args[4]); junk.args[1], junk.args[2], junk.args[3], junk.args[4]);
if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once, if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once,

View file

@ -317,7 +317,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo)
sprintf(cksumout + (j * 2), "%02X", cksum[j]); sprintf(cksumout + (j * 2), "%02X", cksum[j]);
} }
fprintf(hashfile, "file: %s, hash: %s, size: %d\n", filename, cksumout, reader->GetLength()); fprintf(hashfile, "file: %s, hash: %s, size: %ld\n", filename, cksumout, reader->GetLength());
} }
else else

View file

@ -1,144 +1,144 @@
conversationids conversationids
{ {
2 WeaponSmith 2 = WeaponSmith
3 BarKeep 3 = BarKeep
4 Armorer 4 = Armorer
5 Medic 5 = Medic
6 Peasant1 6 = Peasant1
7 Peasant2 7 = Peasant2
8 Peasant3 8 = Peasant3
9 Peasant4 9 = Peasant4
10 Peasant5 10 = Peasant5
11 Peasant6 11 = Peasant6
12 Peasant7 12 = Peasant7
13 Peasant8 13 = Peasant8
14 Peasant9 14 = Peasant9
15 Peasant10 15 = Peasant10
16 Peasant11 16 = Peasant11
17 Peasant12 17 = Peasant12
18 Peasant13 18 = Peasant13
19 Peasant14 19 = Peasant14
20 Peasant15 20 = Peasant15
21 Peasant16 21 = Peasant16
22 Peasant17 22 = Peasant17
23 Peasant18 23 = Peasant18
24 Peasant19 24 = Peasant19
25 Peasant20 25 = Peasant20
26 Peasant21 26 = Peasant21
27 Peasant22 27 = Peasant22
37 Beggar1 37 = Beggar1
38 Beggar2 38 = Beggar2
39 Beggar3 39 = Beggar3
40 Beggar4 40 = Beggar4
41 Beggar5 41 = Beggar5
42 Rebel1 42 = Rebel1
43 Rebel2 43 = Rebel2
44 Rebel3 44 = Rebel3
45 Rebel4 45 = Rebel4
46 Rebel5 46 = Rebel5
47 Rebel6 47 = Rebel6
48 Macil1 48 = Macil1
49 Macil2 49 = Macil2
52 AcolyteTan 52 = AcolyteTan
53 AcolyteRed 53 = AcolyteRed
54 AcolyteRust 54 = AcolyteRust
55 AcolyteGray 55 = AcolyteGray
56 AcolyteDGreen 56 = AcolyteDGreen
57 AcolyteGold 57 = AcolyteGold
58 AcolyteShadow 58 = AcolyteShadow
61 Templar 61 = Templar
62 Oracle 62 = Oracle
63 Loremaster 63 = Loremaster
70 AlienSpectre2 70 = AlienSpectre2
94 InquisitorArm 94 = InquisitorArm
121 MedPatch 121 = MedPatch
122 MedicalKit 122 = MedicalKit
123 SurgeryKit 123 = SurgeryKit
124 DegninOre 124 = DegninOre
125 MetalArmor 125 = MetalArmor
126 LeatherArmor 126 = LeatherArmor
129 BaseKey 129 = BaseKey
130 GovsKey 130 = GovsKey
131 Passcard 131 = Passcard
132 IDBadge 132 = IDBadge
133 PrisonKey 133 = PrisonKey
134 SeveredHand 134 = SeveredHand
135 Power1Key 135 = Power1Key
136 Power2Key 136 = Power2Key
137 Power3Key 137 = Power3Key
138 GoldKey 138 = GoldKey
139 IDCard 139 = IDCard
140 SilverKey 140 = SilverKey
141 OracleKey 141 = OracleKey
142 MilitaryID 142 = MilitaryID
143 OrderKey 143 = OrderKey
144 WarehouseKey 144 = WarehouseKey
145 BrassKey 145 = BrassKey
146 RedCrystalKey 146 = RedCrystalKey
147 BlueCrystalKey 147 = BlueCrystalKey
148 ChapelKey 148 = ChapelKey
149 CatacombKey 149 = CatacombKey
150 SecurityKey 150 = SecurityKey
151 CoreKey 151 = CoreKey
152 MaulerKey 152 = MaulerKey
153 FactoryKey 153 = FactoryKey
154 MineKey 154 = MineKey
155 NewKey5 155 = NewKey5
156 ShadowArmor 156 = ShadowArmor
157 EnvironmentalSuit 157 = EnvironmentalSuit
158 GuardUniform 158 = GuardUniform
159 OfficersUniform 159 = OfficersUniform
160 StrifeMap 160 = StrifeMap
161 Coin 161 = Coin
162 Gold10 162 = Gold10
163 Gold25 163 = Gold25
164 Gold50 164 = Gold50
165 BeldinsRing 165 = BeldinsRing
166 OfferingChalice 166 = OfferingChalice
167 Ear 167 = Ear
168 Communicator 168 = Communicator
169 Targeter 169 = Targeter
170 HEGrenadeRounds 170 = HEGrenadeRounds
171 PhosphorusGrenadeRounds 171 = PhosphorusGrenadeRounds
173 ClipOfBullets 173 = ClipOfBullets
174 BoxOfBullets 174 = BoxOfBullets
175 MiniMissiles 175 = MiniMissiles
176 CrateOfMissiles 176 = CrateOfMissiles
177 EnergyPod 177 = EnergyPod
178 EnergyPack 178 = EnergyPack
179 PoisonBolts 179 = PoisonBolts
180 ElectricBolts 180 = ElectricBolts
181 AmmoSatchel 181 = AmmoSatchel
182 AssaultGun 182 = AssaultGun
183 AssaultGunStanding 183 = AssaultGunStanding
184 FlameThrower 184 = FlameThrower
185 FlameThrowerParts 185 = FlameThrowerParts
186 MiniMissileLauncher 186 = MiniMissileLauncher
187 Mauler 187 = Mauler
188 StrifeCrossbow 188 = StrifeCrossbow
189 StrifeGrenadeLauncher 189 = StrifeGrenadeLauncher
190 Sigil1 190 = Sigil1
191 Sigil2 191 = Sigil2
192 Sigil3 192 = Sigil3
193 Sigil4 193 = Sigil4
194 Sigil5 194 = Sigil5
196 RatBuddy 196 = RatBuddy
230 DeadCrusader 230 = DeadCrusader
280 AmmoFillup 280 = AmmoFillup
281 HealthFillup 281 = HealthFillup
282 info 282 = info
283 RaiseAlarm 283 = RaiseAlarm
284 OpenDoor222 284 = OpenDoor222
285 CloseDoor222 285 = CloseDoor222
286 PrisonPass 286 = PrisonPass
287 UpgradeStamina 287 = UpgradeStamina
288 UpgradeAccuracy 288 = UpgradeAccuracy
289 InterrogatorReport 289 = InterrogatorReport
292 OraclePass 292 = OraclePass
293 QuestItem1 293 = QuestItem1
294 QuestItem2 294 = QuestItem2
295 QuestItem3 295 = QuestItem3
296 QuestItem4 296 = QuestItem4
297 QuestItem5 297 = QuestItem5
298 QuestItem6 298 = QuestItem6
} }