# changing the value of player

"Kenneth R. Fox" (fox@ccs.neu.edu)
Thu, 2 May 1996 23:40:48 PDT

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    >Is there some mechanism through which wizards can change the value of
    >'player' for the duration of the verb and all verbs it calls, as well as
    >all verbs they call?  I had been able to do that before, by simply
    >calling player=#xxx, but it seems to be acting very unreliably:

    player = #xxx;

    Setting player with player = #xxx is only reliable when the permissions
    of the currently executing verb are wizardly when a new stack frame
    is created.  The new setting for player only affects stack frames
    below the current verb on the stack.  This means verbs that
    set player and task perms (to a nonwizard) and verbs that set player
    and return to a caller expecting the new player value to persist won't work.

    I suspect you will find that this code:
    37:    elseif (verb_args(this, parts[1]) == {"any", "none", "any"})
    38:      user = this:authorization(args[2]);
    39:      argstr = argstr;
    40:      dobj = dobj;
    41:      dobjstr = dobjstr;
    42:      iobj = iobj;
    43:      iobjstr = iobjstr;
    44:      prepstr = prepstr;
    45:      player = user;
    46:      #735.debugging && #735:notify(tostr("$http:get about to call
    $http:",
    parts[1], " : player=", player, " (", player.name, ")..."));
    47:      set_task_perms(player);
    48:      return this:(parts[1])(@parts[2] ? parts[2..length(parts)] | {});
    only happens to work if and only if `user' is a wizard.

    You need to define a new verb (e.g. call_with_player) with a
    definition similar to:
     (modulo 1.8.0-specific things if you aren't running that)

    $http:call_with_perms tnt
    {perms, verb, @args} = args; if(caller !=
    this)
    	raise(E_PERM);
    endif
    set_task_perms(perms);
    return this:(verb)(@args);

    and then modify the verb that wants to set player and set perms accordingly.

    This will set player and call the verb with both player and the permissions
    set correctly.

    --Ken