diff --git a/src/am_map.cpp b/src/am_map.cpp index 81e45c685..606a65ae8 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2071,17 +2071,17 @@ static bool AM_CheckSecret(line_t *line) { if (line->frontsector != NULL) { - if (line->frontsector->secretsector) + if (line->frontsector->wasSecret()) { - if (am_map_secrets!=0 && !(line->frontsector->special&SECRET_MASK)) return true; + if (am_map_secrets!=0 && !line->frontsector->isSecret()) return true; if (am_map_secrets==2 && !(line->flags & ML_SECRET)) return true; } } if (line->backsector != NULL) { - if (line->backsector->secretsector) + if (line->backsector->wasSecret()) { - if (am_map_secrets!=0 && !(line->backsector->special&SECRET_MASK)) return true; + if (am_map_secrets!=0 && !line->backsector->isSecret()) return true; if (am_map_secrets==2 && !(line->flags & ML_SECRET)) return true; } } diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 0a9e4f0e3..57290a98a 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -1106,11 +1106,8 @@ static void PrintSecretString(const char *string, bool thislevel) if (*string == ';') string++; if (thislevel && secnum >= 0 && secnum < numsectors) { - if (sectors[secnum].secretsector) - { - if ((sectors[secnum].special & SECRET_MASK)) colstr = TEXTCOLOR_RED; - else colstr = TEXTCOLOR_GREEN; - } + if (sectors[secnum].isSecret()) colstr = TEXTCOLOR_RED; + else if (sectors[secnum].wasSecret()) colstr = TEXTCOLOR_GREEN; else colstr = TEXTCOLOR_ORANGE; } } diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index 1edea19fa..7e9330990 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -632,7 +632,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) { if ((sec->special & 0xFF) == Damage_InstantDeath) { - P_DamageMobj (self, NULL, NULL, 999, NAME_None); + P_DamageMobj (self, NULL, NULL, 999, NAME_InstantDeath); } else if ((sec->special & 0xFF) == Scroll_StrifeCurrent) { diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 6af26652f..3fbbfeab7 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -342,8 +342,7 @@ void P_PlayerOnSpecial3DFloor(player_t* player) } // Apply sector specials - if (rover->model->special || rover->model->damageamount) - P_PlayerInSpecialSector(player, rover->model); + P_PlayerInSpecialSector(player, rover->model); // Apply flat specials (using the ceiling!) P_PlayerOnSpecialFlat( diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 9e7806039..42372888b 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -159,7 +159,7 @@ void DFloor::Tick () case donutRaise: case genFloorChgT: case genFloorChg0: - m_Sector->special = (m_Sector->special & SECRET_MASK) | m_NewSpecial; + m_Sector->special = m_Sector->special | m_NewSpecial; //fall thru case genFloorChg: m_Sector->SetTexture(sector_t::floor, m_Texture); @@ -175,7 +175,7 @@ void DFloor::Tick () case floorLowerAndChange: case genFloorChgT: case genFloorChg0: - m_Sector->special = (m_Sector->special & SECRET_MASK) | m_NewSpecial; + m_Sector->special = m_Sector->special | m_NewSpecial; //fall thru case genFloorChg: m_Sector->SetTexture(sector_t::floor, m_Texture); @@ -240,7 +240,7 @@ void DFloor::SetFloorChangeType (sector_t *sec, int change) m_Type = DFloor::genFloorChg; break; case 3: - m_NewSpecial = sec->special & ~SECRET_MASK; + m_NewSpecial = sec->special; m_Type = DFloor::genFloorChgT; break; } @@ -438,11 +438,11 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, { FTextureID oldpic = sec->GetTexture(sector_t::floor); sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor)); - sec->special = (sec->special & SECRET_MASK) | (line->frontsector->special & ~SECRET_MASK); + sec->special = line->frontsector->special; } else { - sec->special &= SECRET_MASK; + sec->special = 0; } break; @@ -454,7 +454,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, // jff 1/24/98 make sure floor->m_NewSpecial gets initialized // in case no surrounding sector is at floordestheight // --> should not affect compatibility <-- - floor->m_NewSpecial = sec->special & ~SECRET_MASK; + floor->m_NewSpecial = sec->special; //jff 5/23/98 use model subroutine to unify fixes and handling sector_t *modelsec; @@ -462,7 +462,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, if (modelsec != NULL) { floor->m_Texture = modelsec->GetTexture(sector_t::floor); - floor->m_NewSpecial = modelsec->special & ~SECRET_MASK; + floor->m_NewSpecial = modelsec->special; } break; @@ -1091,7 +1091,7 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag) if (line) { // [RH] if no line, no change sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor)); - sec->special = (sec->special & SECRET_MASK) | (line->frontsector->special & ~SECRET_MASK); + sec->special = line->frontsector->special; } break; case numChangeOnly: diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 8fa8691b2..53090ef18 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1945,6 +1945,9 @@ FUNC(LS_Sector_ChangeFlags) rtn = false; FSectorTagIterator itr(arg0); + // exclude protected flags + arg1 &= ~SECF_NOMODIFY; + arg2 &= ~SECF_NOMODIFY; while ((secNum = itr.Next()) >= 0) { sectors[secNum].Flags = (sectors[secNum].Flags | arg1) & ~arg2; diff --git a/src/p_lnspec.h b/src/p_lnspec.h index 9fb4c17b3..cb3f6bf85 100644 --- a/src/p_lnspec.h +++ b/src/p_lnspec.h @@ -176,10 +176,12 @@ typedef enum { // [RH] Equivalents for BOOM's generalized sector types +#ifndef SECRET_MASK #define DAMAGE_MASK 0x0300 #define SECRET_MASK 0x0400 #define FRICTION_MASK 0x0800 #define PUSH_MASK 0x1000 +#endif struct line_t; class AActor; diff --git a/src/p_plats.cpp b/src/p_plats.cpp index 7600637b2..eecf521ee 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -281,7 +281,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height, if (line) sec->SetTexture(sector_t::floor, line->sidedef[0]->sector->GetTexture(sector_t::floor)); if (change == 1) - sec->special &= SECRET_MASK; // Stop damage and other stuff, if any + sec->special = 0; // Stop damage and other stuff, if any } switch (type) @@ -293,7 +293,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height, plat->m_Low = sec->floorplane.d; plat->m_Status = DPlat::up; plat->PlayPlatSound ("Floor"); - sec->special &= SECRET_MASK; // NO MORE DAMAGE, IF APPLICABLE + sec->special = 0; // NO MORE DAMAGE, IF APPLICABLE break; case DPlat::platUpByValue: diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index fdf57ddb0..fa1f395cf 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -398,15 +398,25 @@ void P_SerializeWorld (FArchive &arc) } } - arc << sec->SoundTarget + arc << sec->SoundTarget << sec->SecActTarget << sec->sky << sec->MoreFlags << sec->Flags << sec->FloorSkyBox << sec->CeilingSkyBox - << sec->ZoneNumber - << sec->secretsector - << sec->interpolations[0] + << sec->ZoneNumber; + if (SaveVersion < 4529) + { + short secretsector; + arc << secretsector; + if (secretsector) sec->Flags |= SECF_WASSECRET; + if (sec->special & SECRET_MASK) + { + sec->Flags |= SECF_SECRET; + sec->special &= ~SECRET_MASK; + } + } + arc << sec->interpolations[0] << sec->interpolations[1] << sec->interpolations[2] << sec->interpolations[3] diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 50e7f41d6..dbd0954cc 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1512,7 +1512,6 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex) ss->special = LittleShort(ms->special); else // [RH] Translate to new sector special ss->special = P_TranslateSectorSpecial (LittleShort(ms->special)); - ss->secretsector = !!(ss->special&SECRET_MASK); tagManager.AddSectorTag(i, LittleShort(ms->tag)); ss->thinglist = NULL; ss->touching_thinglist = NULL; // phares 3/14/98 diff --git a/src/p_spec.cpp b/src/p_spec.cpp index c439ac50e..d94d91ac5 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -437,7 +437,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) } } - int special = sector->special & ~SECRET_MASK; + int special = sector->special; // Has hit ground. AInventory *ironfeet; @@ -574,9 +574,9 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) } } - if (sector->special & SECRET_MASK) + if (sector->isSecret()) { - sector->special &= ~SECRET_MASK; + sector->ClearSecret(); P_GiveSecret(player->mo, true, true, int(sector - sectors)); } } @@ -1189,7 +1189,11 @@ void P_SpawnSpecials (void) // [RH] All secret sectors are marked with a BOOM-ish bitfield if (sector->special & SECRET_MASK) + { + sector->Flags |= SECF_SECRET | SECF_WASSECRET; + sector->special &= ~SECRET_MASK; level.total_secrets++; + } switch (sector->special & 0xff) { diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 2169da49f..128225e4a 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1567,8 +1567,6 @@ public: if (sc.Number != 0) tagManager.AddSectorTag(index, sc.Number); } } - - sec->secretsector = !!(sec->special&SECRET_MASK); // Reset the planes to their defaults if not all of the plane equation's parameters were found. if (fplaneflags != 15) diff --git a/src/p_user.cpp b/src/p_user.cpp index 8f8a93fdb..922cc2a1c 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2538,10 +2538,8 @@ void P_PlayerThink (player_t *player) if (!(player->cheats & CF_PREDICTING)) { P_PlayerOnSpecial3DFloor (player); - if (player->mo->Sector->special || player->mo->Sector->damageamount != 0) - { - P_PlayerInSpecialSector (player); - } + P_PlayerInSpecialSector (player); + if (player->mo->z <= player->mo->Sector->floorplane.ZatPoint( player->mo->x, player->mo->y) || player->mo->waterlevel) diff --git a/src/r_defs.h b/src/r_defs.h index 89449f446..0c873beeb 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -355,6 +355,12 @@ enum SECF_NOFALLINGDAMAGE= 2, // No falling damage in this sector SECF_FLOORDROP = 4, // all actors standing on this floor will remain on it when it lowers very fast. SECF_NORESPAWN = 8, // players can not respawn in this sector + + + SECF_WASSECRET = 1 << 30, // a secret that was discovered + SECF_SECRET = 1 << 31, // a secret sector + + SECF_NOMODIFY = SECF_SECRET|SECF_WASSECRET // not modifiable by Sector_ChangeFlags }; enum @@ -642,6 +648,20 @@ struct sector_t return pos == floor? floorplane:ceilingplane; } + bool isSecret() const + { + return !!(Flags & SECF_SECRET); + } + + bool wasSecret() const + { + return !!(Flags & SECF_WASSECRET); + } + + void ClearSecret() + { + Flags &= ~SECF_SECRET; + } bool PlaneMoving(int pos); @@ -729,7 +749,6 @@ struct sector_t // regular sky. TObjPtr FloorSkyBox, CeilingSkyBox; - short secretsector; //jff 2/16/98 remembers if sector WAS secret (automap) int sectornum; // for comparing sector copies extsector_t * e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat. diff --git a/src/version.h b/src/version.h index d7026786e..b10074f41 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4528 +#define SAVEVER 4529 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)