Re: [CODE] list_obj_to_char change crashes Circle

From: Warren Robbins (tonyr@NWPACLINK.COM)
Date: 07/01/98


Ok, your problem seems to be that you're trying to make the object pointer
represent something although it is never assigned to anything.

On Wed, 1 Jul 1998, John Woods wrote:

> I know I must be missing something REALLY stupid here but I can't find it. I
> pinpointed the error, however, and it is marked with a <---. Anyone know what
> I'm doing wrong? It of course crashes whenever anyone logs in. ;-)
> The log()s were to look for errors, you can ignore those. :-)
> I'm guessing that maybe struct obj_data * object should be in the arguments
> passed to the function, but I wasn't sure.
>
> void list_obj_to_char2(struct obj_data * list, struct char_data * ch, int
> mode,
>                            int show)
> {
>   struct obj_data * object;
>   struct obj_data *i;
>   bool found;
>
>   found = FALSE;
>
>         //*buf = '\0';
>         log("strcpying You see");
>         strcpy(buf, "   You see ");
>         log("Calling for statement");
>   for (i = list; i; i = i->next_content) {
>     if (CAN_SEE_OBJ(ch, i)) {
Here you will notice that it checks to see if the object "i" is visible to
the character.

Remove the "struct obj_data *object" and change all the object->whatevers
to i->whatevers.  Should fix.

>                         log("Checking to see if buf is still You see");
>                         if (buf != "   You see ") {
>                                 log("strcating , object->shortdesc");
>                                 strcat(buf, ", ");
>                                 strcat(buf, object->short_description);   <---
>                                 log("show_obj_to_char2(i, ch, mode)");
>                                 show_obj_to_char2(i, ch, mode);
>                         } else {
>                                 log("strcating object->short...");
>                                 strcat(buf, object->short_description);
>                                 log("Calling show_obj_to_char2");
>                                 show_obj_to_char2(i, ch, mode);
>                         }
>                         log("Making found = TRUE");
>       found = TRUE;
>                         strcat(buf, ".\r\n");
>     }
>   }
>   if (!found && show)
>     send_to_char(" Nothing.\r\n", ch);
> }
>

BTW, everyone feel free to help themselves to some virtual birthday cake!

-B.


     +------------------------------------------------------------+
     | 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