diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-06-29 07:39:46 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 2000-06-29 07:39:46 +0000 |
commit | 4c4981824991e9ac42791c3203847402110691a2 (patch) | |
tree | 06432c05f169b9ff5925f9294f9ceb4cead66974 | |
parent | d177c7dbc6d18498611a5461023183af6388d58f (diff) |
use SEEK_SET; improve an error message.
-rw-r--r-- | games/phantasia/fight.c | 6 | ||||
-rw-r--r-- | games/phantasia/gamesupport.c | 10 | ||||
-rw-r--r-- | games/phantasia/interplayer.c | 24 | ||||
-rw-r--r-- | games/phantasia/main.c | 10 | ||||
-rw-r--r-- | games/phantasia/misc.c | 23 |
5 files changed, 37 insertions, 36 deletions
diff --git a/games/phantasia/fight.c b/games/phantasia/fight.c index c7488183461..b3dfcbaebd1 100644 --- a/games/phantasia/fight.c +++ b/games/phantasia/fight.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fight.c,v 1.4 2000/04/07 04:31:45 pjanzen Exp $ */ +/* $OpenBSD: fight.c,v 1.5 2000/06/29 07:39:42 pjanzen Exp $ */ /* $NetBSD: fight.c,v 1.2 1995/03/24 03:58:39 cgd Exp $ */ /* @@ -1044,7 +1044,7 @@ callmonster(which) which = MIN(which, 99); /* make sure within range */ /* fill structure */ - fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, 0); + fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, SEEK_SET); fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp); /* handle some special monsters */ @@ -1079,7 +1079,7 @@ callmonster(which) /* pick another name */ { which = (int) ROLL(0.0, 100.0); - fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, 0); + fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, SEEK_SET); fread(&Othermonster, SZ_MONSTERSTRUCT, 1, Monstfp); strcpy(Curmonster.m_name, Othermonster.m_name); } diff --git a/games/phantasia/gamesupport.c b/games/phantasia/gamesupport.c index 82e3e38a2a0..2c9eaf6d098 100644 --- a/games/phantasia/gamesupport.c +++ b/games/phantasia/gamesupport.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gamesupport.c,v 1.3 1998/11/29 19:56:56 pjanzen Exp $ */ +/* $OpenBSD: gamesupport.c,v 1.4 2000/06/29 07:39:43 pjanzen Exp $ */ /* $NetBSD: gamesupport.c,v 1.3 1995/04/24 12:24:28 cgd Exp $ */ /* @@ -513,7 +513,7 @@ monstlist() int count = 0; /* count in file */ puts(" #) Name Str Brain Quick Energy Exper Treas Type Flock%\n"); - fseek(Monstfp, 0L, 0); + fseek(Monstfp, 0L, SEEK_SET); while (fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp) == 1) printf("%2d) %-20.20s%4.0f %4.0f %2.0f %5.0f %5.0f %2d %2d %3.0f\n", count++, Curmonster.m_name, Curmonster.m_strength, Curmonster.m_brains, @@ -584,7 +584,7 @@ scorelist() void activelist() { - fseek(Playersfp, 0L, 0); + fseek(Playersfp, 0L, SEEK_SET); printf("Current characters on file are:\n\n"); while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) @@ -632,7 +632,7 @@ purgeoldplayers() today = localtime(<ime)->tm_yday; for (;;) { - fseek(Playersfp, loc, 0); + fseek(Playersfp, loc, SEEK_SET); if (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) != 1) break; @@ -711,7 +711,7 @@ enterscore() strcpy(sbuf.sb_type, descrtype(&Player, TRUE)); } /* update entry */ - fseek(fp, loc, 0); + fseek(fp, loc, SEEK_SET); fwrite((char *) &sbuf, SZ_SCORESTRUCT, 1, fp); fclose(fp); } diff --git a/games/phantasia/interplayer.c b/games/phantasia/interplayer.c index f457641c365..82e2b47ef66 100644 --- a/games/phantasia/interplayer.c +++ b/games/phantasia/interplayer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interplayer.c,v 1.3 1998/11/29 19:56:56 pjanzen Exp $ */ +/* $OpenBSD: interplayer.c,v 1.4 2000/06/29 07:39:44 pjanzen Exp $ */ /* $NetBSD: interplayer.c,v 1.2 1995/03/24 03:58:47 cgd Exp $ */ /* @@ -38,7 +38,7 @@ checkbattle() 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 @@ -468,7 +468,7 @@ checktampered() 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 @@ -648,7 +648,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 */ @@ -717,7 +717,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"); @@ -807,7 +807,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 */ @@ -843,7 +843,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); @@ -945,7 +945,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); @@ -992,7 +992,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 */ @@ -1117,10 +1117,10 @@ writevoid(vp, loc) 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); } /**/ /************************************************************************ @@ -1153,7 +1153,7 @@ allocvoid() { 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; diff --git a/games/phantasia/main.c b/games/phantasia/main.c index 0a51032aae4..67372748eaa 100644 --- a/games/phantasia/main.c +++ b/games/phantasia/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.6 1998/11/29 19:56:57 pjanzen Exp $ */ +/* $OpenBSD: main.c,v 1.7 2000/06/29 07:39:45 pjanzen Exp $ */ /* $NetBSD: main.c,v 1.3 1995/04/24 12:24:37 cgd Exp $ */ /* @@ -782,7 +782,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) @@ -798,7 +798,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 */ @@ -808,7 +808,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) @@ -827,7 +827,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 */ diff --git a/games/phantasia/misc.c b/games/phantasia/misc.c index cdffc8cf414..e4297236337 100644 --- a/games/phantasia/misc.c +++ b/games/phantasia/misc.c @@ -1,10 +1,11 @@ -/* $OpenBSD: misc.c,v 1.5 1998/11/29 19:56:58 pjanzen Exp $ */ +/* $OpenBSD: misc.c,v 1.6 2000/06/29 07:39:45 pjanzen Exp $ */ /* $NetBSD: misc.c,v 1.2 1995/03/24 03:59:03 cgd Exp $ */ /* * misc.c Phantasia miscellaneous support routines */ +#include <err.h> #include "include.h" @@ -677,7 +678,7 @@ findname(name, playerp) { long loc = 0; /* location in the file */ - fseek(Playersfp, 0L, 0); + fseek(Playersfp, 0L, SEEK_SET); while (fread((char *) playerp, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) { if (strcmp(playerp->p_name, name) == 0) { if (playerp->p_status != S_NOTUSED || Wizard) @@ -719,7 +720,7 @@ allocrecord() { long loc = 0L; /* location in file */ - fseek(Playersfp, 0L, 0); + fseek(Playersfp, 0L, SEEK_SET); while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) { if (Other.p_status == S_NOTUSED) /* found an empty record */ @@ -898,10 +899,10 @@ death(how) { mvaddstr(4, 0, "Your ring has taken control of you and turned you into a monster!\n"); - fseek(Monstfp, 13L * SZ_MONSTERSTRUCT, 0); + fseek(Monstfp, 13L * SZ_MONSTERSTRUCT, SEEK_SET); fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp); strcpy(Curmonster.m_name, Player.p_name); - fseek(Monstfp, 13L * SZ_MONSTERSTRUCT, 0); + fseek(Monstfp, 13L * SZ_MONSTERSTRUCT, SEEK_SET); fwrite((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp); fflush(Monstfp); } @@ -969,7 +970,7 @@ writerecord(playerp, place) struct player *playerp; long place; { - fseek(Playersfp, place, 0); + fseek(Playersfp, place, SEEK_SET); fwrite((char *) playerp, SZ_PLAYERSTRUCT, 1, Playersfp); fflush(Playersfp); } @@ -1152,7 +1153,7 @@ readrecord(playerp, loc) struct player *playerp; long loc; { - fseek(Playersfp, loc, 0); + fseek(Playersfp, loc, SEEK_SET); fread((char *) playerp, SZ_PLAYERSTRUCT, 1, Playersfp); } /**/ @@ -1382,7 +1383,7 @@ readmessage() { move(3, 0); clrtoeol(); - fseek(Messagefp, 0L, 0); + fseek(Messagefp, 0L, SEEK_SET); if (fgets(Databuf, SZ_DATABUF, Messagefp) != NULL) addstr(Databuf); } @@ -1420,8 +1421,8 @@ error(whichfile) clear(); cleanup(FALSE); - printf("An unrecoverable error has occurred reading %s. (errno = %d)\n", whichfile, errno); - printf("Please run 'setup' to determine the problem.\n"); + warn("%s", whichfile); + fprintf(stderr, "Please run 'setup' to determine the problem.\n"); exit(1); /* NOTREACHED */ } @@ -1667,7 +1668,7 @@ collecttaxes(gold, gems) dtemp = 0.0; fread((char *) &dtemp, sizeof(double), 1, fp); dtemp += floor(taxes); - fseek(fp, 0L, 0); + fseek(fp, 0L, SEEK_SET); fwrite((char *) &dtemp, sizeof(double), 1, fp); fclose(fp); } |