Skip to content

Commit

Permalink
- fix the compat_pointonline flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Mar 23, 2019
1 parent 7606b22 commit 5da2ecd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
21 changes: 2 additions & 19 deletions src/d_main.cpp
Expand Up @@ -534,36 +534,19 @@ CVAR (Flag, sv_respawnsuper, dmflags2, DF2_RESPAWN_SUPER);

EXTERN_CVAR(Int, compatmode)

static int GetCompatibility(FLevelLocals *Level, int mask)
{
if (Level->info == nullptr) return mask;
else return (mask & ~Level->info->compatmask) | (Level->info->compatflags & Level->info->compatmask);
}

static int GetCompatibility2(FLevelLocals *Level, int mask)
{
return (Level->info == nullptr) ? mask
: (mask & ~Level->info->compatmask2) | (Level->info->compatflags2 & Level->info->compatmask2);
}

CUSTOM_CVAR (Int, compatflags, 0, CVAR_ARCHIVE|CVAR_SERVERINFO | CVAR_NOINITCALL)
{
for (auto Level : AllLevels())
{
int old = Level->i_compatflags;
Level->i_compatflags = GetCompatibility(Level, self) | Level->ii_compatflags;
if ((old ^ Level->i_compatflags) & COMPATF_POLYOBJ)
{
Level->ClearAllSubsectorLinks();
}
Level->ApplyCompatibility();
}
}

CUSTOM_CVAR (Int, compatflags2, 0, CVAR_ARCHIVE|CVAR_SERVERINFO | CVAR_NOINITCALL)
{
for (auto Level : AllLevels())
{
Level->i_compatflags2 = GetCompatibility2(Level, self) | Level->ii_compatflags2;
Level->ApplyCompatibility2();
Level->SetCompatLineOnSide(true);
}
}
Expand Down
31 changes: 29 additions & 2 deletions src/g_level.cpp
Expand Up @@ -2119,8 +2119,35 @@ int FLevelLocals::GetInfighting()
void FLevelLocals::SetCompatLineOnSide(bool state)
{
int on = (state && (i_compatflags2 & COMPATF2_POINTONLINE));
if (on) for (auto l : lines) l.flags |= ML_COMPATSIDE;
else for (auto l : lines) l.flags &= ML_COMPATSIDE;
if (on) for (auto &l : lines) l.flags |= ML_COMPATSIDE;
else for (auto &l : lines) l.flags &= ~ML_COMPATSIDE;
}

int FLevelLocals::GetCompatibility(int mask)
{
if (info == nullptr) return mask;
else return (mask & ~info->compatmask) | (info->compatflags & info->compatmask);
}

int FLevelLocals::GetCompatibility2(int mask)
{
return (info == nullptr) ? mask
: (mask & ~info->compatmask2) | (info->compatflags2 & info->compatmask2);
}

void FLevelLocals::ApplyCompatibility()
{
int old = i_compatflags;
i_compatflags = GetCompatibility(compatflags) | ii_compatflags;
if ((old ^ i_compatflags) & COMPATF_POLYOBJ)
{
ClearAllSubsectorLinks();
}
}

void FLevelLocals::ApplyCompatibility2()
{
i_compatflags2 = GetCompatibility2(compatflags2) | ii_compatflags2;
}

//==========================================================================
Expand Down
5 changes: 5 additions & 0 deletions src/g_levellocals.h
Expand Up @@ -141,6 +141,11 @@ struct FLevelLocals
int FindNode (const FStrifeDialogueNode *node);
int GetInfighting();
void SetCompatLineOnSide(bool state);
int GetCompatibility(int mask);
int GetCompatibility2(int mask);
void ApplyCompatibility();
void ApplyCompatibility2();

void Init();

private:
Expand Down
4 changes: 2 additions & 2 deletions src/maploader/compatibility.cpp
Expand Up @@ -326,8 +326,8 @@ FName MapLoader::CheckCompatibility(MapData *map)
}

// Reset i_compatflags
compatflags.Callback();
compatflags2.Callback();
Level->ApplyCompatibility();
Level->ApplyCompatibility2();
// Set floatbob compatibility for all maps with an original Hexen MAPINFO.
if (Level->flags2 & LEVEL2_HEXENHACK)
{
Expand Down

0 comments on commit 5da2ecd

Please sign in to comment.