[SMAUG] Bug with my Hometowns snippet

[SMAUG] Bug with my Hometowns snippet



Thanks for Vladaar for reporting this:

 

In save_hometown:

 

After:

       /* print to the list */

      fprintf(list, "%s~\n", nation->fname);

 

Add:

      fprintf(list, "$\n");

 

In function load_nations, starting at the “for” statement, change:

 

for( ; ; )

  {

    char *filename = feof(list) ? "$" : fread_string(list);

 

    /* end of the file */

    if(filename[0] == '$')

     break;

 

    /* load each nation indiviually */

    {

      NATION_DATA *nation = NULL;

      char letter = fread_letter(fp);

 

      if(letter == '$')

      {

            FCLOSE(list);

            checkup( );

            return;

      }

      nation = fread_nation(filename);

      if(!nation)

      {

        bug("load_nations(): error returning back nation from filename %s", filename);

        return;

      }

      /* linker */

      nation_list[top_nation]      = nation;

      top_nation++;

      continue;

    }

  }

 

This should fix the bug that he was having when a log was getting the report of an EOF error.