]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - phantasia/main.c
Undef bool before including <curses.h>, since it tries to typedef
[bsdgames-darwin.git] / phantasia / main.c
index b571be74c554528d38d325b8e62cfeac3caab1cd..b18b32405c541f2a964f41e2db227abba9da3a1b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.5 1998/08/30 09:19:39 veego Exp $   */
+/*     $NetBSD: main.c,v 1.14 2004/04/11 13:35:06 he Exp $     */
 
 /*
  * Phantasia 3.3.2 -- Interterminal fantasy game
  */
 
 #include "include.h"
+#undef bool
+#include <curses.h>
 
-int    main __P((int, char **));
+int    main(int, char **);
 
 int
 main(argc, argv)
@@ -287,6 +289,8 @@ initialstate()
        if ((Playersfp = fopen(_PATH_PEOPLE, "r+")) == NULL)
                error(_PATH_PEOPLE);
        /* NOTREACHED */
+       if (fileno(Playersfp) < 3)
+               exit(1);
 
        if ((Monstfp = fopen(_PATH_MONST, "r+")) == NULL)
                error(_PATH_MONST);
@@ -383,7 +387,7 @@ rollnewplayer()
        do {
                mvaddstr(20, 0, "Give your character a password [up to 8 characters] ? ");
                getstring(Player.p_password, SZ_PASSWORD);
-               mvaddstr(21, 0, "One more time to verify ? ");
+               mvaddstr(21, 0, "Enter again to verify: ");
                getstring(Databuf, SZ_PASSWORD);
        }
        while (strcmp(Player.p_password, Databuf) != 0);
@@ -626,7 +630,7 @@ titlelist()
                fclose(fp);
        }
        /* search for king */
-       fseek(Playersfp, 0L, 0);
+       fseek(Playersfp, 0L, SEEK_SET);
        while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
                if (Other.p_specialtype == SC_KING &&
                    Other.p_status != S_NOTUSED)
@@ -642,7 +646,7 @@ titlelist()
                mvaddstr(4, 24, "There is no ruler at this time.");
 
        /* search for valar */
-       fseek(Playersfp, 0L, 0);
+       fseek(Playersfp, 0L, SEEK_SET);
        while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
                if (Other.p_specialtype == SC_VALAR && Other.p_status != S_NOTUSED)
                        /* found the valar */
@@ -652,7 +656,7 @@ titlelist()
                        break;
                }
        /* search for council of the wise */
-       fseek(Playersfp, 0L, 0);
+       fseek(Playersfp, 0L, SEEK_SET);
        Lines = 10;
        while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
                if (Other.p_specialtype == SC_COUNCIL && Other.p_status != S_NOTUSED)
@@ -671,7 +675,7 @@ titlelist()
        hiexp = 0.0;
        nxtlvl = hilvl = 0;
 
-       fseek(Playersfp, 0L, 0);
+       fseek(Playersfp, 0L, SEEK_SET);
        while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
                if (Other.p_experience > hiexp && Other.p_specialtype <= SC_KING && Other.p_status != S_NOTUSED)
                        /* highest found so far */
@@ -873,7 +877,7 @@ genchar(type)
        int     type;
 {
        int     subscript;      /* used for subscripting into Stattable */
-       struct charstats *statptr;      /* for pointing into Stattable */
+       const struct charstats *statptr; /* for pointing into Stattable */
 
        subscript = type - '1';
 
@@ -979,7 +983,7 @@ playinit()
 
        initscr();              /* turn on curses */
        noecho();               /* do not echo input */
-       crmode();               /* do not process erase, kill */
+       cbreak();               /* do not process erase, kill */
        clear();
        refresh();
        Windows = TRUE;         /* mark the state */
@@ -992,13 +996,17 @@ cleanup(doexit)
        if (Windows) {
                move(LINES - 2, 0);
                refresh();
-               nocrmode();
+               nocbreak();
                endwin();
        }
-       fclose(Playersfp);
-       fclose(Monstfp);
-       fclose(Messagefp);
-       fclose(Energyvoidfp);
+       if (Playersfp)
+               fclose(Playersfp);
+       if (Monstfp)
+               fclose(Monstfp);
+       if (Messagefp)
+               fclose(Messagefp);
+       if (Energyvoidfp)
+               fclose(Energyvoidfp);
 
        if (doexit)
                exit(0);