A
A. Anderson
Howdy everyone,
I'm experiencing a problem with a program that I'm developing. Take a
look at this stack report from GDB -
#0 0xb7d782a3 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0xb7d4c2f7 in vfprintf () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7d6441b in vsprintf () from /lib/tls/i686/cmov/libc.so.6
#3 0x08049ba0 in character_data:rintf (this=0x800, argument=0x0)
at character.c:198
#4 0x0804a956 in do_look (ch=0x800, argument=0x8659164 "") at
command.c:1062
#5 0x0804ce7d in descriptor_data::interpret (this=0x8656e30,
argument=0x805bde0 "look") at descriptor.c:278
#6 0x0804d945 in descriptor_data:rocess_input (this=0x8656e30)
at descriptor.c:207
#7 0x0804bc08 in main_loop () at core.c:132
#8 0x0804c080 in main (argc=2, argv=0xbf8cd4c4) at core.c:34
And here are the relevant functions:
void do_look( CHARACTER_DATA *ch, char *argument )
{
ROOM_DATA *room;
CHARACTER_DATA *ich;
if( !argument || argument == NULL || argument[0] == '\0' )
{
if(( room = ch->in_room ) == NULL )
{
ch->printf( "It doesnt seem that you are in a room. Please contact
an administrator.\n\r" );
return;
}
else
{
ch->printf( "%s\n\r", room->name );
ch->printf( "-------------------------\n\r" );
if( !room->description || room->description[0] == '\0' )
{
}
else
{
ch->printf( "%s\n\r", room->description );
ch->printf( "-------------------------\n\r" );
}
for( ich = room->first_character; ich; ich = ich->next )
{
if( ich != ch && ich->descriptor && ich->descriptor != NULL && ich-
ch->printf( "%s\n\r", ich->long_desc( ));
}
else
{
continue;
}
continue;
}
return;
}
return;
}
else
{
do_look( ch, "" );
return;
}
return;
}
void character_data:rintf( char *argument, ... )
{
DESCRIPTOR_DATA *descriptor;
char buf[MAX_STRING_LENGTH];
va_list arguments;
if( !argument || argument == NULL || argument[0] == '\0' )
{
return;
}
else
{
va_start( arguments, argument );
vsprintf( buf, argument, arguments );
va_end( arguments );
if(( descriptor = this->descriptor ) == NULL )
{
return;
}
else
{
descriptor->printf( buf );
return;
}
return;
}
return;
}
I've reviewed this a couple dozen times and don't see a problem.
Granted I lack a bit of experience but at about 35000 lines of code
under my belt, and as many warnings or errors as you can come up with
everywhere in between, I would typically see the problem here. If
anyone has any suggestions as to why I'de be experiencing this sort of
a problem I'de appreciate any suggestions. Perhaps a bad
initialization? Perhaps something else. This is why I'm here. And if
anyone has any constructive criticism for me as far as my code is
related I would appreciate it. Thanks.
I'm experiencing a problem with a program that I'm developing. Take a
look at this stack report from GDB -
#0 0xb7d782a3 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0xb7d4c2f7 in vfprintf () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7d6441b in vsprintf () from /lib/tls/i686/cmov/libc.so.6
#3 0x08049ba0 in character_data:rintf (this=0x800, argument=0x0)
at character.c:198
#4 0x0804a956 in do_look (ch=0x800, argument=0x8659164 "") at
command.c:1062
#5 0x0804ce7d in descriptor_data::interpret (this=0x8656e30,
argument=0x805bde0 "look") at descriptor.c:278
#6 0x0804d945 in descriptor_data:rocess_input (this=0x8656e30)
at descriptor.c:207
#7 0x0804bc08 in main_loop () at core.c:132
#8 0x0804c080 in main (argc=2, argv=0xbf8cd4c4) at core.c:34
And here are the relevant functions:
void do_look( CHARACTER_DATA *ch, char *argument )
{
ROOM_DATA *room;
CHARACTER_DATA *ich;
if( !argument || argument == NULL || argument[0] == '\0' )
{
if(( room = ch->in_room ) == NULL )
{
ch->printf( "It doesnt seem that you are in a room. Please contact
an administrator.\n\r" );
return;
}
else
{
ch->printf( "%s\n\r", room->name );
ch->printf( "-------------------------\n\r" );
if( !room->description || room->description[0] == '\0' )
{
}
else
{
ch->printf( "%s\n\r", room->description );
ch->printf( "-------------------------\n\r" );
}
for( ich = room->first_character; ich; ich = ich->next )
{
if( ich != ch && ich->descriptor && ich->descriptor != NULL && ich-
{descriptor->connected == CON_PLAYING )
ch->printf( "%s\n\r", ich->long_desc( ));
}
else
{
continue;
}
continue;
}
return;
}
return;
}
else
{
do_look( ch, "" );
return;
}
return;
}
void character_data:rintf( char *argument, ... )
{
DESCRIPTOR_DATA *descriptor;
char buf[MAX_STRING_LENGTH];
va_list arguments;
if( !argument || argument == NULL || argument[0] == '\0' )
{
return;
}
else
{
va_start( arguments, argument );
vsprintf( buf, argument, arguments );
va_end( arguments );
if(( descriptor = this->descriptor ) == NULL )
{
return;
}
else
{
descriptor->printf( buf );
return;
}
return;
}
return;
}
I've reviewed this a couple dozen times and don't see a problem.
Granted I lack a bit of experience but at about 35000 lines of code
under my belt, and as many warnings or errors as you can come up with
everywhere in between, I would typically see the problem here. If
anyone has any suggestions as to why I'de be experiencing this sort of
a problem I'de appreciate any suggestions. Perhaps a bad
initialization? Perhaps something else. This is why I'm here. And if
anyone has any constructive criticism for me as far as my code is
related I would appreciate it. Thanks.