From 06ba8c4c0004517743cd10ab1ba1441c3c602982 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jan 2019 17:35:50 +0100 Subject: [PATCH] - 50 more simple replacements of 'level' --- src/g_levellocals.h | 10 +++--- src/p_3dmidtex.cpp | 31 ++++++++++--------- src/p_doors.cpp | 4 +-- src/p_interaction.cpp | 23 +++++++------- src/p_linkedsectors.cpp | 14 +++++---- src/p_sight.cpp | 2 +- src/p_spec.cpp | 8 +++-- src/p_switch.cpp | 2 +- src/swrenderer/things/r_visiblespritelist.cpp | 2 +- 9 files changed, 50 insertions(+), 46 deletions(-) diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 9bf1386352..20542b9664 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -509,27 +509,27 @@ inline FSectorPortal *line_t::GetTransferredPortal() inline FSectorPortal *sector_t::GetPortal(int plane) { - return &level.sectorPortals[Portals[plane]]; + return &Level->sectorPortals[Portals[plane]]; } inline double sector_t::GetPortalPlaneZ(int plane) { - return level.sectorPortals[Portals[plane]].mPlaneZ; + return Level->sectorPortals[Portals[plane]].mPlaneZ; } inline DVector2 sector_t::GetPortalDisplacement(int plane) { - return level.sectorPortals[Portals[plane]].mDisplacement; + return Level->sectorPortals[Portals[plane]].mDisplacement; } inline int sector_t::GetPortalType(int plane) { - return level.sectorPortals[Portals[plane]].mType; + return Level->sectorPortals[Portals[plane]].mType; } inline int sector_t::GetOppositePortalGroup(int plane) { - return level.sectorPortals[Portals[plane]].mDestination->PortalGroup; + return Level->sectorPortals[Portals[plane]].mDestination->PortalGroup; } inline bool sector_t::PortalBlocksView(int plane) diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 81fb56c0eb..64485522c8 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -119,15 +119,16 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c // invalid set of parameters return; } + auto Level = sector->Level; extsector_t::midtex::plane &scrollplane = ceiling? sector->e->Midtex.Ceiling : sector->e->Midtex.Floor; // Bit arrays that mark whether a line or sector is to be attached. - uint8_t *found_lines = new uint8_t[(level.lines.Size()+7)/8]; - uint8_t *found_sectors = new uint8_t[(level.sectors.Size()+7)/8]; + uint8_t *found_lines = new uint8_t[(Level->lines.Size()+7)/8]; + uint8_t *found_sectors = new uint8_t[(Level->sectors.Size()+7)/8]; - memset(found_lines, 0, sizeof (uint8_t) * ((level.lines.Size()+7)/8)); - memset(found_sectors, 0, sizeof (uint8_t) * ((level.sectors.Size()+7)/8)); + memset(found_lines, 0, sizeof (uint8_t) * ((Level->lines.Size()+7)/8)); + memset(found_sectors, 0, sizeof (uint8_t) * ((Level->sectors.Size()+7)/8)); // mark all lines and sectors that are already attached to this one // and clear the arrays. The old data will be re-added automatically @@ -149,11 +150,11 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c if (tag == 0) { - auto itr = level.GetLineIdIterator(lineid); + auto itr = Level->GetLineIdIterator(lineid); int line; while ((line = itr.Next()) >= 0) { - line_t *ln = &level.lines[line]; + line_t *ln = &Level->lines[line]; if (ln->frontsector == NULL || ln->backsector == NULL || !(ln->flags & ML_3DMIDTEX)) { @@ -165,13 +166,13 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c } else { - auto it = level.GetSectorTagIterator(tag); + auto it = Level->GetSectorTagIterator(tag); int sec; while ((sec = it.Next()) >= 0) { - for (auto ln : level.sectors[sec].Lines) + for (auto ln : Level->sectors[sec].Lines) { - if (lineid != 0 && !level.LineHasId(ln, lineid)) continue; + if (lineid != 0 && !Level->LineHasId(ln, lineid)) continue; if (ln->frontsector == NULL || ln->backsector == NULL || !(ln->flags & ML_3DMIDTEX)) { @@ -185,28 +186,28 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c } - for(unsigned i=0; i < level.lines.Size(); i++) + for(unsigned i=0; i < Level->lines.Size(); i++) { if (found_lines[i>>3] & (1 << (i&7))) { - auto &line = level.lines[i]; + auto &line = Level->lines[i]; scrollplane.AttachedLines.Push(&line); v = line.frontsector->Index(); - assert(v < (int)level.sectors.Size()); + assert(v < (int)Level->sectors.Size()); found_sectors[v>>3] |= 1 << (v&7); v = line.backsector->Index(); - assert(v < (int)level.sectors.Size()); + assert(v < (int)Level->sectors.Size()); found_sectors[v>>3] |= 1 << (v&7); } } - for (unsigned i=0; i < level.sectors.Size(); i++) + for (unsigned i=0; i < Level->sectors.Size(); i++) { if (found_sectors[i>>3] & (1 << (i&7))) { - scrollplane.AttachedSectors.Push(&level.sectors[i]); + scrollplane.AttachedSectors.Push(&Level->sectors[i]); } } diff --git a/src/p_doors.cpp b/src/p_doors.cpp index a0bc8af660..00b4f214e8 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -132,7 +132,7 @@ void DDoor::Tick () // killough 10/98: implement gradual lighting effects if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fD()) { - level.EV_LightTurnOnPartway (m_LightTag, + Level->EV_LightTurnOnPartway (m_LightTag, (m_Sector->ceilingplane.fD() + m_Sector->floorplane.fD()) / (m_TopDist + m_Sector->floorplane.fD())); } @@ -178,7 +178,7 @@ void DDoor::Tick () // killough 10/98: implement gradual lighting effects if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fD()) { - level.EV_LightTurnOnPartway (m_LightTag, + Level->EV_LightTurnOnPartway (m_LightTag, (m_Sector->ceilingplane.fD() + m_Sector->floorplane.fD()) / (m_TopDist + m_Sector->floorplane.fD())); } diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index ec2854c6a9..a4916e5cfc 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -352,7 +352,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf // [JM] Fire KILL type scripts for actor. Not needed for players, since they have the "DEATH" script type. if (!player && !(flags7 & MF7_NOKILLSCRIPTS) && ((flags7 & MF7_USEKILLSCRIPTS) || gameinfo.forcekillscripts)) { - level.Behaviors.StartTypedScripts(SCRIPT_Kill, this, true, 0, true); + Level->Behaviors.StartTypedScripts(SCRIPT_Kill, this, true, 0, true); } flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY); @@ -387,7 +387,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf } if (CountsAsKill()) - level.killed_monsters++; + Level->killed_monsters++; if (source && source->player) { @@ -399,7 +399,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf // Don't count any frags at level start, because they're just telefrags // resulting from insufficient deathmatch starts, and it wouldn't be // fair to count them toward a player's score. - if (player && level.maptime) + if (player && Level->maptime) { source->player->frags[player - players]++; if (player == source->player) // [RH] Cumulative frag count @@ -492,7 +492,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf source->player->multicount++; if (source->player->lastkilltime > 0) { - if (source->player->lastkilltime < level.time - 3*TICRATE) + if (source->player->lastkilltime < Level->time - 3*TICRATE) { source->player->multicount = 1; } @@ -535,7 +535,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf } } } - source->player->lastkilltime = level.time; + source->player->lastkilltime = Level->time; } // [RH] Implement fraglimit @@ -563,10 +563,10 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf E_PlayerDied(int(player - players)); // Death script execution, care of Skull Tag - level.Behaviors.StartTypedScripts (SCRIPT_Death, this, true); + Level->Behaviors.StartTypedScripts (SCRIPT_Death, this, true); // [RH] Force a delay between death and respawn - player->respawn_time = level.time + TICRATE; + player->respawn_time = Level->time + TICRATE; //Added by MC: Respawn bots if (bglobal.botnum && !demoplayback) @@ -617,8 +617,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf } // [RH] If this is the unmorphed version of another monster, destroy this - // actor, because the morphed version is the one that will stick around in - // the level. + // actor, because the morphed version is the one that will stick around. if (flags & MF_UNMORPHED) { Destroy (); @@ -1247,7 +1246,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da //Use the original damage to check for telefrag amount. Don't let the now-amplified damagetypes do it. if (!telefragDamage || (target->flags7 & MF7_LAXTELEFRAGDMG)) { // Still allow telefragging :-( - damage = (int)(damage * level.teamdamage); + damage = (int)(damage * target->Level->teamdamage); if (damage <= 0) { return (damage < 0) ? -1 : 0; @@ -1681,7 +1680,7 @@ bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poi } if (source != NULL && source->player != player && player->mo->IsTeammate (source)) { - poison = (int)(poison * level.teamdamage); + poison = (int)(poison * player->mo->Level->teamdamage); } if (poison > 0) { @@ -1802,7 +1801,7 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPain return; } } - if (!(level.time&63) && playPainSound) + if (!(target->Level->time&63) && playPainSound) { FState *painstate = target->FindState(NAME_Pain, player->poisonpaintype); if (painstate != NULL) diff --git a/src/p_linkedsectors.cpp b/src/p_linkedsectors.cpp index f50c68b604..5d327643e8 100644 --- a/src/p_linkedsectors.cpp +++ b/src/p_linkedsectors.cpp @@ -288,7 +288,8 @@ static void RemoveTaggedSectors(extsector_t::linked::plane &scrollplane, int tag { for(int i = scrollplane.Sectors.Size()-1; i>=0; i--) { - if (level.SectorHasTag(scrollplane.Sectors[i].Sector, tag)) + auto sec = scrollplane.Sectors[i].Sector; + if (sec->Level->SectorHasTag(sec, tag)) { scrollplane.Sectors.Delete(i); } @@ -313,6 +314,7 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype) if ((ceiling && control->PlaneMoving(sector_t::ceiling)) || (!ceiling && control->PlaneMoving(sector_t::floor))) return false; + auto Level = control->Level; // Make sure we have only valid combinations movetype &= LINK_FLAGMASK; if ((movetype & LINK_FLOORMIRROR) == LINK_FLOORMIRRORFLAG) movetype &= ~LINK_FLOORMIRRORFLAG; @@ -327,16 +329,16 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype) if (movetype > 0) { int sec; - auto itr = level.GetSectorTagIterator(tag); + auto itr = Level->GetSectorTagIterator(tag); while ((sec = itr.Next()) >= 0) { // Don't attach to self (but allow attaching to this sector's oposite plane. - if (control == &level.sectors[sec]) + if (control == &Level->sectors[sec]) { if (ceiling == sector_t::floor && movetype & LINK_FLOOR) continue; if (ceiling == sector_t::ceiling && movetype & LINK_CEILING) continue; } - AddSingleSector(scrollplane, &level.sectors[sec], movetype); + AddSingleSector(scrollplane, &Level->sectors[sec], movetype); } } else @@ -360,11 +362,11 @@ void P_AddSectorLinksByID(sector_t *control, int id, INTBOOL ceiling) { extsector_t::linked::plane &scrollplane = ceiling? control->e->Linked.Ceiling : control->e->Linked.Floor; - auto itr = level.GetLineIdIterator(id); + auto itr = control->Level->GetLineIdIterator(id); int line; while ((line = itr.Next()) >= 0) { - line_t *ld = &level.lines[line]; + line_t *ld = &control->Level->lines[line]; if (ld->special == Static_Init && ld->args[1] == Init_SectorLink) { diff --git a/src/p_sight.cpp b/src/p_sight.cpp index fd85a9a080..41ecd23e8f 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -857,7 +857,7 @@ int P_CheckSight (AActor *t1, AActor *t2, int flags) // // check for trivial rejection // - if (!level.CheckReject(s1, s2)) + if (!t1->Level->CheckReject(s1, s2)) { sightcounts[0]++; res = false; // can't possibly be connected diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 0c81a2de0b..f60e614683 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -164,6 +164,8 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe return false; } + auto Level = line->GetLevel(); + // [MK] Use WorldLinePreActivated to decide if activation should continue bool shouldactivate = true; E_WorldLinePreActivated(line, mo, activationType, &shouldactivate); @@ -198,13 +200,13 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe } // 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 - level.LineHasId(line, line->args[0]) && // Safety check: exclude edited UDMF linedefs or ones that don't map the tag to args[0] + Level->LineHasId(line, 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) - level.FindFirstSectorFromTag (line->args[0]) == -1) // only if no sector is tagged to this linedef + Level->FindFirstSectorFromTag (line->args[0]) == -1) // only if no sector is tagged to this linedef { P_ChangeSwitchTexture (line->sidedef[0], repeat, special); line->special = 0; diff --git a/src/p_switch.cpp b/src/p_switch.cpp index ac58e8cc0f..667ff1e3ef 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -97,7 +97,7 @@ static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, const DV } } - level.CreateThinker (side, Where, Switch, pos, useagain); + side->sector->Level->CreateThinker (side, Where, Switch, pos, useagain); return true; } diff --git a/src/swrenderer/things/r_visiblespritelist.cpp b/src/swrenderer/things/r_visiblespritelist.cpp index 108fdb1c73..8c3935a4b0 100644 --- a/src/swrenderer/things/r_visiblespritelist.cpp +++ b/src/swrenderer/things/r_visiblespritelist.cpp @@ -118,7 +118,7 @@ namespace swrenderer } else { - return FindSubsectorDepth(thread, worldPos, level.HeadNode()); + return FindSubsectorDepth(thread, worldPos, Level->HeadNode()); } }