Rationalize attack logic
[open-adventure.git] / main.c
diff --git a/main.c b/main.c
index cf5d396c37e4af6ed2ba46ba391c6734973e552f..7eb21dab571a9be8d7c381f89ddac3d67eafb91a 100644 (file)
--- a/main.c
+++ b/main.c
 
 #define DIM(a) (sizeof(a)/sizeof(a[0]))
 
-FILE *logfp = NULL;
-bool oldstyle = false;
-bool prompt = true;
-
 // LCOV_EXCL_START
 // exclude from coverage analysis because it requires interactivity to test
 static void sig_handler(int signo)
 {
     if (signo == SIGINT) {
-        if (logfp != NULL)
-            fflush(logfp);
+        if (settings.logfp != NULL)
+            fflush(settings.logfp);
     }
     exit(EXIT_FAILURE);
 }
@@ -71,16 +67,16 @@ int main(int argc, char *argv[])
     while ((ch = getopt(argc, argv, opts)) != EOF) {
         switch (ch) {
         case 'l':
-            logfp = fopen(optarg, "w");
-            if (logfp == NULL)
+            settings.logfp = fopen(optarg, "w");
+            if (settings.logfp == NULL)
                 fprintf(stderr,
                         "advent: can't open logfile %s for write\n",
                         optarg);
             signal(SIGINT, sig_handler);
             break;
         case 'o':
-            oldstyle = true;
-            prompt = false;
+            settings.oldstyle = true;
+            settings.prompt = false;
             break;
 #ifndef ADVENT_NOSAVE
         case 'r':
@@ -121,8 +117,8 @@ int main(int argc, char *argv[])
     }
 #endif
 
-    if (logfp)
-        fprintf(logfp, "seed %ld\n", seedval);
+    if (settings.logfp)
+        fprintf(settings.logfp, "seed %ld\n", seedval);
 
     /* interpret commands until EOF or interrupt */
     for (;;) {
@@ -189,7 +185,7 @@ static void checkhints(void)
                     game.hintlc[hint] = 0;
                     return;
                 case 4:        /* dark */
-                    if (game.prop[EMERALD] != -1 && game.prop[PYRAMID] == -1)
+                    if (game.prop[EMERALD] != NOT_YET_FOUND && game.prop[PYRAMID] == NOT_YET_FOUND)
                         break;
                     game.hintlc[hint] = 0;
                     return;