Fixed nuke timer and better support for dry runs.

This commit is contained in:
Bruce Hill 2019-01-03 05:43:51 -08:00
parent 8d50b6da80
commit 6e703c4f80

14
nuke.c
View File

@ -125,7 +125,7 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
char *failure_message = "Did not delete."; char *failure_message = "nothing was deleted";
int rows,cols; int rows,cols;
int delay=1E5; int delay=1E5;
@ -136,6 +136,9 @@ int main(int argc, char *argv[])
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
add_files(argv[i], &files, &num_files, &capacity); add_files(argv[i], &files, &num_files, &capacity);
} }
if (argc == 1) {
add_file("<testing grounds>", &files, &num_files, &capacity);
}
/* Initialize ncurses and get window dimensions */ /* Initialize ncurses and get window dimensions */
//initscr(); //initscr();
@ -214,10 +217,7 @@ int main(int argc, char *argv[])
/* Display confirmation */ /* Display confirmation */
attron(COLOR_PAIR(BLACK_ON_RED)); attron(COLOR_PAIR(BLACK_ON_RED));
char description[] = " TARGET: "; char *description = num_files == 1 ? " TARGET: " : " TARGETS: ";
if (num_files > 1) {
description[13] = 'S', description[14] = ':';
}
mvprintw(padframer-2, cols/2 - strlen(description)/2, "%s", description); mvprintw(padframer-2, cols/2 - strlen(description)/2, "%s", description);
attron(COLOR_PAIR(BLACK_ON_RED) | A_BLINK); attron(COLOR_PAIR(BLACK_ON_RED) | A_BLINK);
const char confirm[] = " FIRE NUKE? y/n "; const char confirm[] = " FIRE NUKE? y/n ";
@ -346,7 +346,7 @@ int main(int argc, char *argv[])
mvaddch(targetr-1,targetc+1,'/'); mvaddch(targetr-1,targetc+1,'/');
attroff(COLOR_PAIR(RED)); attroff(COLOR_PAIR(RED));
attron(COLOR_PAIR(BLACK_ON_RED)); attron(COLOR_PAIR(BLACK_ON_RED));
mvprintw(targetr-2,targetc+2,"%s", argc > 1 ? argv[f+1] : "target"); mvprintw(targetr-2,targetc+2,"%s", argc > 1 ? argv[f+1] : "testing grounds");
attroff(COLOR_PAIR(BLACK_ON_RED)); attroff(COLOR_PAIR(BLACK_ON_RED));
if (argc > 2) if (argc > 2)
f = (f + 1) % (argc - 1); f = (f + 1) % (argc - 1);
@ -365,7 +365,7 @@ int main(int argc, char *argv[])
mvaddch(nuker-1,nukec+1,'/'); mvaddch(nuker-1,nukec+1,'/');
attroff(COLOR_PAIR(RED)); attroff(COLOR_PAIR(RED));
attron(COLOR_PAIR(BLACK_ON_RED)); attron(COLOR_PAIR(BLACK_ON_RED));
mvprintw(nuker-2,nukec+2,"%f", (targeting_time+anticipation)-t); mvprintw(nuker-2,nukec+2,"%0.3f", (targeting_time + anticipation + firing_time)-t);
attroff(COLOR_PAIR(BLACK_ON_RED)); attroff(COLOR_PAIR(BLACK_ON_RED));
} }