From 67795d4451529e96a15a76f2cfa761d17671b891 Mon Sep 17 00:00:00 2001 From: wraitii Date: Sun, 1 Sep 2019 14:10:02 +0000 Subject: [PATCH] Fix duplication and clang warning in unreachable gathering target fix 30dcd696eb / D2120 The function was put in an anonymous namespace to avoid linking errors should another one be defined elsewhere. Reviewed By: elexis Differential Revision: https://code.wildfiregames.com/D2243 This was SVN commit r22825. --- .../components/ICmpRangeManager.cpp | 31 +++++++++---------- .../simulation2/components/ICmpRangeManager.h | 1 - 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/source/simulation2/components/ICmpRangeManager.cpp b/source/simulation2/components/ICmpRangeManager.cpp index acd83f00be..4fda230c54 100644 --- a/source/simulation2/components/ICmpRangeManager.cpp +++ b/source/simulation2/components/ICmpRangeManager.cpp @@ -21,28 +21,27 @@ #include "simulation2/system/InterfaceScripted.h" +namespace { + std::string VisibilityToString(ICmpRangeManager::ELosVisibility visibility) + { + switch (visibility) + { + case ICmpRangeManager::VIS_HIDDEN: return "hidden"; + case ICmpRangeManager::VIS_FOGGED: return "fogged"; + case ICmpRangeManager::VIS_VISIBLE: return "visible"; + default: return "error"; // should never happen + } + } +} + std::string ICmpRangeManager::GetLosVisibility_wrapper(entity_id_t ent, int player) const { - ELosVisibility visibility = GetLosVisibility(ent, player); - switch (visibility) - { - case VIS_HIDDEN: return "hidden"; - case VIS_FOGGED: return "fogged"; - case VIS_VISIBLE: return "visible"; - default: return "error"; // should never happen - } + return VisibilityToString(GetLosVisibility(ent, player)); } std::string ICmpRangeManager::GetLosVisibilityPosition_wrapper(entity_pos_t x, entity_pos_t z, int player) const { - ELosVisibility visibility = GetLosVisibilityPosition(x, z, player); - switch (visibility) - { - case VIS_HIDDEN: return "hidden"; - case VIS_FOGGED: return "fogged"; - case VIS_VISIBLE: return "visible"; - default: return "error"; // should never happen - } + return VisibilityToString(GetLosVisibilityPosition(x, z, player)); } BEGIN_INTERFACE_WRAPPER(RangeManager) diff --git a/source/simulation2/components/ICmpRangeManager.h b/source/simulation2/components/ICmpRangeManager.h index 022a1fde79..ef0c3937cd 100644 --- a/source/simulation2/components/ICmpRangeManager.h +++ b/source/simulation2/components/ICmpRangeManager.h @@ -351,7 +351,6 @@ public: */ virtual ELosVisibility GetLosVisibilityPosition(entity_pos_t x, entity_pos_t z, player_id_t player) const = 0; - /** /** * Request the update of the visibility cache of ent at next turn. * Typically used for fogging.