diff --git a/common/main/fwd-wall.h b/common/main/fwd-wall.h index 608211207..c437487ee 100644 --- a/common/main/fwd-wall.h +++ b/common/main/fwd-wall.h @@ -93,25 +93,7 @@ static constexpr WALL_IS_DOORWAY_FLAG operator|(const WALL_IS_DOORWAY_FLAG a, co } enum class wall_is_doorway_result : uint8_t; - -template -inline constexpr wall_is_doorway_result WALL_IS_DOORWAY_static_result{ - (... | static_cast(F)) -}; - -// WALL_IS_DOORWAY return values F/R/RP -constexpr auto WID_WALL = WALL_IS_DOORWAY_static_result; // 0/1/0 wall -constexpr auto WID_TRANSPARENT_WALL = WALL_IS_DOORWAY_static_result; // 0/1/1 transparent wall -constexpr auto WID_ILLUSORY_WALL = WALL_IS_DOORWAY_static_result; // 1/1/0 illusory wall -constexpr auto WID_TRANSILLUSORY_WALL = WALL_IS_DOORWAY_static_result; // 1/1/1 transparent illusory wall -constexpr auto WID_NO_WALL = WALL_IS_DOORWAY_static_result; // 1/0/1 no wall, can fly through -constexpr auto WID_EXTERNAL = WALL_IS_DOORWAY_static_result; // 0/0/0/1 don't see it, dont fly through it } -#if defined(DXX_BUILD_DESCENT_II) -namespace dsx { -constexpr auto WID_CLOAKED_WALL = WALL_IS_DOORWAY_static_result; -} -#endif #endif namespace dcx { diff --git a/common/main/gameseg.h b/common/main/gameseg.h index cef3deed4..0e7502bd9 100644 --- a/common/main/gameseg.h +++ b/common/main/gameseg.h @@ -170,8 +170,8 @@ icsegptridx_t find_point_seg(const d_level_shared_segment_state &, const vms_vec // ---------------------------------------------------------------------------------------------------------- // Determine whether seg0 and seg1 are reachable using wid_flag to go through walls. -// For example, set to WID_RENDPAST_FLAG to see if sound can get from one segment to the other. -// set to WID_FLY_FLAG to see if a robot could fly from one to the other. +// For example, set to WALL_IS_DOORWAY::rendpast to see if sound can get from one segment to the other. +// set to WALL_IS_DOORWAY::fly to see if a robot could fly from one to the other. // Search up to a maximum depth of max_depth. // Return the distance. vm_distance find_connected_distance(const vms_vector &p0, vcsegptridx_t seg0, const vms_vector &p1, vcsegptridx_t seg1, int max_depth, wall_is_doorway_mask wid_flag); diff --git a/common/main/wall.h b/common/main/wall.h index ef9355288..e2081ad9c 100644 --- a/common/main/wall.h +++ b/common/main/wall.h @@ -59,6 +59,16 @@ enum class wall_is_doorway_mask : uint8_t enum class wall_is_doorway_result : uint8_t { + // WALL_IS_DOORWAY return values F/R/RP + wall = static_cast(WALL_IS_DOORWAY_FLAG::render), // 0/1/0 wall + transparent_wall = static_cast(WALL_IS_DOORWAY_FLAG::render) | static_cast(WALL_IS_DOORWAY_FLAG::rendpast), // 0/1/1 transparent wall + illusory_wall = static_cast(WALL_IS_DOORWAY_FLAG::fly) | static_cast(WALL_IS_DOORWAY_FLAG::render), // 1/1/0 illusory wall + transillusory_wall = static_cast(WALL_IS_DOORWAY_FLAG::fly) | static_cast(WALL_IS_DOORWAY_FLAG::render) | static_cast(WALL_IS_DOORWAY_FLAG::rendpast), // 1/1/1 transparent illusory wall + no_wall = static_cast(WALL_IS_DOORWAY_FLAG::fly) | static_cast(WALL_IS_DOORWAY_FLAG::rendpast), // 1/0/1 no wall, can fly through + external = static_cast(WALL_IS_DOORWAY_FLAG::external), // 0/0/0/1 do not see it, do not fly through it + /* if DXX_BUILD_DESCENT_II */ + cloaked_wall = static_cast(WALL_IS_DOORWAY_FLAG::render) | static_cast(WALL_IS_DOORWAY_FLAG::rendpast) | static_cast(WALL_IS_DOORWAY_FLAG::cloaked), + /* endif */ }; [[nodiscard]] diff --git a/similar/editor/seguvs.cpp b/similar/editor/seguvs.cpp index cc495495b..c9405db94 100644 --- a/similar/editor/seguvs.cpp +++ b/similar/editor/seguvs.cpp @@ -966,7 +966,7 @@ static void cast_light_from_side(const vmsegptridx_t segp, const sidenum_t light if (dist_to_rseg <= LIGHT_DISTANCE_THRESHOLD) { for (const auto &&[sidenum, srside, urside] : enumerate(zip(rsegp->shared_segment::sides, rsegp->unique_segment::sides))) { - if (WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, rsegp, static_cast(sidenum)) != WID_NO_WALL) + if (WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, rsegp, static_cast(sidenum)) != wall_is_doorway_result::no_wall) { auto &side_normalp = srside.normals[0]; // kinda stupid? always use vector 0. @@ -1170,7 +1170,7 @@ static void calim_process_all_lights(int quick_light) { for (const auto &&[sidenum, value] : enumerate(segp->unique_segment::sides)) { - if (WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, segp, static_cast(sidenum)) != WID_NO_WALL) + if (WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, segp, static_cast(sidenum)) != wall_is_doorway_result::no_wall) { const auto sidep = &value; fix light_intensity; diff --git a/similar/main/ai.cpp b/similar/main/ai.cpp index 0ff85cfa0..65e4f54c9 100644 --- a/similar/main/ai.cpp +++ b/similar/main/ai.cpp @@ -2318,7 +2318,7 @@ static void init_boss_segments(const segment_array &segments, const object &boss if ((w & WALL_IS_DOORWAY_FLAG::fly) || one_wall_hack) { #if defined(DXX_BUILD_DESCENT_II) - // If we get here and w == WID_WALL, then we want to process through this wall, else not. + // If we get here and w == wall_is_doorway_result::wall, then we want to process through this wall, else not. if (IS_CHILD(csegnum)) { if (one_wall_hack) one_wall_hack--; diff --git a/similar/main/fvi.cpp b/similar/main/fvi.cpp index 38a8e6c02..989bdb681 100644 --- a/similar/main/fvi.cpp +++ b/similar/main/fvi.cpp @@ -960,7 +960,7 @@ static fvi_hit_type fvi_sub(const fvi_query &fq, vms_vector &intp, segnum_t &int if ((wid_flag & WALL_IS_DOORWAY_FLAG::fly) || ( #if defined(DXX_BUILD_DESCENT_I) - (wid_flag == WID_TRANSPARENT_WALL) && + (wid_flag == wall_is_doorway_result::transparent_wall) && #elif defined(DXX_BUILD_DESCENT_II) ((wid_flag & WALL_IS_DOORWAY_FLAG::render) && (wid_flag & WALL_IS_DOORWAY_FLAG::rendpast)) && #endif @@ -1200,7 +1200,7 @@ int check_trans_wall(const vms_vector &pnt, const vcsegptridx_t seg, const siden #ifndef NDEBUG auto &Walls = LevelUniqueWallSubsystemState.Walls; auto &vcwallptr = Walls.vcptr; - assert(WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, seg, sidenum) == WID_TRANSPARENT_WALL); + assert(WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, seg, sidenum) == wall_is_doorway_result::transparent_wall); #endif #endif diff --git a/similar/main/gameseg.cpp b/similar/main/gameseg.cpp index ec4bb2b2e..5d23cbef9 100644 --- a/similar/main/gameseg.cpp +++ b/similar/main/gameseg.cpp @@ -1848,7 +1848,7 @@ static void ambient_mark_bfs(const vmsegptridx_t segp, segment_lava_depth_array /* * No explicit check for IS_CHILD. If !IS_CHILD, then - * WALL_IS_DOORWAY never sets WID_RENDPAST_FLAG. + * WALL_IS_DOORWAY never sets WALL_IS_DOORWAY_FLAG::rendpast. */ if (!(WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, segp, i) & WALL_IS_DOORWAY_FLAG::rendpast)) continue; diff --git a/similar/main/render.cpp b/similar/main/render.cpp index d6552975e..a24bd7096 100644 --- a/similar/main/render.cpp +++ b/similar/main/render.cpp @@ -486,7 +486,7 @@ static void render_side(fvcvertptr &vcvertptr, grs_canvas &canvas, const vcsegpt { fix min_dot, max_dot; - if (!(wid_flags & WALL_IS_DOORWAY_FLAG::render)) //if (WALL_IS_DOORWAY(segp, sidenum) == WID_NO_WALL) + if (!(wid_flags & WALL_IS_DOORWAY_FLAG::render)) //if (WALL_IS_DOORWAY(segp, sidenum) == wall_is_doorway_result::no_wall) return; const auto vertnum_list = get_side_verts(segp,sidenum); @@ -1646,7 +1646,7 @@ void render_mine(grs_canvas &canvas, const vms_vector &Viewer_eye, const vcsegid for (const auto sn : MAX_SIDES_PER_SEGMENT) { const auto wid = WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, seg, sn); - if (wid == WID_TRANSPARENT_WALL || wid == WID_TRANSILLUSORY_WALL + if (wid == wall_is_doorway_result::transparent_wall || wid == wall_is_doorway_result::transillusory_wall #if defined(DXX_BUILD_DESCENT_II) || (wid & WALL_IS_DOORWAY_FLAG::cloaked) #endif @@ -1695,7 +1695,7 @@ void render_mine(grs_canvas &canvas, const vms_vector &Viewer_eye, const vcsegid for (const auto sn : MAX_SIDES_PER_SEGMENT) { const auto wid = WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, seg, sn); - if (wid == WID_TRANSPARENT_WALL || wid == WID_TRANSILLUSORY_WALL + if (wid == wall_is_doorway_result::transparent_wall || wid == wall_is_doorway_result::transillusory_wall #if defined(DXX_BUILD_DESCENT_II) || (wid & WALL_IS_DOORWAY_FLAG::cloaked) #endif diff --git a/similar/main/wall.cpp b/similar/main/wall.cpp index d82e1d143..d2e0f9c83 100644 --- a/similar/main/wall.cpp +++ b/similar/main/wall.cpp @@ -163,15 +163,15 @@ static uint_fast32_t check_transparency(const GameBitmaps_array &GameBitmaps, co // This function checks whether we can fly through the given side. // In other words, whether or not we have a 'doorway' // Flags: -// WID_FLY_FLAG 1 -// WID_RENDER_FLAG 2 -// WID_RENDPAST_FLAG 4 +// WALL_IS_DOORWAY_FLAG::FLY 1 +// WALL_IS_DOORWAY_FLAG::RENDER 2 +// WALL_IS_DOORWAY_FLAG::RENDPAST 4 // Return values: -// WID_WALL 2 // 0/1/0 wall -// WID_TRANSPARENT_WALL 6 // 0/1/1 transparent wall -// WID_ILLUSORY_WALL 3 // 1/1/0 illusory wall -// WID_TRANSILLUSORY_WALL 7 // 1/1/1 transparent illusory wall -// WID_NO_WALL 5 // 1/0/1 no wall, can fly through +// wall_is_doorway_result::wall 2 // 0/1/0 wall +// wall_is_doorway_result::transparent_wall 6 // 0/1/1 transparent wall +// wall_is_doorway_result::illusory_wall 3 // 1/1/0 illusory wall +// wall_is_doorway_result::transillusory_wall 7 // 1/1/1 transparent illusory wall +// wall_is_doorway_result::no_wall 5 // 1/0/1 no wall, can fly through namespace dsx { namespace { @@ -181,41 +181,41 @@ static wall_is_doorway_result wall_is_doorway(const GameBitmaps_array &GameBitma auto &w = *vcwallptr(sside.wall_num); const auto type = w.type; if (type == WALL_OPEN) - return WID_NO_WALL; + return wall_is_doorway_result::no_wall; #if defined(DXX_BUILD_DESCENT_II) if (unlikely(type == WALL_CLOAKED)) - return WID_CLOAKED_WALL; + return wall_is_doorway_result::cloaked_wall; #endif const auto flags = w.flags; if (type == WALL_ILLUSION) { if (flags & wall_flag::illusion_off) - return WID_NO_WALL; + return wall_is_doorway_result::no_wall; else { if (check_transparency(GameBitmaps, Textures, uside)) - return WID_TRANSILLUSORY_WALL; + return wall_is_doorway_result::transillusory_wall; else - return WID_ILLUSORY_WALL; + return wall_is_doorway_result::illusory_wall; } } if (type == WALL_BLASTABLE) { if (flags & wall_flag::blasted) - return WID_TRANSILLUSORY_WALL; + return wall_is_doorway_result::transillusory_wall; } else { if (unlikely(flags & wall_flag::door_opened)) - return WID_TRANSILLUSORY_WALL; + return wall_is_doorway_result::transillusory_wall; if (likely(type == WALL_DOOR) && unlikely(w.state == wall_state::opening)) - return WID_TRANSPARENT_WALL; + return wall_is_doorway_result::transparent_wall; } // If none of the above flags are set, there is no doorway. if (check_transparency(GameBitmaps, Textures, uside)) - return WID_TRANSPARENT_WALL; + return wall_is_doorway_result::transparent_wall; else - return WID_WALL; // There are children behind the door. + return wall_is_doorway_result::wall; // There are children behind the door. } } @@ -224,12 +224,12 @@ wall_is_doorway_result WALL_IS_DOORWAY(const GameBitmaps_array &GameBitmaps, con { const auto child = seg.s.children[side]; if (unlikely(child == segment_none)) - return WID_WALL; + return wall_is_doorway_result::wall; if (unlikely(child == segment_exit)) - return WID_EXTERNAL; + return wall_is_doorway_result::external; auto &sside = seg.s.sides[side]; if (likely(sside.wall_num == wall_none)) - return WID_NO_WALL; + return wall_is_doorway_result::no_wall; auto &uside = seg.u.sides[side]; return wall_is_doorway(GameBitmaps, Textures, vcwallptr, sside, uside); }