From 5c2c2a8c01e0ab207ca80d732ca05052dda18f52 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Tue, 25 Feb 2020 01:50:50 -0600 Subject: [PATCH] Minor cleanup. Octree vfunc reduction. Range-based for loops with map/array llsd types. --- indra/llcommon/aialert.h | 8 +-- indra/llcommon/lleventcoro.h | 2 +- indra/llcommon/lleventdispatcher.cpp | 10 ++-- indra/llcommon/llfile.cpp | 1 + indra/llcommon/llsd.cpp | 52 ++++++++++--------- indra/llcommon/llsd.h | 4 ++ indra/llcommon/llsdjson.cpp | 4 +- indra/llcommon/llsdparam.cpp | 6 +-- indra/llcommon/llsdserialize.cpp | 14 ++--- indra/llcommon/llsdserialize_xml.cpp | 6 +-- indra/llcommon/llsdutil.cpp | 8 +-- indra/llcommon/llstring.cpp | 3 +- indra/llcommon/llstring.h | 2 +- indra/llcommon/llsys.cpp | 12 ++--- indra/llinventory/llsettingsbase.cpp | 8 +-- indra/llinventory/llsettingsdaycycle.cpp | 22 ++++---- indra/llmath/lloctree.h | 30 +++++------ indra/llmath/lltreenode.h | 28 +++++----- indra/llmath/llvolume.h | 4 +- indra/llmath/llvolumeoctree.h | 15 +++--- indra/newview/llaisapi.cpp | 6 +-- indra/newview/llfloaterregioninfo.cpp | 29 +++++------ .../llinventorymodelbackgroundfetch.cpp | 7 +-- indra/newview/llmapresponders.cpp | 5 +- indra/newview/llmarketplacefunctions.cpp | 32 +++--------- indra/newview/llmaterialmgr.cpp | 13 ++--- indra/newview/llpanelobjectinventory.cpp | 13 ++--- indra/newview/llspatialpartition.h | 10 ++-- indra/newview/llspeakers.cpp | 37 +++++-------- indra/newview/llviewermenufile.cpp | 18 +++---- indra/newview/llviewermessage.cpp | 13 ++--- indra/newview/llviewerobjectbackup.cpp | 6 +-- indra/newview/llviewerobjectlist.cpp | 42 ++++++--------- indra/newview/llvieweroctree.cpp | 18 +++---- indra/newview/llvieweroctree.h | 17 +++--- indra/newview/llvovolume.cpp | 6 +-- indra/newview/pipeline.cpp | 3 +- 37 files changed, 218 insertions(+), 296 deletions(-) diff --git a/indra/llcommon/aialert.h b/indra/llcommon/aialert.h index 4d3704cfb..17042cfcc 100644 --- a/indra/llcommon/aialert.h +++ b/indra/llcommon/aialert.h @@ -132,7 +132,7 @@ class LL_COMMON_API AIArgs // Add another replacement. AIArgs& operator()(char const* key, std::string const& replacement) { mArgs[key] = replacement; return *this; } // The destructor may not throw. - ~AIArgs() throw() { } + ~AIArgs() noexcept { } // Accessor. LLStringUtil::format_map_t const& operator*() const { return mArgs; } @@ -193,7 +193,7 @@ class LL_COMMON_API Line Line(std::string const& xml_desc, AIArgs const& args, bool newline = false) : mNewline(newline), mXmlDesc(xml_desc), mArgs(args), mType(normal) { } Line(Prefix const& prefix, bool newline = false) : mNewline(newline), mXmlDesc("AIPrefix"), mArgs("[PREFIX]", prefix.str()), mType(prefix.type()) { } // The destructor may not throw. - ~Line() throw() { } + ~Line() noexcept { } // Prepend a newline before this line. void set_newline(void) { mNewline = true; } @@ -225,7 +225,7 @@ class LL_COMMON_API Error : public std::exception typedef std::deque lines_type; // The destructor may not throw. - ~Error() throw() { } + ~Error() noexcept { } // Accessors. lines_type const& lines(void) const { return mLines; } @@ -267,7 +267,7 @@ class LL_COMMON_API ErrorCode : public Error public: // The destructor may not throw. - ~ErrorCode() throw() { } + ~ErrorCode() noexcept { } // Accessor. int getCode(void) const { return mCode; } diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index b451092bf..3aedb37b1 100644 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -412,7 +412,7 @@ public: std::runtime_error(what), mData(data) {} - virtual ~LLErrorEvent() throw() {} + virtual ~LLErrorEvent() noexcept {} LLSD getData() const { return mData; } diff --git a/indra/llcommon/lleventdispatcher.cpp b/indra/llcommon/lleventdispatcher.cpp index df059bec6..b4ed63998 100644 --- a/indra/llcommon/lleventdispatcher.cpp +++ b/indra/llcommon/lleventdispatcher.cpp @@ -381,10 +381,9 @@ std::string LLSDArgsMapper::formatlist(const LLSD& list) { std::ostringstream out; const char* delim = ""; - for (LLSD::array_const_iterator li(list.beginArray()), lend(list.endArray()); - li != lend; ++li) + for (auto const& entry : list.array()) { - out << delim << li->asString(); + out << delim << entry.asString(); delim = ", "; } return out.str(); @@ -494,10 +493,9 @@ struct LLEventDispatcher::MapParamsDispatchEntry: public LLEventDispatcher::Para { // Build the set of all param keys, then delete the ones that are // optional. What's left are the ones that are required. - for (LLSD::array_const_iterator pi(params.beginArray()), pend(params.endArray()); - pi != pend; ++pi) + for (auto const& entry : params.array()) { - mRequired[pi->asString()] = LLSD(); + mRequired[entry.asString()] = LLSD(); } if (defaults.isArray() || defaults.isUndefined()) diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index becf99092..e68ccd2ad 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -54,6 +54,7 @@ std::string LLFile::strerr(int errn) { char buffer[256]; strerror_s(buffer, errn); // infers sizeof(buffer) -- love it! + buffer[255] = 0; return buffer; } diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index c65c4717c..111973756 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -140,10 +140,14 @@ public: virtual void erase(Integer) { } virtual const LLSD& ref(Integer) const { return undef(); } - virtual LLSD::map_const_iterator beginMap() const { return endMap(); } - virtual LLSD::map_const_iterator endMap() const { static const std::map empty; return empty.end(); } - virtual LLSD::array_const_iterator beginArray() const { return endArray(); } - virtual LLSD::array_const_iterator endArray() const { static const std::vector empty; return empty.end(); } + virtual const std::map& map() const { static const std::map empty; return empty; } + virtual std::map& map() { static std::map empty; return empty; } + LLSD::map_const_iterator beginMap() const { return endMap(); } + LLSD::map_const_iterator endMap() const { return map().end(); } + virtual const std::vector& array() const { static const std::vector empty; return empty; } + virtual std::vector& array() { static std::vector empty; return empty; } + LLSD::array_const_iterator beginArray() const { return endArray(); } + LLSD::array_const_iterator endArray() const { return array().end(); } virtual void dumpStats() const; virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; @@ -388,10 +392,8 @@ namespace virtual int size() const { return mData.size(); } - LLSD::map_iterator beginMap() { return mData.begin(); } - LLSD::map_iterator endMap() { return mData.end(); } - virtual LLSD::map_const_iterator beginMap() const { return mData.begin(); } - virtual LLSD::map_const_iterator endMap() const { return mData.end(); } + DataMap& map() final override { return mData; } + const DataMap& map() const final override { return mData; } virtual void dumpStats() const; virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; @@ -520,12 +522,8 @@ namespace LLSD& ref(LLSD::Integer); virtual const LLSD& ref(LLSD::Integer) const; - LLSD::array_iterator beginArray() { return mData.begin(); } - LLSD::array_iterator endArray() { return mData.end(); } - LLSD::reverse_array_iterator rbeginArray() { return mData.rbegin(); } - LLSD::reverse_array_iterator rendArray() { return mData.rend(); } - virtual LLSD::array_const_iterator beginArray() const { return mData.begin(); } - virtual LLSD::array_const_iterator endArray() const { return mData.end(); } + DataVector& array() final override { return mData; } + const DataVector& array() const final override { return mData; } virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; }; @@ -957,18 +955,24 @@ const char *LLSD::dump(const LLSD &llsd) return llsd_dump(llsd, false); } -LLSD::map_iterator LLSD::beginMap() { return makeMap(impl).beginMap(); } -LLSD::map_iterator LLSD::endMap() { return makeMap(impl).endMap(); } -LLSD::map_const_iterator LLSD::beginMap() const { return safe(impl).beginMap(); } -LLSD::map_const_iterator LLSD::endMap() const { return safe(impl).endMap(); } +std::map& LLSD::map() { return makeMap(impl).map(); } +const std::map& LLSD::map() const { return safe(impl).map(); } -LLSD::array_iterator LLSD::beginArray() { return makeArray(impl).beginArray(); } -LLSD::array_iterator LLSD::endArray() { return makeArray(impl).endArray(); } -LLSD::array_const_iterator LLSD::beginArray() const{ return safe(impl).beginArray(); } -LLSD::array_const_iterator LLSD::endArray() const { return safe(impl).endArray(); } +LLSD::map_iterator LLSD::beginMap() { return map().begin(); } +LLSD::map_iterator LLSD::endMap() { return map().end(); } +LLSD::map_const_iterator LLSD::beginMap() const { return map().cbegin(); } +LLSD::map_const_iterator LLSD::endMap() const { return map().cend(); } -LLSD::reverse_array_iterator LLSD::rbeginArray() { return makeArray(impl).rbeginArray(); } -LLSD::reverse_array_iterator LLSD::rendArray() { return makeArray(impl).rendArray(); } +std::vector& LLSD::array() { return makeArray(impl).array(); } +const std::vector& LLSD::array() const { return safe(impl).array(); } + +LLSD::array_iterator LLSD::beginArray() { return array().begin(); } +LLSD::array_iterator LLSD::endArray() { return array().end(); } +LLSD::array_const_iterator LLSD::beginArray() const{ return array().cbegin(); } +LLSD::array_const_iterator LLSD::endArray() const { return array().cend(); } + +LLSD::reverse_array_iterator LLSD::rbeginArray() { return array().rbegin(); } +LLSD::reverse_array_iterator LLSD::rendArray() { return array().rend(); } namespace llsd { diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index e9fcb8b47..e6c34e32b 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -320,6 +320,8 @@ public: typedef std::map::iterator map_iterator; typedef std::map::const_iterator map_const_iterator; + std::map& map(); + const std::map& map() const; map_iterator beginMap(); map_iterator endMap(); map_const_iterator beginMap() const; @@ -329,6 +331,8 @@ public: typedef std::vector::const_iterator array_const_iterator; typedef std::vector::reverse_iterator reverse_array_iterator; + std::vector& array(); + const std::vector& array() const; array_iterator beginArray(); array_iterator endArray(); array_const_iterator beginArray() const; diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp index 5b49f247a..db89b293e 100644 --- a/indra/llcommon/llsdjson.cpp +++ b/indra/llcommon/llsdjson.cpp @@ -111,9 +111,9 @@ nlohmann::json LlsdToJson(const LLSD &val) } break; case LLSD::TypeArray: - for (LLSD::array_const_iterator it = val.beginArray(); it != val.endArray(); ++it) + for (auto const& entry : val.array()) { - result.push_back(LlsdToJson(*it)); + result.push_back(LlsdToJson(entry)); } break; case LLSD::TypeBinary: diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index 3d86a1f98..b64f3d0e4 100644 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -267,12 +267,10 @@ void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLI } else if (sd.isArray()) { - for (LLSD::array_const_iterator it = sd.beginArray(); - it != sd.endArray(); - ++it) + for (auto const& entry : sd.array()) { stack.push_back(make_pair(std::string(), true)); - readSDValues(cb, *it, stack); + readSDValues(cb, entry, stack); stack.pop_back(); } } diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index 0a9fbb2a6..f8690f63b 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -1323,13 +1323,11 @@ S32 LLSDNotationFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 { ostr << post << pre << "["; bool need_comma = false; - LLSD::array_const_iterator iter = data.beginArray(); - LLSD::array_const_iterator end = data.endArray(); - for(; iter != end; ++iter) + for (const auto& entry : data.array()) { - if(need_comma) ostr << ","; + if (need_comma) ostr << ","; need_comma = true; - format_count += format_impl(*iter, ostr, options, level + 1); + format_count += format_impl(entry, ostr, options, level + 1); } ostr << "]"; break; @@ -1462,11 +1460,9 @@ S32 LLSDBinaryFormatter::format(const LLSD& data, std::ostream& ostr, U32 option ostr.put('['); U32 size_nbo = htonl(data.size()); ostr.write((const char*)(&size_nbo), sizeof(U32)); - LLSD::array_const_iterator iter = data.beginArray(); - LLSD::array_const_iterator end = data.endArray(); - for(; iter != end; ++iter) + for (const auto& entry : data.array()) { - format_count += format(*iter, ostr); + format_count += format(entry, ostr); } ostr.put(']'); break; diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp index 72e6ac611..4608fac88 100644 --- a/indra/llcommon/llsdserialize_xml.cpp +++ b/indra/llcommon/llsdserialize_xml.cpp @@ -116,11 +116,9 @@ S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 opti else { ostr << pre << "" << post; - LLSD::array_const_iterator iter = data.beginArray(); - LLSD::array_const_iterator end = data.endArray(); - for(; iter != end; ++iter) + for (const auto& entry : data.array()) { - format_count += format_impl(*iter, ostr, options, level + 1); + format_count += format_impl(entry, ostr, options, level + 1); } ostr << pre << "" << post; } diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index dc4a960c9..dd14984a5 100644 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -891,9 +891,9 @@ LLSD llsd_clone(LLSD value, LLSD filter) break; case LLSD::TypeArray: clone = LLSD::emptyArray(); - for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) + for (auto const& entry : value.array()) { - clone.append(llsd_clone(*ita, filter)); + clone.append(llsd_clone(entry, filter)); } break; @@ -943,9 +943,9 @@ LLSD llsd_shallow(LLSD value, LLSD filter) else if (value.isArray()) { shallow = LLSD::emptyArray(); - for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) + for (auto const& entry : value.array()) { - shallow.append(*ita); + shallow.append(entry); } } else diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index baf0c028d..3763be08f 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -1340,7 +1340,8 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals) // std::locale() throws if the locale is unknown! (EXT-7926) try { - strStream.imbue(std::locale(sLocale.c_str())); + std::locale locale(sLocale.c_str()); + strStream.imbue(locale); } catch (const std::exception &) { LL_WARNS_ONCE("Locale") << "Cannot set locale to " << sLocale << LL_ENDL; diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index ffb7b4023..a476984a2 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -243,7 +243,7 @@ public: bool operator<(const LLFormatMapString& rhs) const { return mString < rhs.mString; } std::size_t length() const { return mString.length(); } // The destructor may not throw. - ~LLFormatMapString() throw() { } + ~LLFormatMapString() noexcept { } private: std::string mString; diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index ba69408a7..2d67fa721 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -1274,7 +1274,7 @@ BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile) const S32 UNCOMPRESS_BUFFER_SIZE = 32768; BOOL retval = FALSE; gzFile src = NULL; - U8 buffer[UNCOMPRESS_BUFFER_SIZE]; + std::array buffer; LLFILE *dst = NULL; S32 bytes = 0; tmpfile = dstfile + ".t"; @@ -1288,8 +1288,8 @@ BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile) if (! dst) goto err; do { - bytes = gzread(src, buffer, UNCOMPRESS_BUFFER_SIZE); - size_t nwrit = fwrite(buffer, sizeof(U8), bytes, dst); + bytes = gzread(src, buffer.data(), buffer.size()); + size_t nwrit = fwrite(buffer.data(), sizeof(U8), bytes, dst); if (nwrit < (size_t) bytes) { LL_WARNS() << "Short write on " << tmpfile << ": Wrote " << nwrit << " of " << bytes << " bytes." << LL_ENDL; @@ -1311,7 +1311,7 @@ BOOL gzip_file(const std::string& srcfile, const std::string& dstfile) const S32 COMPRESS_BUFFER_SIZE = 32768; std::string tmpfile; BOOL retval = FALSE; - U8 buffer[COMPRESS_BUFFER_SIZE]; + std::array buffer; gzFile dst = NULL; LLFILE *src = NULL; S32 bytes = 0; @@ -1325,9 +1325,9 @@ BOOL gzip_file(const std::string& srcfile, const std::string& dstfile) src = LLFile::fopen(srcfile, "rb"); /* Flawfinder: ignore */ if (! src) goto err; - while ((bytes = (S32)fread(buffer, sizeof(U8), COMPRESS_BUFFER_SIZE, src)) > 0) + while ((bytes = (S32)fread(buffer.data(), sizeof(U8), buffer.size(), src)) > 0) { - if (gzwrite(dst, buffer, bytes) <= 0) + if (gzwrite(dst, buffer.data(), bytes) <= 0) { LL_WARNS() << "gzwrite failed: " << gzerror(dst, NULL) << LL_ENDL; goto err; diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 7d7547ecb..978edbf2e 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -103,9 +103,9 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons break; case LLSD::TypeArray: newSettings[key_name] = LLSD::emptyArray(); - for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) + for (auto const& entry : value.array()) { - newSettings[key_name].append(*ita); + newSettings[key_name].append(entry); } break; //case LLSD::TypeInteger: @@ -137,9 +137,9 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons break; case LLSD::TypeArray: newSettings[key_name] = LLSD::emptyArray(); - for (LLSD::array_const_iterator ita = value.beginArray(); ita != value.endArray(); ++ita) + for (auto const& entry : value.array()) { - newSettings[key_name].append(*ita); + newSettings[key_name].append(entry); } break; //case LLSD::TypeInteger: diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index b170abfbc..bfb755fd0 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -240,16 +240,16 @@ bool LLSettingsDay::initialize(bool validate_frames) { mDayTracks[i].clear(); LLSD curtrack = tracks[i]; - for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it) + for (const auto& entry : curtrack.array()) { - LLSettingsBase::TrackPosition keyframe = LLSettingsBase::TrackPosition((*it)[SETTING_KEYKFRAME].asReal()); + LLSettingsBase::TrackPosition keyframe = LLSettingsBase::TrackPosition(entry[SETTING_KEYKFRAME].asReal()); keyframe = llclamp(keyframe, 0.0f, 1.0f); LLSettingsBase::ptr_t setting; - if ((*it).has(SETTING_KEYNAME)) + if (entry.has(SETTING_KEYNAME)) { - std::string key_name = (*it)[SETTING_KEYNAME]; + std::string key_name = entry[SETTING_KEYNAME]; if (i == TRACK_WATER) { setting = used[key_name]; @@ -469,36 +469,36 @@ namespace S32 framecount(0); - for (LLSD::array_iterator track = value.beginArray(); track != value.endArray(); ++track) + for (auto& entry : value.array()) { S32 index = 0; - while (index < (*track).size()) + while (index < entry.size()) { - LLSD& elem = (*track)[index]; + LLSD& elem = entry[index]; ++framecount; if (index >= LLSettingsDay::FRAME_MAX) { - (*track).erase(index); + entry.erase(index); continue; } if (!elem.has(LLSettingsDay::SETTING_KEYKFRAME)) { - (*track).erase(index); + entry.erase(index); continue; } if (!elem[LLSettingsDay::SETTING_KEYKFRAME].isReal()) { - (*track).erase(index); + entry.erase(index); continue; } if (!elem.has(LLSettingsDay::SETTING_KEYNAME) && !elem.has(LLSettingsDay::SETTING_KEYID)) { - (*track).erase(index); + entry.erase(index); continue; } diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index de831a4e6..b8b06e6eb 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -425,7 +425,7 @@ public: } void accept(oct_traveler* visitor) { visitor->visit(this); } - virtual bool isLeaf() const { return mChildCount == 0; } + bool isLeaf() const { return mChildCount == 0; } U32 getElementCount() const { return mData.size(); } bool isEmpty() const { return mData.size() == 0; } @@ -498,7 +498,7 @@ public: return node; } - virtual bool insert(T* data) + bool insert(T* data) override { OctreeGuard::checkGuarded(this); if (data == NULL || data->getBinIndex() != -1) @@ -537,7 +537,7 @@ public: OctreeStats::getInstance()->realloc(old_cap,mData.capacity()); #endif - BaseType::insert(data); + notifyAddition(data); return true; } else @@ -593,7 +593,7 @@ public: OctreeStats::getInstance()->realloc(old_cap,mData.capacity()); #endif - BaseType::insert(data); + notifyAddition(data); return true; } @@ -704,11 +704,11 @@ public: #endif } - this->notifyRemoval(data); + notifyRemoval(data); checkAlive(); } - bool remove(T* data) + bool remove(T* data) final override { OctreeGuard::checkGuarded(this); S32 i = data->getBinIndex(); @@ -849,10 +849,9 @@ public: if (!silent) { - for (U32 i = 0; i < this->getListenerCount(); i++) + for (auto& entry : this->mListeners) { - oct_listener* listener = getOctListener(i); - listener->handleChildAddition(this, child); + ((oct_listener*)entry.get())->handleChildAddition(this, child); } } } @@ -861,16 +860,17 @@ public: { OctreeGuard::checkGuarded(this); - for (U32 i = 0; i < this->getListenerCount(); i++) + oct_node* child = getChild(index); + + for (auto& entry : this->mListeners) { - oct_listener* listener = getOctListener(i); - listener->handleChildRemoval(this, getChild(index)); + ((oct_listener*)entry.get())->handleChildRemoval(this, child); } if (destroy) { - mChild[index]->destroy(); - delete mChild[index]; + child->destroy(); + delete child; } --mChildCount; @@ -1012,7 +1012,7 @@ public: } // LLOctreeRoot::insert - bool insert(T* data) + bool insert(T* data) final override { if (data == NULL) { diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h index 36e6f106a..77b36a290 100644 --- a/indra/llmath/lltreenode.h +++ b/indra/llmath/lltreenode.h @@ -44,7 +44,6 @@ public: virtual void handleInsertion(const LLTreeNode* node, T* data) = 0; virtual void handleRemoval(const LLTreeNode* node, T* data) = 0; virtual void handleDestruction(const LLTreeNode* node) = 0; - virtual void handleStateChange(const LLTreeNode* node) = 0; }; template @@ -53,11 +52,15 @@ class LLTreeNode public: virtual ~LLTreeNode(); - virtual bool insert(T* data); - virtual bool remove(T* data); - virtual void notifyRemoval(T* data); - virtual U32 getListenerCount() { return mListeners.size(); } - virtual LLTreeListener* getListener(U32 index) const + virtual bool insert(T* data) = 0; + virtual bool remove(T* data) = 0; + bool notifyAddition(T* data); + void notifyRemoval(T* data); + U32 getListenerCount() const + { + return mListeners.size(); + } + LLTreeListener* getListener(U32 index) const { if(index < mListeners.size()) { @@ -65,7 +68,10 @@ public: } return NULL; } - virtual void addListener(LLTreeListener* listener) { mListeners.push_back(listener); } + void addListener(LLTreeListener* listener) + { + mListeners.push_back(listener); + } protected: void destroyListeners() @@ -97,7 +103,7 @@ LLTreeNode::~LLTreeNode() }; template -bool LLTreeNode::insert(T* data) +bool LLTreeNode::notifyAddition(T* data) { for (U32 i = 0; i < mListeners.size(); i++) { @@ -106,12 +112,6 @@ bool LLTreeNode::insert(T* data) return true; }; -template -bool LLTreeNode::remove(T* data) -{ - return true; -}; - template void LLTreeNode::notifyRemoval(T* data) { diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 1181fb40f..80a5698ef 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -38,7 +38,7 @@ class LLVolumeParams; class LLProfile; class LLPath; -template class LLOctreeNode; +template class LLOctreeRoot; class LLVolumeFace; class LLVolume; @@ -964,7 +964,7 @@ public: // vertices per joint. LLJointRiggingInfoTab mJointRiggingInfoTab; - LLOctreeNode* mOctree; + LLOctreeRoot* mOctree; //whether or not face has been cache optimized BOOL mOptimized; diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h index 0cc78fd13..0c8e1d2b8 100644 --- a/indra/llmath/llvolumeoctree.h +++ b/indra/llmath/llvolumeoctree.h @@ -112,14 +112,13 @@ public: } //LISTENER FUNCTIONS - virtual void handleChildAddition(const LLOctreeNode* parent, - LLOctreeNode* child); - virtual void handleStateChange(const LLTreeNode* node) { } - virtual void handleChildRemoval(const LLOctreeNode* parent, - const LLOctreeNode* child) { } - virtual void handleInsertion(const LLTreeNode* node, LLVolumeTriangle* tri) { } - virtual void handleRemoval(const LLTreeNode* node, LLVolumeTriangle* tri) { } - virtual void handleDestruction(const LLTreeNode* node) { } + void handleChildAddition(const LLOctreeNode* parent, + LLOctreeNode* child) final override; + void handleChildRemoval(const LLOctreeNode* parent, + const LLOctreeNode* child) final override { } + void handleInsertion(const LLTreeNode* node, LLVolumeTriangle* tri) final override { } + void handleRemoval(const LLTreeNode* node, LLVolumeTriangle* tri) final override { } + void handleDestruction(const LLTreeNode* node) final override { } public: diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp index 08596ccfc..c284f33e8 100644 --- a/indra/newview/llaisapi.cpp +++ b/indra/newview/llaisapi.cpp @@ -672,11 +672,9 @@ void AISUpdate::parseUUIDArray(const LLSD& content, const std::string& name, uui { if (content.has(name)) { - for(LLSD::array_const_iterator it = content[name].beginArray(), - end = content[name].endArray(); - it != end; ++it) + for (auto& id : content[name].array()) { - ids.insert((*it).asUUID()); + ids.insert(id.asUUID()); } } } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 792f28cb2..2671d5f9b 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -1644,12 +1644,9 @@ struct LLEstateAccessChangeInfo { mDialogName = sd["dialog_name"].asString(); mOperationFlag = (U32)sd["operation"].asInteger(); - LLSD::array_const_iterator end_it = sd["allowed_ids"].endArray(); - for (LLSD::array_const_iterator id_it = sd["allowed_ids"].beginArray(); - id_it != end_it; - ++id_it) + for (auto const& id : sd["allowed_ids"].array()) { - mAgentOrGroupIDs.push_back(id_it->asUUID()); + mAgentOrGroupIDs.push_back(id.asUUID()); } } @@ -4156,9 +4153,9 @@ void LLPanelEstateAccess::onEstateAccessReceived(const LLSD& result) const auto order = allowed_agent_name_list->getSortOrder(); allowed_agent_name_list->clearSortOrder(); allowed_agent_name_list->deleteAllItems(); - for (LLSD::array_const_iterator it = result["AllowedAgents"].beginArray(); it != result["AllowedAgents"].endArray(); ++it) + for (auto const& entry : result["AllowedAgents"].array()) { - LLUUID id = (*it)["id"].asUUID(); + LLUUID id = entry["id"].asUUID(); allowed_agent_name_list->addNameItem(id); } allowed_agent_name_list->setSortOrder(order); @@ -4177,23 +4174,23 @@ void LLPanelEstateAccess::onEstateAccessReceived(const LLSD& result) const auto order = banned_agent_name_list->getSortOrder(); banned_agent_name_list->clearSortOrder(); banned_agent_name_list->deleteAllItems(); - for (LLSD::array_const_iterator it = result["BannedAgents"].beginArray(); it != result["BannedAgents"].endArray(); ++it) + for (auto const& entry : result["BannedAgents"].array()) { LLSD item; - item["id"] = (*it)["id"].asUUID(); + item["id"] = entry["id"].asUUID(); LLSD& columns = item["columns"]; columns[0]["column"] = "name"; // to be populated later auto& col = columns[1]; col["column"] = "last_login_date"; - handlePseudoISO8601((*it)["last_login_date"].asString(), col, format); + handlePseudoISO8601(entry["last_login_date"].asString(), col, format); columns[2]["column"] = "ban_date"; - handlePseudoISO8601((*it)["ban_date"].asString(), columns[2], format); + handlePseudoISO8601(entry["ban_date"].asString(), columns[2], format); columns[3]["column"] = "bannedby"; - LLUUID banning_id = (*it)["banning_id"].asUUID(); + LLUUID banning_id = entry["banning_id"].asUUID(); LLAvatarName av_name; if (banning_id.isNull()) { @@ -4221,9 +4218,9 @@ void LLPanelEstateAccess::onEstateAccessReceived(const LLSD& result) const auto order = allowed_group_name_list->getSortOrder(); allowed_group_name_list->clearSortOrder(); allowed_group_name_list->deleteAllItems(); - for (LLSD::array_const_iterator it = result["AllowedGroups"].beginArray(); it != result["AllowedGroups"].endArray(); ++it) + for (auto const& entry : result["AllowedGroups"].array()) { - LLUUID id = (*it)["id"].asUUID(); + LLUUID id = entry["id"].asUUID(); allowed_group_name_list->addGroupNameItem(id); } allowed_group_name_list->setSortOrder(order); @@ -4241,9 +4238,9 @@ void LLPanelEstateAccess::onEstateAccessReceived(const LLSD& result) const auto order = estate_manager_name_list->getSortOrder(); estate_manager_name_list->clearSortOrder(); estate_manager_name_list->deleteAllItems(); - for (LLSD::array_const_iterator it = result["Managers"].beginArray(); it != result["Managers"].endArray(); ++it) + for (auto const& entry : result["Managers"].array()) { - LLUUID id = (*it)["agent_id"].asUUID(); + LLUUID id = entry["agent_id"].asUUID(); estate_manager_name_list->addNameItem(id); } estate_manager_name_list->setSortOrder(order); diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 88bbaed3d..e3060d226 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -876,12 +876,9 @@ void BGFolderHttpHandler::httpFailure(void) if (is_internal_http_error_that_warrants_a_retry(mStatus)) // timed out { - for(LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray(); - folder_it != mRequestSD["folders"].endArray(); - ++folder_it) + for (auto const& entry : mRequestSD["folders"].array()) { - LLSD folder_sd(*folder_it); - LLUUID folder_id(folder_sd["folder_id"].asUUID()); + LLUUID folder_id(entry["folder_id"].asUUID()); const BOOL recursive = getIsRecursive(folder_id); fetcher->addRequestAtFront(folder_id, recursive, true); } diff --git a/indra/newview/llmapresponders.cpp b/indra/newview/llmapresponders.cpp index 0a63eb85b..813830a13 100644 --- a/indra/newview/llmapresponders.cpp +++ b/indra/newview/llmapresponders.cpp @@ -59,11 +59,8 @@ void LLMapLayerResponder::httpSuccess(void) LLWorldMap::getInstance()->mMapLayers.clear(); - LLSD::array_const_iterator iter; - for(iter = mContent["LayerData"].beginArray(); iter != mContent["LayerData"].endArray(); ++iter) + for (auto const& layer_data : mContent["LayerData"].array()) { - const LLSD& layer_data = *iter; - LLWorldMapLayer new_layer; new_layer.LayerDefined = TRUE; diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index b2ee4fba4..a42e19c48 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -297,11 +297,8 @@ public: log_SLM_infos("Get /listings", getStatus(), body); // Extract the info from the results - for (LLSD::array_iterator it = result["listings"].beginArray(); - it != result["listings"].endArray(); ++it) + for (auto const& listing : result["listings"].array()) { - LLSD listing = *it; - int listingId = listing["id"].asInteger(); bool isListed = listing["is_listed"].asBoolean(); std::string editUrl = listing["edit_url"].asString(); @@ -359,12 +356,8 @@ public: log_SLM_infos("Post /listings", getStatus(), body); // Extract the info from the Json string - auto it = result["listings"].beginArray(); - - while (it != result["listings"].endArray()) + for (auto const& listing : result["listings"].array()) { - auto listing = *it; - int listing_id = listing["id"].asInteger(); bool is_listed = listing["is_listed"].asBoolean(); std::string edit_url = listing["edit_url"].asString(); @@ -377,7 +370,6 @@ public: LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed,edit_url,count); update_marketplace_category(folder_id, false); gInventory.notifyObservers(); - it++; } } virtual char const* getName() const { return "LLSLMCreateListingsResponder"; } @@ -427,11 +419,8 @@ public: log_SLM_infos("Get /listing", getStatus(), body); // Extract the info from the results - for (LLSD::array_iterator it = result["listings"].beginArray(); - it != result["listings"].endArray(); ++it) + for (auto const& listing : result["listings"].array()) { - LLSD listing = *it; - int resListingId = listing["id"].asInteger(); bool isListed = listing["is_listed"].asBoolean(); std::string editUrl = listing["edit_url"].asString(); @@ -494,11 +483,8 @@ public: log_SLM_infos("Put /listing", getStatus(), body); // Extract the info from the Json string - for (LLSD::array_iterator it = result["listings"].beginArray(); - it != result["listings"].endArray(); ++it) + for (auto const& listing : result["listings"].array()) { - LLSD listing = *it; - int listing_id = listing["id"].asInteger(); bool is_listed = listing["is_listed"].asBoolean(); std::string edit_url = listing["edit_url"].asString(); @@ -571,11 +557,8 @@ public: log_SLM_infos("Put /associate_inventory", getStatus(), body); - for (LLSD::array_iterator it = result["listings"].beginArray(); - it != result["listings"].endArray(); ++it) + for (auto const& listing : result["listings"].array()) { - LLSD listing = *it; - int listing_id = listing["id"].asInteger(); bool is_listed = listing["is_listed"].asBoolean(); std::string edit_url = listing["edit_url"].asString(); @@ -642,11 +625,8 @@ public: log_SLM_infos("Delete /listing", getStatus(), body); - for (LLSD::array_iterator it = result["listings"].beginArray(); - it != result["listings"].endArray(); ++it) + for (auto const& listing : result["listings"].array()) { - LLSD listing = *it; - int listing_id = listing["id"].asInteger(); LLUUID folder_id = LLMarketplaceData::instance().getListingFolder(listing_id); LLMarketplaceData::instance().deleteListing(folder_id); diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 20f3124f1..f6655c8fe 100644 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -420,9 +420,8 @@ void LLMaterialMgr::onGetResponse(bool success, const LLSD& content, const LLUUI llassert(response_data.isArray()); LL_DEBUGS("Materials") << "response has "<< response_data.size() << " materials" << LL_ENDL; - for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) + for (auto const& material_data : response_data.array()) { - const LLSD& material_data = *itMaterial; llassert(material_data.isMap()); llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); @@ -465,9 +464,8 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL llassert(response_data.isArray()); LL_DEBUGS("Materials") << "response has "<< response_data.size() << " materials" << LL_ENDL; - for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) + for (auto const& material_data : response_data.array()) { - const LLSD& material_data = *itMaterial; llassert(material_data.isMap()); llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); @@ -531,11 +529,9 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content) { llassert(response_data.isArray()); LL_DEBUGS("Materials") << "response has "<< response_data.size() << " materials" << LL_ENDL; - for (LLSD::array_const_iterator faceIter = response_data.beginArray(); faceIter != response_data.endArray(); ++faceIter) +#ifdef SHOW_ASSERT + for (auto const& face_data : response_data.array()) { -# ifndef LL_RELEASE_FOR_DOWNLOAD - const LLSD& face_data = *faceIter; // conditional to avoid unused variable warning -# endif llassert(face_data.isMap()); llassert(face_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); @@ -552,6 +548,7 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content) // *TODO: do we really still need to process this? } +#endif } } diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index ae4197578..56d1ee0e6 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -139,8 +139,8 @@ public: virtual void performAction(LLInventoryModel* model, std::string action); virtual BOOL isUpToDate() const { return TRUE; } virtual bool hasChildren() const { return FALSE; } - virtual LLInventoryType::EType getInventoryType() const { return LLInventoryType::IT_NONE; } - virtual LLWearableType::EType getWearableType() const { return LLWearableType::WT_NONE; } + virtual LLInventoryType::EType getInventoryType() const { return LLInventoryType::EType::IT_NONE; } + virtual LLWearableType::EType getWearableType() const { return LLWearableType::EType::WT_NONE; } // LLDragAndDropBridge functionality virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id) const; @@ -161,7 +161,7 @@ LLTaskInvFVBridge::LLTaskInvFVBridge( mPanel(panel), mFlags(flags), mAssetType(LLAssetType::AT_NONE), - mInventoryType(LLInventoryType::IT_NONE) + mInventoryType(LLInventoryType::EType::IT_NONE) { const LLInventoryItem *item = findItem(); if (item) @@ -479,12 +479,9 @@ bool remove_task_inventory_callback(const LLSD& notification, const LLSD& respon if(option == 0 && object) { // yes - LLSD::array_const_iterator list_end = notification["payload"]["inventory_ids"].endArray(); - for (LLSD::array_const_iterator list_it = notification["payload"]["inventory_ids"].beginArray(); - list_it != list_end; - ++list_it) + for (auto const& entry : notification["payload"]["inventory_ids"].array()) { - object->removeInventory(list_it->asUUID()); + object->removeInventory(entry.asUUID()); } // refresh the UI. diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index d710e0fde..b52726be1 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -316,13 +316,13 @@ public: void drawObjectBox(LLColor4 col); - LLSpatialPartition* getSpatialPartition() {return (LLSpatialPartition*)mSpatialPartition;} + LLSpatialPartition* getSpatialPartition() const {return (LLSpatialPartition*)mSpatialPartition;} //LISTENER FUNCTIONS - virtual void handleInsertion(const TreeNode* node, LLViewerOctreeEntry* face); - virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face); - virtual void handleDestruction(const TreeNode* node); - virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child); + void handleInsertion(const TreeNode* node, LLViewerOctreeEntry* face) final override; + void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face) final override; + void handleDestruction(const TreeNode* node) final override; + void handleChildAddition(const OctreeNode* parent, OctreeNode* child) final override; LL_ALIGN_16(LLVector4a mViewAngle); diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index a4e11d815..3012aae00 100644 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -778,20 +778,17 @@ void LLIMSpeakerMgr::setSpeakers(const LLSD& speakers) std::vector speakerentries; if ( speakers.has("agent_info") && speakers["agent_info"].isMap() ) { - LLSD::map_const_iterator speaker_it; - for(speaker_it = speakers["agent_info"].beginMap(); - speaker_it != speakers["agent_info"].endMap(); - ++speaker_it) + for (const auto& speaker : speakers["agent_info"].map()) { boost::optional moderator; boost::optional moderator_muted; - if (speaker_it->second.isMap()) + if (speaker.second.isMap()) { - moderator = speaker_it->second["is_moderator"]; - moderator_muted = speaker_it->second["mutes"]["text"]; + moderator = speaker.second["is_moderator"]; + moderator_muted = speaker.second["mutes"]["text"]; } speakerentries.emplace_back( - LLUUID(speaker_it->first), + LLUUID(speaker.first), LLSpeaker::SPEAKER_AGENT, LLSpeaker::STATUS_TEXT_ONLY, moderator, @@ -803,12 +800,9 @@ void LLIMSpeakerMgr::setSpeakers(const LLSD& speakers) { //older, more decprecated way. Need here for //using older version of servers - LLSD::array_const_iterator speaker_it; - for(speaker_it = speakers["agents"].beginArray(); - speaker_it != speakers["agents"].endArray(); - ++speaker_it) + for (auto const& entry : speakers["agents"].array()) { - speakerentries.emplace_back((*speaker_it).asUUID()); + speakerentries.emplace_back(entry.asUUID()); } } LLSpeakerMgr::setSpeakers(speakerentries); @@ -822,20 +816,16 @@ void LLIMSpeakerMgr::updateSpeakers(const LLSD& update) if ( update.has("agent_updates") && update["agent_updates"].isMap() ) { - LLSD::map_const_iterator update_it; - for( - update_it = update["agent_updates"].beginMap(); - update_it != update["agent_updates"].endMap(); - ++update_it) + for (const auto& update : update["agent_updates"].map()) { - LLUUID agent_id(update_it->first); + LLUUID agent_id(update.first); LLPointer speakerp = findSpeaker(agent_id); bool new_speaker = false; boost::optional moderator; boost::optional moderator_muted_text; - LLSD agent_data = update_it->second; + LLSD agent_data = update.second; if (agent_data.isMap() && agent_data.has("transition")) { if (agent_data["transition"].asString() == "LEAVE" && speakerp.notNull()) @@ -883,12 +873,9 @@ void LLIMSpeakerMgr::updateSpeakers(const LLSD& update) else if ( update.has("updates") && update["updates"].isMap() ) { LLSD::map_const_iterator update_it; - for ( - update_it = update["updates"].beginMap(); - update_it != update["updates"].endMap(); - ++update_it) + for (const auto& update : update["updates"].map()) { - LLUUID agent_id(update_it->first); + LLUUID agent_id(update.first); LLPointer speakerp = findSpeaker(agent_id); std::string agent_transition = update_it->second.asString(); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 9b9fdd105..c6f684685 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -474,7 +474,7 @@ class LLFileUploadBulk : public view_listener_t asset_name, 0, LLFolderType::FT_NONE, - LLInventoryType::IT_NONE, + LLInventoryType::EType::IT_NONE, LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), @@ -963,10 +963,10 @@ void upload_new_resource(const std::string& src_filename, std::string name, // hack to create scripts and gestures if(exten == "lsl" || exten == "gesture" || exten == "notecard") // added notecard Oct 15 2009 { - LLInventoryType::EType inv_type = LLInventoryType::IT_GESTURE; - if (exten == "lsl") inv_type = LLInventoryType::IT_LSL; - else if(exten == "gesture") inv_type = LLInventoryType::IT_GESTURE; - else if(exten == "notecard") inv_type = LLInventoryType::IT_NOTECARD; + LLInventoryType::EType inv_type = LLInventoryType::EType::IT_GESTURE; + if (exten == "lsl") inv_type = LLInventoryType::EType::IT_LSL; + else if(exten == "gesture") inv_type = LLInventoryType::EType::IT_GESTURE; + else if(exten == "notecard") inv_type = LLInventoryType::EType::IT_NOTECARD; create_inventory_item( gAgent.getID(), gAgent.getSessionID(), gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(asset_type)), @@ -1354,7 +1354,7 @@ void assign_defaults_and_show_upload_message(LLAssetType::EType asset_type, const std::string& display_name, std::string& description) { - if (LLInventoryType::IT_NONE == inventory_type) + if (LLInventoryType::EType::IT_NONE == inventory_type) { inventory_type = LLInventoryType::defaultForAssetType(asset_type); } @@ -1412,9 +1412,9 @@ void NewResourceItemCallback::fire(const LLUUID& new_item_id) std::string type("Uploads"); switch(new_item->getInventoryType()) { - case LLInventoryType::IT_LSL: type = "Scripts"; break; - case LLInventoryType::IT_GESTURE: type = "Gestures"; break; - case LLInventoryType::IT_NOTECARD: type = "Notecard"; break; + case LLInventoryType::EType::IT_LSL: type = "Scripts"; break; + case LLInventoryType::EType::IT_GESTURE: type = "Gestures"; break; + case LLInventoryType::EType::IT_NOTECARD: type = "Notecard"; break; default: break; } LLPermissions perms = new_item->getPermissions(); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index c23ffa186..5ef9afe22 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1270,7 +1270,7 @@ void open_inventory_offer(const uuid_vec_t& objects, const std::string& from_nam if (gSavedSettings.getBOOL("ShowInInventory") && objects.size() == 1 && item != NULL && asset_type != LLAssetType::AT_CALLINGCARD && - item->getInventoryType() != LLInventoryType::IT_ATTACHMENT && + item->getInventoryType() != LLInventoryType::EType::IT_ATTACHMENT && !from_name.empty()) { LLPanelMainInventory::showAgentInventory(TRUE); @@ -7950,10 +7950,9 @@ void send_lures(const LLSD& notification, const LLSD& response) if ( (RlvActions::hasBehaviour(RLV_BHVR_SENDIM)) || (RlvActions::hasBehaviour(RLV_BHVR_SENDIMTO)) ) { // Filter the lure message if one of the recipients of the lure can't be sent an IM to - for (LLSD::array_const_iterator it = notification["payload"]["ids"].beginArray(); - it != notification["payload"]["ids"].endArray(); ++it) + for (auto const& entry : notification["payload"]["ids"].array()) { - if (!RlvActions::canSendIM(it->asUUID())) + if (!RlvActions::canSendIM(entry.asUUID())) { text = rlv_hidden; break; @@ -7974,11 +7973,9 @@ void send_lures(const LLSD& notification, const LLSD& response) bool fRlvHideName = gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES); bool fRlvNoNearbyNames = gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMETAGS); // [/RLVa:KB] - for(LLSD::array_const_iterator it = notification["payload"]["ids"].beginArray(); - it != notification["payload"]["ids"].endArray(); - ++it) + for (auto const& entry : notification["payload"]["ids"].array()) { - LLUUID target_id = it->asUUID(); + LLUUID target_id = entry.asUUID(); msg->nextBlockFast(_PREHASH_TargetData); msg->addUUIDFast(_PREHASH_TargetID, target_id); diff --git a/indra/newview/llviewerobjectbackup.cpp b/indra/newview/llviewerobjectbackup.cpp index 110a8de90..0c460d62a 100644 --- a/indra/newview/llviewerobjectbackup.cpp +++ b/indra/newview/llviewerobjectbackup.cpp @@ -1123,11 +1123,9 @@ void LLObjectBackup::importObject_continued(AIFilePicker* filepicker) mRezCount = 0; updateImportNumbers(); - for (LLSD::array_const_iterator prim_arr_it = mLLSD["data"].beginArray(), - prim_arr_end = mLLSD["data"].endArray(); - prim_arr_it != prim_arr_end; ++prim_arr_it) + for (auto const& entry : mLLSD["data"].array()) { - LLSD llsd2 = (*prim_arr_it)["group_body"]; + LLSD llsd2 = entry["group_body"]; for (LLSD::map_const_iterator prim_it = llsd2.beginMap(), prim_end = llsd2.endMap(); diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index f6a26905f..2437ce618 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -746,12 +746,9 @@ public: void clear_object_list_pending_requests() { // TODO*: No more hard coding - for ( - LLSD::array_iterator iter = mObjectIDs.beginArray(); - iter != mObjectIDs.endArray(); - ++iter) + for (auto const& id : mObjectIDs.array()) { - gObjectList.onObjectCostFetchFailure(iter->asUUID()); + gObjectList.onObjectCostFetchFailure(id.asUUID()); } } @@ -789,23 +786,20 @@ public: // Success, grab the resource cost and linked set costs // for an object if one was returned - for ( - LLSD::array_iterator iter = mObjectIDs.beginArray(); - iter != mObjectIDs.endArray(); - ++iter) + for (auto const& entry : mObjectIDs.array()) { - LLUUID object_id = iter->asUUID(); + LLUUID object_id = entry.asUUID(); // Check to see if the request contains data for the object - if ( mContent.has(iter->asString()) ) + if ( mContent.has(entry.asString()) ) { F32 link_cost = - mContent[iter->asString()]["linked_set_resource_cost"].asReal(); + mContent[entry.asString()]["linked_set_resource_cost"].asReal(); F32 object_cost = - mContent[iter->asString()]["resource_cost"].asReal(); + mContent[entry.asString()]["resource_cost"].asReal(); - F32 physics_cost = mContent[iter->asString()]["physics_cost"].asReal(); - F32 link_physics_cost = mContent[iter->asString()]["linked_set_physics_cost"].asReal(); + F32 physics_cost = mContent[entry.asString()]["physics_cost"].asReal(); + F32 link_physics_cost = mContent[entry.asString()]["linked_set_physics_cost"].asReal(); gObjectList.updateObjectCost(object_id, object_cost, link_cost, physics_cost, link_physics_cost); } @@ -837,12 +831,9 @@ public: void clear_object_list_pending_requests() { // TODO*: No more hard coding - for ( - LLSD::array_iterator iter = mObjectIDs.beginArray(); - iter != mObjectIDs.endArray(); - ++iter) + for (auto const& id : mObjectIDs.array()) { - gObjectList.onPhysicsFlagsFetchFailure(iter->asUUID()); + gObjectList.onPhysicsFlagsFetchFailure(id.asUUID()); } } @@ -880,17 +871,14 @@ public: // Success, grab the resource cost and linked set costs // for an object if one was returned - for ( - LLSD::array_iterator iter = mObjectIDs.beginArray(); - iter != mObjectIDs.endArray(); - ++iter) + for (auto const& entry : mObjectIDs.array()) { - LLUUID object_id = iter->asUUID(); + LLUUID object_id = entry.asUUID(); // Check to see if the request contains data for the object - if (mContent.has(iter->asString())) + if (mContent.has(entry.asString())) { - const LLSD& data = mContent[iter->asString()]; + const LLSD& data = mContent[entry.asString()]; S32 shape_type = data["PhysicsShapeType"].asInteger(); diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 34065f8ef..bbb57f3b9 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -467,6 +467,11 @@ LLViewerOctreeGroup::LLViewerOctreeGroup(OctreeNode* node) : mBounds[1] = node->getSize(); mOctreeNode->addListener(this); + + for (U32 i = 0; i < sizeof(mVisible) / sizeof(mVisible[0]); i++) + { + mVisible[i] = 0; + } } bool LLViewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) @@ -632,17 +637,6 @@ void LLViewerOctreeGroup::handleDestruction(const TreeNode* node) mOctreeNode = NULL; } -//virtual -void LLViewerOctreeGroup::handleStateChange(const TreeNode* node) -{ - //drop bounding box upon state change - if (mOctreeNode != node) - { - mOctreeNode = (OctreeNode*) node; - } - unbound(); -} - //virtual void LLViewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) { @@ -813,7 +807,7 @@ U32 LLOcclusionCullingGroup::getNewOcclusionQueryObjectName() return sQueryPool.allocate(); } -void LLOcclusionCullingGroup::releaseOcclusionQueryObjectName(GLuint name) +void LLOcclusionCullingGroup::releaseOcclusionQueryObjectName(U32 name) { sQueryPool.release(name); } diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index 78eca7b33..b60875b58 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -222,12 +222,11 @@ public: void clearState(U32 state) {mState &= ~state;} //LISTENER FUNCTIONS - virtual void handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj); - virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj); - virtual void handleDestruction(const TreeNode* node); - virtual void handleStateChange(const TreeNode* node); - virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child); - virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child); + void handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj) override; + void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj) override; + void handleDestruction(const TreeNode* node) override; + void handleChildAddition(const OctreeNode* parent, OctreeNode* child) override; + void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child) final override; OctreeNode* getOctreeNode() {return mOctreeNode;} LLViewerOctreeGroup* getParent(); @@ -308,11 +307,11 @@ public: U32 getLastOcclusionIssuedTime(); //virtual - void handleChildAddition(const OctreeNode* parent, OctreeNode* child); + void handleChildAddition(const OctreeNode* parent, OctreeNode* child) override; //virtual BOOL isRecentlyVisible() const; - LLViewerOctreePartition* getSpatialPartition()const {return mSpatialPartition;} + //LLViewerOctreePartition* getSpatialPartition()const {return mSpatialPartition;} BOOL isAnyRecentlyVisible() const; static U32 getNewOcclusionQueryObjectName(); @@ -350,7 +349,7 @@ public: public: U32 mPartitionType; U32 mDrawableType; - OctreeNode* mOctree; + OctreeRoot* mOctree; LLViewerRegion* mRegionp; // the region this partition belongs to. BOOL mOcclusionEnabled; // if TRUE, occlusion culling is performed U32 mLODSeed; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 2d9f841b6..26628e6f0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2528,12 +2528,10 @@ void LLVOVolume::updateObjectMediaData(const LLSD &media_data_array, const std:: mLastFetchedMediaVersion = fetched_version; //LL_INFOS() << "updating:" << this->getID() << " " << ll_pretty_print_sd(media_data_array) << LL_ENDL; - LLSD::array_const_iterator iter = media_data_array.beginArray(); - LLSD::array_const_iterator end = media_data_array.endArray(); U8 texture_index = 0; - for (; iter != end; ++iter, ++texture_index) + for (auto const& entry : media_data_array.array()) { - syncMediaData(texture_index, *iter, false/*merge*/, false/*ignore_agent*/); + syncMediaData(texture_index++, entry, false/*merge*/, false/*ignore_agent*/); } } } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a68b191ca..ee4c4c25d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2273,8 +2273,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl BOOL to_texture = LLPipeline::sUseOcclusion > 1 && !hasRenderType(LLPipeline::RENDER_TYPE_HUD) && LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && - LLGLSLShader::sNoFixedFunction && - sRenderGlow; + LLGLSLShader::sNoFixedFunction; if (to_texture) {