note command

Posted by Ithildin on Wed 07 Apr 2004 05:36 AM — 13 posts, 38,315 views.

USA #0
i'm wanting to make it to where we don't use boards to post a note. i want the character to be able to post it globally. envy has a really good way for notes. all you do is type:

note to all
note subject *subject*
note + *message*
note post

and it posts to everyone. smaugFUss is too complicated. i jsut want it simplified. i've been trying to convert the envy over to smaug but it's been long and tedious and i'm not that good. i've got it down to a lot of errors instead of MANY errors. heh. is there any easier way to do this?
USA #1
Nevermind, i ported the envy22 over to smaug. yay for me. hehe. i'm ecstatic about doing this by myself. lol. i'm not a newbie coder anymore!!! ok wait, i still am. but now i have global notes and exactly how i wanted them.
USA #2
*slinks back into newbie coder mode*

ok, on first reboot when i had no notes, everything went fine, i wrote a couple notes, rebooted, and now i get a bug along with the notes are showing up as new notes again. i still have to put the finishing touches in my save file etc. i forgot about those little details..heh. but i do need some help i think with this:

this is what i need to port over to smaug in fread_char. this is the envy code.


{ "Note",   FALSE, 0,			{ &ch->last_note,     NULL } },


i know that's not how to write it. i figure that it might have to look something along these lines.
here is the smaug code:

	case 'N':
	    KEY ("Name", ch->name, fread_string( fp ) );
            KEY ("NoAffectedBy", ch->no_affected_by, fread_bitvector( fp ) );
            KEY ("NoImmune", ch->no_immune, fread_number( fp ) );
            KEY ("NoResistant", ch->no_resistant, fread_number( fp ) );
            KEY ("NoSusceptible", ch->no_susceptible, fread_number( fp ) );
	    if ( !strcmp ( "Nuisance", word ) )
            {
                fMatch = TRUE;
                CREATE( ch->pcdata->nuisance, NUISANCE_DATA, 1 );
                ch->pcdata->nuisance->time = fread_number( fp );
                ch->pcdata->nuisance->max_time = fread_number( fp );
                ch->pcdata->nuisance->flags = fread_number( fp );
		ch->pcdata->nuisance->power = 1;
            }
	    if ( !strcmp ( "NuisanceNew", word ) )
	    {
		fMatch = TRUE;
		CREATE( ch->pcdata->nuisance, NUISANCE_DATA, 1 );
		ch->pcdata->nuisance->time = fread_number( fp );
		ch->pcdata->nuisance->max_time = fread_number( fp );
		ch->pcdata->nuisance->flags = fread_number( fp );
		ch->pcdata->nuisance->power = fread_number( fp );
	    }
	    break;


i'm figuring that just:


KEY ("Note",  ch->last_note, fread_number( fp ) );


won't work even though it does compile cleanly.


i put the code into nanny to get the number of notes when they log in, but it crashes the mud before i can log in. i'll try to move that around a little bit.

USA #3
here's envy code in nanny:


do_look( ch, "auto" );
	/* check for new notes */
	notes = 0;

	for ( pnote = note_list; pnote; pnote = pnote->next )
	    if ( is_note_to( ch, pnote ) && str_cmp( ch->name, pnote->sender )
		&& pnote->date_stamp > ch->last_note )
	        notes++;

	if ( notes == 1 )
	    send_to_char( "\n\rYou have one new note waiting.\n\r", ch );
	else
	    if ( notes > 1 )
	    {
		sprintf( buf, "\n\rYou have %d new notes waiting.\n\r",
			notes );
		send_to_char( buf, ch );
	    }


and here's my code in smaug:


do_look( ch, "auto" );

    if ( !ch->was_in_room && ch->in_room == get_room_index( ROOM_VNUM_TEMPLE ))
      	ch->was_in_room = get_room_index( ROOM_VNUM_TEMPLE );
    else if ( ch->was_in_room == get_room_index( ROOM_VNUM_TEMPLE ))
        ch->was_in_room = get_room_index( ROOM_VNUM_TEMPLE );
    else if ( !ch->was_in_room )
    	ch->was_in_room = ch->in_room;

	/* check for new notes */
	notes = 0;

	for ( pnote = note_list; pnote; pnote = pnote->next )
	    if ( is_note_to( ch, pnote ) && str_cmp( ch->name, pnote->sender )
		&& pnote->date_stamp > ch->last_note )
	        notes++;

	if ( notes == 1 )
	    send_to_char( "\n\rYou have one new note waiting.\n\r", ch );
	else
	    if ( notes > 1 )
	    {
		sprintf( buf, "\n\rYou have %d new notes waiting.\n\r",
			notes );
		send_to_char( buf, ch );
	    }


i'm not sure what's wrong.

any thoughts?

______________________________________

i can start a new character, but as soon as i type note, it crashes. so it's got to be in the save.c file i would guess? but i don't know. i don't know how to use gdb. i tried that one link, but i couldn't get anything to work.
Amended on Sat 10 Apr 2004 01:58 AM by Ithildin
USA #4
i tried to use gdb again here's my ls -lt:


$ ls -lt
total 2165
-rwxr-x---    1 TYLER    None          752 Apr  9 21:09 smaug.exe.stackdump
-rw-r--r--    1 TYLER    None         1597 Apr  9 19:24 NOTES.TXT
-rw-r-----    1 TYLER    None       614668 Apr  9 19:13 help.are
-rw-r--r--    1 TYLER    None          315 Apr  9 18:55 shutdown.txt
-rw-r--r--    1 TYLER    None       171281 Apr  7 01:17 newdark.are


some of it anway, the top one is my segment fault.

when i try to look for a core file though i don't get anything.

$ ls -lt core*
ls: core*: No such file or directory

and when i try to run 752..

$ gdb ../src/smaug core.752
GNU gdb 2003-09-20-cvs (cygwin-special)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
/home/TYLER/smaugfuss/area/core.752: No such file or directory.
(gdb)


all my sigvio is commented out just like you said to do. i'm using smaugfuss, maybe that has something to do with it.


Australia Forum Administrator #5
Why did you type:


$ gdb ../src/smaug core.752

when there is no such file?

Do you mean process ID 752? (Did you do a "ps" and find that number?)

In that case you want:

gdb ../src/smaug 752
USA #6
would my note in save.c look something like this:


if ( !strcmp ( "Note", word ) )
			{
				fmatch = TRUE;
				CREATE(ch->pcdata->last_note, NOTE_DATA, 1 );
				ch->pcdata->last_note= fread_number( fp );


it didn't compile. it had errors.


save.c:1410: error: `fmatch' undeclared (first use in this function)
save.c:1410: error: (Each undeclared identifier is reported only once
save.c:1410: error: for each function it appears in.)
save.c:1411: warning: assignment makes integer from pointer without a cast
Australia Forum Administrator #7
You have to be precise, it is "fMatch" not "fmatch".
USA #8

$ ls -lt
total 2165
-rwxr-x---    1 TYLER    None          814 Apr  9 21:26 smaug.exe.stackdump
and so on


$ gdb ../src/smaug 814
GNU gdb 2003-09-20-cvs (cygwin-special)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
Can't attach to process.
/home/TYLER/smaugfuss/area/814: No such file or directory.
(gdb)


still no file. i'm not sure what i'm really doin with gdb.
USA #9
so i took out these lines in save.c

fprintf( fp, "Note         %ld\n",   (unsigned long)ch->last_note );

//			KEY ("Note",  ch->last_note, fread_number( fp ) );
		/*
		if ( !strcmp ( "Note", word ) )
			{ 
				fMatch = TRUE;
				CREATE(ch->pcdata->last_note, NOTE_DATA, 1 );
				ch->pcdata->last_note= fread_number( fp );
			}
			
			*/



the notes are working. no crashes, but if i read a note, then log back on, it still says i have a new note. and i have to read it again. i just need to find out how to write the above code into my code. hrmm...suggestions?
USA #10
well..i don't know what happened or what i did. but it seems to be working fine right now. i put those code lines back in. and it's working like it is supposed to. i have no idea what i did though. wierd.

but hey, it's working.
USA #11
well it's kind of working. it just randomly crashes sometimes during the note send. it always crashes on note remove. i don't know what's up with that.


________________________________________

so it crashes when i type note send. i restart up, i note send again and it's fine. i reboot and try another note. crash. it just randomly crashes...this is upsetting.
Amended on Sat 10 Apr 2004 05:24 AM by Ithildin
Australia Forum Administrator #12
Can't help you with random crashes. I suggest you concentrate on getting gdb to work.

You should be able to go to your area directory, and then type:

gdb ../src/smaug

That will fire up the server, using gdb. Then when it crashes you will find out where.