Skip to content

Commit

Permalink
connection: Fix command chaining and recursion.
Browse files Browse the repository at this point in the history
Too much was being carried in some cases of recursion, but I'm not sure if
now there'll be too little carried through. Check me in the future.
  • Loading branch information
Rosuav committed Jun 23, 2023
1 parent 2a2406d commit c059a41
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions connection.pike
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class channel(string name) { //name begins with hash and is all lower case
}
if (!msg) return; //If a message doesn't have an Otherwise, it'll end up null.

if (mappingp(msg)) {_send_recursive(person, message | (["conditional": 0]) | msg, vars, cfg); return;}
if (mappingp(msg)) {_send_recursive(person, (["conditional": 0]) | msg, vars, cfg); return;} //CJA 20230623: See other of this datemark.

if (arrayp(msg))
{
Expand All @@ -450,11 +450,17 @@ class channel(string name) { //name begins with hash and is all lower case
msg = msg[val];
vars["$" + varname + "$"] = set_variable(varname, (string)(val + 1), "", cfg->users);
} else {
//CJA 20230623: This previously kept all attributes from the current
//message except for conditional, and merged that with the message.
//Why? I don't understand what I was thinking at the time (see fbd850)
//and it's causing issues with a random that contains groups. If it is
//needed, it may be better to whitelist attributes to retain, rather
//than blacklisting those to remove.
foreach (msg, echoable_message m)
_send_recursive(person, message | (["conditional": 0, "message": m]), vars, cfg);
_send_recursive(person, m, vars, cfg);
return;
}
_send_recursive(person, message | (["conditional": 0, "message": msg]), vars, cfg);
_send_recursive(person, (["conditional": 0, "message": msg]), vars, cfg); //CJA 20230623: See other.
return;
}

Expand All @@ -478,11 +484,14 @@ class channel(string name) { //name begins with hash and is all lower case
//You know what the chain of command is? It's a chain that I get, and then
//I BREAK so that nobody else can ever be in command.
if (cfg->chaindepth) return; //For now, no chaining if already chaining - hard and fast rule.
//Note that cfg is completely independent in the chained-to command; the
//only value retained is the chaindepth itself. Everything else - voice
//selection, destination, etc - is reset to defaults as per the normal
//start of a command.
_send_recursive(person, cmd, vars | (["%s": destcfg]), (["chaindepth": cfg->chaindepth + 1]));
//Note that cfg is largely independent in the chained-to command; the
//only values retained are the chaindepth itself, and the "current user"
//(normally the one who invoked it). Everything else - voice selection,
//destination, etc - is reset to defaults as per the normal start of a
//command. This does mean that a "User Vars" with no keyword will carry,
//where one with a keyword won't. Unsure if this is good or bad.
_send_recursive(person, cmd, vars | (["%s": destcfg]),
(["users": (["": cfg->users[""]]), "chaindepth": cfg->chaindepth + 1]));
return;
}

Expand Down

0 comments on commit c059a41

Please sign in to comment.