-/* $NetBSD: interplayer.c,v 1.3 1997/10/13 02:18:22 lukem Exp $ */
+/* $NetBSD: interplayer.c,v 1.12 2009/08/31 08:27:16 dholland Exp $ */
/*
* interplayer.c - player to player routines for Phantasia
*/
-#include "include.h"
+#include <math.h>
+#include <setjmp.h>
+#include <stdio.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>
+
+static long allocvoid(void);
+static void battleplayer(long);
+static void myturn(void);
+static void tampered(int, double, double);
void
-checkbattle()
+checkbattle(void)
{
long foeloc = 0L; /* location in file of person to fight */
Users = 0;
- fseek(Playersfp, 0L, 0);
+ fseek(Playersfp, 0L, SEEK_SET);
while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) {
if (Other.p_status != S_OFF
}
}
-void
-battleplayer(foeplace)
- long foeplace;
+static void
+battleplayer(long foeplace)
{
double dtemp; /* for temporary calculations */
double oldhits = 0.0; /* previous damage inflicted by foe */
death("Interterminal battle");
}
-void
-myturn()
+static void
+myturn(void)
{
double dtemp; /* for temporary calculations */
int ch; /* input */
}
void
-checktampered()
+checktampered(void)
{
long loc = 0L; /* location in energy void file */
/* first check for energy voids */
- fseek(Energyvoidfp, 0L, 0);
+ fseek(Energyvoidfp, 0L, SEEK_SET);
while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
if (Enrgyvoid.ev_active
&& Enrgyvoid.ev_x == Player.p_x
tampered(Other.p_tampered, Other.p_1scratch, Other.p_2scratch);
}
-void
-tampered(what, arg1, arg2)
- int what;
- double arg1;
- double arg2;
+static void
+tampered(int what, double arg1, double arg2)
{
long loc; /* location in file of other players */
addstr("You made to position of Valar!\n");
Player.p_specialtype = SC_VALAR;
Player.p_lives = 5;
- fseek(Playersfp, 0L, 0);
+ fseek(Playersfp, 0L, SEEK_SET);
loc = 0L;
while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
/* search for existing valar */
}
void
-userlist(ingameflag)
- bool ingameflag;
+userlist(phbool ingameflag)
{
int numusers = 0; /* number of users on file */
mvaddstr(8, 0, "You cannot see anyone.\n");
return;
}
- fseek(Playersfp, 0L, 0);
+ fseek(Playersfp, 0L, SEEK_SET);
mvaddstr(8, 0,
"Name X Y Lvl Type Login Status\n");
}
void
-throneroom()
+throneroom(void)
{
FILE *fp; /* to clear energy voids */
long loc = 0L; /* location of old king in player file */
if (Player.p_specialtype < SC_KING)
/* not already king -- assumes crown */
{
- 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)
/* found old king */
fclose(fp);
/* clear all energy voids; retain location of holy grail */
- fseek(Energyvoidfp, 0L, 0);
+ fseek(Energyvoidfp, 0L, SEEK_SET);
fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
fp = fopen(_PATH_VOID, "w");
fwrite((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, fp);
}
void
-dotampered()
+dotampered(void)
{
short tamper; /* value for tampering with other players */
- char *option; /* pointer to option description */
+ const char *option; /* pointer to option description */
double temp1 = 0.0, temp2 = 0.0; /* other tampering values */
int ch; /* input */
long loc; /* location in energy void file */
break;
case '3': /* create energy void */
- if ((loc = allocvoid()) > 20L * SZ_VOIDSTRUCT)
+ if ((loc = allocvoid()) > 20L * (long)SZ_VOIDSTRUCT)
/* can only have 20 void active at once */
mvaddstr(5, 0, "Sorry, void creation limit reached.\n");
else {
/* collect taxes */
{
fread((char *) &temp1, sizeof(double), 1, fp);
- fseek(fp, 0L, 0);
+ fseek(fp, 0L, SEEK_SET);
/* clear out value */
temp2 = 0.0;
fwrite((char *) &temp2, sizeof(double), 1, fp);
if (Player.p_palantir)
/* need a palantir to seek */
{
- fseek(Energyvoidfp, 0L, 0);
+ fseek(Energyvoidfp, 0L, SEEK_SET);
fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
temp1 = distance(Player.p_x, Enrgyvoid.ev_x, Player.p_y, Enrgyvoid.ev_y);
temp1 += ROLL(-temp1 / 10.0, temp1 / 5.0); /* add some error */
}
void
-writevoid(vp, loc)
- struct energyvoid *vp;
- long loc;
+writevoid(struct energyvoid *vp, long loc)
{
- fseek(Energyvoidfp, loc, 0);
+ fseek(Energyvoidfp, loc, SEEK_SET);
fwrite((char *) vp, SZ_VOIDSTRUCT, 1, Energyvoidfp);
fflush(Energyvoidfp);
- fseek(Energyvoidfp, 0L, 0);
+ fseek(Energyvoidfp, 0L, SEEK_SET);
}
-long
-allocvoid()
+static long
+allocvoid(void)
{
long loc = 0L; /* location of new energy void */
- fseek(Energyvoidfp, 0L, 0);
+ fseek(Energyvoidfp, 0L, SEEK_SET);
while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
if (Enrgyvoid.ev_active)
loc += SZ_VOIDSTRUCT;