For some reason, fread_word refuses to read the string 'Elaen', the name of one of my players. Instead, it'll go into an infinate loop, freezing the game and filling up the log file with: fread_word: EOF encountered on read .
It doesn't happen to seem with any other players, just Elaen..
Any ideas why? Here's my fread_word:
Note: Fread_string works perfectly all right with Elaen though.
It doesn't happen to seem with any other players, just Elaen..
Any ideas why? Here's my fread_word:
char *fread_word( FILE *fp )
{
static char word[MAX_INPUT_LENGTH];
char *pword;
char cEnd;
do
{
if ( feof(fp) )
{
bug("fread_word: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
word[0] = '\0';
return word;
}
cEnd = getc( fp );
}
while ( isspace( cEnd ) );
if ( cEnd == '\'' || cEnd == '"' )
{
pword = word;
}
else
{
word[0] = cEnd;
pword = word+1;
cEnd = ' ';
}
for ( ; pword < word + MAX_INPUT_LENGTH; pword++ )
{
if ( feof(fp) )
{
bug("fread_word: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
*pword = '\0';
return word;
}
*pword = getc( fp );
if ( cEnd == ' ' ? isspace(*pword) : *pword == cEnd )
{
if ( cEnd == ' ' )
ungetc( *pword, fp );
*pword = '\0';
return word;
}
}
bug( "Fread_word: word too long" );
exit( 1 );
return NULL;
}
Note: Fread_string works perfectly all right with Elaen though.