]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - phantasia/interplayer.c
cgram: place the 'solved' marker nearer to the text
[bsdgames-darwin.git] / phantasia / interplayer.c
index 8399f914571be44015e28fc84a9662e03b065e16..7f78368119b4273ea06a31a8c76e7980285572f1 100644 (file)
@@ -1,18 +1,36 @@
-/*     $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
@@ -43,9 +61,8 @@ checkbattle()
        }
 }
 
-void
-battleplayer(foeplace)
-       long    foeplace;
+static void
+battleplayer(long foeplace)
 {
        double  dtemp;          /* for temporary calculations */
        double  oldhits = 0.0;  /* previous damage inflicted by foe */
@@ -272,8 +289,8 @@ LEAVE:
                death("Interterminal battle");
 }
 
-void
-myturn()
+static void
+myturn(void)
 {
        double  dtemp;          /* for temporary calculations */
        int     ch;             /* input */
@@ -351,12 +368,12 @@ HIT:
 }
 
 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
@@ -383,11 +400,8 @@ checktampered()
                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 */
 
@@ -508,7 +522,7 @@ tampered(what, arg1, arg2)
                                        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 */
@@ -536,8 +550,7 @@ tampered(what, arg1, arg2)
 }
 
 void
-userlist(ingameflag)
-       bool    ingameflag;
+userlist(phbool ingameflag)
 {
        int     numusers = 0;   /* number of users on file */
 
@@ -545,7 +558,7 @@ userlist(ingameflag)
                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");
 
@@ -599,7 +612,7 @@ userlist(ingameflag)
 }
 
 void
-throneroom()
+throneroom(void)
 {
        FILE   *fp;             /* to clear energy voids */
        long    loc = 0L;       /* location of old king in player file */
@@ -607,7 +620,7 @@ throneroom()
        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 */
@@ -643,7 +656,7 @@ throneroom()
                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);
@@ -653,10 +666,10 @@ throneroom()
 }
 
 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 */
@@ -685,7 +698,7 @@ dotampered()
                        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 {
@@ -718,7 +731,7 @@ dotampered()
                                /* 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);
@@ -765,7 +778,7 @@ dotampered()
                        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 */
@@ -860,23 +873,21 @@ dotampered()
 }
 
 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;