From 2faf836aa143afa2fd378a8fc90effb029d3ce23 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 14 Apr 2015 18:48:19 +0200 Subject: [PATCH] - some minor rework of tag access interface after I realized that some stuff (e.g. Strife's scrolling sector special) need the primary tag to treated specially. --- src/compatibility.cpp | 3 ++- src/fragglescript/t_func.cpp | 5 +++-- src/g_strife/a_strifestuff.cpp | 2 +- src/p_mobj.cpp | 2 +- src/p_sectors.cpp | 9 +++++++-- src/p_setup.cpp | 6 +++--- src/p_udmf.cpp | 2 +- src/p_writemap.cpp | 2 +- src/p_xlat.cpp | 2 +- src/r_defs.h | 5 +++-- 10 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/compatibility.cpp b/src/compatibility.cpp index ff3a67e61..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]].SetTag(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 0359aa423..039d261d7 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1158,7 +1158,7 @@ void FParser::SF_ObjSector(void) } t_return.type = svt_int; - t_return.value.i = mo ? mo->Sector->GetTag() : 0; // nullptr check + t_return.value.i = mo ? mo->Sector->GetMainTag() : 0; // nullptr check } //========================================================================== @@ -4388,7 +4388,8 @@ void FParser::SF_ChangeTag() { for (int secnum = -1; (secnum = P_FindSectorFromTag (t_argv[0].value.i, secnum)) >= 0; ) { - sectors[secnum].SetTag(t_argv[1].value.i); + sectors[secnum].ClearTags(); + sectors[secnum].SetMainTag(t_argv[1].value.i); } sector_t::HashTags(); } diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index e8dff183f..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->GetTag() - 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/p_mobj.cpp b/src/p_mobj.cpp index ffb12fddd..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->GetTag() - 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_sectors.cpp b/src/p_sectors.cpp index f34eadb44..d96540351 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -830,16 +830,21 @@ bool sector_t::HasTag(int checktag) const return tag == checktag; } -void sector_t::SetTag(int tagnum, bool discardall) +void sector_t::SetMainTag(int tagnum) { tag = tagnum; } -int sector_t::GetTag() const +int sector_t::GetMainTag() const { return tag; } +void sector_t::ClearTags() +{ + tag = 0; +} + void sector_t::HashTags() { int i; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 990a18ae5..62270567c 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1514,7 +1514,7 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex) else // [RH] Translate to new sector special ss->special = P_TranslateSectorSpecial (LittleShort(ms->special)); ss->secretsector = !!(ss->special&SECRET_MASK); - ss->SetTag(LittleShort(ms->tag)); + ss->SetMainTag(LittleShort(ms->tag)); ss->thinglist = NULL; ss->touching_thinglist = NULL; // phares 3/14/98 ss->seqType = defSeqType; @@ -3131,9 +3131,9 @@ static void P_GroupLines (bool buildmap) { if (sector->linecount == 0) { - Printf ("Sector %i (tag %i) has no lines\n", i, sector->GetTag()); + 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->SetTag(0); + sector->ClearTags(); } else { diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 4ad3c3efc..aab952f21 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1316,7 +1316,7 @@ public: continue; case NAME_Id: - sec->SetTag((short)CheckInt(key), false); + sec->SetMainTag((short)CheckInt(key)); continue; default: diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index e21eb506e..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].GetTag()); + 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 68780fdba..2d48e6053 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -304,7 +304,7 @@ void P_TranslateTeleportThings () while ( (dest = iterator.Next()) ) { - if (dest->Sector->GetTag() == 0) + if (dest->Sector->GetMainTag() == 0) { dest->tid = 1; dest->AddToHash (); diff --git a/src/r_defs.h b/src/r_defs.h index 5cdbb9f82..41821cb62 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -634,8 +634,9 @@ struct sector_t } bool HasTag(int checktag) const; - void SetTag(int tagnum, bool discardall = true); - int GetTag() const; + void SetMainTag(int tagnum); + int GetMainTag() const; + void ClearTags(); static void HashTags(); bool PlaneMoving(int pos);