diff options
author | Ian C <ianc@noddybox.co.uk> | 2011-04-21 12:59:57 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2011-04-21 12:59:57 +0000 |
commit | b3fb34a535c1f9ef34b1651b265a3c7b950a8c7d (patch) | |
tree | 51abad645af7083470c1ea2ea5a02fa3f63c10e5 | |
parent | b66d1278e8bf257dd2e03b496cff332339d32b3e (diff) |
Fixed problem with long routes in interactive mode and improved switch
handling code.
-rw-r--r-- | dbox.c | 64 | ||||
-rw-r--r-- | levelF | 2 |
2 files changed, 42 insertions, 24 deletions
@@ -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) @@ -1,4 +1,4 @@ -Test Level +Short Targets Test ########## #@ # # # # |