dmuck0.15-beta/docs/muf/
dmuck0.15-beta/game/
dmuck0.15-beta/game/logs/
dmuck0.15-beta/game/muf/
dmuck0.15-beta/game/muf/text/
#include "copyright.h"
#include "config.h"

#include "db.h"
#include "externs.h"

/* remove the first occurence of what in list headed by first */
dbref remove_first(dbref first, dbref what)
{
  dbref prev;
  
  /* special case if it's the first one */
  if(first == what)
    return DBFETCH(first)->next;
  else
  {
    /* have to find it */
    DOLIST(prev, first)
    {
      if(DBFETCH(prev)->next == what)
      {
        DBSTORE(prev, next, DBFETCH(what)->next);
        return first;
      }
    }
    return first;
  }
}

int member(dbref thing, dbref list)
{
  DOLIST(list, list)
  {
    if(list == thing) return 1;
  }
  
  return 0;
}

dbref reverse(dbref list)
{
  dbref newlist;
  dbref rest;
  
  newlist = NOTHING;
  while(list != NOTHING)
  {
    rest = DBFETCH(list)->next;
    PUSH(list, newlist);
    DBDIRTY(newlist);
    list = rest;
  }
  return newlist;
}