Fix code formatting.
[neverball] / ball / level.c
index be7f39b..515a247 100644 (file)
 void score_init_hs(struct score *s, int timer, int coins)
 {
     int i;
+
     strcpy(s->player[0], "Hard");
     strcpy(s->player[1], "Medium");
     strcpy(s->player[2], "Easy");
     strcpy(s->player[3], "");
+
     for (i = 0; i < NSCORE + 1; i++)
     {
         s->timer[i] = timer;
@@ -104,39 +106,34 @@ 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': %s\n"), filename,
+                errno ? strerror(errno) : _("Not a valid level file"));
         return 0;
     }
 
-    /* Set filename */
     strcpy(level->file, filename);
 
     /* Init hs with default values */
@@ -166,7 +163,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 +212,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 +227,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");
     }
 }