From d4d010ac322626aa3373b3ea6d6071105ef1180e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 11 Feb 2019 16:26:11 +0200 Subject: [PATCH] - added compatibility flag for buggy CheckSwitchRange behavior https://forum.zdoom.org/viewtopic.php?t=63008 https://forum.zdoom.org/viewtopic.php?t=63650 --- src/d_main.cpp | 3 ++- src/doomdef.h | 1 + src/g_shared/p_switch.cpp | 12 +++++++++--- src/gamedata/g_mapinfo.cpp | 1 + src/maploader/compatibility.cpp | 1 + wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + wadsrc/static/zscript/constants.txt | 1 + 8 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index a2c758e0b..d2a43f969 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -600,7 +600,7 @@ CUSTOM_CVAR(Int, compatmode, 0, CVAR_ARCHIVE|CVAR_NOINITCALL) case 4: // Old ZDoom compat mode v = COMPATF_SOUNDTARGET | COMPATF_LIGHT; - w = COMPATF2_MULTIEXIT | COMPATF2_TELEPORT | COMPATF2_PUSHWINDOW; + w = COMPATF2_MULTIEXIT | COMPATF2_TELEPORT | COMPATF2_PUSHWINDOW | COMPATF2_CHECKSWITCHRANGE; break; case 5: // MBF compat mode @@ -658,6 +658,7 @@ CVAR (Flag, compat_pointonline, compatflags2, COMPATF2_POINTONLINE); CVAR (Flag, compat_multiexit, compatflags2, COMPATF2_MULTIEXIT); CVAR (Flag, compat_teleport, compatflags2, COMPATF2_TELEPORT); CVAR (Flag, compat_pushwindow, compatflags2, COMPATF2_PUSHWINDOW); +CVAR (Flag, compat_checkswitchrange, compatflags2, COMPATF2_CHECKSWITCHRANGE); CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) diff --git a/src/doomdef.h b/src/doomdef.h index a8f0250d5..14d029f8b 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -328,6 +328,7 @@ enum : unsigned int COMPATF2_MULTIEXIT = 1 << 4, // Level exit can be triggered multiple times (required by Daedalus's travel tubes, thanks to a faulty script) COMPATF2_TELEPORT = 1 << 5, // Don't let indirect teleports trigger sector actions COMPATF2_PUSHWINDOW = 1 << 6, // Disable the window check in CheckForPushSpecial() + COMPATF2_CHECKSWITCHRANGE = 1 << 7, // Enable buggy CheckSwitchRange behavior }; // Emulate old bugs for select maps. These are not exposed by a cvar diff --git a/src/g_shared/p_switch.cpp b/src/g_shared/p_switch.cpp index 2e092b5c3..81ce5b58b 100644 --- a/src/g_shared/p_switch.cpp +++ b/src/g_shared/p_switch.cpp @@ -194,7 +194,9 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 * } } - return (user->Top() > open.top); + return (user->Level->i_compatflags2 & COMPATF2_CHECKSWITCHRANGE) + ? (user->Top() >= open.top) + : (user->Top() > open.top); } else if ((TexMan.FindSwitch(side->GetTexture(side_t::bottom))) != NULL) { @@ -216,7 +218,9 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 * } } - return (user->Z() < open.bottom); + return (user->Level->i_compatflags2 & COMPATF2_CHECKSWITCHRANGE) + ? (user->Z() <= open.bottom) + : (user->Z() < open.bottom); } else if ((flags & ML_3DMIDTEX) || (TexMan.FindSwitch(side->GetTexture(side_t::mid))) != NULL) { @@ -229,7 +233,9 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 * else { // no switch found. Check whether the player can touch either top or bottom texture - return (user->Top() > open.top) || (user->isBelow(open.bottom)); + return (user->Level->i_compatflags2 & COMPATF2_CHECKSWITCHRANGE) + ? ( (user->Top() >= open.top) || (user->Z() <= open.bottom) ) + : ( (user->Top() > open.top) || user->isBelow(open.bottom) ); } } diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index f5f45fdca..e4dae12fe 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -1619,6 +1619,7 @@ MapFlagHandlers[] = { "compat_multiexit", MITYPE_COMPATFLAG, 0, COMPATF2_MULTIEXIT }, { "compat_teleport", MITYPE_COMPATFLAG, 0, COMPATF2_TELEPORT }, { "compat_pushwindow", MITYPE_COMPATFLAG, 0, COMPATF2_PUSHWINDOW }, + { "compat_checkswitchrange", MITYPE_COMPATFLAG, 0, COMPATF2_CHECKSWITCHRANGE }, { "cd_start_track", MITYPE_EATNEXT, 0, 0 }, { "cd_end1_track", MITYPE_EATNEXT, 0, 0 }, { "cd_end2_track", MITYPE_EATNEXT, 0, 0 }, diff --git a/src/maploader/compatibility.cpp b/src/maploader/compatibility.cpp index ad792dc5a..61c3106c4 100644 --- a/src/maploader/compatibility.cpp +++ b/src/maploader/compatibility.cpp @@ -164,6 +164,7 @@ static FCompatOption Options[] = { "multiexit", COMPATF2_MULTIEXIT, SLOT_COMPAT2 }, { "teleport", COMPATF2_TELEPORT, SLOT_COMPAT2 }, { "disablepushwindowcheck", COMPATF2_PUSHWINDOW, SLOT_COMPAT2 }, + { "checkswitchrange", COMPATF2_CHECKSWITCHRANGE, SLOT_COMPAT2 }, { NULL, 0, 0 } }; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 54cb51ef1..e49759b6a 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2184,6 +2184,7 @@ CMPTMNU_SOUNDCUTOFF = "Sounds stop when actor vanishes"; CMPTMNU_SOUNDTARGET = "Use original sound target handling"; CMPTMNU_TELEPORT = "Scripted teleports don't trigger sector actions"; CMPTMNU_PUSHWINDOW = "Non-blocking lines can be pushed"; +CMPTMNU_CHECKSWITCHRANGE = "Enable buggy CheckSwitchRange behavior"; // Sound Options SNDMNU_TITLE = "SOUND OPTIONS"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 6633265f2..2a6fe6a65 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1434,6 +1434,7 @@ OptionMenu "CompatibilityOptions" protected Option "$CMPTMNU_MULTIEXIT", "compat_multiexit", "YesNo" Option "$CMPTMNU_TELEPORT", "compat_teleport", "YesNo" Option "$CMPTMNU_PUSHWINDOW", "compat_pushwindow", "YesNo" + Option "$CMPTMNU_CHECKSWITCHRANGE", "compat_checkswitchrange", "YesNo" StaticText " " StaticText "$CMPTMNU_PHYSICSBEHAVIOR",1 diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index 0de7ec391..0df017485 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -1338,4 +1338,5 @@ enum ECompatFlags COMPATF2_MULTIEXIT = 1 << 4, // Level exit can be triggered multiple times (required by Daedalus's travel tubes, thanks to a faulty script) COMPATF2_TELEPORT = 1 << 5, // Don't let indirect teleports trigger sector actions COMPATF2_PUSHWINDOW = 1 << 6, // Disable the window check in CheckForPushSpecial() + COMPATF2_CHECKSWITCHRANGE = 1 << 7, // Enable buggy CheckSwitchRange behavior };