From b3fb34a535c1f9ef34b1651b265a3c7b950a8c7d Mon Sep 17 00:00:00 2001 From: Ian C Date: Thu, 21 Apr 2011 12:59:57 +0000 Subject: Fixed problem with long routes in interactive mode and improved switch handling code. --- dbox.c | 64 +++++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 23 deletions(-) (limited to 'dbox.c') diff --git a/dbox.c b/dbox.c index 428f518..4dbb4f6 100644 --- a/dbox.c +++ b/dbox.c @@ -172,36 +172,38 @@ int main(int argc, char *argv[]) int play = FALSE; int base; int f; - int verbose = TRUE; + int verbose = FALSE; g_name = argv[0]; - if (argc<2) - { - fprintf(stderr,"%s: usage %s [-i|-p] file [file2 ...]\n", - g_name, g_name); - return EXIT_FAILURE; - } + base = 1; - if (strcmp(argv[1],"-i")==0) + while(argv[base] && argv[base][0] == '-') { - interact = TRUE; - base = 2; - } - else if (strcmp(argv[1],"-p")==0) - { - interact = TRUE; - play = TRUE; - base = 2; - } - else - { - base = 1; + switch(argv[base++][1]) + { + case 'i': + interact = TRUE; + break; + + case 'p': + interact = TRUE; + play = TRUE; + break; + + case 'v': + verbose = TRUE; + break; + + default: + base = argc; + break; + } } - if (argc <= base) + if (!argv[base]) { - fprintf(stderr,"%s: usage %s [-i|-p] file [file2 ...]\n", + fprintf(stderr,"%s: usage %s [-v|-i|-p] file [file2 ...]\n", g_name, g_name); return EXIT_FAILURE; } @@ -1230,7 +1232,23 @@ static void Interactive(const level_t *p_level, int play) if (!play) { - mvprintw(p_level->height + 9, 0, "Route:%s", route); + if (route[0]) + { + if (strlen(route) > COLS-6) + { + mvprintw(p_level->height + 9, 0, "Route:%*.*s...", + COLS-10, COLS-10, route); + } + else + { + mvprintw(p_level->height + 9, 0, "Route:%s", route); + } + } + else + { + mvprintw(p_level->height + 9, 0, "Route: None found -- " + "level possibly impossible"); + } } while(!quit) -- cgit v1.2.3