From b4f84e24ff5a33b22fcdeeec2f7180248e535e52 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Mon, 23 Jun 2014 15:08:58 -0400 Subject: Cleaned up code, fixed some bugs --- Makefile | 6 ++++-- chatbot.c | 2 +- games.c | 12 +++++------- joshua.c | 7 +++++++ location.h | 5 +++-- map.h | 33 +++++++++++++++++---------------- 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 14bd0b8..cbd7609 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ SOURCES=joshua.o main.o util.o chatbot.o games.o strings.o -CXXFLAGS=-I. -lncurses -CFLAGS=-I. -std=gnu99 +CXXFLAGS=-I. -lncurses -g +CFLAGS=-I. -std=gnu99 -g all: $(SOURCES) g++ $(SOURCES) -lncurses +clean: + rm -f $(SOURCES) a.out *~ diff --git a/chatbot.c b/chatbot.c index 7ef3b69..f9549e6 100644 --- a/chatbot.c +++ b/chatbot.c @@ -18,7 +18,7 @@ void do_chatbot(void) if(ret==ERR) { print_string("\n\n"); - print_string("Sorry?"); + print_string("SORRY?"); print_string("\n\n"); } else diff --git a/games.c b/games.c index 94d2190..1f939d2 100644 --- a/games.c +++ b/games.c @@ -37,19 +37,17 @@ void global_thermonuclear_war(void) good=false; } else - ++num_targets; + { + ++num_targets; + } } struct location_t targets[32]; int num_targets_found=0; - print_string("point 1"); for(int i=0;i #include #include +#include #define RANDOM_TIME 1 +void cleanup(int signum) +{ + endwin(); + exit(0); +} void random_stuff(void) /* print random junk on the screen for about 3 seconds */ { clear(); @@ -19,6 +25,7 @@ void be_joshua() { initscr(); clear(); + signal(SIGINT, &cleanup); /* start_color(); init_pair(1, COLOR_BLUE, COLOR_BLACK); diff --git a/location.h b/location.h index 6fd05f2..b88c026 100644 --- a/location.h +++ b/location.h @@ -1,7 +1,8 @@ /* provide the GTNW with some geographical data to draw the missiles */ struct location_t { const char* name; - int x, y; /* x,y-coords on the map */ + int x; + int y; /* x,y-coords on the map */ }; struct location_t world[]={ /* US cities */ @@ -13,7 +14,7 @@ struct location_t world[]={ {"washington dc", 33, 6}, {"winston-salem", 30, 7}, {"san francisco", 1, 6}, - {"chicago", 26, 4}, + {"chicago", 24, 4}, /* Soviet cities */ /* NOTE: These are not neccessarily correct. I simply eyed them relative to Murmansk */ diff --git a/map.h b/map.h index 63ed445..3fb4d63 100644 --- a/map.h +++ b/map.h @@ -1,18 +1,19 @@ -char* map[] = { - /* 0 */ " .", - /* 1 */ " __________--^-^-\\. ____ __----/^\\.", - /* 2 */ "|\\/. \\__. ___/ || ___/ _/._-_ .", - /* 3 */ "| \\. /. /. __ __/ /__/ \\/^^\\___-__.", - /* 4 */ "| L-^-/. /. \\.\\_-- \\.", - /* 5 */ "| / _/ _/\\/.", - /* 6 */ "|. | _/. __ __/", - /* 7 */ " \\. /. / ___/.//", - /* 8 */ " \\__ / | / \\/.", - /* 9 */ " \\________ __ _____.\\. \\_. ____--_ /\\_ \\", - /* 10 */ " \\__. / V. \\ \\ \\__ _/. \\_/ //", - /* 11 */ " \\ /. \\/. \\. _/. //", - /* 12 */ " \\_/. \\_/", - /* 13 */ "", - /* 14 */ " UNITED STATES SOVIET UNION" +#define LITERAL(x) (char[]){x} +char *map[] = { + /* 0 */ (char[]){" ."}, + /* 1 */ (char[]){" __________--^-^-\\. ____ __----/^\\."}, + /* 2 */ (char[]){"|\\/. \\__. ___/ || ___/ _/._-_ ."}, + /* 3 */ (char[]){"| \\. /. /. __ __/ /__/ \\/^^\\___-__."}, + /* 4 */ (char[]){"| L-^-/. /. \\.\\_-- \\."}, + /* 5 */ (char[]){"| / _/ _/\\/."}, + /* 6 */ (char[]){"|. | _/. __ __/"}, + /* 7 */ (char[]){" \\. /. / ___/.//"}, + /* 8 */ (char[]){" \\__ / | / \\/."}, + /* 9 */ (char[]){" \\________ __ _____.\\. \\_. ____--_ /\\_ \\"}, + /* 10 */ (char[]){" \\__. / V. \\ \\ \\__ _/. \\_/ //"}, + /* 11 */ (char[]){" \\ /. \\/. \\. _/. //"}, + /* 12 */ (char[]){" \\_/. \\_/"}, + /* 13 */ (char[]){""}, + /* 14 */ (char[]){" UNITED STATES SOVIET UNION"} }; -- cgit v1.1