MOO-cows Mailing List Archive


Re: byte quotas

>Is there some handy guide written up someplace on how to switch over to 
>byte quotas?

Here is my documentation, for what it's worth.  It's definitely old (August
1994) and it's probably outdated, but you can use it as a guide.  (Someone
who's done it more recently, please let me know if this is useless crap, 'k?)

Seth / Blackbriar

These are the docs I wrote eons ago (ported here directly from MediaMOO).
Some things I've found since then -- for example, the names of the
properties on #0 have changed, and $no_one's quota has to be set
explicitly to 0... but basically I think this is kosher.

>From LambdaMOO, there are two objects to be ported:
  $quota_utils -- byte-based quota utilities
  $alt_quota_utils -- object-based quota utilities
You'll also want to make a character named Quota and give Quota ownership
of those objects (this is optional; you can use Hacker, or whoever).
Also, change the ownership of $player.ownership_quota (and its kids) to
Quota, and add a property on $player called size_quota, with initial
value {0,0,0,0}.  Perms "" (or, at worst, "r").  Quota must be a
programmer, but need not (and should not) be a wizard.

You also want a property on $root_class called .object_size, which is
owned by Quota and has perms "r".  Default value here should be {0,0}.

When you port these, the first things you will want to do is change the
names so they don't call themselves LambdaMOO Utilities and such.  Call
them object-based quota utilities and byte-based quota utilities, so you
don't get confused later.

Also, and this is important, -switch- the pointers on #0.  In other
words, make $quota_utils point to the object-based utilities and
$alt_quota_utils to the byte-based utilities (the opposite of LambdaMOO).

Verbs you want to be sure to modify [this list is taken from yduJ's
documentation on porting the byte-based utilities] follow.  It might be
good to look at the LambdaMOO versions of these verbs; in many cases, the
changes are very small.
    check $quota_utils:verb_addition_permitted
    check $quota_utils:property_addition_permitted
    LambdaMOO has a modified version which moves verbs while copying;
    this allows for verbs to be copied when a user is out of quota

    use $quota_utils to display current quota, instead of having that
    information grabbed directly from the property
    use $quota_utils:set_quota instead of raw munging on the property
    in addition, LambdaMOO has a 'public' option; this is probably

    use $quota_utils:adjust_quota_for_programmer to give additional
    quota upon @programmer'ing
    use $quota_utils to handle quota transfer when an object's ownership
    use $quota_utils:initialize_quota to set the player's default

    use $quota_utils:display_quota
    use $quota_utils:bi_create instead of the create() call

    this is a verb you will likely want to install

    these need to use $quota_utils as well

    similar to $wiz_utils:make_player

The next thing you want to do is switch all remaining references to
ownership_quota.  Do this:
  @grep ownership_quota
This will give you all the references to ownership_quota.  You will want
to modify those references (here, you need to be a bit clever) so that
they use verbs on $quota_utils.  Specifically, bear in mind
$quota_utils:creation_permitted and $quota_utils:quota_remaining.
Everywhere you use a raw create(), you want to use $quota_utils:bi_create
[standing for builtin-create(), nothing sexual or political].

Now that these changes are made, and object-based quota is installed, let
it sit a while.  Try building, creating, recycling, mucking with your
quota, everything.  Look for places you didn't make changes.  Peek
through code all over the place.  Once you're comfortable that everything
relevant is going through $quota_utils, you're ready for the next step.

That next step is deciding on a translation factor.  Sample code from
OpalMOO was this:
  "Set up the byte-based stuff.  Give every player 20000 bytes for eir
own character, plus 5000 bytes per original quota point.";
  for x in (players())
    x.size_quota = {20000 + 5000 * x.ownership_quota, 0, 0, 0};
  x = 0;
  while (x <= tonum(max_object()))
    o = toobj(x);
    if (valid(o))
      o.owner.size_quota = o.owner.size_quota;
      o.owner.size_quota[1] = o.owner.size_quota[1] + 2000;
      $quota_utils:recent_object_bytes(o, 1);
      $alt_quota_utils:charge_quota(o.owner, o);
    $command_utils:suspend_if_needed(0, tostr("...#", x));
    x = x + 1;
    overs = {};
    for x in (players())
      if (x.size_quota[2] > x.size_quota[1])
        overs = setadd(overs, x);
      $command_utils:suspend_if_needed(0, tostr("...", x));
    player:tell($string_utils:english_number(length(overs)), " players
are over.");
That code is kinda stingy.  You might want to be more generous.

Once everyone is initialized to what you feel to be comfortable, and you
want to switch to byte-based quota, set everyone's .ownership_quota to
  ;for x in (players()) x.ownership_quota=-10000; endfor;
and swap the quota utilities:
and watch it go.

Note: The byte-based implementation does allow anyone to see anyone
else's quota.  You may want to fix this, in :display_quota.

Note: In the byte-based implementation, characters with "second"
characters will have quota pooled, if there exists
$local.second_character_registry such as on LambdaMOO.

After switching to byte-based quota, you'll want to start up
$quota_utils:measurement_task(), which will slowly plod through the DB,
measuring objects and fixing people's quota.  You'll want to play with
the time used for the suspend() calls in there, 'cause it's designed for
a HUGE DB like LambdaMOO's.
Seth I. Rich -
                                 There is nothing more precious than
Rabbits on walls, no problem.    a tear of true repentance.

Home | Subject Index | Thread Index