From 69b9f107f06188ad5e342d00669efa1d974a0c82 Mon Sep 17 00:00:00 2001 From: inkoalawetrust <56005600+inkoalawetrust@users.noreply.github.com> Date: Sun, 25 Sep 2022 01:25:18 +0300 Subject: [PATCH] Added support for BLOCKLANDMONSTERS in Line_SetBlocking. This PR was written by MrRaveYard --- src/playsim/p_lnspec.cpp | 67 +++++++++++++++++------------- wadsrc/static/zscript/constants.zs | 1 + 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/playsim/p_lnspec.cpp b/src/playsim/p_lnspec.cpp index 787a5bded..d73f18e5e 100644 --- a/src/playsim/p_lnspec.cpp +++ b/src/playsim/p_lnspec.cpp @@ -2736,40 +2736,47 @@ FUNC(LS_Line_SetTextureScale) FUNC(LS_Line_SetBlocking) // Line_SetBlocking (id, setflags, clearflags) { - static const int flagtrans[] = - { - ML_BLOCKING, - ML_BLOCKMONSTERS, - ML_BLOCK_PLAYERS, - ML_BLOCK_FLOATERS, - ML_BLOCKPROJECTILE, - ML_BLOCKEVERYTHING, - ML_RAILING, - ML_BLOCKUSE, - ML_BLOCKSIGHT, - ML_BLOCKHITSCAN, - ML_SOUNDBLOCK, - -1 - }; + struct FlagTransEntry + { + int fieldIndex, bitmask; + }; - if (arg0 == 0) return false; + static const FlagTransEntry flagtrans[] = + { + {0, ML_BLOCKING}, + {0, ML_BLOCKMONSTERS}, + {0, ML_BLOCK_PLAYERS}, + {0, ML_BLOCK_FLOATERS}, + {0, ML_BLOCKPROJECTILE}, + {0, ML_BLOCKEVERYTHING}, + {0, ML_RAILING}, + {0, ML_BLOCKUSE}, + {0, ML_BLOCKSIGHT}, + {0, ML_BLOCKHITSCAN}, + {0, ML_SOUNDBLOCK}, + {1, ML2_BLOCKLANDMONSTERS}, + {-1, -1}, + }; - int setflags = 0; - int clearflags = 0; + if (arg0 == 0) return false; - for(int i = 0; flagtrans[i] != -1; i++, arg1 >>= 1, arg2 >>= 1) - { - if (arg1 & 1) setflags |= flagtrans[i]; - if (arg2 & 1) clearflags |= flagtrans[i]; - } + int setflags[2] = {}; + int clearflags[2] = {}; - auto itr = Level->GetLineIdIterator(arg0); - int line; - while ((line = itr.Next()) >= 0) - { - Level->lines[line].flags = (Level->lines[line].flags & ~clearflags) | setflags; - } - return true; + for (int i = 0; flagtrans[i].bitmask != -1; i++, arg1 >>= 1, arg2 >>= 1) + { + if (arg1 & 1) setflags[flagtrans[i].fieldIndex] |= flagtrans[i].bitmask; + if (arg2 & 1) clearflags[flagtrans[i].fieldIndex] |= flagtrans[i].bitmask; + } + + auto itr = Level->GetLineIdIterator(arg0); + int line; + while ((line = itr.Next()) >= 0) + { + Level->lines[line].flags = (Level->lines[line].flags & ~clearflags[0]) | setflags[0]; + Level->lines[line].flags2 = (Level->lines[line].flags2 & ~clearflags[1]) | setflags[1]; + } + return true; } FUNC(LS_Line_SetAutomapFlags) diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index 73ae5b385..f5fcfc33b 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -451,6 +451,7 @@ enum EBlockFlags BLOCKF_SIGHT = 256, BLOCKF_HITSCAN = 512, BLOCKF_SOUND = 1024, + BLOCKF_LANDMONSTERS = 2048, }; // Pointer constants, bitfield-enabled