Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ still note problem...
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Tue 11 May 2004 04:29 AM (UTC) |
| Message
| ok, this is frustrating me to no end. i've tried to mess with this, i've tried to just set it down and think about it, i've tried to not think about it. but i can't seem to get what's goin on here. it sometimes crashes on note send when it's the first note, but always crashes on note remove 0. i can remove any other note except note 0. here's the code:
void note_remove( CHAR_DATA *ch, NOTE_DATA *pnote )
{
FILE *fp;
NOTE_DATA *prev;
char *to_list;
char to_new [ MAX_INPUT_LENGTH ];
char to_one [ MAX_INPUT_LENGTH ];
/*
* Build a new to_list.
* Strip out this recipient.
*/
to_new[0] = '\0';
to_list = pnote->to_list;
while ( *to_list != '\0' )
{
to_list = one_argument( to_list, to_one );
if ( to_one[0] != '\0' && str_cmp( ch->name, to_one ) )
{
strcat( to_new, " " );
strcat( to_new, to_one );
}
}
/*
* Just a simple recipient removal?
*/
if ( str_cmp( ch->name, pnote->sender ) && to_new[0] != '\0' )
{
STRFREE( pnote->to_list );
pnote->to_list = str_dup( to_new + 1 );
return;
}
/*
* Remove note from linked list.
*/
if ( pnote == note_list )
{
note_list = pnote->next;
}
else
{
for ( prev = note_list; prev; prev = prev->next )
{
if ( prev->next == pnote )
break;
}
if ( !prev )
{
bug( "Note_remove: pnote not found.", 0 );
return;
}
prev->next = pnote->next;
}
STRFREE( pnote->text );
STRFREE( pnote->subject );
STRFREE( pnote->to_list );
STRFREE( pnote->date );
STRFREE( pnote->sender );
pnote->next = note_free;
note_free = pnote;
/*
* Rewrite entire list.
*/
fclose( fpReserve );
if ( !( fp = fopen( NOTE_FILE, "w" ) ) )
{
perror( NOTE_FILE );
}
else
{
for ( pnote = note_list; pnote; pnote = pnote->next )
{
fprintf( fp, "Sender %s~\n", pnote->sender );
fprintf( fp, "Date %s~\n", pnote->date );
fprintf( fp, "Stamp %ld\n", (unsigned long)pnote->date_stamp );
fprintf( fp, "To %s~\n", pnote->to_list );
fprintf( fp, "Subject %s~\n", pnote->subject );
fprintf( fp, "Text\n%s~\n\n", pnote->text );
}
fclose( fp );
}
fpReserve = fopen( NULL_FILE, "r" );
return;
}
and here is the remove in do_note:
if ( !str_cmp( arg, "remove" ) )
{
if ( !is_number( argument ) )
{
send_to_char( "Note remove which number?\n\r", ch );
return;
}
anum = atoi( argument );
vnum = 0;
for ( pnote = note_list; pnote; pnote = pnote->next )
{
if ( is_note_to( ch, pnote ) && vnum++ == anum )
{
note_remove( ch, pnote );
send_to_char( "Ok.\n\r", ch );
return;
}
}
does anyone see anything? i just can't seem to figure this out | | Top |
|
| Posted by
| Greven
Canada (835 posts) Bio
|
| Date
| Reply #1 on Tue 11 May 2004 07:14 AM (UTC) |
| Message
| As to which line its crashing on, can you paste a back trace from gdb while running it inside? Should give you exactly where you need to look. However, this: STRFREE( pnote->to_list );
pnote->to_list = str_dup( to_new + 1 );
Is quite wrong. This MAY be the problem, that if your removing more than one note, pnote->to_list will not be the proper type when its called at "STRFREE( pnote->to_list );". If you change it to STRALLOC instead of str_dup, it may clear up a few problems. Can't see anything when I'm quite this tired, but that is definately a problem. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | | Top |
|
| Posted by
| Ithildin
USA (262 posts) Bio
|
| Date
| Reply #2 on Wed 12 May 2004 06:10 AM (UTC) |
| Message
|
(gdb) bt
#0 0x610ab081 in random () from /usr/bin/cygwin1.dll
#1 0x610aae17 in random () from /usr/bin/cygwin1.dll
#2 0x61054ca6 in localtime_r () from /usr/bin/cygwin1.dll
#3 0x610e26ba in wmemset () from /usr/bin/cygwin1.dll
#4 0x610e1d3a in wmemset () from /usr/bin/cygwin1.dll
#5 0x610cf303 in wmemset () from /usr/bin/cygwin1.dll
#6 0x610cf1f4 in wmemset () from /usr/bin/cygwin1.dll
#7 0x610d2e9f in wmemset () from /usr/bin/cygwin1.dll
#8 0x61086211 in cygwin1!aclcheck () from /usr/bin/cygwin1.dll
#9 0x004829ff in do_note (ch=0x1038fa88, argument=0x22ea2c "0")
at boards.c:483
#10 0x004faecd in interpret (ch=0x1038fa88, argument=0x22ea25 "remove 0")
at interp.c:547
#11 0x004b5087 in game_loop () at comm.c:643
#12 0x004b4284 in main (argc=1, argv=0x10010da0) at comm.c:289
i've shown some stuff in my old note post. you can take a gander at that as well. i just started a new post to start fresh over. | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
14,053 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top