Re: Consent Command

From: David Cole (tiznor@softhome.net)
Date: 04/10/02


Well now thats a huge improvment there, many thanks, but know we have a new
problem. Now for some reason it working in odd ways, as follows.

Tiznor consents Fibblibip, then fibblebip has tiznors consent.
Pilo consents Fibblibip, then fibblebip has Pilo's consent.

Now however keeping in mind that tiznor never consented pilo, tiznor is now
in pilo's list of consented froms. This is odd, also when the person who has
both players consent nolonger has both players consent they still apear in
the consented from list. So after they stop consenting and then they
reconsent, you get double consented froms:

Consent Information
-=-=-=-=-=-=-=-=-=-
You are currently consenting: Tiznor

The following people have given you their consent:
Pilo
Fibblebip
Pilo
Fibblebip

Perhpase I cut and pasted wrong? I did not change that much, i will include
the structures as well.

in structs.h in char_data below the *master stuff for following and groups.

   struct consent_type *consented;       /* List of chars consenting      */
   struct char_data *consenter;          /* Who is char consenting?       */

right above char_data:

/* Structure used for chars consenting other chars */
struct consent_type {
   struct char_data *consented;
   struct consent_type *next;
};

consent.c;

void PrintConsent(struct char_data *ch)
{
  struct char_data *k;
  struct consent_type *f;

  send_to_char("Consent Information\r\n", ch);
  send_to_char("-=-=-=-=-=-=-=-=-=-\r\n", ch);

  k = (ch->consenter ? ch->consenter : ch);

  sprintf(buf, "You are currently consenting: $N");
  act(buf, FALSE, ch, 0, k, TO_CHAR);

  send_to_char("\r\nThe following people have given you their consent:\r\n",
ch);
  for (f = k->consented; f; f = f->next) {
    sprintf(buf, "$N");
    act(buf, FALSE, ch, 0, f->consented, TO_CHAR);
  }
}


/* we put remove the consent external 'cause we'll use it twice */
/* this function clear the consent on a character */
void ClearConsent(struct char_data *ch)
{
  struct char_data * victim ;
  struct consent_type *f, *temp;

  victim = ch->consenter;

  if (!victim)
 return;

  for (f = victim->consented; f; f = f->next) {
    if (f->consented == ch ) {
      /* this is the character that want to remove the consent */
      sprintf(buf2, "%s stops consenting you.\r\n", GET_NAME(ch));
      send_to_char (buf2,victim) ;
      act("You stop consenting: $N.", FALSE, ch, 0, victim, TO_CHAR);
      REMOVE_FROM_LIST(f, ch->consented,next);
      break ;
 }
  }
  ch->consenter = NULL;
}


ACMD(do_consent)
{
  struct char_data *vict;
  struct consent_type *f;

  one_argument(argument, buf);

  if (!*buf)
 PrintConsent(ch);
  else if (!(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
     send_to_char(NOPERSON, ch);
  else if (IS_NPC(vict))
  send_to_char(NOPERSON, ch);
  else if (ch->consenter == vict)
  act("You have already given your consent to $M.", FALSE, ch, 0, vict,
TO_CHAR);
  else if (vict == ch) {
    /* we clear the consent on the character */
    ClearConsent(ch);
    send_to_char ("You give your consent too yourself.\n\r",ch);
  } else {
    /* now we take care of the case you want to change the consent victim */
    /* first we clear any existing consenter */
    ClearConsent(ch);
    /* second we put the consenter on the character */
    ch->consenter = vict;
    /* third we add the character to the consented list of the victim */
    /* i add the victim to the list */
    CREATE(f, struct consent_type, 1);
    f->next = vict->consented;
    f->consented = ch;
    vict->consented = f;
    act("You give your consent too: $N.", FALSE, ch, 0, vict, TO_CHAR);
    act("$n has given you $s consent.", FALSE, ch, 0, vict, TO_VICT);
  }
}

Also when tiznor consents someone else, he apears in his own consented from
list, and it sticks the same as above, if he stops consenting fibblebip then
then he still apears in his own list and then he duplicates etc etc..

Thanks,
Dave

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT