Quest.c

Posted by Gregar on Mon 09 Feb 2004 10:39 AM — 8 posts, 28,759 views.

#0
I have recently added first the quest snippet from Aurora at Lost Prophecies, and then removed that and used the quest snippet from Vassago.

Both compiled after some tweaks and booted up the game fine.

The addition of either quest snippet caused the MUD to crash when logging in pre-quest characters. However, new character gen works fine, up until the new character quits, at which point the MUD crashes.

Has anyone else had this problem when applying the questmaster snippets?

Gregar
Canada #1
I beleive I know the problem: When you log in, your character is loaded to check the password, and then is cleared away. It is then re-loaded fully later to allow you to play. To clear away the memory used from the first load, it uses a function called free_char. This is also called when a player quits, but not when you make a new character. I would suggest looking at free_char. Make sure any information that is being read in with fread_string is cleared away with STRALLOC, and anything read in with fread_string_nohash is cleared with DISPOSE.

KEY(Quest, ch->questmaster, fread_string);
STRFREE(ch->questmaster);


As opposed to:

KEY(Quest, ch->questmaster, fread_string_nohash);
DISPOSE(ch->questmaster);


Hope that helps.
#2
Just to clarify before I mess this up any further..

What I have added, per the snippet, are these lines of code to save.c, fread_char function



        case 'Q':
            KEY( "QuestPnts",   ch->questpoints,        fread_number( fp ) );
            KEY( "QuestNext",   ch->nextquest,          fread_number( fp ) );
            break;


I see fread_number, and did not add anything with fread_string, so my question comes more for clarification.

Does the fread_number need to be declared in db.c at free_char, and if so, I am presuming it would be;


	if (ch->pcdata->questpnts) 
        STRFREE(ch->pcdata->questpoints);
    if (ch->pcdata->questnext)
        STRFREE(ch->pcdata->nextquest);


or am I just off somewhere that nooone should tread?

Thanks in advance.
Gregar
Amended on Mon 09 Feb 2004 08:51 PM by Gregar
Canada #3
Heh, you only need to use STRFREE/DISPOSE on strings, if you've added only inegers, you don't need to work about it.

I would check your core, see whats coming up.
United Kingdom #4
Just a quick question on Vassago's Quest snippet...
I see you have it working... i have a problem in the compile of:



quest.c: In function 'generate_quest':
quest.c:486: error: 'char_list' undeclared (first use in this function.)
quest.c:486: error: (Each undeclared identify is reported only once
quest.c:486: error: for each function it appears in)
make[1]: *** [quest.o] Error 1



Any ideas behind this one?
#5
At a glance I would vote you are missing this declaration..

 void generate_quest	args(( CHAR_DATA *ch, CHAR_DATA *questman )); 


Somewhere around line 40.


Then the first line of the function, on my working copy, (your line 486) reads as follows;


void generate_quest(CHAR_DATA *ch, CHAR_DATA *questman)


I don't know if this is any help, but thats how it works for us.
USA #6
Quote:

quest.c: In function 'generate_quest':
quest.c:486: error: 'char_list' undeclared (first use in this function.)
quest.c:486: error: (Each undeclared identify is reported only once
quest.c:486: error: for each function it appears in)
make[1]: *** [quest.o] Error 1

These generally means that its using an undefined variable within the function. Simply go to the top and define it. Not sure the variable type, but I'm going to guess this:

CHAR_DATA *char_list;

Then again, that might be wrong. To be safe (if you are unsure about what to do) post the lines 480-490 so we can see what char_list is used for.
United Kingdom #7
It okay i figured out what the problem was.

char_list is ROM's way of going throught the characters/mobs in a room. So i changed it to first_char
and it works fine now. Everything going clean and working fine. Iv just got add a few if checks to stop the quest guys giving quests to hell and limbo :-p

Rash