demo_header_write() now writes the header. :-P
[neverball] / ball / level.c
index be7f39b..9003f8f 100644 (file)
@@ -104,39 +104,33 @@ static int level_scan_metadata(struct level *l, char *av)
             strcpy(l->author, v);
         else if (CASE("special"))
             l->is_bonus = atoi(v);
-        /*else
-            fprintf(stderr, "File %s, ignore %s metadata.\n", l->file, c);*/
 
         c = e;
     }
     return 1;
 }
 
+/* Load the sol file 'filename' and fill the 'level' structure.  Return 1 on
+ * success, 0 on error. */
+
 int level_load(const char *filename, struct level *level)
-/* Load the sol file 'filename' and fill the 'level' structure
- * return 1 on success, 0 on error */
 {
-    struct s_file sol; /* The solid file data */
-    int i;
-    int money; /* sum of coin value */
+    struct s_file sol;
 
-    /* raz level */
-    memset(level, 0, sizeof(struct level));
+    int money;
+    int i;
 
-    memset(&sol, 0, sizeof(sol));
+    memset(level, 0, sizeof (struct level));
+    memset(&sol,  0, sizeof (sol));
 
     /* Try to load the sol file */
     if (!sol_load_only_file(&sol, filename))
     {
-        fprintf(stderr, _("Error while loading level file '%s': "), filename);
-        if (errno)
-           perror(NULL);
-        else
-           fprintf(stderr, _("Not a valid level file\n"));
+        fprintf(stderr, _("Error while loading level file '%s': \n"), filename,
+                errno ? strerror(errno) : _("Not a valid level file\n"));
         return 0;
     }
 
-    /* Set filename */
     strcpy(level->file, filename);
 
     /* Init hs with default values */
@@ -166,7 +160,6 @@ int level_load(const char *filename, struct level *level)
     HOP(level->goal_score.timer, <=);
     HOP(level->coin_score.coins, >=);
 
-    /* Free the sol structure, no more needed */
     sol_free(&sol);
 
     return 1;
@@ -216,7 +209,7 @@ const char *mode_to_str(int m)
     case MODE_NORMAL:    return _("Normal");
     case MODE_PRACTICE:  return _("Practice");
     case MODE_SINGLE:    return _("Single");
-    default:             return "???";
+    default:             return _("Unknown");
     }
 }
 
@@ -231,7 +224,7 @@ const char *state_to_str(int m)
     case GAME_SPEC:
     case GAME_GOAL:    return _("Success");
     case GAME_FALL:    return _("Fall-out");
-    default:           return "???";
+    default:           return _("Unknown");
     }
 }