Talk:BTLT

From Second Life Wiki
Revision as of 22:06, 4 November 2007 by Cron Stardust (talk | contribs) (Info on bug in the vector conversion functions.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A bug in stiufv/vfuist

I was trying to use BTLT in one of my projects, and I kept noticing that the vectors were not coming beck out correctly, so I built a simple test script to demo what I thought I was observing, and sure enough, the first value in every vector I gave BTLT came back out incorrect. So, after some sniffing around the code, I came up with this fix:

Code: BTLT stiufv/vfuist fix
vector stiufv(string in)
{    //-XXXXYYYYZZZZ
    integer     raw = llBase64ToInteger(llGetSubString("AAA" + in + "AAAAAA", 0, 5)) >> 2;
    integer     offset = 1;
    integer     len = raw & 7;
    return <stiuf(llDeleteSubString(in, -~len, 1)),
        stiuf(llDeleteSubString(in, (len = (7 & (raw >> 3))) - ~(offset += len), offset)),
        stiuf(llDeleteSubString(in, 0, offset + len)) >;
}

string vfuist(vector in)
{
    string      buf = fuist(in.y);
    integer     len = llStringLength(buf);
    return llGetSubString(llIntegerToBase64(((len << 3) | llStringLength(buf)) << 2), 3, 4) + (buf = fuist(in.x)) + buf + fuist(in.z);
}    //-XXXXYYYYZZZZ 

I can't say that I understood all the code, I am still not up to the level of understanding code this optimized... But I compared these vector functions to the (working) rotation functions to come up with this fix, and found that it seems to work! Cron Stardust 21:06, 4 November 2007 (PST)