summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsariel Hiller <Ansariel@users.noreply.github.com>2024-09-12 08:18:34 +0200
committerGitHub <noreply@github.com>2024-09-12 09:18:34 +0300
commit5f622a071c1682fd86b2d8365a58aaa90aee8809 (patch)
tree1e954be899849197b4e6b9288037516c8dd38c61
parentf90712b9837957f2a0d11386c6bf48e9a48ff745 (diff)
Fix incorrect operator warning and possible dereferencing of null pointer (#2546)
-rw-r--r--indra/newview/llvoavatar.cpp108
1 files changed, 47 insertions, 61 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 5329b354d3..67bf93a155 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2881,7 +2881,7 @@ static void override_bbox(LLDrawable* drawable, LLVector4a* extents)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL;
drawable->setSpatialExtents(extents[0], extents[1]);
- drawable->setPositionGroup(LLVector4a(0, 0, 0));
+ drawable->setPositionGroup(LLVector4a(0.f, 0.f, 0.f));
drawable->movePartition();
}
@@ -2902,19 +2902,12 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
if (detailed_update)
{
U32 draw_order = 0;
- S32 attachment_selected = LLSelectMgr::getInstance()->getSelection()->getObjectCount() && LLSelectMgr::getInstance()->getSelection()->isAttachment();
- for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end();
- ++iter)
+ bool attachment_selected = LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 0 && LLSelectMgr::getInstance()->getSelection()->isAttachment();
+ for (const auto& [attachment_point_id, attachment] : mAttachmentPoints)
{
- LLViewerJointAttachment* attachment = iter->second;
-
- for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
- attachment_iter != attachment->mAttachedObjects.end();
- ++attachment_iter)
+ for (auto& attached_object : attachment->mAttachedObjects)
{
- LLViewerObject* attached_object = attachment_iter->get();
- if (!attached_object
+ if (attached_object.isNull()
|| attached_object->isDead()
|| !attachment->getValid()
|| attached_object->mDrawable.isNull())
@@ -8615,60 +8608,53 @@ void LLVOAvatar::updateMeshVisibility()
if (getOverallAppearance() == AOA_NORMAL)
{
- for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end();
- ++iter)
+ for (const auto& [attachment_point_id, attachment] : mAttachmentPoints)
{
- LLViewerJointAttachment* attachment = iter->second;
- if (attachment)
+ if (!attachment)
+ continue;
+
+ for (const auto& objectp : attachment->mAttachedObjects)
{
- for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
- attachment_iter != attachment->mAttachedObjects.end();
- ++attachment_iter)
+ if (objectp.isNull())
+ continue;
+
+ for (int face_index = 0; face_index < objectp->getNumTEs(); face_index++)
{
- LLViewerObject *objectp = attachment_iter->get();
- if (objectp)
- {
- for (int face_index = 0; face_index < objectp->getNumTEs(); face_index++)
- {
- LLTextureEntry* tex_entry = objectp->getTE(face_index);
- bake_flag[BAKED_HEAD] |= (tex_entry->getID() == IMG_USE_BAKED_HEAD);
- bake_flag[BAKED_EYES] |= (tex_entry->getID() == IMG_USE_BAKED_EYES);
- bake_flag[BAKED_HAIR] |= (tex_entry->getID() == IMG_USE_BAKED_HAIR);
- bake_flag[BAKED_LOWER] |= (tex_entry->getID() == IMG_USE_BAKED_LOWER);
- bake_flag[BAKED_UPPER] |= (tex_entry->getID() == IMG_USE_BAKED_UPPER);
- bake_flag[BAKED_SKIRT] |= (tex_entry->getID() == IMG_USE_BAKED_SKIRT);
- bake_flag[BAKED_LEFT_ARM] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTARM);
- bake_flag[BAKED_LEFT_LEG] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTLEG);
- bake_flag[BAKED_AUX1] |= (tex_entry->getID() == IMG_USE_BAKED_AUX1);
- bake_flag[BAKED_AUX2] |= (tex_entry->getID() == IMG_USE_BAKED_AUX2);
- bake_flag[BAKED_AUX3] |= (tex_entry->getID() == IMG_USE_BAKED_AUX3);
- }
- }
+ LLTextureEntry* tex_entry = objectp->getTE(face_index);
+ const auto& tex_id = tex_entry->getID();
+ bake_flag[BAKED_HEAD] |= (tex_id == IMG_USE_BAKED_HEAD);
+ bake_flag[BAKED_EYES] |= (tex_id == IMG_USE_BAKED_EYES);
+ bake_flag[BAKED_HAIR] |= (tex_id == IMG_USE_BAKED_HAIR);
+ bake_flag[BAKED_LOWER] |= (tex_id == IMG_USE_BAKED_LOWER);
+ bake_flag[BAKED_UPPER] |= (tex_id == IMG_USE_BAKED_UPPER);
+ bake_flag[BAKED_SKIRT] |= (tex_id == IMG_USE_BAKED_SKIRT);
+ bake_flag[BAKED_LEFT_ARM] |= (tex_id == IMG_USE_BAKED_LEFTARM);
+ bake_flag[BAKED_LEFT_LEG] |= (tex_id == IMG_USE_BAKED_LEFTLEG);
+ bake_flag[BAKED_AUX1] |= (tex_id == IMG_USE_BAKED_AUX1);
+ bake_flag[BAKED_AUX2] |= (tex_id == IMG_USE_BAKED_AUX2);
+ bake_flag[BAKED_AUX3] |= (tex_id == IMG_USE_BAKED_AUX3);
+ }
- LLViewerObject::const_child_list_t& child_list = objectp->getChildren();
- for (LLViewerObject::child_list_t::const_iterator iter1 = child_list.begin();
- iter1 != child_list.end(); ++iter1)
+ for (const auto& objectchild : objectp->getChildren())
+ {
+ if (objectchild.isNull())
+ continue;
+
+ for (int face_index = 0; face_index < objectchild->getNumTEs(); face_index++)
{
- LLViewerObject* objectchild = *iter1;
- if (objectchild)
- {
- for (int face_index = 0; face_index < objectchild->getNumTEs(); face_index++)
- {
- LLTextureEntry* tex_entry = objectchild->getTE(face_index);
- bake_flag[BAKED_HEAD] |= (tex_entry->getID() == IMG_USE_BAKED_HEAD);
- bake_flag[BAKED_EYES] |= (tex_entry->getID() == IMG_USE_BAKED_EYES);
- bake_flag[BAKED_HAIR] |= (tex_entry->getID() == IMG_USE_BAKED_HAIR);
- bake_flag[BAKED_LOWER] |= (tex_entry->getID() == IMG_USE_BAKED_LOWER);
- bake_flag[BAKED_UPPER] |= (tex_entry->getID() == IMG_USE_BAKED_UPPER);
- bake_flag[BAKED_SKIRT] |= (tex_entry->getID() == IMG_USE_BAKED_SKIRT);
- bake_flag[BAKED_LEFT_ARM] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTARM);
- bake_flag[BAKED_LEFT_LEG] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTLEG);
- bake_flag[BAKED_AUX1] |= (tex_entry->getID() == IMG_USE_BAKED_AUX1);
- bake_flag[BAKED_AUX2] |= (tex_entry->getID() == IMG_USE_BAKED_AUX2);
- bake_flag[BAKED_AUX3] |= (tex_entry->getID() == IMG_USE_BAKED_AUX3);
- }
- }
+ LLTextureEntry* tex_entry = objectchild->getTE(face_index);
+ const auto& tex_id = tex_entry->getID();
+ bake_flag[BAKED_HEAD] |= (tex_id == IMG_USE_BAKED_HEAD);
+ bake_flag[BAKED_EYES] |= (tex_id == IMG_USE_BAKED_EYES);
+ bake_flag[BAKED_HAIR] |= (tex_id == IMG_USE_BAKED_HAIR);
+ bake_flag[BAKED_LOWER] |= (tex_id == IMG_USE_BAKED_LOWER);
+ bake_flag[BAKED_UPPER] |= (tex_id == IMG_USE_BAKED_UPPER);
+ bake_flag[BAKED_SKIRT] |= (tex_id == IMG_USE_BAKED_SKIRT);
+ bake_flag[BAKED_LEFT_ARM] |= (tex_id == IMG_USE_BAKED_LEFTARM);
+ bake_flag[BAKED_LEFT_LEG] |= (tex_id == IMG_USE_BAKED_LEFTLEG);
+ bake_flag[BAKED_AUX1] |= (tex_id == IMG_USE_BAKED_AUX1);
+ bake_flag[BAKED_AUX2] |= (tex_id == IMG_USE_BAKED_AUX2);
+ bake_flag[BAKED_AUX3] |= (tex_id == IMG_USE_BAKED_AUX3);
}
}
}