void load_corpses( void )
{
DIR *dp;
struct direct *de;
extern FILE *fpArea;
extern char strArea[MAX_INPUT_LENGTH];
extern int falling;
if ( !(dp = opendir(CORPSE_DIR)) )
{
bug( "Load_corpses: can't open CORPSE_DIR", 0);
perror(CORPSE_DIR);
return;
}
falling = 1; /* Arbitrary, must be >0 though. */
while ( (de = readdir(dp)) != NULL )
{
if ( de->d_name[0] != '.' )
{
sprintf(strArea, "%s%s", CORPSE_DIR, de->d_name );
fprintf(stderr, "Corpse -> %s\n", strArea);
if ( !(fpArea = fopen(strArea, "r")) )
{
perror(strArea);
continue;
}
for ( ; ; )
{
char letter;
char *word;
letter = fread_letter( fpArea );
if ( letter == '*' )
{
fread_to_eol(fpArea);
continue;
}
if ( letter != '#' )
{
bug( "Load_corpses: # not found.", 0 );
break;
}
word = fread_word( fpArea );
if ( !str_cmp(word, "CORPSE" ) )
fread_obj( NULL, fpArea, OS_CORPSE );
else if ( !str_cmp(word, "OBJECT" ) )
fread_obj( NULL, fpArea, OS_CARRY );
else if ( !str_cmp( word, "END" ) )
break;
else
{
bug( "Load_corpses: bad section.", 0 );
break;
}
}
fclose(fpArea);
}
}
fpArea = NULL;
strcpy(strArea, "$");
closedir(dp);
falling = 0;
return;
}
Line 2055: while ( (de = readdir(dp)) != NULL )
Line 2057: if ( de->d_name[0] != '.' )
Line 2059: sprintf(strArea, "%s%s", CORPSE_DIR, de->d_name ); |