-/* $NetBSD: main.c,v 1.20 2009/05/26 00:27:23 dholland Exp $ */
+/* $NetBSD: main.c,v 1.24 2019/02/03 03:19:25 mrg 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 <sys/stat.h>
#include <err.h>
+#include <math.h>
#include <pwd.h>
+#include <setjmp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "macros.h"
+#include "phantdefs.h"
+#include "phantstruct.h"
+#include "phantglobs.h"
+#include "pathnames.h"
+
+#undef bool
+#include <curses.h>
/*
* The program allocates as much file space as it needs to store characters,
* main.c Main routines for Phantasia
*/
-#include "include.h"
-#undef bool
-#include <curses.h>
+static void genchar(int);
+static void initialstate(void);
+static void neatstuff(void);
+static void playinit(void);
+static void procmain(void);
+static long recallplayer(void);
+static long rollnewplayer(void);
+static void titlelist(void);
int main(int, char **);
case 'a': /* all users */
activelist();
cleanup(TRUE);
+ __unreachable();
/* NOTREACHED */
case 'p': /* purge old players */
purgeoldplayers();
cleanup(TRUE);
+ __unreachable();
/* NOTREACHED */
case 'S': /* set 'Wizard' */
case 'm': /* monsters */
monstlist();
cleanup(TRUE);
+ __unreachable();
/* NOTREACHED */
case 'b': /* scoreboard */
scorelist();
cleanup(TRUE);
+ __unreachable();
/* NOTREACHED */
}
if (examine) {
changestats(FALSE);
cleanup(TRUE);
+ __unreachable();
/* NOTREACHED */
}
if (!noheader) {
titlelist();
purgeoldplayers(); /* clean up old characters */
}
- if (headeronly)
+ if (headeronly) {
cleanup(TRUE);
- /* NOTREACHED */
+ __unreachable();
+ /* NOTREACHED */
+ }
do
/* get the player structure filled */
case 'Q':
cleanup(TRUE);
+ __unreachable();
/* NOTREACHED */
default:
Timeout = TRUE;
/* update some important player statistics */
- strcpy(Player.p_login, Login);
+ strlcpy(Player.p_login, Login, sizeof(Player.p_login));
time(&seconds);
Player.p_lastused = localtime(&seconds)->tm_yday;
Player.p_status = S_PLAYING;
}
}
-void
+static void
initialstate(void)
{
struct stat sb;
srandom((unsigned) time(NULL)); /* prime random numbers */
}
-long
+static long
rollnewplayer(void)
{
int chartype; /* character type */
return (allocrecord());
}
-void
+static void
procmain(void)
{
int ch; /* input */
case '5': /* good-bye */
leavegame();
+ __unreachable();
/* NOTREACHED */
case '6': /* cloak */
}
}
-void
+static void
titlelist(void)
{
FILE *fp; /* used for opening various files */
refresh();
}
-long
+static long
recallplayer(void)
{
long loc = 0L; /* location in player file */
return (-1L);
}
-void
+static void
neatstuff(void)
{
double temp; /* for temporary calculations */
}
}
-void
+static void
genchar(int type)
{
int subscript; /* used for subscripting into Stattable */
Player.p_experience = ROLL(600.0, 200.0);
}
-void
+static void
playinit(void)
{
/* catch/ingnore signals */