> void add_trophy (CHAR_DATA *ch, CHAR_DATA *victim)
> {
>    int i = 0;
>    TROPHY_DATA * trophy;
>
>    /* If were the first entry, set it up */
>    if (ch->pcdata->trophy_list->next == NULL)

Where are you initializing ch->pcdata->trophy_list?
You neglected to show that code.

Well, I have a call in new_pcdata in recycle.c that initializes
trophy_list using new_trophy_data();.  In doing this it sets the
trophy_list->next to NULL.  So I assume here that if it's null an actual
->pcdata->trophy isn't initialized yet.

You seem to be a bit confused on linked lists.
Either you use an empty head node, like you seem to be doing here,
or you treat the case of adding to an empty list specially, also
like you seem to be doing.  Not both.  If you're initializing
ch->pcdata->trophy_list somewhere to an empty value, the whole
first part of this function (everything inside this if) is
unnecessary.  The code below takes care of it.

You are correct here.  What I intended to do is have trophy_list be
the empty head node.  I initialize trophy_list like I mentioned above
and I believe I'm trying to initialize a first "instance" of a trophy
structure as trophy_list should point to NULL if there aren't any actual
trophy's set yet.

What are you using ch->pcdata->trophy for?
It looks to me like you're using it instead of using the
local variable trophy in this function?

Indeed I am.  An error on my part, still haven't gotten my head
completely wrapped around Linked lists.

>        strcat(ch->pcdata->trophy->short_desc, victim->short_descr);
         ^^^^^^
Big no no.  Don't ever do this unless you have a large character
buffer (you don't here.  All you have is a pointer)

Thanks for the heads up.  When dealing with copying strings of this
nature, what is the prefered method to do it?

It would seem to me at least that keeping a seperate empty "start of
list" variable would be the easiest way to keep track of things.
But I could very well be wrong on this as well. At any rate, thanks for the response. I will be keeping on this until I get it working properly, so expect another question or two in the coming days.

Thanks,
Brett
[EMAIL PROTECTED]

_________________________________________________________________
The new MSN 8 is here: Try it free* for 2 months http://join.msn.com/?page=dept/dialup


Reply via email to