@prog MUF:stats.mudlink
1 9999 d
1 i
var garbage  var room  var thing  var player  var exits  var pp  var user
var total  var counter

: init_vars
  0 garbage !
  0 room !
  0 thing !
  0 player !
  0 exits !
  0 pp !
  db_top 1 - dup total ! counter !
;

: dump_stats
  me @ "@pemit " user @ strcat "=Database stats" strcat notify
  me @ "@pemit " user @ strcat "=Total objects: " strcat total @ intostr
        strcat notify
  me @ "@pemit " user @ strcat "=Players:       " strcat player @ intostr
        strcat notify
  me @ "@pemit " user @ strcat "=Rooms:         " strcat room @ intostr
        strcat notify
  me @ "@pemit " user @ strcat "=Things:        " strcat thing @ intostr
        strcat notify
  me @ "@pemit " user @ strcat "=Exits:         " strcat exits @ intostr
        strcat notify
  me @ "@pemit " user @ strcat "=Programs:      " strcat pp @ intostr
        strcat notify
  me @ "@pemit " user @ strcat "=Garbage:       " strcat garbage @ intostr
        strcat notify
;

: loop_counters
  0 db_top 1 for
   dbref dup ok? not 
                   if garbage ++ pop else 
      dup player?  if player  ++ pop else
      dup exit?    if exits   ++ pop else
      dup program? if pp      ++ pop else
      dup room?    if room    ++ pop else 
      thing?       if thing   ++ then
      then then then then then
  loop
;

: main
 user !
 0 sleep
 init_vars 
 loop_counters
 dump_stats
;
.
c
q
