@paranoid database (#68)

(an instance of Root Class made by Hacker)

     
     This object stores the @paranoid data from :tell. Normally it is not necessary to access these things directly. All verbs are controlled by a caller_perms() check. All data is stored in the old .responsible format.
     
     :add_data(who,data) adds one line's worth of data to the collection, trimming from the front as necessary.
     
     :get_data(who) retrieves the entire batch of data.
     
     :erase_data(who) sets the data to {}
     
     :set_kept_lines(who,number) Changes the number of kept lines. Maximum is 20.
     
     Core verbs that call the above are this are $player:tell, @check, @paranoid, and :erase_paranoid_data.
     
     Internal:
      Properties used are
      tostr(player)+"lines"
      tostr(player)+"pdata"
      :ensure_props_exist(who,linesname,dataname): creates the above
      :GC() --- loops over all data and verifies they're for players.

Go to location of this object, Cluttered Closet.



VERB SOURCE CODE:

ensure_props_exist:
"*Must* be called with PDATA first, and LINES second.";
if ((caller != this) && (!caller_perms().wizard))
    return E_PERM;
else
    if (this.(args[2]) == E_PROPNF)
        add_property(this, args[2], {}, {$hacker, ""});
    endif
    if (this.(args[3]) == E_PROPNF)
        add_property(this, args[3], 0, {$hacker, ""});
    endif
endif
.


init_for_core:
if (!caller_perms().wizard)
    return;
else
    for x in (properties(this))
        delete_property(this, x);
        $command_utils:suspend_if_needed(0);
    endfor
endif
.


add_data:
who = args[1];
if ($perm_utils:controls(caller_perms(), who))
    d = tostr(who, "pdata");
    l = tostr(who, "lines");
    this:ensure_props_exist(who, d, l);
    data = this.(d);
    lines = this.(l);
    "Icky G7 code copied straight out of $player:tell.";
    if (((len = length(this.(d) = {@data, args[2]})) * 2) > (lines * 3))
        this.(d) = this.(d)[(len - lines) + 1..len];
    endif
else
    return E_PERM;
endif
.


get_data:
who = args[1];
if ($perm_utils:controls(caller_perms(), who))
    d = tostr(who, "pdata");
    if (typeof(this.(d)) == LIST)
        return this.(d);
    else
        return {};
    endif
else
    return E_PERM;
endif
.


erase_data:
who = args[1];
if ($perm_utils:controls(caller_perms(), who))
    d = tostr(who, "pdata");
    "OK if this would toss its cookies if no prop, no damage.";
    this.(d) = {};
else
    return E_PERM;
endif
.


set_kept_lines:
maximum = 20;
who = args[1];
if ($perm_utils:controls(caller_perms(), who))
    l = tostr(who, "lines");
    this:ensure_props_exist(who, l, l);
    this.(l) = min(args[2], maximum);
else
    return E_PERM;
endif
.


gc:
threshold = ((60 * 60) * 24) * 3;
for x in (properties(this))
    l = length(x);
    who = toobj(x[1..l - 5]);
    if (((!valid(who)) || (!is_player(who))) || (!who.paranoid))
        delete_property(this, x);
    else
        if (index(x, "lines"))
            if (typeof(this.(x)) != NUM)
                this.(x) = 10;
            endif
        elseif (index(x, "pdata"))
            if ((who.last_disconnect_time < (time() - threshold)) && (who.last_connect_time 
< (time() - threshold)))
                this.(x) = {};
            endif
            if (typeof(this.(x)) != LIST)
                this.(x) = {};
            endif
        endif
    endif
    $command_utils:suspend_if_needed(0);
endfor
.


help_msg:
return this:description();
.



PROPERTY DATA:
      #100pdata
      #100lines
      #95pdata
      #95lines
      #116pdata
      #116lines
      #293pdata
      #293lines
      #445pdata
      #445lines
      #478lines
      #478pdata
      #103lines
      #215lines
      #215pdata
      #103pdata
      #494lines
      #494pdata
      #509lines
      #509pdata
      #299lines
      #299pdata
      #806lines
      #806pdata
      #96lines
      #96pdata
      #352lines
      #352pdata
      #1149lines
      #1149pdata
      #1185lines
      #1185pdata
      #302lines
      #302pdata
      #297lines
      #297pdata
      #1399lines
      #1399pdata
      #907lines
      #1473lines
      #1473pdata
      #907pdata
      #875lines
      #875pdata
      #883lines
      #883pdata
      #538lines
      #538pdata
      #539lines
      #539pdata
      #78lines
      #78pdata
      #2230lines
      #2230pdata
      #1551lines
      #1551pdata
      #381lines
      #2082lines
      #2082pdata
      #2372lines
      #2372pdata
      #558lines
      #558pdata
      #2376lines
      #2376pdata
      #2021lines
      #2021pdata
      #2486lines
      #2486pdata
      #888lines
      #2316lines
      #2316pdata
      #2666lines