summaryrefslogtreecommitdiff
path: root/dbox.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2011-04-21 12:59:57 +0000
committerIan C <ianc@noddybox.co.uk>2011-04-21 12:59:57 +0000
commitb3fb34a535c1f9ef34b1651b265a3c7b950a8c7d (patch)
tree51abad645af7083470c1ea2ea5a02fa3f63c10e5 /dbox.c
parentb66d1278e8bf257dd2e03b496cff332339d32b3e (diff)
Fixed problem with long routes in interactive mode and improved switch
handling code.
Diffstat (limited to 'dbox.c')
-rw-r--r--dbox.c64
1 files changed, 41 insertions, 23 deletions
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)