From 727a91b6891984ee6ade62a9a162582b666fe3fc Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Thu, 7 Jul 2016 22:39:06 -0400 Subject: [PATCH] Actually solve SV-2103 Tons of duplicate code cleanup, yaaaay~ --- indra/newview/llfloateravatarlist.cpp | 37 +++------------------------ indra/newview/llviewermenu.cpp | 18 ++++++++----- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/indra/newview/llfloateravatarlist.cpp b/indra/newview/llfloateravatarlist.cpp index ca5fc7fe0..54956d6ec 100644 --- a/indra/newview/llfloateravatarlist.cpp +++ b/indra/newview/llfloateravatarlist.cpp @@ -1355,38 +1355,7 @@ void send_eject(const LLUUID& avatar_id, bool ban) } } -static void send_estate_message( - const char* request, - const LLUUID& target) -{ - - LLMessageSystem* msg = gMessageSystem; - LLUUID invoice; - - // This seems to provide an ID so that the sim can say which request it's - // replying to. I think this can be ignored for now. - invoice.generate(); - - LL_INFOS() << "Sending estate request '" << request << "'" << LL_ENDL; - msg->newMessage("EstateOwnerMessage"); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgentID); - msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID); - msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used - msg->nextBlock("MethodData"); - msg->addString("Method", request); - msg->addUUID("Invoice", invoice); - - // Agent id - msg->nextBlock("ParamList"); - msg->addString("Parameter", gAgentID.asString().c_str()); - - // Target - msg->nextBlock("ParamList"); - msg->addString("Parameter", target.asString().c_str()); - - msg->sendReliable(gAgent.getRegion()->getHost()); -} +static void send_estate_message(const std::string request, const std::vector& strings); static void cmd_append_names(const LLAvatarListEntry* entry, std::string &str, std::string &sep) { if(!str.empty())str.append(sep);str.append(entry->getName()); } @@ -1398,8 +1367,8 @@ static void cmd_freeze(const LLAvatarListEntry* entry) { send_freeze(entry->get static void cmd_unfreeze(const LLAvatarListEntry* entry) { send_freeze(entry->getID(), false); } static void cmd_eject(const LLAvatarListEntry* entry) { send_eject(entry->getID(), false); } static void cmd_ban(const LLAvatarListEntry* entry) { send_eject(entry->getID(), true); } -static void cmd_estate_eject(const LLAvatarListEntry* entry){ send_estate_message("kickestate", entry->getID()); } -static void cmd_estate_tp_home(const LLAvatarListEntry* entry){ send_estate_message("teleporthomeuser", entry->getID()); } +static void cmd_estate_eject(const LLAvatarListEntry* entry){ send_estate_message("kickestate", {entry->getID().asString()}); } +static void cmd_estate_tp_home(const LLAvatarListEntry* entry){ send_estate_message("teleporthomeuser", {gAgentID.asString(), entry->getID().asString()}); } static void cmd_estate_ban(const LLAvatarListEntry* entry) { LLPanelEstateInfo::sendEstateAccessDelta(ESTATE_ACCESS_BANNED_AGENT_ADD | ESTATE_ACCESS_ALLOWED_AGENT_REMOVE | ESTATE_ACCESS_NO_REPLY, entry->getID()); } void LLFloaterAvatarList::doCommand(avlist_command_t func, bool single/*=false*/) const diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 608f1f3e8..d56d7092b 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -9182,18 +9182,22 @@ class ListFreeze : public view_listener_t } }; +static void send_estate_message(const std::string request, const std::vector& strings) +{ + LLRegionInfoModel::sendEstateOwnerMessage(gMessageSystem, request, LLFloaterRegionInfo::getLastInvoice(), strings); +} + void estate_bulk_eject(const uuid_vec_t& ids, bool ban, S32 option) { if (ids.empty() || option == (ban ? 1 : 2)) return; - std::vector strings(2, gAgentID.asString()); // [0] = our agent id - const std::string request(option == 1 ? "teleporthomeuser" : "kickestate"); - for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it) + const bool tphome(option == 1); + const std::string request(tphome ? "teleporthomeuser" : "kickestate"); + const std::string agent(tphome ? gAgentID.asString() : LLStringUtil::null); + for (const LLUUID& id : ids) { - LLUUID id(*it); if (id.isNull()) continue; - strings[1] = id.asString(); // [1] = target agent id - - LLRegionInfoModel::sendEstateOwnerMessage(gMessageSystem, request, LLFloaterRegionInfo::getLastInvoice(), strings); + const string idstr(id.asString()); + send_estate_message(request, tphome ? {agent, idstr} : {idstr}); if (ban) LLPanelEstateInfo::sendEstateAccessDelta(ESTATE_ACCESS_BANNED_AGENT_ADD | ESTATE_ACCESS_ALLOWED_AGENT_REMOVE | ESTATE_ACCESS_NO_REPLY, id); }