Skip to content

Commit

Permalink
Merge pull request #1010 from NikkiLacrima/NikkiLacrima-patch-runaway
Browse files Browse the repository at this point in the history
Nikki lacrima patch runaway
  • Loading branch information
SilkieSabra authored Dec 2, 2023
2 parents d560434 + fdbe574 commit bf0f15f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 128 deletions.
124 changes: 45 additions & 79 deletions src/collar/oc_api.lsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ Medea (Medea Destiny)
- Prefix reset now works, and notifications sent when changing prefix.
Yosty7b3
*Oct 2021 - Remove unused StrideOfList() function.
*Feb 2022 - Only reset when needed (part of boot speedup project).
*Feb 2022 - Only reset when needed (part of boot speedup project).
Nikki Lacrima
*Nov 2023 - Only wearer can initiate and confirm runaway, add link message "runaway_confirmed" and
remove the g_iRunawayMode.
- Add "#" prefix wildcard, issue #897
- implemented Yosty7b3's menu streamlining, see pr#963
et al.
Licensed under the GPLv2. See LICENSE for full details.
https://github.com/OpenCollarTeam/OpenCollar
Expand All @@ -45,16 +50,10 @@ integer ACTION_OWNER = 8;
integer ACTION_TRUST = 16;
integer ACTION_BLOCK = 32;

//integer g_iLastGranted;
//key g_kLastGranted;
//string g_sLastGranted;

//integer TIMEOUT_READY = 30497;
integer TIMEOUT_REGISTER = 30498;
integer TIMEOUT_FIRED = 30499;



//integer RLV_CMD = 6000;
integer RLV_REFRESH = 6001;//RLV plugins should reinstate their restrictions upon receiving this message.

Expand Down Expand Up @@ -100,12 +99,7 @@ integer LM_SETTING_DELETE = 2003;//delete token from settings
//integer LM_SETTING_EMPTY = 2004;//sent when a token has no value

Dialog(key kID, string sPrompt, list lChoices, list lUtilityButtons, integer iPage, integer iAuth, string sName) {
key kMenuID = llGenerateKey();
llMessageLinked(LINK_SET, DIALOG, (string)kID + "|" + sPrompt + "|" + (string)iPage + "|" + llDumpList2String(lChoices, "`") + "|" + llDumpList2String(lUtilityButtons, "`") + "|" + (string)iAuth, kMenuID);

integer iIndex = llListFindList(g_lMenuIDs, [kID]);
if (~iIndex) g_lMenuIDs = llListReplaceList(g_lMenuIDs, [kID, kMenuID, sName], iIndex, iIndex + g_iMenuStride - 1);
else g_lMenuIDs += [kID, kMenuID, sName];
llMessageLinked(LINK_SET, DIALOG, (string)kID + "|" + sPrompt + "|" + (string)iPage + "|" + llDumpList2String(lChoices, "`") + "|" + llDumpList2String(lUtilityButtons, "`") + "|" + (string)iAuth, sName+"~"+llGetScriptName() );
}
string SLURL(key kID){
return "secondlife:///app/agent/"+(string)kID+"/about";
Expand Down Expand Up @@ -144,9 +138,6 @@ integer CalcAuth(key kID) {
return CMD_NOACCESS;
}

list g_lMenuIDs;
integer g_iMenuStride;

integer NOTIFY = 1002;
integer NOTIFY_OWNERS=1003;
integer g_iPublic;
Expand Down Expand Up @@ -194,25 +185,28 @@ DoListeners(){

integer g_iRunaway=TRUE;
key g_kDenyRunawayRequester;

RunawayMenu(key kID, integer iAuth){
if(iAuth == CMD_OWNER || kID == g_kWearer){
string sPrompt = "\n[Runaway]\n\nAre you sure you want to runaway from all owners?\n\n* This action will reset your owners list, trusted list, and your blocked avatars list.";
list lButtons = ["Yes", "No"];

if(iAuth == CMD_OWNER || ( (kID == g_kWearer) && g_iRunaway ) ){
string sPrompt;
list lButtons = [];

if (kID == g_kWearer){
sPrompt += "[Runaway]\n\nAre you sure you want to runaway from all owners?\n\n* This action will reset your owners list, trusted list, and your blocked avatars list.";
lButtons += ["Yes", "No"];
}
if(iAuth == CMD_OWNER){
sPrompt+="\n\nAs the owner you have the ability to disable or enable runaway.";
if(g_iRunaway)lButtons+=["Disable"];
if(g_iRunaway)lButtons += ["Disable"];
else lButtons += ["Enable"];
} else if(kID == g_kWearer){
if(g_iRunaway){
sPrompt += "\n\nAs the wearer, you can choose to disable your ability to runaway, this action cannot be reversed by you";
lButtons += ["Disable"];
}
}
else if (kID == g_kWearer) {
sPrompt += "\n\nAs the wearer, you can choose to disable your ability to runaway, this action cannot be reversed by you";
lButtons += ["Disable"];
}
Dialog(kID, sPrompt, lButtons, [], 0, iAuth, "RunawayMenu");
} else {
llMessageLinked(LINK_SET,NOTIFY,"0%NOACCESS% to runaway, or the runaway settings menu", kID);
//llMessageLinked(LINK_SET,iAuth,"menu Access", kID);
}
}

Expand All @@ -225,7 +219,6 @@ WearerConfirmListUpdate(key kID, string sReason)
}
integer g_iAllowWearerSetTrusted=FALSE;
integer g_iGrantedConsent=FALSE;
integer g_iRunawayMode = -1;
UpdateLists(key kID, key kIssuer){
//llOwnerSay(llDumpList2String([kID, kIssuer, g_kMenuUser, g_iMode, g_iGrantedConsent], ", "));
integer iMode = g_iMode;
Expand Down Expand Up @@ -328,8 +321,7 @@ UserCommand(integer iAuth, string sCmd, key kID){
llLoadURL(kID, "Want to open our website for further help?", "https://opencollar.cc");
}
}
if((llToLower(sCmd) == "menu runaway" || llToLower(sCmd) == "runaway") && g_iRunawayMode!=2){
g_iRunawayMode=0;
if((llToLower(sCmd) == "menu runaway") || (llToLower(sCmd) == "runaway")){
RunawayMenu(kID,iAuth);
}

Expand Down Expand Up @@ -388,22 +380,8 @@ UserCommand(integer iAuth, string sCmd, key kID){
}
}
if (iAuth <CMD_OWNER || iAuth>CMD_EVERYONE) return;
if (iAuth == CMD_OWNER && sCmd == "runaway") {
// trigger runaway sequence if approval was given
if(g_iRunawayMode == 2){
g_iRunawayMode=-1;
llMessageLinked(LINK_SET, NOTIFY_OWNERS, "Runaway completed on %WEARERNAME%'s collar", kID);
llMessageLinked(LINK_SET, LM_SETTING_DELETE, "auth_owner","origin");
llMessageLinked(LINK_SET, LM_SETTING_DELETE, "auth_trust","origin");
llMessageLinked(LINK_SET, LM_SETTING_DELETE, "auth_block","origin");
llMessageLinked(LINK_SET, LM_SETTING_DELETE, "auth_group","origin");
llMessageLinked(LINK_SET, NOTIFY, "0Runaway complete", g_kWearer);
return;
}

}

if(sCmd == "print auth"){
if(sCmd == "print auth"){
if(iAuth == CMD_OWNER || iAuth == CMD_TRUSTED || iAuth == CMD_WEARER)
PrintAccess(kID);
else
Expand Down Expand Up @@ -489,7 +467,6 @@ state active
}
}


run_time_permissions(integer iPerm) {
if (iPerm & PERMISSION_ATTACH) {
llOwnerSay("@detach=yes");
Expand All @@ -516,32 +493,29 @@ state active
return;
}
}




string CMD="";
if(llToLower(llGetSubString(m,0,llStringLength(g_sPrefix)-1))==llToLower(g_sPrefix)){
string CMD=llGetSubString(m,llStringLength(g_sPrefix),-1);
if(llGetSubString(CMD,0,0)==" ")CMD=llDumpList2String(llParseString2List(CMD,[" "],[]), " ");
llMessageLinked(LINK_SET, CMD_ZERO, CMD, llGetOwnerKey(i));
} else if(llGetSubString(m,0,0) == "*"){
string CMD = llGetSubString(m,1,-1);
if(llGetSubString(CMD,0,0)==" ")CMD=llDumpList2String(llParseString2List(CMD,[" "],[])," ");
llMessageLinked(LINK_SET, CMD_ZERO, CMD, llGetOwnerKey(i));
CMD = llGetSubString(m,llStringLength(g_sPrefix),-1);
} else if ((llGetSubString(m,0,0) == "*") || (llGetSubString(m,0,0) == "#" && i != g_kWearer) ){
CMD = llGetSubString(m,1,-1);
} else {
list lTmp = llParseString2List(m,[" ","(",")"],[]);
string sDump = llToLower(llDumpList2String(lTmp, ""));

string sDump = llToLower(llDumpList2String(lTmp, ""));
if(sDump == llToLower(g_sSafeword) && !g_iSafewordDisable && i == g_kWearer){
llMessageLinked(LINK_SET, CMD_SAFEWORD, "","");
SW();
}
}
if (CMD != "") {
if(llGetSubString(CMD,0,0)==" ")CMD=llDumpList2String(llParseString2List(CMD,[" "],[])," ");
if (CMD == "runaway_confirmed") return;
llMessageLinked(LINK_SET, CMD_ZERO, CMD, llGetOwnerKey(i));
}
}

link_message(integer iSender, integer iNum, string sStr, key kID){



//if(iNum>=CMD_OWNER && iNum <= CMD_NOACCESS) llOwnerSay(llDumpList2String([iSender, iNum, sStr, kID], " ^ "));
if(iNum == CMD_ZERO){
if(sStr == "initialize")return;
Expand All @@ -553,11 +527,6 @@ state active
//llOwnerSay("{API} Calculate auth for "+(string)kID+"="+(string)iAuth+";"+sStr);
llMessageLinked(LINK_SET, AUTH_REPLY, "AuthReply|"+(string)kID+"|"+(string)iAuth,sStr);
} else if(iNum >= CMD_OWNER && iNum <= CMD_NOACCESS) UserCommand(iNum, sStr, kID);

else if (iNum == DIALOG_TIMEOUT) {
integer iMenuIndex = llListFindList(g_lMenuIDs, [kID]);
g_lMenuIDs = llDeleteSubList(g_lMenuIDs, iMenuIndex - 1, iMenuIndex +3); //remove stride from g_lMenuIDs
}
else if(iNum == LM_SETTING_RESPONSE){
list lPar = llParseString2List(sStr, ["_","="],[]);
string sToken = llList2String(lPar,0);
Expand Down Expand Up @@ -672,10 +641,9 @@ state active
} else if(iNum == STARTUP && sStr=="ALL"){
llMessageLinked(LINK_SET, LM_SETTING_REQUEST, "ALL","");
} else if(iNum == DIALOG_RESPONSE){
integer iMenuIndex = llListFindList(g_lMenuIDs, [kID]);
if(iMenuIndex!=-1){
string sMenu = llList2String(g_lMenuIDs, iMenuIndex+1);
g_lMenuIDs = llDeleteSubList(g_lMenuIDs, iMenuIndex-1, iMenuIndex-2+g_iMenuStride);
integer iPos = llSubStringIndex(kID, "~"+llGetScriptName());
if(iPos>0){
string sMenu = llGetSubString(kID, 0, iPos-1);
list lMenuParams = llParseString2List(sStr, ["|"],[]);
key kAv = llList2Key(lMenuParams,0);
string sMsg = llList2String(lMenuParams,1);
Expand Down Expand Up @@ -735,24 +703,22 @@ state active
} else if(sMsg == "Disable"){
g_kDenyRunawayRequester=kAv;
Dialog(g_kWearer, "\nsecondlife:///app/agent/"+(string)kAv+"/about wants to disable your ability to 'Runaway'. This can only be reversed by an owner. \n\nYou may accept or deny this action.", [], ["Accept", "Deny"], 0, CMD_WEARER, "confirmdenyrunaway");
// g_iRunaway=FALSE;
// llMessageLinked(LINK_SET, LM_SETTING_SAVE, "AUTH_runaway=0", "origin");
// llMessageLinked(LINK_SET, TIMEOUT_REGISTER, "5", "spring_access:"+(string)kAv);
} else if(sMsg == "No"){
// return
g_iRunawayMode=-1;
llMessageLinked(LINK_SET, TIMEOUT_REGISTER, "2", "spring_access:"+(string)kAv);
return;
} else if(sMsg == "Yes"){
// trigger runaway
if((kAv == g_kWearer || iAuth == CMD_OWNER ) && g_iRunaway){
g_iRunawayMode=2;
// trigger runaway sequence if approval was given
llMessageLinked(LINK_SET, NOTIFY_OWNERS, "%WEARERNAME% has runaway.", "");
llMessageLinked(LINK_SET, CMD_OWNER, "runaway", g_kWearer);
llMessageLinked(LINK_SET, CMD_OWNER, "runaway_confirmed", g_kWearer);
llMessageLinked(LINK_SET, CMD_SAFEWORD, "safeword", "");
llMessageLinked(LINK_SET, CMD_OWNER, "clear", g_kWearer);

llSleep(0.5); // Wait for notifications before clearing owners
llMessageLinked(LINK_SET, TIMEOUT_REGISTER, "5", "spring_access:"+(string)kAv);
llMessageLinked(LINK_SET, LM_SETTING_DELETE, "auth_owner","origin");
llMessageLinked(LINK_SET, LM_SETTING_DELETE, "auth_trust","origin");
llMessageLinked(LINK_SET, LM_SETTING_DELETE, "auth_block","origin");
llMessageLinked(LINK_SET, LM_SETTING_DELETE, "auth_group","origin");
llMessageLinked(LINK_SET, NOTIFY, "0Runaway complete", g_kWearer);
}
}
} else if(sMenu=="confirmdenyrunaway") {
Expand Down
53 changes: 23 additions & 30 deletions src/collar/oc_leash.lsl
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
// This file is part of OpenCollar.
// Copyright (c) 2008 - 2016 Nandana Singh, Lulu Pink, Garvin Twine,
// Joy Stipe, Cleo Collins, Satomi Ahn, Master Starship, Toy Wylie,
// Kaori Gray, Sei Lisa, Wendy Starfall, littlemousy, Romka Swallowtail,
// Sumi Perl, Karo Weirsider, Kurt Burleigh, Marissa Mistwallow et al.
// Licensed under the GPLv2. See LICENSE for full details.
string g_sScriptVersion = "8.1";
/*
This file is part of OpenCollar.
Copyright (c) 2008 - 2016 Nandana Singh, Lulu Pink, Garvin Twine,
Joy Stipe, Cleo Collins, Satomi Ahn, Master Starship, Toy Wylie,
Kaori Gray, Sei Lisa, Wendy Starfall, littlemousy, Romka Swallowtail,
Sumi Perl, Karo Weirsider, Kurt Burleigh, Marissa Mistwallow et al.
Nikki Larima
Nov 2023 - Remove processing of "runaway" command string, handled by CMD_SATEWORD
implemented Yosty7b3's menu streamlining, see pr#963
Licensed under the GPLv2. See LICENSE for full details.
https://github.com/OpenCollarTeam/OpenCollar
*/

string g_sScriptVersion = "8.3";
integer LINK_CMD_DEBUG=1999;

// ------ TOKEN DEFINITIONS ------
Expand Down Expand Up @@ -41,7 +50,7 @@ integer LM_SETTING_SAVE = 2000;
integer LM_SETTING_REQUEST = 2001;
integer LM_SETTING_RESPONSE = 2002;
integer LM_SETTING_DELETE = 2003;
integer LM_SETTING_EMPTY = 2004;
integer LM_SETTING_EMPTY = 2004;

// -- MENU/DIALOG
integer MENUNAME_REQUEST = 3000;
Expand All @@ -58,7 +67,7 @@ integer LEASH_END_MOVEMENT = 6201;

integer DIALOG = -9000;
integer DIALOG_RESPONSE = -9001;
integer DIALOG_TIMEOUT = -9002;
//integer DIALOG_TIMEOUT = -9002;
integer SENSORDIALOG = -9003;

integer CMD_PARTICLE = 20000;
Expand All @@ -72,8 +81,6 @@ string BUTTON_SUBMENU = "Leash";
// ---------------------------------------------
// ------ VARIABLE DEFINITIONS ------
// ----- menu -----
list g_lMenuIDs;
integer g_iMenuStride = 3;
integer g_iPreviousAuth;
key g_kLeashCmderID;

Expand Down Expand Up @@ -138,20 +145,12 @@ string NameURI(key kID){
}

Dialog(key kRCPT, string sPrompt, list lButtons, list lUtilityButtons, integer iPage, integer iAuth, string sMenuID) {
key kMenuID = llGenerateKey();
llMessageLinked(LINK_SET, DIALOG, (string)kRCPT + "|" + sPrompt + "|" + (string)iPage + "|" + llDumpList2String(lButtons, "`") + "|" + llDumpList2String(lUtilityButtons, "`") + "|" + (string)iAuth, kMenuID);
integer iIndex = llListFindList(g_lMenuIDs, [kRCPT]);
if (~iIndex) g_lMenuIDs = llListReplaceList(g_lMenuIDs, [kRCPT, kMenuID, sMenuID], iIndex, iIndex + g_iMenuStride - 1);
else g_lMenuIDs += [kRCPT, kMenuID, sMenuID];
llMessageLinked(LINK_SET, DIALOG, (string)kRCPT + "|" + sPrompt + "|" + (string)iPage + "|" + llDumpList2String(lButtons, "`") + "|" + llDumpList2String(lUtilityButtons, "`") + "|" + (string)iAuth, sMenuID+"~"+llGetScriptName());
}

SensorDialog(key kRCPT, string sPrompt, string sSearchName, integer iAuth, string sMenuID, integer iSensorType) {
key kMenuID = llGenerateKey();
if (sSearchName != "") sSearchName = "`"+sSearchName+"`1";
llMessageLinked(LINK_SET, SENSORDIALOG, (string)kRCPT +"|"+sPrompt+"|0|``"+(string)iSensorType+"`10`"+(string)PI+sSearchName+"|"+BUTTON_UPMENU+"|" + (string)iAuth, kMenuID);
integer iIndex = llListFindList(g_lMenuIDs, [kRCPT]);
if (~iIndex) g_lMenuIDs = llListReplaceList(g_lMenuIDs, [kRCPT, kMenuID, sMenuID], iIndex, iIndex + g_iMenuStride - 1);
else g_lMenuIDs += [kRCPT, kMenuID, sMenuID];
llMessageLinked(LINK_SET, SENSORDIALOG, (string)kRCPT +"|"+sPrompt+"|0|``"+(string)iSensorType+"`10`"+(string)PI+sSearchName+"|"+BUTTON_UPMENU+"|" + (string)iAuth, sMenuID+"~"+llGetScriptName());
}

ConfirmDialog(key kAv, key kCmdGiver, string sType, integer iAuth) {
Expand Down Expand Up @@ -488,8 +487,6 @@ UserCommand(integer iAuth, string sMessage, key kMessageID, integer bFromMenu) {
//LeashTo((key)sVal, kMessageID, iAuth, [], TRUE,0);
} else
SensorDialog(g_kCmdGiver, "\nWho shall be followed?\n", sVal,iAuth,"FollowTarget", AGENT);
} else if (sMessage == "runaway" && iAuth == CMD_OWNER) {
Unleash(kMessageID);
} else if (sMessage == "unleash" || sMessage == "unfollow" || (sMessage == "toggleleash" && NULL_KEY != g_kLeashedTo)) {
if (CheckCommandAuth(kMessageID, iAuth)) Unleash(kMessageID);
if (bFromMenu) UserCommand(iAuth, "leashmenu", kMessageID ,bFromMenu);
Expand Down Expand Up @@ -814,15 +811,14 @@ state active
g_iRLVOn = FALSE;
ApplyRestrictions();
} else if (iNum == DIALOG_RESPONSE) {
integer iMenuIndex = llListFindList(g_lMenuIDs, [kMessageID]);
if (~iMenuIndex) {
integer iPos = llSubStringIndex(kMessageID, "~"+llGetScriptName());
if (iPos>0) {
list lMenuParams = llParseString2List(sMessage, ["|"], []);
key kAV = (key)llList2String(lMenuParams, 0);
string sButton = llList2String(lMenuParams, 1);
//integer iPage = (integer)llList2String(lMenuParams, 2);
integer iAuth = (integer)llList2String(lMenuParams, 3);
string sMenu=llList2String(g_lMenuIDs, iMenuIndex + 1);
g_lMenuIDs = llDeleteSubList(g_lMenuIDs, iMenuIndex - 1, iMenuIndex - 2 + g_iMenuStride);
string sMenu = llGetSubString(kMessageID, 0, iPos-1);
if (sMenu == "MainDialog"){
if (sButton == BUTTON_UPMENU)
llMessageLinked(LINK_SET, iAuth, "menu "+BUTTON_PARENTMENU, kAV);
Expand Down Expand Up @@ -870,9 +866,6 @@ state active
g_kLeashCmderID = "";
}
}
} else if (iNum == DIALOG_TIMEOUT) {
integer iMenuIndex = llListFindList(g_lMenuIDs, [kMessageID]);
g_lMenuIDs = llDeleteSubList(g_lMenuIDs, iMenuIndex - 1, iMenuIndex - 2 + g_iMenuStride);
} else if (iNum == REBOOT && sMessage == "reboot") llResetScript();
else if(iNum == AUTH_REPLY){
list lParams = llParseString2List(sMessage, ["|"],[]);
Expand Down
Loading

0 comments on commit bf0f15f

Please sign in to comment.