From 9985d6c8fdb82be89f848eaf0f5f7ffc4cf9bba1 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 17 Mar 2024 18:32:07 -0600 Subject: [PATCH] fix odr violations not sure why these only started to be reported on this branch --- common/mapfile.cc | 4 ++++ include/common/mapfile.hh | 6 ++++++ maputil/maputil.cc | 2 ++ qbsp/map.cc | 4 ++-- qbsp/qbsp.cc | 4 ++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/common/mapfile.cc b/common/mapfile.cc index 777c7894..d102aaca 100644 --- a/common/mapfile.cc +++ b/common/mapfile.cc @@ -4,6 +4,8 @@ #include #include +namespace mapfile { + /*static*/ bool brush_side_t::is_valid_texture_projection(const qvec3f &faceNormal, const qvec3f &s_vec, const qvec3f &t_vec) { // TODO: This doesn't match how light does it (TexSpaceToWorld) @@ -1200,3 +1202,5 @@ void map_file_t::convert_to(texcoord_style_t style, const gamedef_t *game, const } } } + +} // namespace mapfile diff --git a/include/common/mapfile.hh b/include/common/mapfile.hh index e0be658d..77e5c779 100644 --- a/include/common/mapfile.hh +++ b/include/common/mapfile.hh @@ -29,6 +29,10 @@ See file, 'COPYING', for details. #include #include +// this file declares some names that clash with names elsewhere in the project and lead to ODR violations +// (e.g. texdef_valve_t). For now just wrap everything in a namespace to avoid issues. +namespace mapfile { + // main brush style; technically these can be mixed enum class texcoord_style_t { @@ -204,3 +208,5 @@ struct map_file_t void convert_to(texcoord_style_t style, const gamedef_t *game, const settings::common_settings &options); }; + +} // namespace mapfile diff --git a/maputil/maputil.cc b/maputil/maputil.cc index fb5ed6cb..f92901b7 100644 --- a/maputil/maputil.cc +++ b/maputil/maputil.cc @@ -37,6 +37,8 @@ extern "C" } #endif +using namespace mapfile; + // global map file state map_file_t map_file; const gamedef_t *current_game = nullptr; diff --git a/qbsp/map.cc b/qbsp/map.cc index 44e5e118..ca8d5d04 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -2005,9 +2005,9 @@ static std::optional ParseBrushFace( // to save on texinfo, reset all invisible sides to default texvecs if (tx.flags.is_nodraw || tx.flags.is_hintskip || tx.flags.is_hint) { - brush_side_t temp; + mapfile::brush_side_t temp; temp.plane = face.get_plane(); - temp.set_texinfo(texdef_quake_ed_t{ { 0, 0 }, 0, { 1, 1 }}); + temp.set_texinfo(mapfile::texdef_quake_ed_t{ { 0, 0 }, 0, { 1, 1 }}); tx.vecs = temp.vecs; } else { // ericw -- round texture vector values that are within ZERO_EPSILON of integers, diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index 52cf1ab5..5196b705 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -833,9 +833,9 @@ static void ExportBrushList_r(const mapentity_t &entity, node_t *node, brush_lis // optimize BSP by using existing world-aligned texinfo // if they exist maptexinfo_t copy = texinfo; - brush_side_t temp; + mapfile::brush_side_t temp; temp.plane = side.get_plane(); - temp.set_texinfo(texdef_quake_ed_t{ { 0, 0 }, 0, { 1, 1 }}); + temp.set_texinfo(mapfile::texdef_quake_ed_t{ { 0, 0 }, 0, { 1, 1 }}); copy.vecs = temp.vecs; texinfo_id = FindTexinfo(copy, temp.plane, false);