27 Sep, 2009, JohnnyStarr wrote in the 41st comment:
Votes: 0
I wrote that before your post, so why wouldnt q->next = NULL
On the first iteration?
Sorry if im not getting my point across.
27 Sep, 2009, David Haley wrote in the 42nd comment:
Votes: 0
Since I think we're sort of posting at the same time, did you see post #40?
27 Sep, 2009, JohnnyStarr wrote in the 43rd comment:
Votes: 0
hehe, yes, i'm sorry, your going to want to kill me!
I'm going to try better to explain what i DONT understand.

Am I thinking of it too much in a linear way?

I get everything you are all saying, and i trust that you are correct.
So, the head pointer isn't connected to the tail?

Please humor me as I try to make a picture of whats going on in my brain:

I imagine the head pointer quests as like the engine on a train, the cars go all the way to the end until you have nothing right?

head -> NOTHINGNESS ->[car]->[car]->[car]->NULL

I get that the last car is where you add the next element. It makes sense to me
that if the head was: head ->[car]->[car]->[car]->NULL that you could do this, but
the only thing i dont get is how does head-> point to the second pointer implicitly?
27 Sep, 2009, ATT_Turan wrote in the 44th comment:
Votes: 0
David Haley said:
// If the list is empty (because quest_first is null) , set
// the new node to be the first quest node.
if(!ch->quest_first )
ch->quest_first = quest;


head->[car]
27 Sep, 2009, JohnnyStarr wrote in the 45th comment:
Votes: 0
Ok, I get it now.
:redface:

Thanks!
27 Sep, 2009, bbailey wrote in the 46th comment:
Votes: 0
In the beginning, when the world was young, brothers quest_head and quest_tail were of one mind, one node, and the node was good. As with all good things, one node led to another node, and the brothers went, each to one node, quest_head to the first, and quest_tail to the last, so they might bound and love them. As node begat node, quest_head held the first node to his bosom, and quest_tail moved from new node to new node, shepherding it to its brothers. As the nodes grew, quest_head lost sight of his brother, but trusted that he was out among the nodes, always tending to most recent addition to their..


staryavsky said:
Ok, I get it now.
:redface:

Thanks!


Ohgoddamnit. :cry:
27 Sep, 2009, JohnnyStarr wrote in the 47th comment:
Votes: 0
I swear this is the last time!!!

I added a quest_last to char_data, i wrote davions code, and when i type the command 'questlog'
it only displays one, yet the Pfile has 5 in it! So, i'm not insane.

I didn't change the iteration code, such as:
for ( q = ch->quests; q != NULL; q = q->next )


so, is it that i have to write that differently?

EDIT:

for some reason, i changed the code from (!ch->quests) to ((ch->quests) != NULL) and it worked! weird.
01 Oct, 2009, JohnnyStarr wrote in the 48th comment:
Votes: 0
Ok, I hate to bring up this thread again, but I am trying to figure something out.
I've gotten the whole singly-linked list with tail pointer down, but I am not sure how to go about
changing my "quest_from_char" routine:
void quest_from_char (CHAR_DATA *ch, QUEST_DATA *q)
{
// check if it's at the top o' the list
if (ch->quests == q)
{
ch->quests = q->next;
}
else // if not iterate
{
QUEST_DATA *prev;

for (prev = ch->quests; prev != NULL; prev = prev->next)
{
if (prev->next == q)
{
// hop to q->next, skipping q and removing from list
prev->next = q->next;
break;
}
}

if (prev == NULL)
bug ("quest_from_char: quest not in list.", 0);
}
}

obviously something needs to change to accommodate for the tail pointer to avoid conflicts, what would you recommend?
01 Oct, 2009, David Haley wrote in the 49th comment:
Votes: 0
Something like if q == ch->last_quest, ch->last_quest = prev.
40.0/49