> I believe this is it.  In order for my olc to work correctly I need to
> change the load_*'s in db.c?  IE:
>
>     mob->name           = pMobIndex->player_name;
>     mob->short_descr    = pMobIndex->short_descr;
>     mob->long_descr     = pMobIndex->long_descr;
>     mob->description    = pMobIndex->description;
>
> TO:
> mob->name        = str_dup(pMobIndex->player_name);
> etc.

Exactly..
When it's just set to the string like it is on top, the string is shared for 
all 3.  Fine, but when a mob dies, it frees the strings.  That means the 
memory can be reused for anything else.
So the other mobs that were sharing the string will still have a pointer to 
the memory address, which might now be used for another purpose, and so what 
you'll see is unpredictable at best.
str_dup is smart so that it will copy the strings that need to be copied and 
not copy the strings that are supposed to be shared.
Understanding how the shared and unshared strings work can be kind of a big 
hurdle :)
--Palrich.

Reply via email to