home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso
/
altsrc
/
articles
/
11241
< prev
next >
Wrap
Text File
|
1994-09-11
|
48KB
|
1,952 lines
Path: wupost!kuhub.cc.ukans.edu!nrlvx1.nrl.navy.mil!ra!news.pop.psu.edu!news.cac.psu.edu!howland.reston.ans.net!europa.eng.gtefsd.com!MathWorks.Com!news.duke.edu!godot.cc.duq.edu!newsfeed.pitt.edu!uunet!news.sprintlink.net!demon!hunting2.demon.co.uk!zondo
Newsgroups: alt.sources
Subject: Wander: puzzle game (2 of 6)
Message-ID: <778924803snz@hunting2.demon.co.uk>
From: zondo@hunting2.demon.co.uk (Zondo Pillock)
Date: Wed, 7 Sep 1994 08:00:03 +0000
Reply-To: zondo@hunting2.demon.co.uk
Sender: usenet@demon.co.uk
Organization: Hunting Engineering Limited
X-Newsreader: Demon Internet Simple News v1.29
Lines: 1939
This is wander, version 1.0.
Wander is a game where you wander around the screen collecting
treasures, solving puzzles and avoiding the nasty monsters. It's
really a new version of an old game called 'wanderer', written by
Steven Shipway back in 1988. Ah, wanderer... excellent game, shame
about the source code. I loved the game so much I rewrote it to
(hopefully) make it more slick and expandable. See the file CHANGES
for the main differences between this version and the old one.
Wander uses curses and has been tested on a DECstation 5000 (ULTRIX)
and SGI Indigo (IRIX).
__o
zondo@hunting2.demon.co.uk _`\<,_
............................(_)/ (_)
Submitted-by: zondo@hunting2.demon.co.uk
Archive-name: wander/part02
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is part 02 of wander.
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo 'WARNING: not restoring timestamps'
fi
rm -f 1231235999 $$.touch
#
# ============= move.c ==============
if test -f 'move.c' && test X"$1" != X"-c"; then
echo 'x - skipping move.c (File already exists)'
else
echo 'x - extracting move.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'move.c' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Object movement stuff */
X
#ifndef lint
static char rcsid[] = "$Id: move.c,v 1.24 1994/06/16 13:17:28 glen Exp $";
#endif
X
#include <stdio.h>
#include "defs.h"
#include "data.h"
#include "proto.h"
#include "config.h"
X
struct {
X int line, col; /* Position to move */
X int moved; /* Has it been moved? */
} movelist[MAXWIDTH*MAXHEIGHT];
X
int nummoves = 0; /* No. of entries in move list */
X
/* Return whether player can move in a direction */
int
canmove(int dir)
{
X int line = curpos->pline;
X int col = curpos->pcol;
X struct loc next, into;
X
X /* Can't move at all if you're dead */
X if (curpos->dead) return 0;
X
X /* Can always do nothing */
X if (dir == NONE) return 1;
X
X /* Can only move onto exit if you have all the diamonds */
X /* (or you're wizard) */
X into = moveto(line, col, dir);
X if (into.type == EXIT) {
X if (!testlevel) {
X return (curpos->diamonds == 0 || wizard);
X } else {
X message("You can't leave a level you're testing");
X beep();
X return 0;
X }
X }
X
X /* Can't move into something that blocks */
X if (obj[into.type].block) return 0;
X
X if (obj[into.type].push) {
X /* Can't push if next space isn't free */
X next = moveto(into.line, into.col, dir);
X if (next.type != BLANK) return 0;
X
X /* Can't push if going 'against the grain' */
X switch (obj[into.type].movedir) {
X case NORTH:
X if (dir == SOUTH) return 0;
X break;
X case SOUTH:
X if (dir == NORTH) return 0;
X break;
X case EAST:
X if (dir == WEST) return 0;
X break;
X case WEST:
X if (dir == EAST) return 0;
X break;
X }
X }
X
X return 1;
}
X
/* Move player */
void
domove(int dir)
{
X int lastscore, pl, pc, plnew, pcnew, teleported = 0;
X struct loc new, next;
X int lpush, cpush;
X
X /* Remove 'future' positions (if any) */
X removepos();
X
X /* Copy current position */
X curpos = copypos(curpos);
X curpos->dir = dir;
X
X /* Do the move */
X if (dir != NONE) {
X pl = curpos->pline;
X pc = curpos->pcol;
X new = moveto(pl, pc, dir);
X plnew = new.line;
X pcnew = new.col;
X
X /* Check for being killed */
X if (obj[new.type].kill) {
X switch (new.type) {
X case BABY:
X case MONSTER:
X doeffect(plnew, pcnew, EATEN);
X die("You've been munched by a hungry monster!");
X break;
X case LANDMINE:
X doeffect(plnew, pcnew, BLOWNUP);
X die("You've been blown up by a landmine!");
X break;
X default:
X die("Oh dear, you're dead. Not sure what killed you, though");
X }
X }
X
X /* Check for pushing something */
X if (obj[new.type].push) {
X next = moveto(plnew, pcnew, dir);
X lpush = next.line;
X cpush = next.col;
X curpos->data[lpush][cpush] = curpos->data[plnew][pcnew];
X }
X
X /* Check for eating something */
X if (obj[new.type].eat) {
X curpos->score += obj[new.type].score;
X
X switch (new.type) {
X case CAPSULE:
X if (curpos->nmoves > 0)
X curpos->nmoves += CAPSULEMOVES;
X break;
X case TREASURE:
X curpos->diamonds--;
X break;
X }
X }
X
X /* Check for teleport */
X if (new.type == TELEPORT) {
X curpos->data[pl][pc] = BLANK;
X curpos->data[plnew][pcnew] = PLAYER;
X doeffect(plnew, pcnew, VANISH);
X curpos->data[plnew][pcnew] = BLANK;
X moveinto(plnew, pcnew);
X plnew = tline;
X pcnew = tcol;
X teleported = 1;
X }
X
X /* Check for escape */
X if (new.type == EXIT) {
X curpos->data[pl][pc] = BLANK;
X curpos->data[plnew][pcnew] = PLAYER;
X doeffect(plnew, pcnew, VANISH);
X curpos->data[plnew][pcnew] = BLANK;
X exited = 1;
X
X /* Add moves left as a bonus */
X if (curpos->nmoves > 0)
X curpos->score += curpos->nmoves;
X
X /* Get last score for this level (if any) */
X lastscore = getscore(myuid, level);
X
X /* Update score for this level */
X while (1) {
X if (lockscores()) {
X readscores();
X updatescore(myuid, level, curpos->score);
X writescores();
X unlockscores();
X break;
X }
X }
X
X /* Report on success */
X if (level == maxlevel) {
X message("Well done! Type %c to go to level %d, %c to save",
X NEXTLEVEL, level+1, SAVE);
X } else if (curpos->score > lastscore) {
X message("You beat your last score on this level by %d points",
X curpos->score-lastscore);
X } else {
X message("You didn't beat your last score of %d points",
X lastscore);
X }
X
X beep();
X }
X
X /* Set final player position */
X if (curpos->data[pl][pc] == PLAYER)
X curpos->data[pl][pc] = BLANK;
X curpos->pline = plnew;
X curpos->pcol = pcnew;
X
X if (teleported) {
X recentre();
X doeffect(plnew, pcnew, APPEAR);
X
X /* Check you didn't appear inside a monster! */
X if (findmonster(plnew, pcnew) != NULL) {
X doeffect(plnew, pcnew, BLOWNUP);
X die("You materialized inside a monster! Yuck!");
X }
X }
X
X curpos->data[plnew][pcnew] = PLAYER;
X
X /* Check for things moving */
X vacate(pl, pc);
X moveinto(plnew, pcnew);
X }
X
X /* Move objects affected by you */
X moveobjects();
X
X /* Move the nasty evil monsters */
X movemonsters();
X
X /* Move objects affected by monsters */
X moveobjects();
X
X /* Decrement moves left */
X if (curpos->nmoves > 0) curpos->nmoves--;
X if (curpos->nmoves == 0) {
X doeffect(curpos->pline, curpos->pcol, TIMEUP);
X die("You ran out of time!");
X }
X
X /* Add new position to stack */
X addpos(curpos);
}
X
/* Check for things moving when something moves next to them */
void
moveinto(int line, int col)
{
X /* Try to move objects in the four adjacent squares */
X addmove(line-1, col );
X addmove(line , col-1);
X addmove(line , col+1);
X addmove(line+1, col );
}
X
/* Check for things moving after a square has been vacated */
void
vacate(int line, int col)
{
X /* Check all surrounding squares for objects which */
X /* might move into or through the vacated one */
X checkmove(line-1, col, line, col);
X checkmove(line , col-1, line, col);
X checkmove(line , col+1, line, col);
X checkmove(line+1, col , line, col);
X checkmove(line-1, col-1, line, col);
X checkmove(line-1, col+1, line, col);
X checkmove(line+1, col-1, line, col);
X checkmove(line+1, col+1, line, col);
}
X
/* Check if an object moves into a vacated square */
void
checkmove(int line, int col, int lastline, int lastcol)
{
X struct loc locs[2];
X int nlocs, i;
X
X /* Would it move at all? */
X if ((nlocs = wouldmove(line, col, locs)) == 0) return;
X
X /* If so, would it move into or through the vacated square? */
X for (i = 0; i < nlocs; i++) {
X if (locs[i].line == lastline &&
X locs[i].col == lastcol)
X addmove(line, col);
X }
}
X
/* Returns whether an object would move if given the */
/* chance, and the path it would take to get there */
int
wouldmove(int line, int col, struct loc locs[2])
{
X struct loc l, next, lsloc[2], rsloc[2];
X int dir, sdir, nlocs = 0, nls = 0, nrs = 0;
X
X /* Everything stops when you die */
X if (curpos->dead) return 0;
X
X l = curloc(curpos, line, col);
X dir = obj[l.type].movedir;
X if (dir == NONE) return 0;
X next = moveto(line, col, dir);
X
X switch (next.type) {
X case BLANK:
X locs[nlocs++] = next;
X break;
X case LSLOPE:
X case RSLOPE:
X sdir = (next.type == LSLOPE ?
X slopes[dir].lsdir :
X slopes[dir].rsdir);
X next = moveto(line, col, sdir);
X if (next.type == BLANK) {
X locs[nlocs++] = next;
X next = moveto(next.line, next.col, dir);
X if (next.type == BLANK) {
X locs[nlocs++] = next;
X } else {
X nlocs = 0;
X }
X }
X break;
X default:
X if (obj[next.type].sloped) {
X lsloc[nls++] = moveto(line, col, slopes[dir].lsdir);
X if (lsloc[0].type == BLANK) {
X lsloc[nls++] = moveto(lsloc[0].line, lsloc[0].col, dir);
X if (lsloc[1].type != BLANK) nls = 0;
X }
X
X rsloc[nrs++] = moveto(line, col, slopes[dir].rsdir);
X if (rsloc[0].type == BLANK) {
X rsloc[nrs++] = moveto(rsloc[0].line, rsloc[0].col, dir);
X if (rsloc[1].type != BLANK) nrs = 0;
X }
X
X if (nls == 2 && nrs < 2) {
X nlocs = nls;
X locs[0] = lsloc[0];
X locs[1] = lsloc[1];
X } else if (nrs == 2 && nls < 2) {
X nlocs = nrs;
X locs[0] = rsloc[0];
X locs[1] = rsloc[1];
X }
X }
X
X break;
X }
X
X return nlocs;
}
X
/* Move an object */
void
moveobject(int line, int col)
{
X int nlocs, lnew, cnew, type, dir;
X struct loc locs[2], next, l;
X
X l = curloc(curpos, line, col);
X type = l.type;
X dir = obj[type].movedir;
X
X while ((nlocs = wouldmove(line, col, locs)) > 0) {
X /* Move it */
X lnew = locs[nlocs-1].line;
X cnew = locs[nlocs-1].col;
X curpos->data[line][col] = BLANK;
X curpos->data[lnew][cnew] = type;
X drawpos(curpos);
X
X /* Check for things moving into the space it left */
X vacate(line, col);
X line = lnew;
X col = cnew;
X moveinto(line, col);
X
X /* Check for bashing things */
X next = moveto(line, col, dir);
X switch (next.type) {
X case PLAYER:
X switch (type) {
X case BOULDER:
X doeffect(next.line, next.col, SQUASHED);
X die("A boulder just squashed you flat!");
X break;
X case LARROW:
X case RARROW:
X doeffect(next.line, next.col, SHOT);
X die("You've been shot by a giant arrow!");
X break;
X case ROCKET:
X doeffect(next.line, next.col, BLOWNUP);
X die("You've been blown up by a rocket!");
X break;
X default:
X die("Oh dear, you're dead. Not sure what killed you, though");
X break;
X }
X
X break;
X case MONSTER:
X switch (type) {
X case BOULDER:
X doeffect(next.line, next.col, SQUASHED);
X killmonster(next.line, next.col);
X break;
X case LARROW:
X case RARROW:
X doeffect(next.line, next.col, SHOT);
X killmonster(next.line, next.col);
X break;
X case ROCKET:
X doeffect(next.line, next.col, BLOWNUP);
X killmonster(next.line, next.col);
X break;
X default:
X killmonster(next.line, next.col);
X break;
X }
X
X break;
X }
X }
}
X
/* Add an object to the move list */
void
addmove(int line, int col)
{
X int i;
X
X for (i = 0; i < nummoves; i++) {
X if (movelist[i].moved) break;
X }
X
X movelist[i].line = line;
X movelist[i].col = col;
X movelist[i].moved = 0;
X
X if (i == nummoves) nummoves++;
}
X
/* Move all the objects in the move list */
void
moveobjects()
{
X int i, priority, p, line, col;
X struct loc l;
X
X while (1) {
X /* Find highest movement priority */
X for (priority = 0, i = 0; i < nummoves; i++) {
X if (!movelist[i].moved) {
X line = movelist[i].line;
X col = movelist[i].col;
X l = curloc(curpos, line, col);
X if ((p = obj[l.type].movepri) == 0) continue;
X if (priority == 0 || p < priority) priority = p;
X }
X }
X
X /* If nothing else to move, that's it */
X if (priority == 0) break;
X
X /* Move all objects of that priority */
X for (i = 0; i < nummoves; i++) {
X if (!movelist[i].moved) {
X line = movelist[i].line;
X col = movelist[i].col;
X l = curloc(curpos, line, col);
X p = obj[l.type].movepri;
X if (p == priority) {
X moveobject(line, col);
X movelist[i].moved = 1;
X }
X }
X }
X }
X
X /* Clear move list */
X nummoves = 0;
}
X
/* Hahahaha, you're dead! */
void
die(char *msg)
{
X curpos->dead = 1;
X beep();
X message(msg);
}
SHAR_EOF
$shar_touch -am 0706083194 'move.c' &&
chmod 0444 'move.c' ||
echo 'restore of move.c failed'
shar_count="`wc -c < 'move.c'`"
test 11194 -eq "$shar_count" ||
echo "move.c: original size 11194, current size $shar_count"
fi
# ============= score.c ==============
if test -f 'score.c' && test X"$1" != X"-c"; then
echo 'x - skipping score.c (File already exists)'
else
echo 'x - extracting score.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'score.c' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Scoring routines */
X
#ifndef lint
static char rcsid[] = "$Id: score.c,v 1.11 1994/06/15 13:47:52 glen Exp $";
#endif
X
#include <stdio.h>
#include <string.h>
#include "defs.h"
#include "data.h"
#include "proto.h"
#include "config.h"
X
/* Field separator in score file */
#define FIELDSEP ":"
X
struct score {
X char *name; /* Player name */
X int uid; /* UID */
X int hide; /* Hide score from other players? */
X int level; /* Max. level */
X int *score; /* Current scores per level */
X struct score *next; /* Next in list */
};
X
static struct score *scores = NULL; /* Score list */
X
char *getenv(char *name);
X
/* Return player's user name */
char *
playername()
{
X static char buf[BUFSIZ];
X
X /* Get name from variable */
X if (getenv("WANDERNAME") != NULL) {
X strcpy(buf, getenv("WANDERNAME"));
X } else if (getenv("USER") != NULL) {
X strcpy(buf, getenv("USER"));
X } else {
X fatal("WANDERNAME or USER environment variables must be set");
X }
X
X /* Check it for validity */
X if (strlen(buf) == 0)
X fatal("WANDERNAME or USER must not be set to a null string");
X if (strstr(buf, FIELDSEP) != NULL)
X fatal("%s must not contain any '%c' characters", buf, FIELDSEP);
X
X return buf;
}
X
/* Add a new player to the score list */
static struct score *
addscore()
{
X struct score *new;
X int i;
X
X new = ALLOC(struct score, 1);
X if (new == NULL)
X fatal("Out of memory");
X
X new->name = NULL;
X new->score = ALLOC(int, nlevels);
X for (i = 0; i < nlevels; i++) new->score[i] = 0;
X new->next = scores;
X scores = new;
X
X return new;
}
X
/* Read the score file */
void
readscores()
{
X char buf[BUFSIZ], *file = scorefile(), *tok;
X struct score *s;
X FILE *fp;
X int i;
X
X if ((fp = fopen(file, "r")) == NULL)
X fatal("Can't open %s", file);
X
X /* Free old score list (if any) */
X while (scores != NULL) {
X s = scores->next;
X DEALLOC(scores->name);
X DEALLOC(scores->score);
X DEALLOC(scores);
X scores = s;
X }
X
X while (fgets(buf, BUFSIZ, fp) != NULL) {
X /* Add new score */
X s = addscore();
X
X /* First field is player name */
X if ((tok = strtok(buf, FIELDSEP)) == NULL)
X fatal("%s: corrupted score file", file);
X s->name = ALLOC(char, strlen(tok)+1);
X strcpy(s->name, tok);
X
X /* Second field is UID */
X if ((tok = strtok(NULL, FIELDSEP)) == NULL)
X fatal("%s: corrupted score file", file);
X s->uid = atoi(tok);
X
X /* Third field is whether to hide score */
X if ((tok = strtok(NULL, FIELDSEP)) == NULL)
X fatal("%s: corrupted score file", file);
X s->hide = atoi(tok);
X
X /* Fourth field is level */
X if ((tok = strtok(NULL, FIELDSEP)) == NULL)
X fatal("%s: corrupted score file", file);
X s->level = atoi(tok);
X
X /* Following fields are scores per level */
X for (i = 0; i < s->level-1; i++) {
X if ((tok = strtok(NULL, FIELDSEP)) == NULL)
X fatal("%s: corrupted score file", file);
X s->score[i] = atoi(tok);
X }
X }
X
X fclose(fp);
}
X
/* Write the score file */
void
writescores()
{
X char *file = scorefile();
X struct score *s;
X FILE *fp;
X int i;
X
X fp = fopen(file, "w");
X
X for (s = scores; s != NULL; s = s->next) {
X fprintf(fp, "%s%s%d%s%d%s%d",
X s->name, FIELDSEP,
X s->uid, FIELDSEP,
X s->hide, FIELDSEP,
X s->level);
X
X for (i = 0; i < s->level-1; i++) {
X fprintf(fp, "%s%d", FIELDSEP, s->score[i]);
X }
X
X fprintf(fp, "\n");
X }
X
X fclose(fp);
}
X
/* Look up a player in the score list */
static struct score *
findscore(int uid)
{
X struct score *s;
X
X for (s = scores; s != NULL; s = s->next) {
X if (s->uid == uid) return s;
X }
X
X return NULL;
}
X
/* Update a player's score */
void
updatescore(int uid, int level, int score)
{
X struct score *s = findscore(uid);
X extern char myname[];
X
X if (s == NULL) {
X s = addscore();
X s->uid = uid;
X }
X
X if (s->name != NULL) DEALLOC(s->name);
X s->name = ALLOC(char, strlen(myname)+1);
X strcpy(s->name, myname);
X s->hide = hidescore;
X
X s->level = level+1;
X s->score[level-1] = score;
}
X
/* Display the score list */
void
showscores()
{
X struct score *s;
X int i, totalscore, title = 0;
X
X for (s = scores; s != NULL; s = s->next) {
X if (s->hide && s->uid != myuid) continue;
X
X if (!title) {
X printf("\n W A N D E R S C O R E S\n\n");
X printf("%-30s %5s %5s\n\n", "Name", "Level", "Score");
X title = 1;
X }
X
X for (i = 0, totalscore = 0; i < s->level-1; i++)
X totalscore += s->score[i];
X
X printf("%-30s %3d %5d\n", s->name, s->level, totalscore);
X }
X
X if (title)
X printf("\n");
X else
X printf("No scores recorded\n");
}
X
/* Display your scores per level */
void
showlevels(int uid)
{
X struct score *s = findscore(uid);
X int i;
X
X if (s == NULL || s->level == 1) {
X printf("You haven't finished any levels yet\n");
X } else {
X printf("Level Score\n");
X for (i = 0; i < s->level-1; i++) {
X printf("%3d %5d\n", i+1, s->score[i]);
X }
X }
}
X
/* Return player's biggest level */
int
getlevel(int uid)
{
X struct score *s = findscore(uid);
X
X return (s != NULL ? s->level : 1);
}
X
/* Return a player's score for a level */
int
getscore(int uid, int level)
{
X struct score *s = findscore(uid);
X
X return (s != NULL ? s->score[level-1] : 0);
}
SHAR_EOF
$shar_touch -am 0615144994 'score.c' &&
chmod 0444 'score.c' ||
echo 'restore of score.c failed'
shar_count="`wc -c < 'score.c'`"
test 5452 -eq "$shar_count" ||
echo "score.c: original size 5452, current size $shar_count"
fi
# ============= save.c ==============
if test -f 'save.c' && test X"$1" != X"-c"; then
echo 'x - skipping save.c (File already exists)'
else
echo 'x - extracting save.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'save.c' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Level saving functions */
X
#ifndef lint
static char rcsid[] = "$Id: save.c,v 1.11 1994/06/29 14:27:43 glen Exp $";
#endif
X
#include <stdio.h>
#include "defs.h"
#include "data.h"
#include "proto.h"
#include "config.h"
X
#define MEMSIZE 100 /* Default memory allocation size */
#define LINESIZE 60 /* Moves per line */
#define DELAY 0.3 /* Default replay frame delay (sec) */
#define WAIT 1000L /* Wait delay (msec) */
X
struct path {
X int level; /* Level */
X int score; /* Score gained */
X char *moves; /* Moves made to do it */
};
X
/* Return the move path of the current level */
static struct path *
movepath()
{
X struct pos *p;
X struct path *new = ALLOC(struct path, 1);
X int msize = MEMSIZE, nmoves = 0;
X
X if (new == NULL) fatal("Out of memory");
X
X new->level = (testlevel ? 0 : level);
X new->score = lastpos->score;
X new->moves = ALLOC(char, msize);
X
X for (p = firstpos->next; p != NULL; p = p->next) {
X if (p->dir == NORTH) {
X new->moves[nmoves++] = 'N';
X } else if (p->dir == EAST) {
X new->moves[nmoves++] = 'E';
X } else if (p->dir == SOUTH) {
X new->moves[nmoves++] = 'S';
X } else if (p->dir == WEST) {
X new->moves[nmoves++] = 'W';
X } else if (p->dir == NONE) {
X new->moves[nmoves++] = '.';
X } else {
X new->moves[nmoves++] = '?';
X }
X
X if (nmoves == msize) {
X msize += MEMSIZE;
X new->moves = REALLOC(new->moves, char, msize);
X }
X }
X
X new->moves[nmoves] = '\0';
X return new;
}
X
/* Interactively write a position to file */
void
save()
{
X FILE *fp;
X char *name = getstring("Save file name: ");
X
X if (name == NULL || strlen(name) == 0) return;
X if ((fp = fopen(name, "w")) == NULL) {
X message("Can't open %s");
X return;
X }
X
X writemoves(fp);
X fclose(fp);
}
X
/* Write moves of current level to output stream */
void
writemoves(FILE *fp)
{
X struct path *p = movepath();
X int col = 0, i = 0;
X
X /* Write header */
X fprintf(fp, "%d %d\n", p->level, p->score);
X
X /* Write moves */
X while (p->moves[i] != NULL) {
X fputc(p->moves[i++], fp);
X if (++col == LINESIZE) {
X col = 0;
X fputc('\n', fp);
X }
X }
X
X if (col > 0) fputc('\n', fp);
X DEALLOC(p->moves);
X DEALLOC(p);
}
X
/* Restore a move path */
void
restore()
{
X char *name = getstring("Restore file name: ");
X
X if (name == NULL) return;
X
X redrawscreen = query("Replay moves on screen? ", 0);
X restorefile(name);
X if (!redrawscreen) recentre();
X redrawscreen = 1;
}
X
/* Restore a move path from file */
void
restorefile(char *name)
{
X FILE *fp = fopen(name, "r");
X int flevel, fscore, dir, c, mini;
X char buf[BUFSIZ];
X double delay = DELAY;
X
X if (fp == NULL) {
X message("Can't open %s", name);
X beep();
X return;
X }
X
X /* Read header */
X if (fgets(buf, BUFSIZ, fp) == NULL) {
X message("Error reading %s", name);
X beep();
X return;
X }
X
X if (sscanf(buf, "%d %d", &flevel, &fscore) != 2) {
X message("%s is not a wander save file", name);
X beep();
X return;
X }
X
X if (!testlevel) {
X if (flevel != 0 && flevel != level) {
X message("%s is not a save file for this level", name);
X beep();
X return;
X }
X }
X
X /* Replay it */
X curpos = firstpos;
X mini = minidisplay;
X exited = 0;
X
X while ((c = fgetc(fp)) != EOF) {
X if (c == '\n') continue;
X
X switch (c) {
X case 'N':
X dir = NORTH;
X break;
X case 'E':
X dir = EAST;
X break;
X case 'S':
X dir = SOUTH;
X break;
X case 'W':
X dir = WEST;
X break;
X case '.':
X dir = NONE;
X break;
X default:
X message("Invalid character in save file: '%c'", c);
X goto finish;
X }
X
X if (canmove(dir)) {
X /* Do the move */
X domove(dir);
X scroll();
X if (exited) goto finish;
X
X /* Update screen */
X drawpos(curpos);
X
X /* If displaying moves, pause and check for keypress */
X if (redrawscreen) {
X freeze(delay);
X if (waitch(WAIT)) {
X c = getakey(0);
X switch (c) {
X case '0':
X case '1':
X case '2':
X case '3':
X case '4':
X case '5':
X case '6':
X case '7':
X case '8':
X case '9':
X delay = (c-'0')/10.0;
X break;
X case TOGGLEWIN:
X minidisplay = !minidisplay;
X break;
X case QUIT:
X if (query("Abort replay? ", 0)) goto finish;
X break;
X default:
X message("Paused...press a key to continue");
X drawpos(curpos);
X getakey(0);
X break;
X }
X }
X }
X } else {
X message("Oops! Duff move in %s", name);
X beep();
X goto finish;
X }
X
X if (curpos->dead) goto finish;
X }
X
X finish:
X minidisplay = mini;
X fclose(fp);
}
X
/* Display the solution to a level */
void
showsolution()
{
X /* Check solution exists */
X if (!solexists(level)) {
X message("Hints for this level are not available");
X return;
X }
X
X /* Ask them if they're REALLY sure */
X if (!query("Hints for this level - are you sure? ", 0)) return;
X if (!query("Are you REALLY REALLY sure? ", 0)) return;
X
X /* Do the replay */
X restorefile(solpath(level));
X query("Press any key to finish: ", 0);
X
X /* Reset to start position */
X curpos = firstpos;
X recentre();
}
SHAR_EOF
$shar_touch -am 0629152894 'save.c' &&
chmod 0444 'save.c' ||
echo 'restore of save.c failed'
shar_count="`wc -c < 'save.c'`"
test 5346 -eq "$shar_count" ||
echo "save.c: original size 5346, current size $shar_count"
fi
# ============= keys.c ==============
if test -f 'keys.c' && test X"$1" != X"-c"; then
echo 'x - skipping keys.c (File already exists)'
else
echo 'x - extracting keys.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'keys.c' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Keypress functions */
X
#if defined(BSDCURSES) || defined(SYSVR3)
#include <curses.h>
#else
#include <cursesX.h>
#endif
X
#include "defs.h"
X
/* VT100 cursor escape characters */
#define ARROW_PREFIX_1 '\033'
#define ARROW_PREFIX_2A '['
#define ARROW_PREFIX_2B 'O'
#define ARROW_UP 'A'
#define ARROW_DOWN 'B'
#define ARROW_RIGHT 'C'
#define ARROW_LEFT 'D'
X
/* Return the value of a pressed key, dealing with cursor keys */
int
keypress()
{
X int c;
X
X switch ((c = getakey(1))) {
X case ARROW_PREFIX_1:
X switch ((c = getakey(1))) {
X case ARROW_PREFIX_2A:
X case ARROW_PREFIX_2B:
X switch ((c = getakey(1))) {
X case ARROW_UP:
X return GONORTH;
X case ARROW_DOWN:
X return GOSOUTH;
X case ARROW_RIGHT:
X return GOEAST;
X case ARROW_LEFT:
X return GOWEST;
X default:
X return c;
X }
X default:
X return c;
X }
X default:
X return c;
X }
X
X /* NOTREACHED */
}
X
/* Return a pressed key */
int
getakey(int flag)
{
X int c;
X
X if (flag) nl();
#ifdef BSDCURSES
X c = getchar();
#else
X c = getch();
#endif
X if (flag) nonl();
X
X return c;
}
SHAR_EOF
$shar_touch -am 0623155694 'keys.c' &&
chmod 0444 'keys.c' ||
echo 'restore of keys.c failed'
shar_count="`wc -c < 'keys.c'`"
test 1318 -eq "$shar_count" ||
echo "keys.c: original size 1318, current size $shar_count"
fi
# ============= timer.c ==============
if test -f 'timer.c' && test X"$1" != X"-c"; then
echo 'x - skipping timer.c (File already exists)'
else
echo 'x - extracting timer.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'timer.c' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Timing functions */
X
#include <stdio.h>
#include <sys/time.h>
#include "defs.h"
X
#ifdef BSD42
#include <sys/timeb.h>
#endif
X
#ifdef SYSVR3
#include <sys/ioctl.h>
#endif
X
#ifdef XCURSES
#ifdef BSD42
#include <cursesX.h>
#else
#include <curses.h>
#endif
#endif
X
/* Wait a while */
void
freeze(double delay)
{
X int sec = (int) delay;
X int msec = (int) (1000 * (delay - sec));
X
X /* If delay is a whole number of seconds, use sleep() */
X if (msec < 5) {
X sleep(sec);
X } else if (msec > 995) {
X sleep(sec + 1);
X } else {
#ifdef BSDCURSES
#ifdef BSD42
X /* Keep checking the time using ftime(). This should really */
X /* use setitimer() but I couldn't get it to work properly for */
X /* intervals less than a second. */
X
X double now, future;
X struct timeb tb;
X
X ftime(&tb);
X future = tb.time + ((double) tb.millitm) / 1000 + delay;
X
X while (1) {
X ftime(&tb);
X now = tb.time + ((double) tb.millitm) / 1000;
X if (now >= future)
X return;
X }
#else /* SYSVR3 */
X /* BSD curses and SYSV? Is this combination even possible? */
X
X /* No ftime() - just sleep an integer no. */
X /* of seconds (rounded down) */
X
X sleep(sec);
#endif
#else /* XCURSES */
X sleep(sec);
X napms(msec);
#endif
X }
}
X
/*
X * Wait up to 'delay' microseconds for input to appear.
X * Returns 1 if input is ready, 0 otherwise.
X */
int
waitch(long delay)
{
#ifdef BSD42
X int fdbits;
X struct timeval duration;
X
X duration.tv_sec = 0L;
X duration.tv_usec = delay;
X fdbits = 1;
X
X return (select(32, &fdbits, 0, 0, &duration));
#else /* BSD42 */
#ifdef SYSVR3
X int nchars;
X
X if (ioctl(fileno(stdin), FIONREAD, &nchars) < 0) {
X perror("ioctl():");
X exit(1);
X }
X
X return (nchars > 0);
#else /* SYSVR3 */
X return 0;
#endif
#endif
}
SHAR_EOF
$shar_touch -am 0623155694 'timer.c' &&
chmod 0444 'timer.c' ||
echo 'restore of timer.c failed'
shar_count="`wc -c < 'timer.c'`"
test 1987 -eq "$shar_count" ||
echo "timer.c: original size 1987, current size $shar_count"
fi
# ============= help.c ==============
if test -f 'help.c' && test X"$1" != X"-c"; then
echo 'x - skipping help.c (File already exists)'
else
echo 'x - extracting help.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'help.c' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Help functions */
X
#ifndef lint
static char rcsid[] = "$Id: help.c,v 1.7 1994/06/23 14:56:13 glen Exp $";
#endif
X
#if defined(BSDCURSES) || defined(SYSVR3)
#include <curses.h>
#else
#include <cursesX.h>
#endif
X
#include "defs.h"
#include "data.h"
#include "proto.h"
#include "config.h"
X
#define PAGESIZE 20 /* Max page size */
#define DELIM "%%" /* Page delimiter */
#define PROMPT "Type 'q' to quit, any other key to continue: "
X
/* Display help file on screen */
static void
helpfile(char *file)
{
X int dlen = strlen(DELIM);
X int plen = strlen(PROMPT);
X int pcol = (COLS-2-plen)/2;
X int key, curline = 0;
X char buf[BUFSIZ];
X FILE *fp;
X
X /* Get pathname of help file */
X if (!wizard)
X sprintf(buf, "%s/%s", LIBDIR, file);
X else
X strcpy(buf, file);
X
X /* Open it */
X if ((fp = fopen(buf, "r")) == NULL) {
X message("Can't open %s", buf);
X beep();
X return;
X }
X
X /* Read and display file one page at a time */
X erase();
X while (fgets(buf, BUFSIZ, fp) != NULL) {
X buf[strlen(buf)-1] = '\0'; /* Strip newline */
X if (++curline == PAGESIZE || !strncmp(buf, DELIM, dlen)) {
X move(LINES-1, pcol);
X addstr(PROMPT);
X move(LINES-1, pcol+plen);
X refresh();
X
X key = keypress();
X switch (key) {
X case 'q':
X case 'Q':
X fclose(fp);
X return;
X default:
X curline = 0;
X erase();
X break;
X }
X } else {
X move(curline, 0);
X addstr(buf);
X }
X }
X
X move(LINES-1, pcol);
X addstr(PROMPT);
X move(LINES-1, pcol+plen);
X refresh();
X key = keypress();
X
X fclose(fp);
}
X
/* Give help on commands */
void
cmdinfo()
{
X helpfile("cmds.help");
}
X
/* Give help on display items */
void
displayinfo()
{
X helpfile(minidisplay ? "mini.help" : "full.help");
}
SHAR_EOF
$shar_touch -am 0623155894 'help.c' &&
chmod 0444 'help.c' ||
echo 'restore of help.c failed'
shar_count="`wc -c < 'help.c'`"
test 1983 -eq "$shar_count" ||
echo "help.c: original size 1983, current size $shar_count"
fi
# ============= will.c ==============
if test -f 'will.c' && test X"$1" != X"-c"; then
echo 'x - skipping will.c (File already exists)'
else
echo 'x - extracting will.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'will.c' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Humorous Shakespeare insult generator nicked from the net */
/* Use it in your own programs for added user-friendliness! 8-) */
X
#ifndef lint
static char rcsid[] = "$Id: will.c,v 1.3 1994/06/02 08:20:05 glen Exp $";
#endif
X
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
X
#define VECLEN(vec) (sizeof(vec)/sizeof(char *))
X
static char *adjv1[] = {
X "artless", "bawdy", "beslubbering", "bootless", "churlish",
X "cockered", "clouted", "craven", "currish", "dankish",
X "dissembling", "droning", "errant", "fawning", "fobbing",
X "froward", "frothy", "gleeking", "goatish", "gorbellied",
X "impertinent", "infectious", "jarring", "loggerheaded", "lumpish",
X "mammering", "mangled", "mewling", "paunchy", "pribbling",
X "puking", "puny", "quailing", "rank", "reeky", "roguish",
X "ruttish", "saucy", "spleeny", "spongy", "surly", "tottering",
X "unmuzzled", "vain", "venomed", "villainous", "warped", "wayward",
X "weedy", "yeasty",
};
X
static char *adjv2[] = {
X "base-court", "bat-fowling", "beef-witted", "beetle-headed",
X "boil-brained", "clapper-clawed", "clay-brained",
X "common-kissing", "crook-pated", "dismal-dreaming", "dizzy-eyed",
X "doghearted", "dread-bolted", "earth-vexing", "elf-skinned",
X "fat-kidneyed", "fen-sucked", "flap-mouthed", "fly-bitten",
X "folly-fallen", "fool-born", "full-gorged", "guts-griping",
X "half-faced", "hasty-witted", "hedge-born", "hell-hated",
X "idle-headed", "ill-breeding", "ill-nurtured", "knotty-pated",
X "milk-livered", "motley-minded", "onion-eyed", "plume-plucked",
X "pottle-deep", "pox-marked", "reeling-ripe", "rough-hewn",
X "rude-growing", "rump-fed", "shard-borne", "sheep-biting",
X "spur-galled", "swag-bellied", "tardy-gaited", "tickle-brained",
X "toad-spotted", "unchin-snouted", "weather-bitten",
};
X
static char *nounv[] = {
X "apple-john", "baggage", "barnacle", "bladder", "boar-pig",
X "bugbear", "bum-bailey", "canker-blossom", "clack-dish",
X "clotpole", "coxcomb", "codpiece", "death-token", "dewberry",
X "flap-dragon", "flax-wench", "flirt-gill", "foot-licker",
X "fustilarian", "giglet", "gudgeon", "haggard", "harpy",
X "hedge-pig", "horn-beast", "hugger-mugger", "jolthead",
X "lewdster", "lout", "maggot-pie", "malt-worm", "mammet", "measle",
X "minnow", "miscreant", "moldwarp", "mumble-news", "nut-hook",
X "pigeon-egg", "pignut", "puttock", "pumpion", "ratsbane", "scut",
X "skainsmate", "strumpet", "varlot", "vassal", "whey-face",
X "wagtail"
};
X
static char *
word(char *list[], int len)
{
X return list[RANDOM(len)];
}
X
char *
willie_phrase(void)
{
X static char buf[BUFSIZ];
X
X char *adj1 = word(adjv1, VECLEN(adjv1));
X char *adj2 = word(adjv2, VECLEN(adjv2));
X char *noun = word(nounv, VECLEN(nounv));
X
X sprintf(buf, "%s %s %s", adj1, adj2, noun);
X return buf;
}
SHAR_EOF
$shar_touch -am 0602092194 'will.c' &&
chmod 0444 'will.c' ||
echo 'restore of will.c failed'
shar_count="`wc -c < 'will.c'`"
test 3094 -eq "$shar_count" ||
echo "will.c: original size 3094, current size $shar_count"
fi
# ============= misc.c ==============
if test -f 'misc.c' && test X"$1" != X"-c"; then
echo 'x - skipping misc.c (File already exists)'
else
echo 'x - extracting misc.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'misc.c' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Miscellaneous functions */
X
#ifndef lint
static char rcsid[] = "$Id: misc.c,v 1.7 1994/06/29 14:27:42 glen Exp $";
#endif
X
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "defs.h"
#include "data.h"
#include "proto.h"
#include "config.h"
X
#define LOCKMODE 0666 /* Lock file permissions */
#define WAITTIME 0.5 /* Time between lock checks (sec) */
#define WAITCOUNT 10 /* Lock checks done before giving up */
X
/* Return the pathname of the score file */
char *
scorefile()
{
X static char buf[BUFSIZ];
X
X if (!wizard)
X sprintf(buf, "%s/scores", LIBDIR);
X else
X strcpy(buf, "scores");
X return buf;
}
X
/* Return pathname of the lock file */
static char *
lockfile()
{
X static char buf[BUFSIZ];
X
X if (!wizard)
X sprintf(buf, "%s/lock", LIBDIR);
X else
X strcpy(buf, "lock");
X return buf;
}
X
/* Return whether the score file is locked */
static int
scoreslocked()
{
X struct stat statbuf;
X char *path = lockfile();
X
X return (!stat(path, &statbuf));
}
X
/* Lock the score file if possible */
int
lockscores()
{
X int waitcount = 0, msg = 0;
X
X while (scoreslocked()) {
X if (!msg) {
X message("Locking score file...");
X drawpos(curpos);
X msg = 1;
X }
X
X freeze(WAITTIME);
X
X if (waitcount++ == WAITCOUNT) {
X message("Lock file is stuck - go and moan at %s", WIZARD);
X drawpos(curpos);
X freeze(2.0);
X return 0;
X }
X }
X
X creat(lockfile(), LOCKMODE);
X return 1;
}
X
/* Unlock the score file */
void
unlockscores()
{
X char *path = lockfile();
X
X unlink(path);
}
X
/* Return the pathname of a level file */
char *
levelpath(int num)
{
X static char buf[BUFSIZ];
X
X if (!wizard)
X sprintf(buf, "%s/screens/screen.%d", LIBDIR, num);
X else
X sprintf(buf, "screens/screen.%d", num);
X return buf;
}
X
/* Return the pathname of a solution file */
char *
solpath(int num)
{
X static char buf[BUFSIZ];
X
X if (!wizard)
X sprintf(buf, "%s/sol/sol.%d", LIBDIR, num);
X else
X sprintf(buf, "sol/sol.%d", num);
X return buf;
}
X
/* Return whether a level number is valid */
int
validlevel(int num)
{
X struct stat statbuf;
X char *path = levelpath(num);
X
X return (!stat(path, &statbuf));
}
X
/* Return whether a level solution exists */
int
solexists(int num)
{
X struct stat statbuf;
X char *path = solpath(num);
X
X return (!stat(path, &statbuf));
}
X
/* Return the number of available levels to play */
int
numlevels()
{
X int num = 1;
X
X while (validlevel(num)) num++;
X
X return num-1;
}
X
/* Return user ID of the player */
int
userid()
{
X return (int) getuid();
}
SHAR_EOF
$shar_touch -am 0629152894 'misc.c' &&
chmod 0444 'misc.c' ||
echo 'restore of misc.c failed'
shar_count="`wc -c < 'misc.c'`"
test 2846 -eq "$shar_count" ||
echo "misc.c: original size 2846, current size $shar_count"
fi
# ============= defs.h ==============
if test -f 'defs.h' && test X"$1" != X"-c"; then
echo 'x - skipping defs.h (File already exists)'
else
echo 'x - extracting defs.h (text)'
sed 's/^X//' << 'SHAR_EOF' > 'defs.h' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Player movement commands */
#define GONORTH 'k'
#define GOSOUTH 'j'
#define GOEAST 'l'
#define GOWEST 'h'
X
/* Other player commands */
#define RECENTRE 'r'
#define REDRAW ''
#define STAYPUT ' '
#define RESTART 's'
#define TOGGLEWIN 'w'
#define SAVE 'S'
#define RESTORE 'R'
#define NEXTLEVEL 'N'
#define SOLUTION 'H'
#define CMDHELP '?'
#define DISPHELP '/'
#define QUIT 'q'
X
/* Wizard commands */
#define JUMPLEVEL 'L'
#define FORWARD '+'
#define BACKWARD '-'
#define FIRSTPOS '<'
#define LASTPOS '>'
X
/* Screen dimensions */
#define MINWIDTH 10
#define MINHEIGHT 10
#define MAXWIDTH 60
#define MAXHEIGHT 20
#define WINLINES 8
#define WINCOLS 18
X
/* Extra moves gained by eating time capsule */
#define CAPSULEMOVES 250
X
/* Special effects */
enum {
X APPEAR, BLOWNUP, CAUGHT, EATEN, GAVEUP, SHOT, SQUASHED, TIMEUP,
X VANISH, WINNER,
};
X
/* Enums here must be in the same order as the entries in the */
/* obj[] array */
enum {
X ARRIVE, BABY, BABYNORTH, BABYEAST, BABYSOUTH, BABYWEST, BLANK,
X BOULDER, CAGE, CAPSULE, EARTH, EXIT, FILLER, LANDMINE, LARROW,
X LSLOPE, MONSTER, PLAYER, RARROW, ROCK1, ROCK2, ROCKET, RSLOPE,
X TELEPORT, TREASURE,
};
X
/* Order here determines baby monster movement (left-hand rule) */
enum {
X NONE = -1, NORTH, EAST, SOUTH, WEST,
};
X
struct object {
X int type; /* Symbol type */
X int sym; /* Symbol */
X char *bigsym[2]; /* Large symbol */
X int movedir; /* Direction it moves */
X int movepri; /* Movement priority */
X int bold; /* Display it in bold? */
X int kill; /* Kills you if you touch it? */
X int block; /* Blocks your move? */
X int push; /* Can you push it? */
X int sloped; /* Will things roll off it? */
X int eat; /* Can you eat it? */
X int score; /* Score if you eat it */
};
X
struct monster {
X int line, col; /* Position */
X int type; /* Monster type */
X int heading; /* Direction last moved in */
X int under; /* Symbol type underneath it */
X int dead; /* Is it dead? */
X struct monster *next; /* Next nasty in list */
};
X
struct pos {
X int **data; /* Screen layout */
X int pline, pcol; /* Where you are */
X struct monster *ml; /* List of monsters */
X int score; /* Score for this screen */
X int diamonds; /* No. of diamonds left */
X int monsters; /* No. of monsters left */
X int nmoves; /* No. of moves left */
X int dead; /* Are you dead? */
X int dir; /* Direction moved to get here */
X struct pos *prev, *next; /* Links */
};
X
struct loc {
X int line, col; /* Position */
X int type; /* What symbol it is */
};
X
struct slope {
X int lsdir, rsdir; /* Left/right slope directions */
};
X
struct dir {
X int line, col; /* Line/column offset */
};
SHAR_EOF
$shar_touch -am 0629135094 'defs.h' &&
chmod 0444 'defs.h' ||
echo 'restore of defs.h failed'
shar_count="`wc -c < 'defs.h'`"
test 2998 -eq "$shar_count" ||
echo "defs.h: original size 2998, current size $shar_count"
fi
# ============= data.h ==============
if test -f 'data.h' && test X"$1" != X"-c"; then
echo 'x - skipping data.h (File already exists)'
else
echo 'x - extracting data.h (text)'
sed 's/^X//' << 'SHAR_EOF' > 'data.h' &&
/*
X * Wander version 1.0, Copyright (C) 1994 G. Hutchings
X * Wander comes with ABSOLUTELY NO WARRANTY.
X * This is free software, and you are welcome to redistribute it
X * under certain conditions; see the file COPYING for details.
X */
X
/* Global data declarations */
X
#ifdef MAIN
X
/*
X * Object type flags
X *
X * 1 Direction it moves in (if it moves)
X * 2 Movement priority (if it moves)
X * 3 Whether to display it in bold (if possible)
X * 4 Does it kill you if you touch it?
X * 5 Does it block your move?
X * 6 Can you push it?
X * 7 Will things roll off it?
X * 8 Can you eat it?
X * 9 Score if you eat or kill it
X */
struct object obj[] = { /* 1 2 3 4 5 6 7 8 9 */
X ARRIVE, 'A', " ", " ", NONE, 0, 0, 0, 0, 0, 0, 0, 0,
X BABY, 'B', "-o-", "/*\\", NONE, 0, 0, 1, 0, 0, 0, 0, 50,
X BABYNORTH, 'N', " ", " ", NONE, 0, 0, 0, 0, 0, 0, 0, 0,
X BABYEAST, 'E', " ", " ", NONE, 0, 0, 0, 0, 0, 0, 0, 0,
X BABYSOUTH, 'S', " ", " ", NONE, 0, 0, 0, 0, 0, 0, 0, 0,
X BABYWEST, 'W', " ", " ", NONE, 0, 0, 0, 0, 0, 0, 0, 0,
X BLANK, ' ', " ", " ", NONE, 0, 0, 0, 0, 0, 0, 0, 0,
X BOULDER, 'O', "/^\\", "\\_/", SOUTH, 1, 0, 0, 0, 1, 1, 0, 0,
X CAGE, '+', "TTT", "III", NONE, 0, 0, 0, 1, 0, 0, 0, 0,
X CAPSULE, 'C', " ", "<O>", NONE, 0, 1, 0, 0, 0, 0, 1, 5,
X EARTH, ':', ". .", " . ", NONE, 0, 0, 0, 0, 0, 0, 1, 1,
X EXIT, 'X', "Way", "Out", NONE, 0, 1, 0, 0, 0, 0, 1, 250,
X FILLER, '-', " ", " ", NONE, 0, 0, 0, 0, 0, 0, 0, 0,
X LANDMINE, '!', " I ", " o ", NONE, 0, 0, 1, 0, 0, 0, 0, 0,
X LARROW, '<', "<--", "<--", WEST, 3, 0, 0, 0, 1, 0, 0, 0,
X LSLOPE, '\\', "\\_ ", " \\", NONE, 0, 0, 0, 1, 0, 1, 0, 0,
X MONSTER, 'M', "}o{", "/^\\", NONE, 0, 0, 1, 0, 0, 0, 0, 100,
X PLAYER, '@', " o ", "<|>", NONE, 0, 0, 0, 0, 0, 0, 0, 0,
X RARROW, '>', "-->", "-->", EAST, 3, 0, 0, 0, 1, 0, 0, 0,
X ROCK1, '#', "###", "###", NONE, 0, 0, 0, 1, 0, 0, 0, 0,
X ROCK2, '=', "-=-", "=-=", NONE, 0, 0, 0, 1, 0, 0, 0, 0,
X ROCKET, '^', " ^ ", "/^\\", NORTH, 2, 0, 0, 0, 1, 1, 0, 0,
X RSLOPE, '/', " _/", "/ ", NONE, 0, 0, 0, 1, 0, 1, 0, 0,
X TELEPORT, 'T', "(*)", "(*)", NONE, 0, 1, 0, 0, 0, 0, 1, 50,
X TREASURE, '*', "/$\\", "\\$/", NONE, 0, 1, 0, 0, 0, 0, 1, 10,
};
X
/* Order corresponds to order of direction enums */
struct dir dirs[] = {
X { -1, 0 }, { 0, 1 }, { 1, 0}, { 0, -1 },
};
X
/* Order corresponds to order of direction enums */
struct slope slopes[] = {
X WEST, EAST,
X SOUTH, NORTH,
X EAST, WEST,
X NORTH, SOUTH,
};
X
int numobj = sizeof(obj)/sizeof(obj[0]); /* No. of object types */
int numdir = sizeof(dirs)/sizeof(dirs[0]); /* No. of directions */
X
int bordersize = 1; /* Distance to screen edge before scrolling */
int donelevel; /* Whether you've already done this level */
int redrawscreen = 1; /* Whether to update screen when replaying */
int exited; /* Whether current level is finished */
int minidisplay = 0; /* Whether to display whole level */
int hidescore = 0; /* Whether to hide score on main table */
int level; /* Current level */
int maxlevel; /* Biggest level reached so far */
int myuid; /* Player's UID */
int nlevels; /* No. of levels available */
int nlines, ncols; /* Screen dimensions */
int screeninit = 0; /* Whether screen initialized */
int testlevel = 0; /* Whether testing a level file */
int tline, tcol; /* Teleport destination */
int wizard; /* Whether in wizard mode */
int wline, wcol; /* Your window position */
int xchars = 0; /* Whether to use extended character set */
X
struct pos *firstpos = NULL; /* Initial screen position */
struct pos *curpos; /* Current screen position */
struct pos *lastpos = NULL; /* Latest screen position */
X
#else
X
extern int nlines, ncols, tline, tcol, myuid, donelevel;
extern int wline, wcol, level, screeninit, maxlevel;
extern int minidisplay, numobj, exited, numdir, nlevels;
extern int maxlevel, wizard, redrawscreen, testlevel;
extern int bordersize, xchars, hidescore;
X
extern struct pos *firstpos, *curpos, *lastpos;
extern struct dir dirs[];
extern struct slope slopes[];
extern struct object obj[];
X
#endif
SHAR_EOF
$shar_touch -am 0616155094 'data.h' &&
chmod 0444 'data.h' ||
echo 'restore of data.h failed'
shar_count="`wc -c < 'data.h'`"
test 4115 -eq "$shar_count" ||
echo "data.h: original size 4115, current size $shar_count"
fi
: || echo 'restore of effect.h failed'
echo 'End of part 2, continue with part 3'
exit 0