Re: Hcontrol problem - UNDEF players in houses

From: Carlo Mocci (mocci@TIN.IT)
Date: 04/22/98


At 22.16 21/04/98 -0400, you wrote:
>> I'd love to see this code, as all I've managed to do is NOTHING!  I
>> can't get rid
>> of those damn UNDEF's.

This is how I solved the problem: I've made a function that erases UNDEFs
from houses, after verifying that many of my problems were caused by not
checking for MAX_GUESTS in do_house (adding players over the maximum number).

As for undefs, this is my function House_undef_clean:

int House_undef_clean()
{
  int i,j,k,toret=0;

  for (i=0; i < num_of_houses; i++)
    {
    j=0;
    while (j < MIN(house_control[i].num_of_guests, MAX_GUESTS))
      {
      if (!get_name_by_id(house_control[i].guests[j]))
        {
        for (k=j; k < MIN(house_control[i].num_of_guests, MAX_GUESTS)-1; k++)
          house_control[i].guests[k] = house_control[i].guests[k+1];
        house_control[i].num_of_guests--;
        sprintf(buf, "SYSLOG: Rimozione UNDEF in casa di %s[id=%ld]",
                get_name_by_id(house_control[i].owner),
house_control[i].owner);
        mudlog(buf, BRF, LVL_IMPL, TRUE);
        toret++;
        }
      else j++;
      }
    }
  House_save_control();
  return toret;
}

I call it when booting houses (in house.c - House_boot, in the place of
House_save_control()) and I've also added a command to hcontrol (hcontrol
clean) that calls this function:

void hcontrol_clean_house(struct char_data * ch)
{
  int i;

  if ((i=House_undef_clean()))
    {
    sprintf(buf, "Cleaned %d <UNDEF> from houses.\r\n", i);
    send_to_char(buf, ch);
    }
  else send_to_char("Nothing to clean.\r\n", ch);
}


I hope this helps... Further comments are desired....

Carlo Mocci
aka KABIR
coder of DalilaMUD
dalila.shopitaly.net
---------------------------------------------------------------
|        __         __            __  __         __       __  |
|   __  (  )  ___  (  )    __    (  \/  )  __   / _)  __ (  ) |
|  / _) /__\ (  ,)  )(__  /  \    )    (  /  \ ( (_  / _) )(  |
| ( (_ (_)(_) )  \ (____)( () )  (_/\/\_)( () ) \__)( (_ (__) |
|  \__)      (_)\_)       \__/            \__/       \__)     |
|                                                             |
| mailto: mocci@tin.it                                        |
| http://volftp.tin.it/IT/IT/ITALIANI/MOCCI                   |
| http://www.geocities.com/SunsetStrip/Palms/7010             |
---------------------------------------------------------------


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST