-/* $NetBSD: main.c,v 1.12 2004/01/01 16:03:46 jsm Exp $ */
+/* $NetBSD: main.c,v 1.17 2008/08/08 16:10:47 drochner Exp $ */
/*
* Phantasia 3.3.2 -- Interterminal fantasy game
* AT&T is in no way connected with this game.
*/
+#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
*/
#include "include.h"
+#undef bool
+#include <curses.h>
int main(int, char **);
void
initialstate()
{
+ struct stat sb;
+
Beyond = FALSE;
Marsh = FALSE;
Throne = FALSE;
if ((Energyvoidfp = fopen(_PATH_VOID, "r+")) == NULL)
error(_PATH_VOID);
+ if (fstat(fileno(Energyvoidfp), &sb) == -1)
+ error("stat");
+ if (sb.st_size == 0) {
+ /* initialize grail to new location */
+ Enrgyvoid.ev_active = TRUE;
+ Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
+ Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
+ writevoid(&Enrgyvoid, 0L);
+ }
+
/* NOTREACHED */
srandom((unsigned) time(NULL)); /* prime random numbers */
&& fgets(Databuf, SZ_DATABUF, fp) != NULL) {
mvaddstr(19, 25, "The last character to die was:");
mvaddstr(20, 40 - strlen(Databuf) / 2, Databuf);
- fclose(fp);
}
+ if (fp)
+ fclose(fp);
refresh();
}
signal(SIGPIPE, ill_sig);
#endif
- initscr(); /* turn on curses */
+ if (!initscr()) { /* turn on curses */
+ fprintf(stderr, "couldn't initialize screen\n");
+ exit (0);
+ }
noecho(); /* do not echo input */
cbreak(); /* do not process erase, kill */
clear();