From eedabe6f1cfbf94c3d2c65c48619faa07f8a7b90 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 14 Jun 2022 18:38:22 -0400 Subject: [PATCH] fix bugs --- common/entdata.cc | 2 +- include/common/entdata.h | 2 +- include/light/entities.hh | 2 +- light/entities.cc | 10 +++++----- qbsp/brush.cc | 10 +++++----- qbsp/qbsp.cc | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/common/entdata.cc b/common/entdata.cc index 6da36b36..881caccd 100644 --- a/common/entdata.cc +++ b/common/entdata.cc @@ -35,7 +35,7 @@ entdict_t::entdict_t(std::initializer_list l) : keyvalues(l) { } entdict_t::entdict_t() = default; -const std::string &entdict_t::get(const std::string_view &key) const +std::string entdict_t::get(const std::string_view &key) const { if (auto it = find(key); it != keyvalues.end()) { return it->second; diff --git a/include/common/entdata.h b/include/common/entdata.h index e64ad940..156b157f 100644 --- a/include/common/entdata.h +++ b/include/common/entdata.h @@ -41,7 +41,7 @@ public: entdict_t(); inline entdict_t(parser_base_t &parser) { parse(parser); } - const std::string &get(const std::string_view &key) const; + std::string get(const std::string_view &key) const; vec_t get_float(const std::string_view &key) const; int32_t get_int(const std::string_view &key) const; // returns number of vector components read diff --git a/include/light/entities.hh b/include/light/entities.hh index c4b4b036..fa446b30 100644 --- a/include/light/entities.hh +++ b/include/light/entities.hh @@ -98,7 +98,7 @@ public: settings::setting_string suntexture{this, "suntexture", ""}; settings::setting_bool nostaticlight{this, "nostaticlight", false}; - const std::string &classname() const; + std::string classname() const; const light_formula_t &getFormula() const { return formula.value(); } diff --git a/light/entities.cc b/light/entities.cc index 6abf8510..7c4c711c 100644 --- a/light/entities.cc +++ b/light/entities.cc @@ -49,7 +49,7 @@ static void MakeSurfaceLights(const mbsp_t *bsp); // light_t -const std::string &light_t::classname() const +std::string light_t::classname() const { return epairs->get("classname"); } @@ -181,12 +181,12 @@ bool EntDict_CheckTargetKeysMatched( "target", "killtarget", "target2", "angrytarget", "deathtarget" // from AD }; - const std::string &targetname = EntDict_StringForKey(entity, "targetname"); + const std::string &targetname = entity.get("targetname"); // search for "target" values such that no entity has a matching "targetname" for (const auto &targetKey : targetKeys) { - const auto &targetVal = EntDict_StringForKey(entity, targetKey); + const auto &targetVal = entity.get(targetKey); if (!targetVal.length()) continue; @@ -202,7 +202,7 @@ bool EntDict_CheckTargetKeysMatched( continue; } - if (string_iequals(targetVal, EntDict_StringForKey(target, "targetname"))) { + if (string_iequals(targetVal, target.get("targetname"))) { found = true; break; } @@ -227,7 +227,7 @@ bool EntDict_CheckTargetnameKeyMatched( bool ok = true; - const auto &targetnameVal = EntDict_StringForKey(entity, "targetname"); + const auto &targetnameVal = entity.get("targetname"); if (targetnameVal.length()) { bool found = false; for (const entdict_t &targetter : all_edicts) { diff --git a/qbsp/brush.cc b/qbsp/brush.cc index e42775ab..d8b9b3d2 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -930,14 +930,14 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int bool detail = false; bool detail_illusionary = false; bool detail_fence = false; - bool mirrorinside = all_mirrorinside; + std::optional mirrorinside = all_mirrorinside; // inherit the per-entity settings detail |= all_detail; detail_illusionary |= all_detail_illusionary; detail_fence |= all_detail_fence; - if (!mirrorinside_set) { + if (!mirrorinside) { if (options.target_game->id == GAME_QUAKE_II && (contents.native & (Q2_CONTENTS_AUX | Q2_CONTENTS_MIST))) { mirrorinside = true; } @@ -1011,7 +1011,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int before writing the bsp, and bmodels normally have CONTENTS_SOLID as their contents type. */ - if (hullnum <= 0 && mirrorinside) { + if (hullnum <= 0 && mirrorinside.value_or(false)) { contents = {contents.native, CFLAGS_DETAIL_FENCE}; } } @@ -1025,10 +1025,10 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int contents = options.target_game->create_solid_contents(); // apply extended flags - if (mirrorinside) { + if (mirrorinside.value_or(false)) { contents.extended |= CFLAGS_BMODEL_MIRROR_INSIDE; } - if (noclipfaces) { + if (clipsametype.value_or(false)) { contents.extended |= CFLAGS_NO_CLIPPING_SAME_TYPE; } if (func_illusionary_visblocker) { diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index af11ed25..398a73c8 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -446,7 +446,7 @@ static mapentity_t *AreanodeEntityForLeaf(node_t *node) } for (auto *face : node->markfaces) { - const char *classname = ValueForKey(face->src_entity, "classname"); + const std::string &classname = face->src_entity->epairs.get("classname"); if (0 == Q_strcasecmp(classname, "func_areaportal")) { return face->src_entity; }