Skip to content

Commit

Permalink
Agree with firestorm on the old RLV attachment code
Browse files Browse the repository at this point in the history
  • Loading branch information
RyeMutt committed May 12, 2024
1 parent af65db7 commit c1b0b36
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 471 deletions.
160 changes: 55 additions & 105 deletions indra/newview/llaisapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,122 +952,68 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht

if (callback && !callback.empty())
{
// [SL:KB] - Patch: Appearance-SyncAttach | Checked: Catznip-3.7
uuid_list_t ids;
bool needs_callback = true;
LLUUID id(LLUUID::null);

switch (type)
{
case COPYLIBRARYCATEGORY:
case FETCHCATEGORYCATEGORIES:
case FETCHCATEGORYCHILDREN:
case FETCHCATEGORYSUBSET:
case FETCHCATEGORYLINKS:
case FETCHCOF:
if (result.has("category_id"))
{
ids.emplace(result["category_id"]);
}
break;
case FETCHITEM:
if (result.has("linked_id"))
{
ids.emplace(result["linked_id"]);
}
else if (result.has("item_id"))
{
// Error message might contain an item_id!!!
ids.emplace(result["item_id"]);
}
break;
case COPYINVENTORY:
case CREATEINVENTORY:
case COPYLIBRARYCATEGORY:
case FETCHCATEGORYCATEGORIES:
case FETCHCATEGORYCHILDREN:
case FETCHCATEGORYSUBSET:
case FETCHCATEGORYLINKS:
case FETCHCOF:
if (result.has("category_id"))
{
id = result["category_id"];
}
break;
case FETCHITEM:
if (result.has("item_id"))
{
// Error message might contain an item_id!!!
id = result["item_id"];
}
if (result.has("linked_id"))
{
id = result["linked_id"];
}
break;
case CREATEINVENTORY:
// CREATEINVENTORY can have multiple callbacks
if (result.has("_created_categories"))
{
LLSD& cats = result["_created_categories"];
LLSD::array_const_iterator cat_iter;
for (cat_iter = cats.beginArray(); cat_iter != cats.endArray(); ++cat_iter)
{
AISUpdate::parseUUIDArray(result, "_created_categories", ids);
AISUpdate::parseUUIDArray(result, "_created_items", ids);
LLUUID cat_id = *cat_iter;
callback(cat_id);
needs_callback = false;
}
break;
case UPDATECATEGORY:
}
if (result.has("_created_items"))
{
LLSD& items = result["_created_items"];
LLSD::array_const_iterator item_iter;
for (item_iter = items.beginArray(); item_iter != items.endArray(); ++item_iter)
{
AISUpdate::parseUUIDArray(result, "_updated_categories", ids);
LLUUID item_id = *item_iter;
callback(item_id);
needs_callback = false;
}
break;
default:
break;
}

// Call callback at least once regardless of failure.
if (ids.empty())
{
ids.emplace(LLUUID::null);
}
break;
default:
break;
}

for (const auto& id : ids)
if (needs_callback)
{
// Call callback at least once regardless of failure.
// UPDATEITEM doesn't expect an id
callback(id);
}

// [/SL:KB]
//bool needs_callback = true;
//LLUUID id(LLUUID::null);

//switch (type)
//{
//case COPYLIBRARYCATEGORY:
//case FETCHCATEGORYCATEGORIES:
//case FETCHCATEGORYCHILDREN:
//case FETCHCATEGORYSUBSET:
//case FETCHCATEGORYLINKS:
//case FETCHCOF:
// if (result.has("category_id"))
// {
// id = result["category_id"];
// }
// break;
//case FETCHITEM:
// if (result.has("item_id"))
// {
// // Error message might contain an item_id!!!
// id = result["item_id"];
// }
// if (result.has("linked_id"))
// {
// id = result["linked_id"];
// }
// break;
//case CREATEINVENTORY:
// // CREATEINVENTORY can have multiple callbacks
// if (result.has("_created_categories"))
// {
// LLSD& cats = result["_created_categories"];
// LLSD::array_const_iterator cat_iter;
// for (cat_iter = cats.beginArray(); cat_iter != cats.endArray(); ++cat_iter)
// {
// LLUUID cat_id = *cat_iter;
// callback(cat_id);
// needs_callback = false;
// }
// }
// if (result.has("_created_items"))
// {
// LLSD& items = result["_created_items"];
// LLSD::array_const_iterator item_iter;
// for (item_iter = items.beginArray(); item_iter != items.endArray(); ++item_iter)
// {
// LLUUID item_id = *item_iter;
// callback(item_id);
// needs_callback = false;
// }
// }
// break;
//default:
// break;
//}

//if (needs_callback)
//{
// // Call callback at least once regardless of failure.
// // UPDATEITEM doesn't expect an id
// callback(id);
//}
}

}
Expand Down Expand Up @@ -1373,11 +1319,15 @@ void AISUpdate::parseCategory(const LLSD& category_map, S32 depth)
{
LL_WARNS() << "Got stale folder, known: " << curr_cat->getVersion()
<< ", received: " << version << LL_ENDL;
// <FS:Beq> FIRE-33337 workaround for rename issue until proper fix is in place and tested
// Also servers a general handler for version de-sync bugs in the future.
if( version < curr_cat->getVersion() )
{
// AIS version is considered canonical, so we need to refetch
curr_cat->setVersion(LLViewerInventoryCategory::VERSION_UNKNOWN);
curr_cat->fetch();
}
// </FS:Beq>
return;
}

Expand Down
5 changes: 1 addition & 4 deletions indra/newview/llaisapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ class AISUpdate
void parseUpdate(const LLSD& update);
void parseMeta(const LLSD& update);
void parseContent(const LLSD& update);
// [SL:KB] - Patch: Appearance-SyncAttach | Checked: Catznip-3.7
static void parseUUIDArray(const LLSD& content, const std::string_view name, uuid_list_t& ids);
// [/SL:KB]
// void parseUUIDArray(const LLSD& content, const std::string& name, uuid_list_t& ids);
void parseUUIDArray(const LLSD& content, const std::string_view name, uuid_list_t& ids);
void parseLink(const LLSD& link_map, S32 depth);
void parseItem(const LLSD& link_map);
void parseCategory(const LLSD& link_map, S32 depth);
Expand Down
Loading

0 comments on commit c1b0b36

Please sign in to comment.