[celx] Fix location type returned by loc:getinfo()

getFeatureType() returns std::uint64_t
  + C++14 style for lambda
  + tiny-tiny optimization around std::string usage
pull/1176/head
Hleb Valoshka 2021-11-17 22:57:24 +02:00
parent e92c3d9bd5
commit 2ff075d843
1 changed files with 5 additions and 5 deletions

View File

@ -710,15 +710,15 @@ static int object_getinfo(lua_State* l)
celx.setTable("importance", (lua_Number)location->getImportance());
celx.setTable("infoURL", location->getInfoURL().c_str());
uint32_t featureType = location->getFeatureType();
string featureName("Unknown");
auto featureType = location->getFeatureType();
auto &LocationFlagMap = celx.appCore(AllErrors)->scriptMaps()->LocationFlagMap;
auto iter = std::find_if(LocationFlagMap.begin(),
LocationFlagMap.end(),
[&featureType](pair<const string, uint64_t>& it){ return it.second == featureType; });
[&featureType](auto& it){ return it.second == featureType; });
if (iter != LocationFlagMap.end())
featureName = iter->first;
celx.setTable("featureType", featureName.c_str());
celx.setTable("featureType", iter->first.c_str());
else
celx.setTable("featureType", "Unknown");
Body* parent = location->getParentBody();
if (parent != nullptr)