cinderblocks / libremetaverse

An fork of the libopenmetaverse library striving for performance improvements and up-to-date compatibility with SL/OS/Halcyon
BSD 3-Clause "New" or "Revised" License
60 stars 40 forks source link

Assets.RequestInventoryAsset is broken for reading notecards [SL] #86

Closed Madpeterz closed 3 days ago

Madpeterz commented 1 year ago

libremetaverse Known broken versions:

works on version:

Radegast

example code

    public void NotecardToMem(string notecardUUID)
    {
        if (UUID.TryParse(notecardUUID, out UUID inventoryUUID) == false)
        {
             client.Self.Chat("Unable to read notecard UUID", 0, ChatType.Normal);
        }
        InventoryItem A = client.Inventory.FetchItem(inventoryUUID, client.Self.AgentID, 2000);
        if (A == null)
        {
            client.Self.Chat("Unable to find notecard with UUID", 0, ChatType.Normal);
        }
        if(A.InventoryType != InventoryType.Notecard)
        {
            client.Self.Chat("Unable to find notecard with UUID", 0, ChatType.Normal);
        }
        var transferID = UUID.Random();
        client.Assets.RequestInventoryAsset(
            A,
            true,
            transferID,
            (AssetDownload transfer, Asset asset) =>
            {
                if (transfer.Success && transfer.ID == transferID)
                {
                    AssetNotecard n = (AssetNotecard)asset;
                    n.Decode();
                    AssetNotecard recievedNotecard = n;

                    string text = string.Empty;

                    for (int i = 0; i < n.BodyText.Length; i++)
                    {
                        char c = n.BodyText[i];

                        // Special marker for embedded things.
                        if ((int)c == 0xdbc0)
                        {
                            int index = (int)n.BodyText[++i] - 0xdc00;
                            InventoryItem e = n.EmbeddedItems[index];
                            text += " (embedded) ";
                        }
                        else
                        {
                            text += c;
                        }
                    }
                    client.Self.Chat(text, 0, ChatType.Normal);

                }
                else
                {
                    client.Self.Chat("Transfer failed", 0, ChatType.Normal);
                }
            }
        );
        client.Self.Chat("working on it", 0, ChatType.Normal);
    }

expected output: working on it "Hello world"

current results: Failed to fetch asset : BadRequest Bad Request

notes: if you request a asset that was loaded with the older version and then update to current and redo the request it works as expected.

Madpeterz commented 1 year ago

worked around by: https://github.com/cinderblocks/libremetaverse/pull/87

cinderblocks commented 3 days ago

Should be fixed as of 7df9068e