[CIRCLE][CODE]complainer

From: Hydragon (doogie@amnesiac.NMSU.Edu)
Date: 12/14/96


I have recently installed the complainer code from the list and did 
a few fix ups to allow it to compile without errors, now the game
crashes after only a few seconds of active connection.

int get_people_room(const int room)
{
  struct char_data *person;
  int i = 0;

  for(person = world[room].people; person; person = person->next_in_room)
    {
      if(person)
        i++;
    }

  return i;
}

struct char_data *select_person_room(const int room)
{
  struct char_data *person;
  int i;

  i = get_people_room(room);

  if(!i)
    return NULL;

  for(person = world[room].people; i; person = person->next_in_room)
   {
     i--;
   }

  return person;
}

SPECIAL(complainer)
{
  struct char_data *vict1, *self;
  ACMD(do_wake);
  ACMD(do_flee);
  ACMD(do_sleep);
  ACMD(do_say);

  self = (struct char_data *) me;

  if(!AWAKE(self))
    {
      if(cmd)
        {
          if(number(0,1))
            {
              do_wake(self,0,0,0);
            }
          return (0);
        }
      else
        {
          if(number(1,5) == 5)
            {
              do_wake(self,0,0,0);
            }
          return (1);
        }
    }

  if(CMD_IS("flee") && CAN_SEE(self, ch))
    {
      act("$n tells you 'You wuss! haha...'", FALSE, self, 0, ch, TO_VICT);
      do_flee(ch,argument,cmd,0);
      switch(number(1,6))
        {
          case 1:
            act("$n says 'I bet $N just peed $S pants.'", FALSE,
                self, 0, ch, TO_ROOM);
          break;
          case 2:
            act("$n says 'I heard $N runs from $S own shadow too.'", FALSE,
                self, 0, ch, TO_ROOM);
          break;
          case 3:
            act("$n says 'I bet $N's afraid of the dark too.'", FALSE,
                self, 0, ch, TO_ROOM);
          break;
          default:
          break;
        }
      return (1);
    }

  if(CMD_IS("sleep") && CAN_SEE(self, ch))
    {
      do_sleep(ch,argument,cmd,0);
      switch(number(1,6))
        {
          case 1:
            do_say(self, "Ok everyone... Shhhhhh", 0, 0);
          break;

          case 2:
            do_say(self, "That's a good idea... I'm going to sleep too.", 0, 0);            do_sleep(self,0,0,0);
          break;

          case 3:
            do_say(self, "Heh. What a sleepyhead.", 0, 0);
          break;

          default:
          break;
        }
    }

  if(cmd)
    return (0);

  if(FIGHTING(self))
    {
      switch(number(1,8))
        {
          case 1:
            do_say(self,"I think I'm losing...",0,0);
          break;
          case 2:
            do_say(self,"The world won't miss a loudmouth like me. Hah.",0,0);
          break;
          case 3:
            if(GET_HIT(self) < (GET_MAX_HIT(self)/3))
              {
                do_say(self,"I'll live...",0,0);
                do_say(self,"My cuts are only flesh wounds.",0,0);
              }
          break;
          default:
          break;
        }
      return (1);
    }

  if(get_people_room(self->in_room) <= 1)
    return (0);

  vict1 = select_person_room(self->in_room);

  if(!AWAKE(vict1)) || (!CAN_SEE(self, vict1)) || (vict1 == self)) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gdb does not like this line, I believe there is a problem with the 
select_person_room but I can't put my finger on it.

Program received signal SIGSEGV, Segmentation fault.
0x808d321 in complainer (ch=0x826acd8, me=0x826acd8, cmd=0,
    argument=0x80b198b "") at spec_procs.c:984
984       if(!AWAKE(vict1)) || (!CAN_SEE(self, vict1)) || (vict1 == self))

Any assistance you can render would be greatly appreciated.

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
    return (0);

  if(FIGHTING(vict1))
    {
      if((number(0,1)) && CAN_SEE(self, vict1))
        {
          vict1 = FIGHTING(vict1);  /* swap the person we're talking about*/
                                    /* makes it more interesting. */
        }

      switch(number(1,8))
        {
          case 1:
            act("$n says '$N started it!'", FALSE, self, 0, vict1,
                 TO_NOTVICT);
            act("$n says 'I KNOW you started it!'", FALSE, self,
                0, vict1, TO_VICT);
          break;
          case 2:
            act("$n says '$N's fighting technique is so lame...'", FALSE,
                self, 0, vict1, TO_NOTVICT);
            act("$n says 'Your fighting technique is so lame...'", FALSE,
                self,0,vict1,TO_VICT);
          break;
          case 3:
            act("$n says 'Hehe. I think $N is going to die.'", FALSE,
                self,0,vict1,TO_NOTVICT);
          break;
          case 4:
            act("$n says 'Hehe. I hope $N loses. $E's such a jerk.'", FALSE,
                self,0,vict1,TO_NOTVICT);
          default:
          break;
        }
      return (1);
    }

  /* just a summary of how we can get to this point :P. (for those who
     might be lost already. */
  /* execution gets here only if the mob assigned with this is not sleeping,
     not fighting, if a person hasn't fled or gone to sleep, or the person
     we've chosen isn't fighting and awake. */

  switch(number(1,14))
    {
      case 1:
        do_say(self,"I talk too much!",0,0);
      break;
      case 2:
        do_say(self,"I think I'm brainless.",0,0);
      break;
      case 3:
        do_say(self,"I think YOU'RE brainless.",0,0);
      break;
      case 4:
        do_say(self,"People are stupid.",0,0);
      break;
      case 5:
        do_say(self,"Who's to blame?",0,0);
      break;
      case 6:
        if(IS_NPC(vict1) && MEMORY(vict1))
          act("$n says 'I think $N is after someone.'",FALSE, self, 0,
              vict1, TO_ROOM);
      break;
      case 7:
        act("$n says '$N sleeps too much.'", FALSE, self, 0,
            vict1, TO_NOTVICT);
      break;
      case 8:
        act("$n says 'Run everyone!!! $N is going to kill you!'", FALSE, self,
                0, vict1, TO_NOTVICT);
      break;
      case 9:
        act("$n says '$N eats the crumbs on the floor of the bakery.'", FALSE,
            self, 0, vict1, TO_NOTVICT);
        act("$n 


   _/  _/  _/  _/  _/_/    _/_/      _/_/     _/_/_/    _/_/   _/_/  _/
   _/  _/  _/  _/  _/ _/   _/ _/    _/  _/  _/_/   _/  _/  _/  _/ _/ _/
   _/_/_/   _/_/   _/  _/  _/_/    _/_//_/  _/         _/  _/  _/ _/ _/
   _/  _/    _/    _/  _/  _/ _/   _/   _/  _/  _/_/   _/  _/  _/  _/_/
   _/  _/    _/    _/__/   _/  _/  _/   _/   _/_/_/     _/_/   _/   _/_

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



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