diff options
Diffstat (limited to 'indra/newview/llgroupmgr.cpp')
-rw-r--r-- | indra/newview/llgroupmgr.cpp | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index af58e81ca4..6dbd3a81e8 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -677,9 +677,12 @@ void LLGroupMgrGroupData::sendRoleChanges() break; } case RC_UPDATE_ALL: + // fall through case RC_UPDATE_POWERS: need_power_recalc = true; + // fall through case RC_UPDATE_DATA: + // fall through default: { LLGroupRoleData* group_role_data = (*role_it).second; @@ -762,6 +765,14 @@ void LLGroupMgr::addObserver(LLGroupMgrObserver* observer) mObservers.insert(std::pair<LLUUID, LLGroupMgrObserver*>(observer->getID(), observer)); } +void LLGroupMgr::addObserver(const LLUUID& group_id, LLParticularGroupObserver* observer) +{ + if(group_id.notNull() && observer) + { + mParticularObservers[group_id].insert(observer); + } +} + void LLGroupMgr::removeObserver(LLGroupMgrObserver* observer) { if (!observer) @@ -784,6 +795,23 @@ void LLGroupMgr::removeObserver(LLGroupMgrObserver* observer) } } +void LLGroupMgr::removeObserver(const LLUUID& group_id, LLParticularGroupObserver* observer) +{ + if(group_id.isNull() || !observer) + { + return; + } + + observer_map_t::iterator obs_it = mParticularObservers.find(group_id); + if(obs_it == mParticularObservers.end()) + return; + + obs_it->second.erase(observer); + + if (obs_it->second.size() == 0) + mParticularObservers.erase(obs_it); +} + LLGroupMgrGroupData* LLGroupMgr::getGroupData(const LLUUID& id) { group_map_t::iterator gi = mGroups.find(id); @@ -1325,6 +1353,7 @@ void LLGroupMgr::notifyObservers(LLGroupChange gc) LLUUID group_id = gi->first; if (gi->second->mChanged) { + // notify LLGroupMgrObserver // Copy the map because observers may remove themselves on update observer_multimap_t observers = mObservers; @@ -1336,6 +1365,18 @@ void LLGroupMgr::notifyObservers(LLGroupChange gc) oi->second->changed(gc); } gi->second->mChanged = FALSE; + + + // notify LLParticularGroupObserver + observer_map_t::iterator obs_it = mParticularObservers.find(group_id); + if(obs_it == mParticularObservers.end()) + return; + + observer_set_t& obs = obs_it->second; + for (observer_set_t::iterator ob_it = obs.begin(); ob_it != obs.end(); ++ob_it) + { + (*ob_it)->changed(group_id, gc); + } } } } @@ -1670,19 +1711,24 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, bool start_message = true; LLMessageSystem* msg = gMessageSystem; + + LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id); if (!group_datap) return; for (std::vector<LLUUID>::iterator it = member_ids.begin(); it != member_ids.end(); ++it) { + LLUUID& ejected_member_id = (*it); + // Can't use 'eject' to leave a group. - if ((*it) == gAgent.getID()) continue; + if (ejected_member_id == gAgent.getID()) continue; // Make sure they are in the group, and we need the member data - LLGroupMgrGroupData::member_list_t::iterator mit = group_datap->mMembers.find(*it); + LLGroupMgrGroupData::member_list_t::iterator mit = group_datap->mMembers.find(ejected_member_id); if (mit != group_datap->mMembers.end()) { + LLGroupMemberData* member_data = (*mit).second; // Add them to the message if (start_message) { @@ -1696,7 +1742,7 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, } msg->nextBlock("EjectData"); - msg->addUUID("EjecteeID",(*it)); + msg->addUUID("EjecteeID",ejected_member_id); if (msg->isSendFull()) { @@ -1705,16 +1751,18 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, } // Clean up groupmgr - for (LLGroupMemberData::role_list_t::iterator rit = (*mit).second->roleBegin(); - rit != (*mit).second->roleEnd(); ++rit) + for (LLGroupMemberData::role_list_t::iterator rit = member_data->roleBegin(); + rit != member_data->roleEnd(); ++rit) { - if ((*rit).first.notNull()) + if ((*rit).first.notNull() && (*rit).second!=0) { - (*rit).second->removeMember(*it); + (*rit).second->removeMember(ejected_member_id); } } - delete (*mit).second; - group_datap->mMembers.erase(*it); + + group_datap->mMembers.erase(ejected_member_id); + + delete member_data; } } |