Minor simplification of code in date_to_str().
[neverball] / ball / main.c
index 846b11a..3321266 100644 (file)
@@ -57,8 +57,7 @@ static void shot(void)
 
     sprintf(filename, _("screen%02d.png"), num++);
 
-    image_snap(filename, config_get_d(CONFIG_WIDTH),
-               config_get_d(CONFIG_HEIGHT));
+    image_snap(filename);
 }
 
 /*---------------------------------------------------------------------------*/
@@ -221,7 +220,6 @@ static int loop(void)
 
 static char *data_path    = NULL;
 static char *replay_path  = NULL;
-static char *level_path   = NULL;
 static int   display_info = 0;
 
 /* Option handling */
@@ -234,7 +232,6 @@ static void parse_args(int argc, char **argv)
     const char *usage = _(
         "Usage: %s [options ...]\n"
         "-r, --replay file         play the replay 'file'.\n"
-        "-l, --level file.sol      play the level 'file.sol'.\n"
         "-i, --info                display info about level or replay.\n"
         "    --data dir            use 'dir' as game data directory.\n"
         "-v, --version             show version.\n"
@@ -254,15 +251,13 @@ static void parse_args(int argc, char **argv)
         }
         else if (CASE("-v") || CASE("--version"))
         {
-            printf(_("%s: %s version %s\n"), exec, TITLE, VERSION);
+            printf("%s %s\n", TITLE, VERSION);
             exit(0);
         }
         else if (CASE("--data") && MAND)
             data_path = *(++argv);
         else if ((CASE("-r") || CASE("--replay")) && MAND)
             replay_path = *(++argv);
-        else if ((CASE("-l") || CASE("--level")) && MAND)
-            level_path = *(++argv);
         else if ((CASE("-i") || CASE("--info")))
             display_info = 1;
         else if (!missing)
@@ -286,8 +281,9 @@ static void parse_args(int argc, char **argv)
 int main(int argc, char *argv[])
 {
     SDL_Joystick *joy = NULL;
-    int t1, t0;               /* ticks */
-    SDL_Surface *icon;        /* WM icon */
+    SDL_Surface *icon;
+
+    int t1, t0;
 
     language_init("neverball", CONFIG_LOCALE);
 
@@ -314,37 +310,25 @@ int main(int argc, char *argv[])
 
     language_set(language_from_code(config_simple_get_s(CONFIG_LANG)));
 
-    /* Prepare run without sdl */
+    /* Prepare run without SDL */
 
-    if (replay_path != NULL)
+    if (replay_path)
     {
         if (!level_replay(replay_path))
         {
-            fprintf(stderr, _("Replay file '%s': "), replay_path);
-            if (errno)
-                perror(NULL);
-            else
-                fprintf(stderr, _("Not a replay file\n"));
+            fprintf(stderr, _("Replay file '%s': %s\n"), replay_path,
+                    errno ? strerror(errno) : _("Not a replay file"));
             return 1;
         }
         else if (display_info)
             demo_replay_dump_info();
     }
 
-    if (level_path != NULL)
-    {
-        struct level l;
-        if (!level_load(level_path, &l))
-            return 1;
-        else if (display_info)
-            level_dump_info(&l);
-    }
-
     if (display_info)
     {
-        if (replay_path == NULL && level_path == NULL)
+        if (replay_path == NULL)
         {
-            fprintf(stderr, _("%s: --info requires --replay or --level\n"),
+            fprintf(stderr, _("%s: --info requires --replay\n"),
                     argv[0]);
             return 1;
         }
@@ -371,10 +355,10 @@ int main(int argc, char *argv[])
     /* Initialize the audio. */
 
     audio_bind(AUD_MENU,   3, "snd/menu.wav");
-    audio_bind(AUD_START,  1, "snd/select.ogg");
-    audio_bind(AUD_READY,  1, "snd/ready.ogg");
-    audio_bind(AUD_SET,    1, "snd/set.ogg");
-    audio_bind(AUD_GO,     1, "snd/go.ogg");
+    audio_bind(AUD_START,  1, _("snd/select.ogg"));
+    audio_bind(AUD_READY,  1, _("snd/ready.ogg"));
+    audio_bind(AUD_SET,    1, _("snd/set.ogg"));
+    audio_bind(AUD_GO,     1, _("snd/go.ogg"));
     audio_bind(AUD_BALL,   2, "snd/ball.ogg");
     audio_bind(AUD_BUMP,   3, "snd/bump.ogg");
     audio_bind(AUD_COIN,   2, "snd/coin.wav");
@@ -383,10 +367,10 @@ int main(int argc, char *argv[])
     audio_bind(AUD_SWITCH, 5, "snd/switch.wav");
     audio_bind(AUD_JUMP,   5, "snd/jump.ogg");
     audio_bind(AUD_GOAL,   5, "snd/goal.wav");
-    audio_bind(AUD_SCORE,  1, "snd/record.ogg");
-    audio_bind(AUD_FALL,   1, "snd/fall.ogg");
-    audio_bind(AUD_TIME,   1, "snd/time.ogg");
-    audio_bind(AUD_OVER,   1, "snd/over.ogg");
+    audio_bind(AUD_SCORE,  1, _("snd/record.ogg"));
+    audio_bind(AUD_FALL,   1, _("snd/fall.ogg"));
+    audio_bind(AUD_TIME,   1, _("snd/time.ogg"));
+    audio_bind(AUD_OVER,   1, _("snd/over.ogg"));
 
     audio_init();
 
@@ -422,15 +406,12 @@ int main(int argc, char *argv[])
     /* Initialize the run state. */
 
     init_state(&st_null);
-    if (replay_path != NULL)
+
+    if (replay_path)
     {
         level_replay(replay_path);
-        goto_demo_play(1);
-    }
-    else if (level_path != NULL)
-    {
-        level_play_single(level_path);
-        goto_state(&st_level);
+        demo_play_goto(1);
+        goto_state(&st_demo_play);
     }
     else
         goto_state(&st_title);
@@ -445,7 +426,7 @@ int main(int argc, char *argv[])
             {
                 st_paint();
                 gui_blank();
-                SDL_Delay(10); /* Be nice! */
+                SDL_Delay(10);
             }
             else
             {