diff options
| author | Franklin Wei <frankhwei536@gmail.com> | 2014-06-23 15:08:58 -0400 |
|---|---|---|
| committer | Franklin Wei <frankhwei536@gmail.com> | 2014-06-23 15:08:58 -0400 |
| commit | b4f84e24ff5a33b22fcdeeec2f7180248e535e52 (patch) | |
| tree | f63caa643dae391b8c6f9359709e0329eda41f52 | |
| parent | fb1871333736e17196ee0bb72a7dc86aabfd55f4 (diff) | |
| download | wargames-server-b4f84e24ff5a33b22fcdeeec2f7180248e535e52.zip wargames-server-b4f84e24ff5a33b22fcdeeec2f7180248e535e52.tar.gz wargames-server-b4f84e24ff5a33b22fcdeeec2f7180248e535e52.tar.bz2 wargames-server-b4f84e24ff5a33b22fcdeeec2f7180248e535e52.tar.xz | |
Cleaned up code, fixed some bugs
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | chatbot.c | 2 | ||||
| -rw-r--r-- | games.c | 12 | ||||
| -rw-r--r-- | joshua.c | 7 | ||||
| -rw-r--r-- | location.h | 5 | ||||
| -rw-r--r-- | map.h | 33 |
6 files changed, 37 insertions, 28 deletions
@@ -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 *~ @@ -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 @@ -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<num_targets;++i) { - print_string("point 2"); allLower(target_names[i]); - print_string("point 3"); remove_punct(target_names[i]); bool found=false; - print_string("point 4"); for(int j=0;j<sizeof(world)/sizeof(struct location_t);++j) { if(strcmp(world[j].name, target_names[i])==0) @@ -59,7 +57,6 @@ void global_thermonuclear_war(void) found=true; } } - print_string("point 5"); if(!found) { print_string("TARGET NOT FOUND: "); @@ -71,8 +68,9 @@ void global_thermonuclear_war(void) { map[targets[i].y][targets[i].x]='X'; } + usleep(SLEEP_TIME*100); clear(); - for(int i=0;i<sizeof(map)/sizeof(const char*);++i) + for(int i=0;i<sizeof(map)/sizeof(char*);++i) { print_string(map[i]); print_string("\n"); @@ -3,7 +3,13 @@ #include <curses.h> #include <stdlib.h> #include <util.h> +#include <signal.h> #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); @@ -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 */ @@ -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"} }; |