- fixed: A_CheckTerrain did not use the proper damage type for processing an instant death sector.

- moved sector secret information from sector_t::special and secretsector to two flag bits in sector_t::Flags.

This is to get rid of the bit masking madness in the floor/ceiling thinkers which need to preserve this bit when they change a sector's type.
This commit is contained in:
Christoph Oelckers 2016-01-06 01:50:45 +01:00
parent 1c6a00059f
commit 6a63effa1f
15 changed files with 67 additions and 38 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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)
{

View file

@ -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(

View file

@ -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:

View file

@ -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;

View file

@ -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;

View file

@ -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:

View file

@ -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]

View file

@ -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

View file

@ -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)
{

View file

@ -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)

View file

@ -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)

View file

@ -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<ASkyViewpoint> 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.

View file

@ -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)