aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2014-06-23 15:08:58 -0400
committerFranklin Wei <frankhwei536@gmail.com>2014-06-23 15:08:58 -0400
commitb4f84e24ff5a33b22fcdeeec2f7180248e535e52 (patch)
treef63caa643dae391b8c6f9359709e0329eda41f52
parentfb1871333736e17196ee0bb72a7dc86aabfd55f4 (diff)
downloadwargames-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--Makefile6
-rw-r--r--chatbot.c2
-rw-r--r--games.c12
-rw-r--r--joshua.c7
-rw-r--r--location.h5
-rw-r--r--map.h33
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<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");
diff --git a/joshua.c b/joshua.c
index f225ec9..5b5f27a 100644
--- a/joshua.c
+++ b/joshua.c
@@ -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);
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"}
};