Re: ASCII Pfiles and load_char()

From: Todd A Laycock (tlayco1@uic.edu)
Date: 05/04/99


What I did to fix some of those load_char problems (stat file, show
player, last, etc) was this

struct char_data *vict;

CREATE(vict, struct char_data, 1);
clear_char(vict);
init_char(vict);
if (load_char(vict, name) < 0) /* fill in stuff for when the char wasn't
                                * loaded, usually a return or such */

Otherwise it's good to go.  I haven't come across anymore crashes from
load_char since I added the init_char(vict) line in the right spots.  I'm
not sure if this is the best way to do it but it works. =)

Todd A. Laycock


On Tue, 4 May 1999, Tony Robbins wrote:

> When I installed ASCII Pfiles into my MUD, I ran into errors with various
> sections of code due to the fact that the character structure was not being
> CREATE'd or clear_char()'d.  Now I went into load_char() and added this:
>
>   if (ch == NULL) {
>     CREATE(ch, struct char_data, 1);
>     clear_char(ch);
>     CREATE(ch->player_specials, struct player_special_data, 1); /* I think
> */
>   }
>
> In theory, it would allocate memory if necessary, in actuality, it does not.
> load_char() goes through and does a successful return, but once I'm back in
> the calling function (do_last, for example), the char_data structure has
> been NULL'd again.
>
> Is there a way I can make the if() check inside load_char() work as kind of
> a blanket check?  I just found it odd that the allocated memory would vanish
> at the end of the function.
>
> -K.


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



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