diff --git a/src/d_main.cpp b/src/d_main.cpp index 3035d53e9..bda6b3e97 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -534,28 +534,11 @@ 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(); } } @@ -563,7 +546,7 @@ CUSTOM_CVAR (Int, compatflags2, 0, CVAR_ARCHIVE|CVAR_SERVERINFO | CVAR_NOINITCAL { for (auto Level : AllLevels()) { - Level->i_compatflags2 = GetCompatibility2(Level, self) | Level->ii_compatflags2; + Level->ApplyCompatibility2(); Level->SetCompatLineOnSide(true); } } diff --git a/src/g_level.cpp b/src/g_level.cpp index 6f90326b3..380e21ab9 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -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; } //========================================================================== diff --git a/src/g_levellocals.h b/src/g_levellocals.h index fac345de0..4068b56ee 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -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: diff --git a/src/gamedata/textures/texture.cpp b/src/gamedata/textures/texture.cpp index 85d319ffc..046807b4c 100644 --- a/src/gamedata/textures/texture.cpp +++ b/src/gamedata/textures/texture.cpp @@ -226,7 +226,7 @@ FTexture *FTexture::GetRawTexture() if (OffsetLess) return OffsetLess; // Reject anything that cannot have been a single-patch multipatch texture in vanilla. auto image = static_cast(GetImage()); - if (bMultiPatch != 1 || UseType != ETextureType::Wall || Scale.X != 1 || Scale.Y != 1 || bWorldPanning || image == nullptr || image->NumParts != 1) + if (bMultiPatch != 1 || UseType != ETextureType::Wall || Scale.X != 1 || Scale.Y != 1 || bWorldPanning || image == nullptr || image->NumParts != 1 || _TopOffset[0] == 0) { OffsetLess = this; return this; @@ -234,6 +234,15 @@ FTexture *FTexture::GetRawTexture() // Set up a new texture that directly references the underlying patch. // From here we cannot retrieve the original texture made for it, so just create a new one. FImageSource *source = image->Parts[0].Image; + + // Size must match for this to work as intended + if (source->GetWidth() != Width || source->GetHeight() != Height) + { + OffsetLess = this; + return this; + } + + OffsetLess = new FImageTexture(source, ""); TexMan.AddTexture(OffsetLess); return OffsetLess; diff --git a/src/maploader/compatibility.cpp b/src/maploader/compatibility.cpp index 61c3106c4..a978ec47e 100644 --- a/src/maploader/compatibility.cpp +++ b/src/maploader/compatibility.cpp @@ -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) { diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index a5fbe691a..59e7f9149 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -197,6 +197,7 @@ BA4860C7A2F5D705DB32A1A38DB77EC4 // pl2.wad map10 EDA5CE7C462BD171BF8110AC56B67857 // pl2.wad map11 A9A9A728E689266939C1B71655F320CA // pl2.wad map25 62CA74092FC88C1E7FE2D0B1A8034E29 // pl2.wad map29 +19E1CFD717FC6BBA9371F0F529B4CDFF // ur_final.wad map27 { rebuildnodes }