diff --git a/src/compatibility.cpp b/src/compatibility.cpp index fd309ec8b..096811def 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -551,7 +551,8 @@ void SetCompatibilityParams() { 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; break; diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 0bddcd7fd..a0609377e 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -67,6 +67,7 @@ #include "v_font.h" #include "r_data/colormaps.h" #include "farchive.h" +#include "p_setup.h" static FRandom pr_script("FScript"); @@ -312,18 +313,24 @@ static int T_GetPlayerNum(const svalue_t &arg) // 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; - if (-tagnumSector->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]); int i=-1; - while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) + FSSectorTagIterator itr(tagnum); + while ((i = itr.Next()) >= 0) { sector = §ors[i]; 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 - 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! @@ -1612,7 +1621,7 @@ void FParser::SF_FloorHeight(void) } else { - secnum = T_FindSectorFromTag(tagnum, -1); + secnum = T_FindFirstSectorFromTag(tagnum); if(secnum < 0) { script_error("sector not found with tagnum %i\n", tagnum); @@ -1671,7 +1680,8 @@ void FParser::SF_MoveFloor(void) // move all sectors with tag - while ((secnum = T_FindSectorFromTag(tagnum, secnum)) >= 0) + FSSectorTagIterator itr(tagnum); + while ((secnum = itr.Next()) >= 0) { sec = §ors[secnum]; // Don't start a second thinker on the same floor @@ -1733,7 +1743,8 @@ void FParser::SF_CeilingHeight(void) dest = fixedvalue(t_argv[1]); // 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! @@ -1750,7 +1761,7 @@ void FParser::SF_CeilingHeight(void) } else { - secnum = T_FindSectorFromTag(tagnum, -1); + secnum = T_FindFirstSectorFromTag(tagnum); if(secnum < 0) { 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; // move all sectors with tag - while ((secnum = T_FindSectorFromTag(tagnum, secnum)) >= 0) + FSSectorTagIterator itr(tagnum); + while ((secnum = itr.Next()) >= 0) { sec = §ors[secnum]; @@ -1851,7 +1863,7 @@ void FParser::SF_LightLevel(void) tagnum = intvalue(t_argv[0]); // argv is sector tag - secnum = T_FindSectorFromTag(tagnum, -1); + secnum = T_FindFirstSectorFromTag(tagnum); if(secnum < 0) { @@ -1865,7 +1877,8 @@ void FParser::SF_LightLevel(void) int i = -1; // 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])); } @@ -1984,7 +1997,8 @@ void FParser::SF_FadeLight(void) destlevel = intvalue(t_argv[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(§ors[i],destlevel,speed); } @@ -2006,7 +2020,7 @@ void FParser::SF_FloorTexture(void) tagnum = intvalue(t_argv[0]); // argv is sector tag - secnum = T_FindSectorFromTag(tagnum, -1); + secnum = T_FindFirstSectorFromTag(tagnum); if(secnum < 0) { 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); // 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); } @@ -2057,7 +2072,7 @@ void FParser::SF_SectorColormap(void) tagnum = intvalue(t_argv[0]); // argv is sector tag - secnum = T_FindSectorFromTag(tagnum, -1); + secnum = T_FindFirstSectorFromTag(tagnum); if(secnum < 0) { 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); - while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) + FSSectorTagIterator itr(tagnum); + while ((i = itr.Next()) >= 0) { sectors[i].midmap=cm; sectors[i].heightsec=§ors[i]; @@ -2094,7 +2110,7 @@ void FParser::SF_CeilingTexture(void) tagnum = intvalue(t_argv[0]); // argv is sector tag - secnum = T_FindSectorFromTag(tagnum, -1); + secnum = T_FindFirstSectorFromTag(tagnum); if(secnum < 0) { 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); // 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); } @@ -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() { if (CheckArgs(1)) @@ -2221,7 +2235,7 @@ void FParser::SF_LineTrigger() maplinedef_t mld; mld.special=intvalue(t_argv[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, line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]); } @@ -2281,9 +2295,11 @@ void FParser::SF_SetLineBlocking(void) { blocking=blocks[blocking]; 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 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; } @@ -2357,12 +2375,13 @@ void FParser::SF_SetLineTexture(void) texture = stringvalue(t_argv[3]); 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! - if(lines[i].sidedef[side] != NULL) + if (lines[i].sidedef[side] != NULL) { - if (position >=0 && position <=2) + if (position >= 0 && position <= 2) { lines[i].sidedef[side]->SetTexture(position, texturenum); } @@ -2376,7 +2395,8 @@ void FParser::SF_SetLineTexture(void) int sections = intvalue(t_argv[3]); // 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]; if(sided != NULL) @@ -4201,7 +4221,7 @@ void FParser::SF_SetColor(void) { tagnum = intvalue(t_argv[0]); - secnum = T_FindSectorFromTag(tagnum, -1); + secnum = T_FindFirstSectorFromTag(tagnum); if(secnum < 0) { @@ -4222,7 +4242,8 @@ void FParser::SF_SetColor(void) else return; // 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); } @@ -4291,7 +4312,7 @@ void FParser::SF_KillInSector() while ((mo=it.Next())) { - if (mo->flags3&MF3_ISMONSTER && mo->Sector->tag==tag) P_DamageMobj(mo, NULL, NULL, 1000000, NAME_Massacre); + if (mo->flags3&MF3_ISMONSTER && mo->Sector->HasTag(tag)) P_DamageMobj(mo, NULL, NULL, 1000000, NAME_Massacre); } } } @@ -4314,7 +4335,7 @@ void FParser::SF_SectorType(void) tagnum = intvalue(t_argv[0]); // argv is sector tag - secnum = T_FindSectorFromTag(tagnum, -1); + secnum = T_FindFirstSectorFromTag(tagnum); if(secnum < 0) { 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]); // set all sectors with tag - while ((i = T_FindSectorFromTag(tagnum, i)) >= 0) + FSSectorTagIterator itr(tagnum); + while ((i = itr.Next()) >= 0) { sectors[i].special = spec; } @@ -4355,18 +4377,17 @@ void FParser::SF_SetLineTrigger() id=intvalue(t_argv[0]); spec=intvalue(t_argv[1]); 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; - mld.special=spec; - mld.tag=tag; - mld.flags=0; + mld.special = spec; + mld.tag = tag; + mld.flags = 0; int f = lines[i].flags; - P_TranslateLineDef(&lines[i], &mld); - lines[i].id=tag; - lines[i].flags = (lines[i].flags & (ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_SPAC_MASK|ML_FIRSTSIDEONLY)) | - (f & ~(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_SPAC_MASK|ML_FIRSTSIDEONLY)); + P_TranslateLineDef(&lines[i], &mld, false); + 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)); } } @@ -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() { - if (CheckArgs(2)) - { - 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; - } - } + // Development garbage! } diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index 09c65d073..98911a418 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -452,9 +452,9 @@ bool DFraggleThinker::wait_finished(DRunningScript *script) case wt_tagwait: { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag(script->wait_data, secnum)) >= 0) + int secnum; + FSectorTagIterator itr(script->wait_data); + while ((secnum = itr.Next()) >= 0) { sector_t *sec = §ors[secnum]; if(sec->floordata || sec->ceilingdata || sec->lightingdata) diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 14b270435..87491073e 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1757,6 +1757,7 @@ IMPLEMENT_CLASS(APowerRegeneration) void APowerRegeneration::DoEffect() { + Super::DoEffect(); if (Owner != NULL && Owner->health > 0 && (level.time & 31) == 0) { if (P_GiveBody(Owner, Strength/FRACUNIT)) diff --git a/src/g_shared/a_skies.cpp b/src/g_shared/a_skies.cpp index 616b87c9e..d62a2a07b 100644 --- a/src/g_shared/a_skies.cpp +++ b/src/g_shared/a_skies.cpp @@ -119,7 +119,9 @@ void ASkyCamCompat::BeginPlay () // Finally, skyboxify all tagged sectors // This involves changing their texture to the sky flat, because while // 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 if (refline->args[2] == 1 || refline->args[2] == 2) diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index 95b0030a0..aa9f629db 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -636,7 +636,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) } else if ((sec->special & 0xFF) == Scroll_StrifeCurrent) { - int anglespeed = sec->tag - 100; + int anglespeed = sec->GetMainTag() - 100; fixed_t speed = (anglespeed % 10) << (FRACBITS - 4); angle_t finean = (anglespeed / 10) << (32-3); finean >>= ANGLETOFINESHIFT; diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index c4f970db9..30dc2276d 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -429,7 +429,7 @@ void FGameConfigFile::DoKeySetup(const char *gamename) { "Bindings", &Bindings }, { "DoubleBindings", &DoubleBindings }, { "AutomapBindings", &AutomapBindings }, - NULL, NULL + { NULL, NULL } }; const char *key, *value; diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index bc3805074..ae1c31a86 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -490,7 +490,7 @@ void P_Recalculate3DFloors(sector_t * sector) // by the clipping code below. 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 if (solid != NULL && solid_bottom < height) diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 7f934e2f5..ff0d3a181 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -143,7 +143,9 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c 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]; @@ -157,13 +159,15 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c } 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 ++) { 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)) { diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 5556507b7..9ea8624f6 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1341,7 +1341,7 @@ DPlaneWatcher::DPlaneWatcher (AActor *it, line_t *line, int lineSide, bool ceili { int secnum; - secnum = P_FindSectorFromTag (tag, -1); + secnum = P_FindFirstSectorFromTag (tag); if (secnum >= 0) { secplane_t plane; @@ -3211,7 +3211,7 @@ do_count: if (actor->health > 0 && (kind == NULL || actor->IsA (kind))) { - if (actor->Sector->tag == tag || tag == -1) + if (actor->Sector->HasTag(tag) || tag == -1) { // Don't count items in somebody's inventory if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) || @@ -3231,7 +3231,7 @@ do_count: if (actor->health > 0 && (kind == NULL || actor->IsA (kind))) { - if (actor->Sector->tag == tag || tag == -1) + if (actor->Sector->HasTag(tag) || tag == -1) { // Don't count items in somebody's inventory if (!actor->IsKindOf (RUNTIME_CLASS(AInventory)) || @@ -3268,7 +3268,8 @@ void DLevelScript::ChangeFlat (int tag, int name, bool floorOrCeiling) 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; 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); - while ((linenum = P_FindLineFromID (lineid, linenum)) >= 0) + FLineIdIterator itr(lineid); + while ((linenum = itr.Next()) >= 0) { side_t *sidedef; @@ -4457,7 +4459,7 @@ int DLevelScript::SideFromID(int id, int side) } else { - int line = P_FindLineFromID(id, -1); + int line = P_FindFirstLineFromID(id); if (line == -1) return -1; if (lines[line].sidedef[side] == NULL) return -1; return lines[line].sidedef[side]->Index; @@ -4473,7 +4475,7 @@ int DLevelScript::LineFromID(int id) } 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 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: - 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: 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]; if (seqname != NULL) { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0) + FSectorTagIterator it(args[0]); + int s; + while ((s = it.Next()) >= 0) { - SN_StartSequence(§ors[secnum], args[2], seqname, 0); + SN_StartSequence(§ors[s], args[2], seqname, 0); } } } @@ -5692,9 +5694,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_SetLineActivation: if (argCount >= 2) { - int line = -1; - - while ((line = P_FindLineFromID(args[0], line)) >= 0) + int line; + FLineIdIterator itr(args[0]); + while ((line = itr.Next()) >= 0) { lines[line].activation = args[1]; } @@ -5704,7 +5706,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetLineActivation: if (argCount > 0) { - int line = P_FindLineFromID(args[0], -1); + int line = P_FindFirstLineFromID(args[0]); return line >= 0 ? lines[line].activation : 0; } break; @@ -5952,11 +5954,13 @@ int DLevelScript::RunScript () // Wait for tagged sector(s) to go inactive, then enter // state running { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag (statedata, secnum)) >= 0) + int secnum; + FSectorTagIterator it(statedata); + while ((secnum = it.Next()) >= 0) + { if (sectors[secnum].floordata || sectors[secnum].ceilingdata) return resultValue; + } // If we got here, none of the tagged sectors were busy state = SCRIPT_Running; @@ -7996,9 +8000,10 @@ scriptwait: 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)) { @@ -8031,9 +8036,10 @@ scriptwait: 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)) lines[line].flags |= ML_BLOCKMONSTERS; @@ -8058,7 +8064,8 @@ scriptwait: 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->special = specnum; @@ -8518,7 +8525,7 @@ scriptwait: fixed_t z = 0; if (tag != 0) - secnum = P_FindSectorFromTag (tag, -1); + secnum = P_FindFirstSectorFromTag (tag); else secnum = int(P_PointInSector (x, y) - sectors); @@ -8540,7 +8547,7 @@ scriptwait: case PCD_GETSECTORLIGHTLEVEL: { - int secnum = P_FindSectorFromTag (STACK(1), -1); + int secnum = P_FindFirstSectorFromTag (STACK(1)); int z = -1; if (secnum >= 0) diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index d0c54761a..7efef80a5 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -510,9 +510,9 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, P_ActivateInStasisCeiling (tag); } - secnum = -1; // 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(§ors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); } diff --git a/src/p_doors.cpp b/src/p_doors.cpp index 844f23af9..49ed20f46 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -484,8 +484,8 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing, else { // [RH] Remote door - secnum = -1; - while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0) + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sec = §ors[secnum]; // 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; } - while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sec = §ors[secnum]; if (sec->ceilingdata != NULL) diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 9a5a6eaf8..97e23571b 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -290,28 +290,13 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, rtn = false; // check if a manual trigger; if so do just the sector on the backside - if (tag == 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) + FSectorTagIterator it(tag, line); + while ((secnum = it.Next()) >= 0) { sec = §ors[secnum]; - -manual_floor: // ALREADY MOVING? IF SO, KEEP GOING... 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; } @@ -545,9 +530,9 @@ manual_floor: bool EV_FloorCrushStop (int tag) { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) + int secnum; + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sector_t *sec = sectors + secnum; @@ -562,21 +547,6 @@ bool EV_FloorCrushStop (int tag) 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> 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 - if (tag == 0) - { - if (!line || !(sec = line->backsector)) - return rtn; - secnum = (int)(sec-sectors); - manual = true; - goto manual_stair; - } - + FSectorTagIterator itr(tag, line); // The compatibility mode doesn't work with a hashing algorithm. // It needs the original linear search method. This was broken in Boom. - - secnum = -1; - while ((secnum = FindSector (tag, secnum)) >= 0) + bool compatible = tag != 0 && (i_compatflags & COMPATF_STAIRINDEX); + while ((secnum = itr.NextCompat(compatible, secnum)) >= 0) { sec = §ors[secnum]; -manual_stair: // ALREADY MOVING? IF SO, KEEP GOING... //jff 2/26/98 add special lockout condition to wait for entire //staircase to build before retriggering if (sec->PlaneMoving(sector_t::floor) || sec->stairlock) { - if (!manual) - continue; - else - return rtn; + continue; } // new floor thinker @@ -781,14 +734,6 @@ manual_stair: // [RH] make sure the first sector doesn't point to a previous one, otherwise // it can infinite loop when the first sector stops moving. sectors[osecnum].prevsec = -1; - if (manual) - { - return rtn; - } - if (!(i_compatflags & COMPATF_STAIRINDEX)) - { - secnum = osecnum; //jff 3/4/98 restore loop index - } } return rtn; } @@ -811,21 +756,13 @@ bool EV_DoDonut (int tag, line_t *line, fixed_t pillarspeed, fixed_t slimespeed) vertex_t* spot; fixed_t height; - secnum = -1; rtn = false; - if (tag == 0) - { - if (!line || !(s1 = line->backsector)) - return rtn; - goto manual_donut; - } - - while (tag && (secnum = P_FindSectorFromTag(tag,secnum)) >= 0) + FSectorTagIterator itr(tag, line); + while ((secnum = itr.Next()) >= 0) { s1 = §ors[secnum]; // s1 is pillar's sector -manual_donut: // ALREADY MOVING? IF SO, KEEP GOING... if (s1->PlaneMoving(sector_t::floor)) 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; rtn = false; - if (tag == 0) - { - if (!line || !(sec = line->backsector)) - return rtn; - goto manual_elevator; - } - + FSectorTagIterator itr(tag, line); // 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 = §ors[secnum]; -manual_elevator: // If either floor or ceiling is already activated, skip it 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] @@ -1142,10 +1072,10 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag) sector_t *sec; sector_t *secm; - secnum = -1; rtn = false; // 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 = §ors[secnum]; @@ -1374,20 +1304,12 @@ bool EV_StartWaggle (int tag, line_t *line, int height, int speed, int offset, bool retCode; retCode = false; - sectorIndex = -1; - if (tag == 0) - { - if (!line || !(sector = line->backsector)) - return retCode; - goto manual_waggle; - } + FSectorTagIterator itr(tag, line); - - while (tag && (sectorIndex = P_FindSectorFromTag(tag, sectorIndex)) >= 0) + while ((sectorIndex = itr.Next()) >= 0) { sector = §ors[sectorIndex]; -manual_waggle: if ((!ceiling && sector->PlaneMoving(sector_t::floor)) || (ceiling && sector->PlaneMoving(sector_t::ceiling))) { // Already busy with another thinker diff --git a/src/p_lights.cpp b/src/p_lights.cpp index 878b1f5c3..b4bfa1669 100644 --- a/src/p_lights.cpp +++ b/src/p_lights.cpp @@ -189,9 +189,8 @@ DFlicker::DFlicker (sector_t *sector, int upper, int lower) void EV_StartLightFlickering (int tag, int upper, int lower) { int secnum; - - secnum = -1; - while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0) + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { new DFlicker (§ors[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) { int secnum; - - secnum = -1; - while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0) + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sector_t *sec = §ors[secnum]; 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) { int secnum; - - secnum = -1; - while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0) + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sector_t *sec = §ors[secnum]; if (sec->lightingdata) @@ -396,16 +393,14 @@ void EV_StartLightStrobing (int tag, int utics, int ltics) void EV_TurnTagLightsOff (int tag) { - int i; int secnum; - - // [RH] Don't do a linear search - for (secnum = -1; (secnum = P_FindSectorFromTag (tag, secnum)) >= 0; ) + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sector_t *sector = sectors + secnum; 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); if (!tsec) @@ -427,10 +422,9 @@ void EV_TurnTagLightsOff (int tag) void EV_LightTurnOn (int tag, int bright) { - int secnum = -1; - - // [RH] Don't do a linear search - while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) + int secnum; + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sector_t *sector = sectors + secnum; 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) { - int i; - frac = clamp (frac, 0, FRACUNIT); // Search all sectors for ones with same tag as activating line - i = -1; - while ((i = P_FindSectorFromTag (tag, i)) >= 0) + int secnum; + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { - sector_t *temp, *sector = sectors + i; + sector_t *temp, *sector = §ors[secnum]; int j, bright = 0, min = sector->lightlevel; 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) { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) + int secnum; + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sectors[secnum].SetLightLevel(sectors[secnum].lightlevel + value); } @@ -681,8 +674,8 @@ void EV_StartLightGlowing (int tag, int upper, int lower, int tics) lower = temp; } - secnum = -1; - while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0) + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sector_t *sec = §ors[secnum]; 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) { int secnum; - - secnum = -1; - while ((secnum = P_FindSectorFromTag (tag,secnum)) >= 0) + FSectorTagIterator it(tag); + while ((secnum = it.Next()) >= 0) { sector_t *sec = §ors[secnum]; if (sec->lightingdata) @@ -846,7 +838,7 @@ void EV_StopLightEffect (int tag) while ((effect = iterator.Next()) != NULL) { - if (effect->GetSector()->tag == tag) + if (effect->GetSector()->HasTag(tag)) { effect->Destroy(); } diff --git a/src/p_linkedsectors.cpp b/src/p_linkedsectors.cpp index 2d06bc043..8f78aadda 100644 --- a/src/p_linkedsectors.cpp +++ b/src/p_linkedsectors.cpp @@ -278,7 +278,7 @@ static void RemoveTaggedSectors(extsector_t::linked::plane &scrollplane, int tag { for(int i = scrollplane.Sectors.Size()-1; i>=0; i--) { - if (scrollplane.Sectors[i].Sector->tag == tag) + if (scrollplane.Sectors[i].Sector->HasTag(tag)) { scrollplane.Sectors.Delete(i); } @@ -316,7 +316,9 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype) 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! if (control != §ors[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; - 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]; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index b550eeb77..16372b206 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1266,7 +1266,7 @@ FUNC(LS_Thing_Destroy) while (actor) { AActor *temp = iterator.Next (); - if (actor->flags & MF_SHOOTABLE && actor->Sector->tag == arg2) + if (actor->flags & MF_SHOOTABLE && actor->Sector->HasTag(arg2)) P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None); actor = temp; } @@ -1279,7 +1279,7 @@ FUNC(LS_Thing_Destroy) while (actor) { AActor *temp = iterator.Next (); - if (actor->flags & MF_SHOOTABLE && (arg2 == 0 || actor->Sector->tag == arg2)) + if (actor->flags & MF_SHOOTABLE && (arg2 == 0 || actor->Sector->HasTag(arg2))) P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None); actor = temp; } @@ -1914,9 +1914,9 @@ FUNC(LS_Sector_ChangeSound) if (!arg0) return false; - secNum = -1; rtn = false; - while ((secNum = P_FindSectorFromTag (arg0, secNum)) >= 0) + FSectorTagIterator itr(arg0); + while ((secNum = itr.Next()) >= 0) { sectors[secNum].seqType = arg1; rtn = true; @@ -1933,9 +1933,9 @@ FUNC(LS_Sector_ChangeFlags) if (!arg0) return false; - secNum = -1; 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; rtn = true; @@ -1969,10 +1969,11 @@ void AdjustPusher (int tag, int magnitude, int angle, DPusher::EPusher type) } size_t numcollected = Collection.Size (); - int secnum = -1; + int secnum; // 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; for (i = 0; i < numcollected; i++) @@ -2020,9 +2021,9 @@ FUNC(LS_Sector_SetTranslucent) { if (arg0 != 0) { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + int secnum; + FSectorTagIterator itr(arg0); + while ((secnum = itr.Next()) >= 0) { sectors[secnum].SetAlpha(arg1, Scale(arg2, OPAQUE, 255)); 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 { - int control = P_FindSectorFromTag(arg0, -1); + int control = P_FindFirstSectorFromTag(arg0); if (control >= 0) { return P_AddSectorLinks(§ors[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 (); - if (wallnum >= 0 && sides[wallnum].linedef->id == id && + if (wallnum >= 0 && sides[wallnum].linedef->HasId(id) && int(sides[wallnum].linedef->sidedef[sidechoice] - sides) == wallnum && Where == scroller->GetScrollParts()) { @@ -2081,7 +2082,7 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int while ( (collect.Obj = iterator.Next ()) ) { if ((collect.RefNum = ((DScroller *)collect.Obj)->GetWallNum ()) != -1 && - sides[collect.RefNum].linedef->id == id && + sides[collect.RefNum].linedef->HasId(id) && int(sides[collect.RefNum].linedef->sidedef[sidechoice] - sides) == collect.RefNum && Where == ((DScroller *)collect.Obj)->GetScrollParts()) { @@ -2092,10 +2093,11 @@ static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int } size_t numcollected = Collection.Size (); - int linenum = -1; + int linenum; // 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) { @@ -2167,7 +2169,7 @@ static void SetScroller (int tag, DScroller::EScrollType type, fixed_t dx, fixed { if (scroller->IsType (type)) { - if (sectors[scroller->GetAffectee ()].tag == tag) + if (sectors[scroller->GetAffectee ()].HasTag(tag)) { i++; scroller->SetRate (dx, dy); @@ -2181,7 +2183,8 @@ static void SetScroller (int tag, DScroller::EScrollType type, fixed_t dx, fixed } // 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); } @@ -2240,8 +2243,10 @@ FUNC(LS_Sector_SetDamage) // problems by adding an unwanted constructor. // Since it doesn't really matter whether the type is translated // here or in P_PlayerInSpecialSector I think it's the best solution. - int secnum = -1; - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { + FSectorTagIterator itr(arg0); + int secnum; + while ((secnum = itr.Next()) >= 0) + { sectors[secnum].damage = arg1; sectors[secnum].mod = arg2; } @@ -2251,14 +2256,15 @@ FUNC(LS_Sector_SetDamage) FUNC(LS_Sector_SetGravity) // Sector_SetGravity (tag, intpart, fracpart) { - int secnum = -1; float gravity; if (arg2 > 99) arg2 = 99; 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; return true; @@ -2267,9 +2273,9 @@ FUNC(LS_Sector_SetGravity) FUNC(LS_Sector_SetColor) // Sector_SetColor (tag, r, g, b, desaturate) { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + FSectorTagIterator itr(arg0); + int secnum; + while ((secnum = itr.Next()) >= 0) { sectors[secnum].SetColor(arg1, arg2, arg3, arg4); } @@ -2280,9 +2286,9 @@ FUNC(LS_Sector_SetColor) FUNC(LS_Sector_SetFade) // Sector_SetFade (tag, r, g, b) { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + FSectorTagIterator itr(arg0); + int secnum; + while ((secnum = itr.Next()) >= 0) { sectors[secnum].SetFade(arg1, arg2, arg3); } @@ -2292,11 +2298,12 @@ FUNC(LS_Sector_SetFade) FUNC(LS_Sector_SetCeilingPanning) // Sector_SetCeilingPanning (tag, x-int, x-frac, y-int, y-frac) { - int secnum = -1; fixed_t xofs = arg1 * FRACUNIT + arg2 * (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].SetYOffset(sector_t::ceiling, yofs); @@ -2307,11 +2314,12 @@ FUNC(LS_Sector_SetCeilingPanning) FUNC(LS_Sector_SetFloorPanning) // Sector_SetFloorPanning (tag, x-int, x-frac, y-int, y-frac) { - int secnum = -1; fixed_t xofs = arg1 * FRACUNIT + arg2 * (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].SetYOffset(sector_t::floor, yofs); @@ -2322,7 +2330,6 @@ FUNC(LS_Sector_SetFloorPanning) FUNC(LS_Sector_SetFloorScale) // Sector_SetFloorScale (tag, x-int, x-frac, y-int, y-frac) { - int secnum = -1; fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); @@ -2331,7 +2338,9 @@ FUNC(LS_Sector_SetFloorScale) if (yscale) yscale = FixedDiv (FRACUNIT, yscale); - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + FSectorTagIterator itr(arg0); + int secnum; + while ((secnum = itr.Next()) >= 0) { if (xscale) sectors[secnum].SetXScale(sector_t::floor, xscale); @@ -2344,7 +2353,6 @@ FUNC(LS_Sector_SetFloorScale) FUNC(LS_Sector_SetCeilingScale) // Sector_SetCeilingScale (tag, x-int, x-frac, y-int, y-frac) { - int secnum = -1; fixed_t xscale = arg1 * FRACUNIT + arg2 * (FRACUNIT/100); fixed_t yscale = arg3 * FRACUNIT + arg4 * (FRACUNIT/100); @@ -2353,7 +2361,9 @@ FUNC(LS_Sector_SetCeilingScale) if (yscale) yscale = FixedDiv (FRACUNIT, yscale); - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + FSectorTagIterator itr(arg0); + int secnum; + while ((secnum = itr.Next()) >= 0) { if (xscale) sectors[secnum].SetXScale(sector_t::ceiling, xscale); @@ -2366,14 +2376,14 @@ FUNC(LS_Sector_SetCeilingScale) FUNC(LS_Sector_SetFloorScale2) // Sector_SetFloorScale2 (tag, x-factor, y-factor) { - int secnum = -1; - if (arg1) arg1 = FixedDiv (FRACUNIT, arg1); if (arg2) arg2 = FixedDiv (FRACUNIT, arg2); - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + FSectorTagIterator itr(arg0); + int secnum; + while ((secnum = itr.Next()) >= 0) { if (arg1) sectors[secnum].SetXScale(sector_t::floor, arg1); @@ -2386,14 +2396,14 @@ FUNC(LS_Sector_SetFloorScale2) FUNC(LS_Sector_SetCeilingScale2) // Sector_SetFloorScale2 (tag, x-factor, y-factor) { - int secnum = -1; - if (arg1) arg1 = FixedDiv (FRACUNIT, arg1); if (arg2) arg2 = FixedDiv (FRACUNIT, arg2); - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + FSectorTagIterator itr(arg0); + int secnum; + while ((secnum = itr.Next()) >= 0) { if (arg1) sectors[secnum].SetXScale(sector_t::ceiling, arg1); @@ -2406,11 +2416,12 @@ FUNC(LS_Sector_SetCeilingScale2) FUNC(LS_Sector_SetRotation) // Sector_SetRotation (tag, floor-angle, ceiling-angle) { - int secnum = -1; angle_t ceiling = arg2 * 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::ceiling, ceiling); @@ -2421,30 +2432,28 @@ FUNC(LS_Sector_SetRotation) FUNC(LS_Line_AlignCeiling) // Line_AlignCeiling (lineid, side) { - int line = P_FindLineFromID (arg0, -1); bool ret = 0; - if (line < 0) - I_Error ("Sector_AlignCeiling: Lineid %d is undefined", arg0); - do + FLineIdIterator itr(arg0); + int line; + while ((line = itr.Next()) >= 0) { ret |= P_AlignFlat (line, !!arg1, 1); - } while ( (line = P_FindLineFromID (arg0, line)) >= 0); + } return ret; } FUNC(LS_Line_AlignFloor) // Line_AlignFloor (lineid, side) { - int line = P_FindLineFromID (arg0, -1); bool ret = 0; - if (line < 0) - I_Error ("Sector_AlignFloor: Lineid %d is undefined", arg0); - do + FLineIdIterator itr(arg0); + int line; + while ((line = itr.Next()) >= 0) { ret |= P_AlignFlat (line, !!arg1, 0); - } while ( (line = P_FindLineFromID (arg0, line)) >= 0); + } return ret; } @@ -2456,7 +2465,9 @@ FUNC(LS_Line_SetTextureOffset) if (arg0 == 0 || arg3 < 0 || arg3 > 1) 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]; if (side != NULL) @@ -2507,7 +2518,9 @@ FUNC(LS_Line_SetTextureScale) if (arg0 == 0 || arg3 < 0 || arg3 > 1) 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]; if (side != NULL) @@ -2578,7 +2591,9 @@ FUNC(LS_Line_SetBlocking) 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; } @@ -2871,8 +2886,9 @@ FUNC(LS_SetPlayerProperty) FUNC(LS_TranslucentLine) // TranslucentLine (id, amount, type) { - int linenum = -1; - while ((linenum = P_FindLineFromID (arg0, linenum)) >= 0) + FLineIdIterator itr(arg0); + int linenum; + while ((linenum = itr.Next()) >= 0) { lines[linenum].Alpha = Scale(clamp(arg1, 0, 255), FRACUNIT, 255); if (arg2 == 0) @@ -2997,10 +3013,11 @@ FUNC(LS_ForceField) FUNC(LS_ClearForceField) // ClearForceField (tag) { - int secnum = -1; bool rtn = false; - while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) + FSectorTagIterator itr(arg0); + int secnum; + while ((secnum = itr.Next()) >= 0) { sector_t *sec = §ors[secnum]; rtn = true; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 2571413c8..14837a1e2 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3437,7 +3437,7 @@ void AActor::Tick () } else if (scrolltype == Scroll_StrifeCurrent) { // Strife scroll special - int anglespeed = sec->tag - 100; + int anglespeed = sec->GetMainTag() - 100; fixed_t carryspeed = DivScale32 (anglespeed % 10, 16*CARRYFACTOR); angle_t fineangle = (anglespeed / 10) << (32-3); fineangle >>= ANGLETOFINESHIFT; diff --git a/src/p_pillar.cpp b/src/p_pillar.cpp index 809542949..884218bee 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -220,20 +220,11 @@ bool EV_DoPillar (DPillar::EPillar type, line_t *line, int tag, bool rtn = false; // check if a manual trigger; if so do just the sector on the backside - if (tag == 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) + FSectorTagIterator itr(tag, line); + while ((secnum = itr.Next()) >= 0) { sec = §ors[secnum]; -manual_pillar: if (sec->PlaneMoving(sector_t::floor) || sec->PlaneMoving(sector_t::ceiling)) continue; diff --git a/src/p_plats.cpp b/src/p_plats.cpp index d87c30991..7600637b2 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -233,42 +233,33 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height, fixed_t newheight = 0; vertex_t *spot; + if (tag != 0) + { + // Activate all plats that are in_stasis + switch (type) + { + case DPlat::platToggle: + rtn = true; + case DPlat::platPerpetualRaise: + P_ActivateInStasis (tag); + break; + + default: + break; + } + } + + // [RH] If tag is zero, use the sector on the back side // 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 plats that are in_stasis - switch (type) - { - case DPlat::platToggle: - rtn = true; - case DPlat::platPerpetualRaise: - P_ActivateInStasis (tag); - break; - - default: - break; - } - - secnum = -1; - while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) + FSectorTagIterator itr(tag, line); + while ((secnum = itr.Next()) >= 0) { sec = §ors[secnum]; -manual_plat: if (sec->PlaneMoving(sector_t::floor)) { - if (!manual) - continue; - else - return false; + continue; } // Find lowest & highest floors around sector @@ -406,8 +397,6 @@ manual_plat: default: break; } - if (manual) - return rtn; } return rtn; } diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 904c76c1b..7061af788 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -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 copy = false; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 80c84ffde..4a1527514 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -96,7 +96,6 @@ CVAR (Bool, gennodes, false, CVAR_SERVERINFO|CVAR_GLOBALCONFIG); CVAR (Bool, genglnodes, false, CVAR_SERVERINFO); CVAR (Bool, showloadtimes, false, 0); -static void P_InitTagLists (); static void P_Shutdown (); bool P_IsBuildMap(MapData *map); @@ -1514,7 +1513,7 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex) else // [RH] Translate to new sector special ss->special = P_TranslateSectorSpecial (LittleShort(ms->special)); ss->secretsector = !!(ss->special&SECRET_MASK); - ss->tag = LittleShort(ms->tag); + ss->SetMainTag(LittleShort(ms->tag)); ss->thinglist = NULL; ss->touching_thinglist = NULL; // phares 3/14/98 ss->seqType = defSeqType; @@ -1920,40 +1919,40 @@ void P_SetLineID (line_t *ld) case Line_SetIdentification: if (!(level.flags2 & LEVEL2_HEXENHACK)) { - ld->id = ld->args[0] + 256 * ld->args[4]; + ld->SetMainId(ld->args[0] + 256 * ld->args[4]); ld->flags |= ld->args[1]<<16; } else { - ld->id = ld->args[0]; + ld->SetMainId(ld->args[0]); } ld->special = 0; break; case TranslucentLine: - ld->id = ld->args[0]; + ld->SetMainId(ld->args[0]); ld->flags |= ld->args[3]<<16; break; case Teleport_Line: case Scroll_Texture_Model: - ld->id = ld->args[0]; + ld->SetMainId(ld->args[0]); break; case Polyobj_StartLine: - ld->id = ld->args[3]; + ld->SetMainId(ld->args[3]); break; case Polyobj_ExplicitLine: - ld->id = ld->args[4]; + ld->SetMainId(ld->args[4]); break; case Plane_Align: - ld->id = ld->args[2]; + ld->SetMainId(ld->args[2]); break; case Static_Init: - if (ld->args[1] == Init_SectorLink) ld->id = ld->args[0]; + if (ld->args[1] == Init_SectorLink) ld->SetMainId(ld->args[0]); break; } } @@ -2038,7 +2037,7 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha) { for (j = 0; j < numlines; j++) { - if (lines[j].id == ld->args[0]) + if (lines[j].HasId(ld->args[0])) { lines[j].Alpha = alpha; if (additive) @@ -2146,11 +2145,10 @@ void P_LoadLineDefs (MapData * map) // [RH] Translate old linedef special and flags to be // compatible with the new format. - P_TranslateLineDef (ld, mld); + P_TranslateLineDef (ld, mld, true); ld->v1 = &vertexes[LittleShort(mld->v1)]; 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[1], LittleShort(mld->sidenum[1])); @@ -2233,7 +2231,7 @@ void P_LoadLineDefs2 (MapData * map) ld->v1 = &vertexes[LittleShort(mld->v1)]; ld->v2 = &vertexes[LittleShort(mld->v2)]; ld->Alpha = FRACUNIT; // [RH] Opaque by default - ld->id = -1; + ld->ClearIds(); P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0])); P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1])); @@ -2495,7 +2493,7 @@ void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmaps for (s = 0; s < numsectors; s++) { - if (sectors[s].tag == tag) + if (sectors[s].HasTag(tag)) { if (!colorgood) color = sectors[s].ColorMap->Color; if (!foggood) fog = sectors[s].ColorMap->Fade; @@ -3131,9 +3129,9 @@ static void P_GroupLines (bool buildmap) { if (sector->linecount == 0) { - Printf ("Sector %i (tag %i) has no lines\n", i, sector->tag); + Printf ("Sector %i (tag %i) has no lines\n", i, sector->GetMainTag()); // 0 the sector's tag so that no specials can use it - sector->tag = 0; + sector->ClearTags(); } else { @@ -3209,7 +3207,9 @@ static void P_GroupLines (bool buildmap) // [RH] Moved this here 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[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 &spots, TArray &anchors) { if (map->HasBehavior) diff --git a/src/p_setup.h b/src/p_setup.h index ee26f4c57..20caa5d76 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -115,7 +115,7 @@ struct line_t; struct maplinedef_t; 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 GetUDMFInt(int type, int index, const char *key); diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index 41f7a1837..c0b9b5ef0 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -45,9 +45,10 @@ 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]; sector_t *sec; @@ -123,7 +124,7 @@ static void P_CopyPlane (int tag, sector_t *dest, bool copyCeil) int secnum; size_t planeofs; - secnum = P_FindSectorFromTag (tag, -1); + secnum = P_FindFirstSectorFromTag (tag); if (secnum == -1) { return; diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 676191555..8dbb73f37 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -195,29 +195,48 @@ bool CheckIfExitIsGood (AActor *self, level_info_t *info) // Find the next sector with a specified tag. // 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 : - sectors[(unsigned) tag % (unsigned) numsectors].firsttag; - while (start >= 0 && sectors[start].tag != tag) + int ret; + if (searchtag == INT_MIN) + { + ret = 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 start; + } + 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 -int P_FindLineFromID (int id, int start) +int FLineIdIterator::Next() { - start = start >= 0 ? lines[start].nextid : - lines[(unsigned) id % (unsigned) numlines].firstid; - while (start >= 0 && lines[start].id != id) - start = lines[start].nextid; - return start; + while (start != -1 && lines[start].id != searchtag) start = lines[start].nextid; + if (start == -1) return -1; + int ret = start; + start = lines[start].nextid; + return ret; } - - //============================================================================ // // P_ActivateLine @@ -260,13 +279,13 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType) } // some old WADs use this method to create walls that change the texture when shot. else if (activationType == SPAC_Impact && // only for shootable triggers - (level.flags2 & LEVEL2_DUMMYSWITCHES) && // this is only a compatibility setting for an old hack! + (level.flags2 & LEVEL2_DUMMYSWITCHES) && // this is only a compatibility setting for an old hack! !repeat && // only non-repeatable triggers (specialGeneric_Crusher) && // not for Boom's generalized linedefs special && // not for lines without a special - line->args[0] == line->id && // Safety check: exclude edited UDMF linedefs or ones that don't map the tag to args[0] + line->HasId(line->args[0]) && // Safety check: exclude edited UDMF linedefs or ones that don't map the tag to args[0] line->args[0] && // only if there's a tag (which is stored in the first arg) - P_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); 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) { - int secnum = -1; - - while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) + FSectorTagIterator itr(tag); + int secnum; + while ((secnum = itr.Next()) >= 0) { AActor *actor, *next; sector_t *sec = §ors[secnum]; @@ -884,12 +903,14 @@ DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool 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); } 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); } ChangeStatNum (STAT_LIGHTTRANSFER); @@ -912,12 +933,14 @@ void DLightTransfer::DoTransfer (int level, int target, bool 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); } 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); } } @@ -985,7 +1008,8 @@ DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, BYTE flags 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) { @@ -1015,7 +1039,8 @@ void DWallLightTransfer::DoTransfer (short lightlevel, int target, BYTE flags) { int linenum; - for (linenum = -1; (linenum = P_FindLineFromID (target, linenum)) >= 0; ) + FLineIdIterator itr(target); + while ((linenum = itr.Next()) >= 0) { 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; 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(§ors[s], plane, reference, alpha); } @@ -1193,7 +1220,8 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha) } 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(§ors[s], plane, reference, alpha); } @@ -1374,38 +1402,41 @@ void P_SpawnSpecials (void) // killough 3/7/98: // support for drawn heights coming from different sector case Transfer_Heights: - sec = lines[i].frontsector; - if (lines[i].args[1] & 2) { - sec->MoreFlags |= SECF_FAKEFLOORONLY; + sec = lines[i].frontsector; + if (lines[i].args[1] & 2) + { + sec->MoreFlags |= SECF_FAKEFLOORONLY; + } + if (lines[i].args[1] & 4) + { + sec->MoreFlags |= SECF_CLIPFAKEPLANES; + } + if (lines[i].args[1] & 8) + { + sec->MoreFlags |= SECF_UNDERWATER; + } + else if (forcewater) + { + sec->MoreFlags |= SECF_FORCEDUNDERWATER; + } + if (lines[i].args[1] & 16) + { + sec->MoreFlags |= SECF_IGNOREHEIGHTSEC; + } + if (lines[i].args[1] & 32) + { + sec->MoreFlags |= SECF_NOFAKELIGHT; + } + FSectorTagIterator itr(lines[i].args[0]); + while ((s = itr.Next()) >= 0) + { + sectors[s].heightsec = sec; + sec->e->FakeFloor.Sectors.Push(§ors[s]); + sectors[s].AdjustFloorClip(); + } + break; } - if (lines[i].args[1] & 4) - { - sec->MoreFlags |= SECF_CLIPFAKEPLANES; - } - if (lines[i].args[1] & 8) - { - sec->MoreFlags |= SECF_UNDERWATER; - } - else if (forcewater) - { - sec->MoreFlags |= SECF_FORCEDUNDERWATER; - } - if (lines[i].args[1] & 16) - { - sec->MoreFlags |= SECF_IGNOREHEIGHTSEC; - } - if (lines[i].args[1] & 32) - { - sec->MoreFlags |= SECF_NOFAKELIGHT; - } - for (s = -1; (s = P_FindSectorFromTag(lines[i].args[0],s)) >= 0;) - { - sectors[s].heightsec = sec; - sec->e->FakeFloor.Sectors.Push(§ors[s]); - sectors[s].AdjustFloorClip(); - } - break; // killough 3/16/98: Add support for setting // floor lighting independently (e.g. lava) @@ -1458,9 +1489,10 @@ void P_SpawnSpecials (void) { case Init_Gravity: { - 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;) - sectors[s].gravity = grav; + float grav = ((float)P_AproxDistance (lines[i].dx, lines[i].dy)) / (FRACUNIT * 100.0f); + FSectorTagIterator itr(lines[i].args[0]); + while ((s = itr.Next()) >= 0) + sectors[s].gravity = grav; } break; @@ -1470,7 +1502,8 @@ void P_SpawnSpecials (void) case Init_Damage: { 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].mod = 0;//MOD_UNKNOWN; @@ -1493,9 +1526,12 @@ void P_SpawnSpecials (void) // or ceiling texture, to distinguish floor and ceiling sky. case Init_TransferSky: - for (s = -1; (s = P_FindSectorFromTag(lines[i].args[0],s)) >= 0;) - sectors[s].sky = (i+1) | PL_SKYFLAT; - break; + { + FSectorTagIterator itr(lines[i].args[0]); + while ((s = itr.Next()) >= 0) + sectors[s].sky = (i + 1) | PL_SKYFLAT; + break; + } } break; } @@ -1756,7 +1792,7 @@ static void P_SpawnScrollers(void) 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. - if (lines[i].args[0] != lines[i].frontsector->tag) + if (lines[i].frontsector->HasTag(lines[i].args[0])) { copyscrollers.Push(i); } @@ -1832,25 +1868,29 @@ static void P_SpawnScrollers(void) register int s; 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); } - for(unsigned j = 0;j < copyscrollers.Size(); j++) + for (unsigned j = 0; j < copyscrollers.Size(); j++) { line_t *line = &lines[copyscrollers[j]]; if (line->args[0] == l->args[0] && (line->args[1] & 1)) { - new DScroller (DScroller::sc_ceiling, -dx, dy, control, int(line->frontsector-sectors), accel); + new DScroller(DScroller::sc_ceiling, -dx, dy, control, int(line->frontsector - sectors), accel); } } break; + } case Scroll_Floor: if (l->args[2] != 1) { // 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); } @@ -1867,7 +1907,8 @@ static void P_SpawnScrollers(void) if (l->args[2] > 0) { // 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); } @@ -1886,10 +1927,15 @@ static void P_SpawnScrollers(void) // killough 3/1/98: scroll wall according to linedef // (same direction and speed as scrolling floors) 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) - new DScroller (dx, dy, lines+s, control, accel); + new DScroller(dx, dy, lines + s, control, accel); + } break; + } case Scroll_Texture_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'. movefactor = FrictionToMoveFactor(friction); - for (s = -1; (s = P_FindSectorFromTag (tag,s)) >= 0; ) + FSectorTagIterator itr(tag); + while ((s = itr.Next()) >= 0) { // 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) { - if (m_Type == type && sectors[m_Affectee].tag == tag) + if (m_Type == type && sectors[m_Affectee].HasTag(tag)) return m_Affectee; else return -1; @@ -2356,20 +2403,27 @@ static void P_SpawnPushers () switch (l->special) { case Sector_SetWind: // wind - for (s = -1; (s = P_FindSectorFromTag (l->args[0],s)) >= 0 ; ) - new DPusher (DPusher::p_wind, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s); + { + 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); l->special = 0; break; + } case Sector_SetCurrent: // current - for (s = -1; (s = P_FindSectorFromTag (l->args[0],s)) >= 0 ; ) - new DPusher (DPusher::p_current, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s); + { + 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); l->special = 0; break; + } case PointPush_SetForce: // push/pull 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); if (thing) { // No MT_P* means no effect diff --git a/src/p_spec.h b/src/p_spec.h index 5b4f0ba99..45eaf7e41 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -242,10 +242,66 @@ inline sector_t *getNextSector (line_t *line, const sector_t *sec) line->frontsector; } +class FSectorTagIterator +{ +protected: + int searchtag; + int start; -int P_FindSectorFromTag (int tag, int start); -int P_FindLineFromID (int id, int start); +public: + 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 diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 3e3b03c4e..de16a57fa 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -250,7 +250,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) int count = 0; while ( (searcher = iterator.Next ()) ) { - if (tag == 0 || searcher->Sector->tag == tag) + if (tag == 0 || searcher->Sector->HasTag(tag)) { count++; } @@ -289,7 +289,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) while (count > 0) { searcher = iterator.Next (); - if (tag == 0 || searcher->Sector->tag == tag) + if (tag == 0 || searcher->Sector->HasTag(tag)) { count--; } @@ -300,9 +300,10 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) 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 // 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) return false; - for (i = -1; (i = P_FindLineFromID (id, i)) >= 0; ) + FLineIdIterator itr(id); + while ((i = itr.Next()) >= 0) { if (line-lines == i) continue; @@ -726,7 +728,8 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro int secnum; secnum = -1; - while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) + FSectorTagIterator itr(tag); + while ((secnum = itr.Next()) >= 0) { msecnode_t *node; const sector_t * const sec = §ors[secnum]; diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 31634ee81..09cee8441 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -722,6 +722,7 @@ public: break; default: + CHECK_N(Zd | Zdt) if (0 == strnicmp("user_", key.GetChars(), 5)) { // Custom user key - Sets an actor's user variable directly FMapThingUserData ud; @@ -753,7 +754,7 @@ public: mld.flags = 0; mld.special = th->special; mld.tag = th->args[0]; - P_TranslateLineDef(&ld, &mld); + P_TranslateLineDef(&ld, &mld, true); th->special = ld.special; memcpy(th->args, ld.args, sizeof (ld.args)); } @@ -780,7 +781,7 @@ public: memset(ld, 0, sizeof(*ld)); ld->Alpha = FRACUNIT; - ld->id = -1; + ld->ClearIds(); ld->sidedef[0] = ld->sidedef[1] = NULL; if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX; if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX; @@ -813,7 +814,7 @@ public: continue; case NAME_Id: - ld->id = CheckInt(key); + ld->SetMainId(CheckInt(key)); continue; case NAME_Sidefront: @@ -1040,7 +1041,20 @@ public: 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); } @@ -1053,8 +1067,8 @@ public: maplinedef_t mld; memset(&mld, 0, sizeof(mld)); mld.special = ld->special; - mld.tag = ld->id; - P_TranslateLineDef(ld, &mld); + mld.tag = ld->GetMainId(); + P_TranslateLineDef(ld, &mld, false); ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY)); } if (passuse && (ld->activation & SPAC_Use)) @@ -1226,7 +1240,7 @@ public: break; } - if (!strnicmp("user_", key.GetChars(), 5)) + if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5)) { AddUserKey(key, UDMF_Side, index); } @@ -1316,7 +1330,7 @@ public: continue; case NAME_Id: - sec->tag = (short)CheckInt(key); + sec->SetMainTag((short)CheckInt(key)); continue; default: @@ -1497,8 +1511,20 @@ public: default: break; } +#if 0 // for later + if (namespace_bits & (Zd)) && !strnicmp(key.GetChars(), "Id", 2)) + { + char *endp; + int num = strtol(key.GetChars(), &endp, 10); + if (num > 0 && *endp == NULL) + { + // only allow ID## with ## as a proper number + sec->SetTag((short)CheckInt(key), false); + } + } +#endif - if (!strnicmp("user_", key.GetChars(), 5)) + if ((namespace_bits & (Zd | Zdt)) && !strnicmp("user_", key.GetChars(), 5)) { AddUserKey(key, UDMF_Sector, index); } diff --git a/src/p_user.cpp b/src/p_user.cpp index 6042d5662..5f9a69c3a 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -295,23 +295,23 @@ player_t::player_t() respawn_time(0), camera(0), air_finished(0), + MUSINFOactor(0), + MUSINFOtics(-1), + crouching(0), + crouchdir(0), Bot(0), BlendR(0), BlendG(0), BlendB(0), BlendA(0), LogText(), - crouching(0), - crouchdir(0), crouchfactor(0), crouchoffset(0), crouchviewdelta(0), ConversationNPC(0), ConversationPC(0), ConversationNPCAngle(0), - ConversationFaceTalker(0), - MUSINFOactor(0), - MUSINFOtics(-1) + ConversationFaceTalker(0) { memset (&cmd, 0, sizeof(cmd)); memset (frags, 0, sizeof(frags)); diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index 83ed40b5b..2f11ee5c1 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -262,7 +262,7 @@ static int WriteSECTORS (FILE *file) uppercopy (ms.ceilingpic, GetTextureName (sectors[i].GetTexture(sector_t::ceiling))); ms.lightlevel = LittleShort((short)sectors[i].lightlevel); ms.special = LittleShort(sectors[i].special); - ms.tag = LittleShort(sectors[i].tag); + ms.tag = LittleShort(sectors[i].GetMainTag()); fwrite (&ms, sizeof(ms), 1, file); } return numsectors * sizeof(ms); diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index be2d154c3..4b1373817 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -60,7 +60,7 @@ typedef enum PushMany, } 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); short tag = LittleShort(mld->tag); @@ -100,11 +100,14 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) } flags = newflags; - // For purposes of maintaining BOOM compatibility, each - // line also needs to have its ID set to the same as its tag. - // An external conversion program would need to do this more - // intelligently. - ld->id = tag; + if (setid) + { + // For purposes of maintaining BOOM compatibility, each + // line also needs to have its ID set to the same as its tag. + // An external conversion program would need to do this more + // intelligently. + ld->SetMainId(tag); + } // 0 specials are never translated. if (special == 0) @@ -304,7 +307,7 @@ void P_TranslateTeleportThings () while ( (dest = iterator.Next()) ) { - if (dest->Sector->tag == 0) + if (dest->Sector->GetMainTag() == 0) { dest->tid = 1; dest->AddToHash (); diff --git a/src/r_defs.h b/src/r_defs.h index 14d58e4b9..49b18c13a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -686,6 +686,12 @@ struct sector_t 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); @@ -989,6 +995,13 @@ struct line_t sector_t *frontsector, *backsector; int validcount; // if == validcount, already checked int locknumber; // [Dusk] lock number for special + + + void SetMainId(int newid); + int GetMainId() const; + void ClearIds(); + bool HasId(int id) const; + static void HashIds(); }; // phares 3/14/98 diff --git a/src/resourcefiles/file_zip.cpp b/src/resourcefiles/file_zip.cpp index 5d6ff6c9e..c7e787c70 100644 --- a/src/resourcefiles/file_zip.cpp +++ b/src/resourcefiles/file_zip.cpp @@ -168,7 +168,7 @@ bool FZipFile::Open(bool quiet) 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; } @@ -180,7 +180,7 @@ bool FZipFile::Open(bool quiet) if (info.NumEntries != info.NumEntriesOnAllDisks || 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; } @@ -188,9 +188,10 @@ bool FZipFile::Open(bool quiet) Lumps = new FZipLump[NumLumps]; // 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->Read(directory, LittleLong(info.DirectorySize)); + Reader->Read(directory, dirsize); char *dirptr = (char*)directory; FZipLump *lump_p = Lumps; @@ -204,6 +205,13 @@ bool FZipFile::Open(bool quiet) LittleShort(zip_fh->NameLength) + LittleShort(zip_fh->ExtraLength) + 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 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_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++; continue; } @@ -229,7 +237,7 @@ bool FZipFile::Open(bool quiet) zip_fh->Flags = LittleShort(zip_fh->Flags); 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++; continue; } @@ -260,7 +268,7 @@ bool FZipFile::Open(bool quiet) NumLumps -= skipped; free(directory); - if (!quiet) Printf(", %d lumps\n", NumLumps); + if (!quiet) Printf(TEXTCOLOR_NORMAL ", %d lumps\n", NumLumps); PostProcessArchive(&Lumps[0], sizeof(FZipLump)); return true; diff --git a/src/textures/animations.cpp b/src/textures/animations.cpp index ffff062c6..0290a293f 100644 --- a/src/textures/animations.cpp +++ b/src/textures/animations.cpp @@ -177,8 +177,8 @@ void FTextureManager::InitAnimated (void) { FMemLump animatedlump = Wads.ReadLump (lumpnum); int animatedlen = Wads.LumpLength(lumpnum); - const char *animdefs = (const char *)animatedlump.GetMem(); - const char *anim_p; + const BYTE *animdefs = (const BYTE *)animatedlump.GetMem(); + const BYTE *anim_p; FTextureID pic1, pic2; int animtype; DWORD animspeed; @@ -186,7 +186,7 @@ void FTextureManager::InitAnimated (void) // Init animation 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. if (anim_p + 22 >= animdefs + animatedlen) @@ -196,8 +196,8 @@ void FTextureManager::InitAnimated (void) if (*anim_p /* .istexture */ & 1) { // different episode ? - if (!(pic1 = CheckForTexture (anim_p + 10 /* .startname */, FTexture::TEX_Wall, texflags)).Exists() || - !(pic2 = CheckForTexture (anim_p + 1 /* .endname */, FTexture::TEX_Wall, texflags)).Exists()) + if (!(pic1 = CheckForTexture ((const char*)(anim_p + 10) /* .startname */, FTexture::TEX_Wall, texflags)).Exists() || + !(pic2 = CheckForTexture ((const char*)(anim_p + 1) /* .endname */, FTexture::TEX_Wall, texflags)).Exists()) continue; // [RH] Bit 1 set means allow decals on walls with this texture @@ -205,16 +205,16 @@ void FTextureManager::InitAnimated (void) } else { - if (!(pic1 = CheckForTexture (anim_p + 10 /* .startname */, FTexture::TEX_Flat, texflags)).Exists() || - !(pic2 = CheckForTexture (anim_p + 1 /* .startname */, FTexture::TEX_Flat, texflags)).Exists()) + if (!(pic1 = CheckForTexture ((const char*)(anim_p + 10) /* .startname */, FTexture::TEX_Flat, texflags)).Exists() || + !(pic2 = CheckForTexture ((const char*)(anim_p + 1) /* .startname */, FTexture::TEX_Flat, texflags)).Exists()) continue; } FTexture *tex1 = Texture(pic1); FTexture *tex2 = Texture(pic2); - animspeed = (BYTE(anim_p[19]) << 0) | (BYTE(anim_p[20]) << 8) | - (BYTE(anim_p[21]) << 16) | (BYTE(anim_p[22]) << 24); + animspeed = (anim_p[19] << 0) | (anim_p[20] << 8) | + (anim_p[21] << 16) | (anim_p[22] << 24); // SMMU-style swirly hack? Don't apply on already-warping texture if (animspeed > 65535 && tex1 != NULL && !tex1->bWarped) @@ -242,7 +242,7 @@ void FTextureManager::InitAnimated (void) if (pic1 == pic2) { // 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; } // [RH] Allow for backward animations as well as forward. diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index cb59f8a1f..b63ba567f 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -70,6 +70,7 @@ #include "m_bbox.h" #include "r_data/r_translate.h" #include "p_trace.h" +#include "p_setup.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) { ACTION_PARAM_START(2); @@ -4520,7 +4520,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect) if ((oldjunk.special = special)) // Linedef type { 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], junk.args[1], junk.args[2], junk.args[3], junk.args[4]); if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once, diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 4d0b51623..2b3413460 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -317,7 +317,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) 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 diff --git a/wadsrc/static/filter/strifeteaser1/mapinfo/conversationids.txt b/wadsrc/static/filter/strifeteaser1/mapinfo/conversationids.txt index 268702d52..b1b6ae380 100644 --- a/wadsrc/static/filter/strifeteaser1/mapinfo/conversationids.txt +++ b/wadsrc/static/filter/strifeteaser1/mapinfo/conversationids.txt @@ -1,144 +1,144 @@ conversationids { - 2 WeaponSmith - 3 BarKeep - 4 Armorer - 5 Medic - 6 Peasant1 - 7 Peasant2 - 8 Peasant3 - 9 Peasant4 - 10 Peasant5 - 11 Peasant6 - 12 Peasant7 - 13 Peasant8 - 14 Peasant9 - 15 Peasant10 - 16 Peasant11 - 17 Peasant12 - 18 Peasant13 - 19 Peasant14 - 20 Peasant15 - 21 Peasant16 - 22 Peasant17 - 23 Peasant18 - 24 Peasant19 - 25 Peasant20 - 26 Peasant21 - 27 Peasant22 - 37 Beggar1 - 38 Beggar2 - 39 Beggar3 - 40 Beggar4 - 41 Beggar5 - 42 Rebel1 - 43 Rebel2 - 44 Rebel3 - 45 Rebel4 - 46 Rebel5 - 47 Rebel6 - 48 Macil1 - 49 Macil2 - 52 AcolyteTan - 53 AcolyteRed - 54 AcolyteRust - 55 AcolyteGray - 56 AcolyteDGreen - 57 AcolyteGold - 58 AcolyteShadow - 61 Templar - 62 Oracle - 63 Loremaster - 70 AlienSpectre2 - 94 InquisitorArm - 121 MedPatch - 122 MedicalKit - 123 SurgeryKit - 124 DegninOre - 125 MetalArmor - 126 LeatherArmor - 129 BaseKey - 130 GovsKey - 131 Passcard - 132 IDBadge - 133 PrisonKey - 134 SeveredHand - 135 Power1Key - 136 Power2Key - 137 Power3Key - 138 GoldKey - 139 IDCard - 140 SilverKey - 141 OracleKey - 142 MilitaryID - 143 OrderKey - 144 WarehouseKey - 145 BrassKey - 146 RedCrystalKey - 147 BlueCrystalKey - 148 ChapelKey - 149 CatacombKey - 150 SecurityKey - 151 CoreKey - 152 MaulerKey - 153 FactoryKey - 154 MineKey - 155 NewKey5 - 156 ShadowArmor - 157 EnvironmentalSuit - 158 GuardUniform - 159 OfficersUniform - 160 StrifeMap - 161 Coin - 162 Gold10 - 163 Gold25 - 164 Gold50 - 165 BeldinsRing - 166 OfferingChalice - 167 Ear - 168 Communicator - 169 Targeter - 170 HEGrenadeRounds - 171 PhosphorusGrenadeRounds - 173 ClipOfBullets - 174 BoxOfBullets - 175 MiniMissiles - 176 CrateOfMissiles - 177 EnergyPod - 178 EnergyPack - 179 PoisonBolts - 180 ElectricBolts - 181 AmmoSatchel - 182 AssaultGun - 183 AssaultGunStanding - 184 FlameThrower - 185 FlameThrowerParts - 186 MiniMissileLauncher - 187 Mauler - 188 StrifeCrossbow - 189 StrifeGrenadeLauncher - 190 Sigil1 - 191 Sigil2 - 192 Sigil3 - 193 Sigil4 - 194 Sigil5 - 196 RatBuddy - 230 DeadCrusader - 280 AmmoFillup - 281 HealthFillup - 282 info - 283 RaiseAlarm - 284 OpenDoor222 - 285 CloseDoor222 - 286 PrisonPass - 287 UpgradeStamina - 288 UpgradeAccuracy - 289 InterrogatorReport - 292 OraclePass - 293 QuestItem1 - 294 QuestItem2 - 295 QuestItem3 - 296 QuestItem4 - 297 QuestItem5 - 298 QuestItem6 + 2 = WeaponSmith + 3 = BarKeep + 4 = Armorer + 5 = Medic + 6 = Peasant1 + 7 = Peasant2 + 8 = Peasant3 + 9 = Peasant4 + 10 = Peasant5 + 11 = Peasant6 + 12 = Peasant7 + 13 = Peasant8 + 14 = Peasant9 + 15 = Peasant10 + 16 = Peasant11 + 17 = Peasant12 + 18 = Peasant13 + 19 = Peasant14 + 20 = Peasant15 + 21 = Peasant16 + 22 = Peasant17 + 23 = Peasant18 + 24 = Peasant19 + 25 = Peasant20 + 26 = Peasant21 + 27 = Peasant22 + 37 = Beggar1 + 38 = Beggar2 + 39 = Beggar3 + 40 = Beggar4 + 41 = Beggar5 + 42 = Rebel1 + 43 = Rebel2 + 44 = Rebel3 + 45 = Rebel4 + 46 = Rebel5 + 47 = Rebel6 + 48 = Macil1 + 49 = Macil2 + 52 = AcolyteTan + 53 = AcolyteRed + 54 = AcolyteRust + 55 = AcolyteGray + 56 = AcolyteDGreen + 57 = AcolyteGold + 58 = AcolyteShadow + 61 = Templar + 62 = Oracle + 63 = Loremaster + 70 = AlienSpectre2 + 94 = InquisitorArm + 121 = MedPatch + 122 = MedicalKit + 123 = SurgeryKit + 124 = DegninOre + 125 = MetalArmor + 126 = LeatherArmor + 129 = BaseKey + 130 = GovsKey + 131 = Passcard + 132 = IDBadge + 133 = PrisonKey + 134 = SeveredHand + 135 = Power1Key + 136 = Power2Key + 137 = Power3Key + 138 = GoldKey + 139 = IDCard + 140 = SilverKey + 141 = OracleKey + 142 = MilitaryID + 143 = OrderKey + 144 = WarehouseKey + 145 = BrassKey + 146 = RedCrystalKey + 147 = BlueCrystalKey + 148 = ChapelKey + 149 = CatacombKey + 150 = SecurityKey + 151 = CoreKey + 152 = MaulerKey + 153 = FactoryKey + 154 = MineKey + 155 = NewKey5 + 156 = ShadowArmor + 157 = EnvironmentalSuit + 158 = GuardUniform + 159 = OfficersUniform + 160 = StrifeMap + 161 = Coin + 162 = Gold10 + 163 = Gold25 + 164 = Gold50 + 165 = BeldinsRing + 166 = OfferingChalice + 167 = Ear + 168 = Communicator + 169 = Targeter + 170 = HEGrenadeRounds + 171 = PhosphorusGrenadeRounds + 173 = ClipOfBullets + 174 = BoxOfBullets + 175 = MiniMissiles + 176 = CrateOfMissiles + 177 = EnergyPod + 178 = EnergyPack + 179 = PoisonBolts + 180 = ElectricBolts + 181 = AmmoSatchel + 182 = AssaultGun + 183 = AssaultGunStanding + 184 = FlameThrower + 185 = FlameThrowerParts + 186 = MiniMissileLauncher + 187 = Mauler + 188 = StrifeCrossbow + 189 = StrifeGrenadeLauncher + 190 = Sigil1 + 191 = Sigil2 + 192 = Sigil3 + 193 = Sigil4 + 194 = Sigil5 + 196 = RatBuddy + 230 = DeadCrusader + 280 = AmmoFillup + 281 = HealthFillup + 282 = info + 283 = RaiseAlarm + 284 = OpenDoor222 + 285 = CloseDoor222 + 286 = PrisonPass + 287 = UpgradeStamina + 288 = UpgradeAccuracy + 289 = InterrogatorReport + 292 = OraclePass + 293 = QuestItem1 + 294 = QuestItem2 + 295 = QuestItem3 + 296 = QuestItem4 + 297 = QuestItem5 + 298 = QuestItem6 }