[GEDIT] Inherent Error? [LONG]

From: StormeRider (silk@ICI.NET)
Date: 11/25/97


Ok, can anyone see any inherent errors in this code? The two characters are
both in the same guild (an immortal guild), both GET_GUILD(ch)'s = 1. I've
checked the pfiles as well.

As soon as I do a guildlist on one of them it says the guild is invalid
(*something is screwed up with a guild pointer*). It didn't do this before
I started using the is_in_guild proc, so I am wondering if this might
somehow coruppt the guild pointers. (*which as you can tell would not be a
good thing...*) If I have the second one whose guild is invalid try to join
(*immortal command that searches through the guilds and just sets the
GET_GUILD (ch), no changes made to it at all*), it crashes the mud.

Interesting enough, when I put in the logging and tried a guildlist, the
log shows:

Tue Nov 25 07:11:05 :: Char Pajro: GUILD [1], ginfo.number [1]
Tue Nov 25 07:11:05 :: Char StormRider: GUILD [1], ginfo.number [1918986307]

Anyways:
int is_in_guild(struct char_data *ch, struct guild_type *ginfo)
{
  char *buf;

  if (ginfo == NULL) {
        log("Invalid guild call!!");
        return 0;
  }

  sprintf(buf, "Char %s: GUILD [%d], ginfo.number [%d]", GET_NAME(ch),
GET_GUILD(ch), ginfo->number);
  log(buf);

  switch (ginfo->gtype) {
    case 1:
      if (GET_GUILD(ch) == ginfo->number)
        return 1;  /* yes */
      else
        return 0;    /* no */
    case 2:
      if (GET_SGUILD(ch) == ginfo->number)
        return 1;  /* yes */
      else
        return 0;    /* no */
    case 3:
      if (GET_SHGUILD(ch) == ginfo->number)
        return 1;  /* yes */
      else
        return 0;    /* no */
    default:
      break;
   }
   return 0;
}

and here's the guildlist funct (yes it still has to be cleaned up, not as
much worried about that part yet):
ACMD(do_guild_list)
{
   struct descriptor_data  *i;
   struct guild_type *gptr = NULL;

   if (IS_NPC(ch))
        return;

   if (GET_GUILD(ch) == GUILD_NONE || GET_GUILD(ch) == GUILD_UNDEFINED) {
        send_to_char("You must be a member of a guild to do this.\n\r", ch);
        return;
   }

   for (gptr = g_info; gptr && gptr->number != GET_GUILD(ch); gptr =
gptr->next)
        /* The for loop should do all the work */;

   if (gptr == NULL) {
        send_to_char("It seems as though your guild is invalid!\r\n", ch);
        return;
   }

  send_to_char(CCNRM(ch, C_NRM), ch);
  send_to_char("___________________________________________",ch);
  send_to_char("\r\n\r\n",ch);
  sprintf(buf, "Other members of %s", gptr->name);
  sprintf(buf,
"%s...\r\n___________________________________________%s\r\n\r\n",
          buf, CCNRM(ch, C_NRM));
  send_to_char(buf, ch);
  /* Go through the entire list of players color coding those who are on*/
  for (i = descriptor_list; i; i = i->next) {
    if (is_in_guild(i->character, gptr)) {
      if ((!PLR_FLAGGED(i->character, PLR_GINVIS)) &&
(GET_INVIS_LEV(i->character) <= GET_LEVEL(ch))){
        if (GET_LEVEL(i->character) >= LVL_IMMORT) {
          sprintf(buf, "(%d)[%s]%s %s\r\n",
GET_GUILD_LEV(i->character),GET_GTITLE(i->character),
                   IMM_NAME(i->character), GET_TITLE(i->character));
          send_to_char(buf, ch);
        } else {
          sprintf(buf, "(%d)[%s]%s %s\r\n",
GET_GUILD_LEV(i->character),GET_GTITLE(i->character),
                   GET_NAME(i->character), GET_TITLE(i->character));
          send_to_char(buf, ch);
        }
      } else {
         if (GET_GUILD_LEV(ch) > 4 && (GET_GUILD_LEV(ch) >
GET_GUILD_LEV(i->character))) {
           sprintf(buf, "(%d){I}[%s]%s %s\r\n", GET_GUILD_LEV(i->character),
              GET_GTITLE(i->character), GET_NAME(i->character),
GET_TITLE(i->character));
           send_to_char(buf, ch);
         }
      }
    }
  }
}


StormeRider                  --- http://www.windsofstorm.net/wos/
silk@ici.net                 --- telnet://cmoo.com:4004


     +------------------------------------------------------------+
     | 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/08/00 PST