Added support for BLOCKLANDMONSTERS in Line_SetBlocking.

This PR was written by MrRaveYard
This commit is contained in:
inkoalawetrust 2022-09-25 01:25:18 +03:00 committed by Christoph Oelckers
parent 502c9fef5c
commit 69b9f107f0
2 changed files with 38 additions and 30 deletions

View file

@ -2736,40 +2736,47 @@ FUNC(LS_Line_SetTextureScale)
FUNC(LS_Line_SetBlocking) FUNC(LS_Line_SetBlocking)
// Line_SetBlocking (id, setflags, clearflags) // Line_SetBlocking (id, setflags, clearflags)
{ {
static const int flagtrans[] = struct FlagTransEntry
{ {
ML_BLOCKING, int fieldIndex, bitmask;
ML_BLOCKMONSTERS, };
ML_BLOCK_PLAYERS,
ML_BLOCK_FLOATERS,
ML_BLOCKPROJECTILE,
ML_BLOCKEVERYTHING,
ML_RAILING,
ML_BLOCKUSE,
ML_BLOCKSIGHT,
ML_BLOCKHITSCAN,
ML_SOUNDBLOCK,
-1
};
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; if (arg0 == 0) return false;
int clearflags = 0;
for(int i = 0; flagtrans[i] != -1; i++, arg1 >>= 1, arg2 >>= 1) int setflags[2] = {};
{ int clearflags[2] = {};
if (arg1 & 1) setflags |= flagtrans[i];
if (arg2 & 1) clearflags |= flagtrans[i];
}
auto itr = Level->GetLineIdIterator(arg0); for (int i = 0; flagtrans[i].bitmask != -1; i++, arg1 >>= 1, arg2 >>= 1)
int line; {
while ((line = itr.Next()) >= 0) if (arg1 & 1) setflags[flagtrans[i].fieldIndex] |= flagtrans[i].bitmask;
{ if (arg2 & 1) clearflags[flagtrans[i].fieldIndex] |= flagtrans[i].bitmask;
Level->lines[line].flags = (Level->lines[line].flags & ~clearflags) | setflags; }
}
return true; 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) FUNC(LS_Line_SetAutomapFlags)

View file

@ -451,6 +451,7 @@ enum EBlockFlags
BLOCKF_SIGHT = 256, BLOCKF_SIGHT = 256,
BLOCKF_HITSCAN = 512, BLOCKF_HITSCAN = 512,
BLOCKF_SOUND = 1024, BLOCKF_SOUND = 1024,
BLOCKF_LANDMONSTERS = 2048,
}; };
// Pointer constants, bitfield-enabled // Pointer constants, bitfield-enabled