From c13b14df0770e6a6e6b6eb9290774c4c7dff60ec Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sat, 18 Aug 2018 16:17:21 +0200 Subject: [PATCH] Optimizations to rez_prop() Compensate for the code added in the previous commit, by removing a bunch of locals and forcing long common substrings to appear once. --- AVsitter2/Plugins/AVprop/[AV]prop.lsl | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/AVsitter2/Plugins/AVprop/[AV]prop.lsl b/AVsitter2/Plugins/AVprop/[AV]prop.lsl index 6610089..f8536f4 100644 --- a/AVsitter2/Plugins/AVprop/[AV]prop.lsl +++ b/AVsitter2/Plugins/AVprop/[AV]prop.lsl @@ -120,18 +120,6 @@ rez_prop(integer index) { vector pos = llList2Vector(prop_positions, index) * llGetRot() + llGetPos(); rotation rot = llEuler2Rot(llList2Vector(prop_rotations, index) * DEG_TO_RAD) * llGetRot(); - integer pt = get_point(llList2String(prop_points, index)); - string point = (string)pt; - if (llStringLength(point) == 1) - { - point = "0" + point; - } - string prop_id = (string)index; - if (llStringLength(prop_id) == 1) - { - prop_id = "0" + prop_id; - } - integer int = (integer)((string)comm_channel + prop_id + point + (string)type); if (llGetInventoryType(object) != INVENTORY_OBJECT) { llSay(0, "Could not find prop '" + object + "'."); @@ -150,7 +138,7 @@ rez_prop(integer index) { if (!(perms & PERM_COPY)) { - llSay(0, "Can't rez '" + object + "'. Props and their content must be COPY-OK" + next); + llSay(0, "Can't rez '" + object + ("'. P"+("rops and their content must be COPY-"+("OK" + next)))); return; } } @@ -158,11 +146,25 @@ rez_prop(integer index) { if ((!(perms & PERM_COPY)) || (!(perms & PERM_TRANSFER))) { - llSay(0, "Can't rez '" + object + "'. Attachment props and their content must be COPY-TRANSFER" + next); + llSay(0, "Can't rez '" + object + ("'. Attachment p"+("rops and their content must be COPY-"+("TRANSFER" + next)))); return; } } - llRezAtRoot(object, pos, ZERO_VECTOR, rot, int); + // Param must be: + // - Negative + // - 4 digits comm_channel + // - 2 digits prop_id (index) + // - 2 digits attachment point + // - 1 digit prop_type + // HACK: reuse 'perms' rather than calling the function in the + // expression, to reduce stack usage + perms = get_point(llList2String(prop_points, index)); + llRezAtRoot(object, pos, ZERO_VECTOR, rot, + comm_channel * 100000 // negative, so we subtract everything else instead of adding + - (index * 1000 + + perms * 10 + + type) + ); } }