From f816b433d179e32d85e82662ec32d62b3255bd71 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 7 Jun 2024 21:22:38 -0400 Subject: [PATCH] fix visible clip brushes add support for the two missing content flags from re-release --- common/bspfile.cc | 6 +-- common/decompile.cc | 10 +++- include/common/bspfile_common.hh | 80 ++++++++++++++++++-------------- include/common/bspfile_q2.hh | 4 +- 4 files changed, 58 insertions(+), 42 deletions(-) diff --git a/common/bspfile.cc b/common/bspfile.cc index a927c9f4..5d8d47ee 100644 --- a/common/bspfile.cc +++ b/common/bspfile.cc @@ -864,6 +864,7 @@ struct gamedef_q2_t : public gamedef_t if (native & Q2_CONTENTS_AREAPORTAL) result |= EWT_INVISCONTENTS_AREAPORTAL; if (native & Q2_CONTENTS_PLAYERCLIP) result |= EWT_INVISCONTENTS_PLAYERCLIP; if (native & Q2_CONTENTS_MONSTERCLIP) result |= EWT_INVISCONTENTS_MONSTERCLIP; + if (native & Q2_CONTENTS_PROJECTILECLIP) result |= EWT_INVISCONTENTS_PROJECTILECLIP; if (native & Q2_CONTENTS_ORIGIN) result |= EWT_INVISCONTENTS_ORIGIN; // contents flags @@ -888,8 +889,6 @@ struct gamedef_q2_t : public gamedef_t if (native & Q2_CONTENTS_UNUSED_10) result |= EWT_CFLAG_Q2_UNUSED_10; if (native & Q2_CONTENTS_UNUSED_11) result |= EWT_CFLAG_Q2_UNUSED_11; if (native & Q2_CONTENTS_UNUSED_12) result |= EWT_CFLAG_Q2_UNUSED_12; - if (native & Q2_CONTENTS_UNUSED_13) result |= EWT_CFLAG_Q2_UNUSED_13; - if (native & Q2_CONTENTS_UNUSED_14) result |= EWT_CFLAG_Q2_UNUSED_14; if (native & Q2_CONTENTS_UNUSED_30) result |= EWT_CFLAG_Q2_UNUSED_30; if (native & Q2_CONTENTS_UNUSED_31) result |= EWT_CFLAG_Q2_UNUSED_31; @@ -911,6 +910,7 @@ struct gamedef_q2_t : public gamedef_t if (contents.flags & EWT_INVISCONTENTS_ORIGIN) result |= Q2_CONTENTS_ORIGIN; if (contents.flags & EWT_INVISCONTENTS_PLAYERCLIP) result |= Q2_CONTENTS_PLAYERCLIP; if (contents.flags & EWT_INVISCONTENTS_MONSTERCLIP) result |= Q2_CONTENTS_MONSTERCLIP; + if (contents.flags & EWT_INVISCONTENTS_PROJECTILECLIP) result |= Q2_CONTENTS_PROJECTILECLIP; if (contents.flags & EWT_INVISCONTENTS_AREAPORTAL) result |= Q2_CONTENTS_AREAPORTAL; if (contents.flags & EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER) throw std::invalid_argument("illusionary visblocker not a contents in Q2"); if (contents.flags & EWT_CFLAG_DETAIL) result |= Q2_CONTENTS_DETAIL; @@ -932,8 +932,6 @@ struct gamedef_q2_t : public gamedef_t if (contents.flags & EWT_CFLAG_Q2_UNUSED_10) result |= Q2_CONTENTS_UNUSED_10; if (contents.flags & EWT_CFLAG_Q2_UNUSED_11) result |= Q2_CONTENTS_UNUSED_11; if (contents.flags & EWT_CFLAG_Q2_UNUSED_12) result |= Q2_CONTENTS_UNUSED_12; - if (contents.flags & EWT_CFLAG_Q2_UNUSED_13) result |= Q2_CONTENTS_UNUSED_13; - if (contents.flags & EWT_CFLAG_Q2_UNUSED_14) result |= Q2_CONTENTS_UNUSED_14; if (contents.flags & EWT_CFLAG_Q2_UNUSED_30) result |= Q2_CONTENTS_UNUSED_30; if (contents.flags & EWT_CFLAG_Q2_UNUSED_31) result |= Q2_CONTENTS_UNUSED_31; diff --git a/common/decompile.cc b/common/decompile.cc index 6d1ca504..a28ea69d 100644 --- a/common/decompile.cc +++ b/common/decompile.cc @@ -566,6 +566,8 @@ static const char *DefaultTextureForContents(const mbsp_t *bsp, const contentfla return "e1u1/clip"; } else if (native & Q2_CONTENTS_MONSTERCLIP) { return "e1u1/clip_mon"; + } else if (native & Q2_CONTENTS_PROJECTILECLIP) { + return "e1u1/clip_proj"; } else if (native & Q2_CONTENTS_AREAPORTAL) { return "e1u1/trigger"; } @@ -591,9 +593,13 @@ static void OverrideTextureForContents( if (bsp->loadversion->game->id == GAME_QUAKE_II) { int native = bsp->loadversion->game->contents_to_native(contents); - if (native & (Q2_CONTENTS_PLAYERCLIP | Q2_CONTENTS_MONSTERCLIP)) { - if (!(native & Q2_CONTENTS_PLAYERCLIP)) { + if (native & (Q2_CONTENTS_PLAYERCLIP | Q2_CONTENTS_MONSTERCLIP | Q2_CONTENTS_PROJECTILECLIP)) { + if ((native & Q2_CONTENTS_PLAYERCLIP) == Q2_CONTENTS_PLAYERCLIP) { + side.texture_name = "e1u1/clip_player"; + } else if ((native & Q2_CONTENTS_MONSTERCLIP) == Q2_CONTENTS_MONSTERCLIP) { side.texture_name = "e1u1/clip_mon"; + } else if ((native & Q2_CONTENTS_PROJECTILECLIP) == Q2_CONTENTS_PROJECTILECLIP) { + side.texture_name = "e1u1/clip_proj"; } else { side.texture_name = "e1u1/clip"; } diff --git a/include/common/bspfile_common.hh b/include/common/bspfile_common.hh index 0814b5aa..6463b037 100644 --- a/include/common/bspfile_common.hh +++ b/include/common/bspfile_common.hh @@ -68,37 +68,14 @@ enum contents_t : contents_int_t { EWT_LAST_VISIBLE_CONTENTS_INDEX = 8, EWT_LAST_VISIBLE_CONTENTS = EWT_VISCONTENTS_MIST, - EWT_ALL_LIQUIDS = - EWT_VISCONTENTS_LAVA | - EWT_VISCONTENTS_SLIME | - EWT_VISCONTENTS_WATER, - - EWT_ALL_VISIBLE_CONTENTS = - EWT_VISCONTENTS_SOLID | - EWT_VISCONTENTS_SKY | - EWT_VISCONTENTS_DETAIL_WALL | - EWT_VISCONTENTS_WINDOW | - EWT_VISCONTENTS_AUX | - EWT_VISCONTENTS_LAVA | - EWT_VISCONTENTS_SLIME | - EWT_VISCONTENTS_WATER | - EWT_VISCONTENTS_MIST, - EWT_INVISCONTENTS_ORIGIN = nth_bit(9), // removed before bsping an entity // Q1 clip EWT_INVISCONTENTS_PLAYERCLIP = nth_bit(10), EWT_INVISCONTENTS_MONSTERCLIP = nth_bit(11), EWT_INVISCONTENTS_AREAPORTAL = nth_bit(12), - EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER = nth_bit(13), + EWT_INVISCONTENTS_NO_WATERJUMP = nth_bit(13), // re-release + EWT_INVISCONTENTS_PROJECTILECLIP = nth_bit(14), // re-release - EWT_ALL_INVISCONTENTS = - EWT_INVISCONTENTS_ORIGIN | - EWT_INVISCONTENTS_PLAYERCLIP | - EWT_INVISCONTENTS_MONSTERCLIP | - EWT_INVISCONTENTS_AREAPORTAL | - EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER, - - EWT_CFLAG_DETAIL = nth_bit(14), // brushes to be added after vis leafs EWT_CFLAG_MIRROR_INSIDE = nth_bit(15), EWT_CFLAG_MIRROR_INSIDE_SET = nth_bit(16), EWT_CFLAG_SUPPRESS_CLIPPING_SAME_TYPE = nth_bit(17), @@ -114,17 +91,43 @@ enum contents_t : contents_int_t { EWT_CFLAG_MONSTER = nth_bit(26), // disallowed in maps, only for gamecode use EWT_CFLAG_DEADMONSTER = nth_bit(27), // disallowed in maps, only for gamecode use + EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER = nth_bit(28), + EWT_CFLAG_DETAIL = nth_bit(29), // brushes to be added after vis leafs + // unused Q2 contents bits - just present here so we can roundtrip all 32-bit Q2 contents - EWT_CFLAG_Q2_UNUSED_7 = nth_bit(28), - EWT_CFLAG_Q2_UNUSED_8 = nth_bit(29), - EWT_CFLAG_Q2_UNUSED_9 = nth_bit(30), - EWT_CFLAG_Q2_UNUSED_10 = nth_bit(31), - EWT_CFLAG_Q2_UNUSED_11 = nth_bit(32), - EWT_CFLAG_Q2_UNUSED_12 = nth_bit(33), - EWT_CFLAG_Q2_UNUSED_13 = nth_bit(34), - EWT_CFLAG_Q2_UNUSED_14 = nth_bit(35), + EWT_CFLAG_Q2_UNUSED_7 = nth_bit(30), + EWT_CFLAG_Q2_UNUSED_8 = nth_bit(31), + EWT_CFLAG_Q2_UNUSED_9 = nth_bit(32), + EWT_CFLAG_Q2_UNUSED_10 = nth_bit(33), + EWT_CFLAG_Q2_UNUSED_11 = nth_bit(34), + EWT_CFLAG_Q2_UNUSED_12 = nth_bit(35), EWT_CFLAG_Q2_UNUSED_30 = nth_bit(36), - EWT_CFLAG_Q2_UNUSED_31 = nth_bit(37) + EWT_CFLAG_Q2_UNUSED_31 = nth_bit(37), + + // masks + EWT_ALL_LIQUIDS = + EWT_VISCONTENTS_LAVA | + EWT_VISCONTENTS_SLIME | + EWT_VISCONTENTS_WATER, + + EWT_ALL_VISIBLE_CONTENTS = + EWT_VISCONTENTS_SOLID | + EWT_VISCONTENTS_SKY | + EWT_VISCONTENTS_DETAIL_WALL | + EWT_VISCONTENTS_WINDOW | + EWT_VISCONTENTS_AUX | + EWT_VISCONTENTS_LAVA | + EWT_VISCONTENTS_SLIME | + EWT_VISCONTENTS_WATER | + EWT_VISCONTENTS_MIST, + + EWT_ALL_INVISCONTENTS = + EWT_INVISCONTENTS_ORIGIN | + EWT_INVISCONTENTS_PLAYERCLIP | + EWT_INVISCONTENTS_MONSTERCLIP | + EWT_INVISCONTENTS_AREAPORTAL | + EWT_INVISCONTENTS_ILLUSIONARY_VISBLOCKER | + EWT_INVISCONTENTS_PROJECTILECLIP, }; struct gamedef_t; @@ -202,6 +205,15 @@ struct contentflags_t return index; } } + + if (flags & EWT_INVISCONTENTS_PLAYERCLIP) { + return 10; + } else if (flags & EWT_INVISCONTENTS_MONSTERCLIP) { + return 11; + } else if (flags & EWT_INVISCONTENTS_PROJECTILECLIP) { + return 14; + } + return -1; } diff --git a/include/common/bspfile_q2.hh b/include/common/bspfile_q2.hh index 1bc43200..adcb9cdd 100644 --- a/include/common/bspfile_q2.hh +++ b/include/common/bspfile_q2.hh @@ -116,8 +116,8 @@ enum q2_contents_t : int32_t Q2_CONTENTS_UNUSED_10 = nth_bit(10), Q2_CONTENTS_UNUSED_11 = nth_bit(11), Q2_CONTENTS_UNUSED_12 = nth_bit(12), - Q2_CONTENTS_UNUSED_13 = nth_bit(13), - Q2_CONTENTS_UNUSED_14 = nth_bit(14), + Q2_CONTENTS_NO_WATERJUMP = nth_bit(13), // liquid-only; re-release + Q2_CONTENTS_PROJECTILECLIP = nth_bit(14), // like playerclip/monsterclip, but only affects projectiles Q2_LAST_VISIBLE_CONTENTS = Q2_CONTENTS_MIST, Q2_ALL_VISIBLE_CONTENTS = Q2_CONTENTS_SOLID | Q2_CONTENTS_WINDOW | Q2_CONTENTS_AUX | Q2_CONTENTS_LAVA |