games-request@tekred.TEK.COM (07/24/87)
Submitted by: "J.D. McDonald " <mcdonald@uxe.cso.uiuc.edu>
Comp.sources.games: Volume 1, Issue 106
Archive-name: world/Part07
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 7 (of 7)."
# Contents: helper.c
# Wrapped by billr@tekred on Thu Jul 23 17:18:03 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f helper.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"helper.c\"
else
echo shar: Extracting \"helper.c\" \(26257 characters\)
sed "s/^X//" >helper.c <<'END_OF_helper.c'
X#include <stdio.h>
X#include "parame.inc"
X#include "variab.h"
X#include "arrays.h"
X#include "qtext.inc"
X
X#define Q1TEXT "/usr/games/lib/q1text.dat"
X
X/* World C Version 1.00 copyright 1987 J.D.McDonald
X Use as you like for non-commercial purposes, but please
X leave this note, and document any changes you make as yours */
X
Xstatic int start = 0;
Xint q1text_dat;
Xstatic int debugflg = 1;
Xstatic char filenm[] = "world.sav";
X
Xstatic short buffer[512];
Xstatic long filepos, oldpos;
X
X
Xspeak(point)
X int point;
X{
X /*
X * this is the main routine to output text from the data file the word
X * rtext(point) points to the proper record in the file
X */
X int i, bi, t, kk;
X long z;
X
X if (start == 0) {
X start += 1;
X oldpos = -1;
X q1text_dat = open(Q1TEXT, 0);
X }
X z = (long) ((unsigned long) rtext[point]);
X filepos = z * 2 & ~1023l;
X if (filepos != oldpos) {
X oldpos = filepos;
X lseek(q1text_dat, filepos, 0);
X read(q1text_dat, buffer, 512*sizeof(short));
X }
X bi = z & 511;
X do {
X kk = 0;
X while (1) {
X if (bi == 512) {
X oldpos += 1024;
X lseek(q1text_dat, oldpos, 0);
X read(q1text_dat, buffer, 512*sizeof(short));
X bi = 0;
X }
X t = buffer[bi];
X z++;
X bi++;
X
X if (t < 0) {
X t = -t;
X outst2[kk++] = t & 127;
X outst2[kk++] = t >> 8;
X } else {
X outst2[kk++] = (t % 32) + 96;
X outst2[kk++] = ((t >> 5) % 32) + 96;
X outst2[kk++] = t / 1024 + 96;
X if (outst2[kk - 3] == '{') {
X kmax = kk - 4;
X break;
X }
X }
X if (outst2[kk - 2] == '{') {
X kmax = kk - 3;
X break;
X } else if (outst2[kk - 1] == '{') {
X kmax = kk - 2;
X break;
X }
X }
X for (i = 0; i <= kmax; i++) {
X if (outst2[i] == '`')
X outst2[i] = ' ';
X if (outst2[i] == '|')
X outst2[i] = '.';
X }
X if (wwflag == 0)
X linout(outst2, kmax + 1);
X } while (z < rtext[point + 1]);
X}
X
Xvlocat(i, h)
X int i, h;
X{
X int k, p, r, nowir, xloc, xturn;
X /*
X * code for "l" or "locate" but NOT "look" gtext(2) points to short
X * descriptions in the location area of the text file, while gtext(1)
X * points to the long ones
X */
X
X if (brfflg == 2 || i == 1 || ((locdat[loc] & 16384) == 0
X && brfflg != 0) || (loc >= 101 && loc <= 116))
X xloc = loc + gtext[1];
X else
X xloc = loc + gtext[2];
X speak(xloc);
X if (loc == 89) {
X if (easttm == 0) {
X speak(372);
X eastsc |= 1;
X } else if (easttm > 0 && easttm <= 50) {
X speak(373);
X eastsc |= 2;
X } else if (easttm == 51)
X speak(374);
X else {
X speak(375);
X eastsc |= 4;
X }
X }
X xturn = turns % 100;
X if (turns < 8)
X xturn = 8;
X if (h == 0)
X return;
X /* this section prints out the objects at "loc" */
X for (k = 1; k <= OBJMAX; k++) {
X p = obimpr[k];
X if (!((k <= MOVMAX && obloc[k] != loc) ||
X (k > MOVMAX && (obw3[k] != loc && obw4[k] != loc)) ||
X (k == HPUCK && loc == 38 && marflg[1]))) {
X r = (p / 8) % 8;
X if (r >= 1) {
X if ((p & 1) == 1)
X speak(odistb[k] + r);
X }
X if (!(obpprp[k] / 2048 == 0 && k != ZROBOT))
X xcontn(k);
X } continue;
X }
X /* standing on something? */
X if (spcloc == 1)
X speak(212);
X if (spcloc == 2) {
X if (dirty == 0)
X speak(509);
X else
X speak(510);
X }
X /* is the wire lying on the ground */
X nowir = 1;
X for (i = 0; i < 6; i++) {
X if (wirelc[i] == loc)
X nowir = 0;
X }
X if (nowir == 0)
X speak(215);
X
X if ((loc == 76 || loc == 77 || loc == 79) && obloc[ZCAT] ==
X 80)
X speak(280);
X /* flowers following sun */
X if (loc == 86 && xturn > 6 && xturn < 69 && obimpr[ZSEED] > 4000)
X speak(341);
X /* vine describe */
X if (loc == 74 && obimpr[ZVINE] == 9) {
X speak(339);
X obimpr[ZVINE] = 8201;
X } else if (loc == 74 && obimpr[ZVINE] == 8201)
X speak(259);
X}
X
Xvinven()
X/* "inventory" */
X{
X int carryn, wearn, i, k;
X
X carryn = 0;
X wearn = 0;
X if (wirelc[5] == 1000)
X carryn = 1;
X for (i = 1; i <= MOVMAX; i++) {
X if (obloc[i] == 1000)
X carryn = 1;
X if (obloc[i] == 3000)
X wearn = 1;
X }
X if (carryn == 1) {
X speak(62);
X xindnt += 2;
X if (wirelc[5] == 1000)
X speak(256);
X for (k = 1; k <= MOVMAX; k++) {
X if (obloc[k] != 1000)
X continue;
X speak(odistb[k]);
X if (obpprp[k] / 2048 != 0)
X xcontn(k);
X }
X xindnt -= 2;
X }
X if (wearn == 1) {
X speak(63);
X xindnt += 2;
X for (k = 1; k <= MOVMAX; k++) {
X if (obloc[k] != 3000)
X continue;
X speak(odistb[k]);
X if (obpprp[k] / 2048 != 0)
X xcontn(k);
X }
X xindnt -= 2;
X }
X if (carryn == 0 && wearn == 0)
X speak(64);
X nonext = 1;
X}
X
Xxcontn(k) /* RECURSIVE FUNCTION */
X int k;
X{
X int p, empty, k1;
X /*
X * list contents of a container
X * calls itself recursively to list things inside other containers
X */
X
X if (k == LFUNNE || k == MFUNNE || k == RFUNNE)
X return;
X p = obimpr[k];
X if ((p & 2) == 0 || (obpprp[k] & 128) == 0) {
X empty = 1;
X for (k1 = 1; k1 <= MOVMAX; k1++)
X if (obloc[k1] == k + 2000)
X empty = 0;
X if (empty) {
X xindnt += 2;
X speak(odistb[k] + ((p / 512) % 8));
X xindnt -= 2;
X } else {
X xindnt += 2;
X speak(odistb[k] + ((p / 512) % 8) + 1);
X xindnt += 2;
X for (k1 = 1; k1 <= MOVMAX; k1++) {
X if (obloc[k1] == k + 2000) {
X speak(odistb[k1]);
X if (obpprp[k1] / 2048 != 0)
X xcontn(k1);
X }
X }
X xindnt -= 4;
X }
X } else if ((p & 2) != 0 && (obpprp[k] & 128) != 0 && prepdo == IN)
X speak(386);
X}
X
Xdbg()
X{
X if(debugflg == 0) return;
X debugflg = 2;
X printf(" loc is %5d \n", loc);
X printf(" enter new loc ");
X scanf("%d", &loc);
X}
X
Xscorng()
X{
X int result, i, q, v, l, n, plce, xplc;
X result = 0;
X if (loc >= 153)
X return (0);
X result = (diesc - 3) * 2;
X if (result < 0)
X result = 0;
X if (cactsc == 1 || cactsc == 2)
X result += 2;
X if (cactsc == 3)
X result += 4;
X if ((eastsc & 1) != 0)
X result += 2;
X if ((eastsc & 2) != 0)
X result += 2;
X if ((eastsc & 4) != 0)
X result += 2;
X if(debugflg == 2)
X printf(" east+cact %5d out of 10\n",result);
X for (i = 1; i <= MOVMAX; i++) {
X q = obw4[i];
X v = q / 4096;
X l = q - v * 4096;
X if (v == 0)
X continue;
X n = 0;
X itsher(i, &plce);
X if (i == GDISC) {
X if (plce != 0 && rvtim == 2)
X n = v;
X } else if (l >= 4000 && l - 4000 != obloc[i])
X n = v;
X else if (l == 3000 && obloc[i] == 3000)
X n = v;
X else if (l == 1000 && (plce == 1 || plce == 3))
X n = v;
X else if (l == 3000 && (plce == 1 || plce == 3))
X n = v / 2;
X else if (l < 1000 && l == obloc[i])
X n = v;
X else if (l > 2000 && l < 3000 && obloc[i] == l) {
X itsher((l - 2000), &xplc);
X if (xplc > 0 && xplc <= 3)
X n = v;
X }
X result += n;
X if(debugflg == 2)printf("obj %5d %5d points out of %5d\n",i,n,v);
X }
X if (deadf)
X result -= 5;
X if (result < 0)
X result = 0;
X result *= 5;
X return (result);
X}
X
Xgetrob(don, doa)
X int don, doa;
X{
X int result, i;
X /*
X * search table for object return object number if found and unambiguous
X * return 0 if not found return -1 if ambiguous
X */
X
X for (i = 1; i <= OBJMAX; i++) {
X if (don != obnoun[i])
X continue;
X if ((doa == abs(obadjv[i])) || (doa == 0 && obadjv[i] < 0))
X return (i);
X else if (doa == 0 && obadjv[i] > 0)
X result = -1;
X else
X result = 0;
X }
X return (result);
X}
X
X static char sstring[] =
X "Your score is out of a total of in turns.";
X static int breakp[] = {0, 35, 70, 90, 130, 170, 210, 260, 330,
X 380, 450, 900};
Xscorpt(scor, mxsc)
X int scor, mxsc;
X{
X char cnum[4];
X int i;
X
X numcvt(scor, cnum);
X sstring[14] = cnum[1];
X sstring[15] = cnum[2];
X sstring[16] = cnum[3];
X numcvt(mxsc, cnum);
X sstring[36] = cnum[1];
X sstring[37] = cnum[2];
X sstring[38] = cnum[3];
X numcvt(turns, cnum);
X sstring[43] = cnum[0];
X sstring[44] = cnum[1];
X sstring[45] = cnum[2];
X sstring[46] = cnum[3];
X linout(sstring, 54);
X for (i = 0; i < 10; i++) {
X if (scor >= breakp[i] && scor < breakp[i + 1])
X break;
X }
X speak(481 + i);
X
X}
X
Xnumcvt(num, cnum)
X int num;
X char *cnum;
X{
X int lx, m;
X
X m = num / 1000;
X lx = (m) ? '0' + m : ' ';
X *cnum++ = lx;
X m = (num / 100) % 10;
X lx = (m == 0 && lx == ' ') ? ' ' : '0' + m;
X *cnum++ = lx;
X m = (num / 10) % 10;
X lx = (m == 0 && lx == ' ') ? ' ' : '0' + m;
X *cnum++ = lx;
X m = num % 10;
X *cnum = '0' + m;
X}
X
Xrobdsc()
X{
X int rempty, lempty, k;
X
X if (obloc[ZROBOT] >= 90 && obloc[ZROBOT] <= 95)
X speak(gtext[1] + obloc[ZROBOT]);
X else
X speak(226 + obloc[ZROBOT]);
X rempty = 1;
X lempty = 1;
X for (k = 1; k <= MOVMAX; k++) {
X if (obloc[k] == 2000 + ZROBOT)
X rempty = 0;
X if (obloc[k] == obloc[ZROBOT] && k != ZROBOT)
X lempty = 0;
X }
X if (rempty == 0) {
X speak(odistb[ZROBOT] + 5);
X for (k = 1; k <= MOVMAX; k++) {
X xindnt += 2;
X if (obloc[k] == 2000 + ZROBOT)
X speak(odistb[k]);
X xindnt -= 2;
X }
X }
X if (lempty == 0) {
X speak(350);
X for (k = 1; k <= MOVMAX; k++) {
X xindnt += 2;
X if (k != ZROBOT && obloc[k] == obloc[ZROBOT])
X speak(odistb[k]);
X xindnt -= 2;
X }
X }
X if (obloc[ZROBOT] == 90 && (obloc[ZORCHI] == 2000 + ZROBOT
X || obloc[ZFLYTR] == 2000 + ZROBOT))
X speak(353);
X}
X
X
Xendsl()
X{
X /* dummy routine to maybe clear screen? */
X}
X
X
Xvdead()
X{
X int i;
X /*
X * "you're dead,fred" it is incumbent on the calling routine to get to
X * where the body is supposed to lie, and to set oldloc and oldlc2 to
X * ,usually, 0 this routine sets deadf to .true. and drops all his
X * possessions where he is now
X */
X
X eattim = 0;
X rdietm = 0;
X deadf = 1;
X for (i = 1; i <= MOVMAX; i++)
X if (obloc[i] == 1000 || obloc[i] == 3000)
X obloc[i] = loc;
X if (loc < 153)
X speak(55);
X else
X speak(552);
X nonext = 1;
X eolflg = 1;
X spcloc = 0;
X for (i = 0; i < 6; i++)
X if (wirelc[i] == 1000)
X wirelc[i] = loc;
X if (wirelc[0] != obloc[ZWIRE])
X return;
X for (i = 0; i < 6; i++)
X wirelc[i] = 0;
X diesc += 1;
X}
X
Xitsher(objt, plce)
X int objt;
X int *plce;
X{
X int n1;
X /*
X * this subroutine tells if an object is either: being carried plce=1
X * being worn plce=2 inside something being carried,and not hidden
X * from view (3) at "loc" and not hidden (4) inside something at loc (5)
X */
X
X *plce = 0;
X if (objt <= MOVMAX) {
X if (obloc[objt] == 1000)
X *plce = 1;
X else if (obloc[objt] == 3000)
X *plce = 2;
X else if (obloc[objt] == loc && (obimpr[objt] & 1) == 1)
X *plce = 4;
X else if (obloc[objt] > 2000 && obloc[objt] < 3000) {
X n1 = obloc[objt] - 2000;
X if (n1 <= MOVMAX) {
X if ((obloc[n1] == 1000 || obloc[n1] == 3000)
X && (obimpr[n1] & 2) == 0)
X *plce = 3;
X else if (obloc[n1] == loc && ((obimpr[n1] & 1) == 1)
X && ((obimpr[n1] & 2) == 0))
X *plce = 5;
X else;
X } else if ((obw3[n1] == loc || obw4[n1] == loc) &&
X ((obimpr[n1] & 1) == 1) && ((obimpr[n1] & 2) == 0))
X *plce = 5;
X else;
X } else;
X } else if ((obw3[objt] == loc || obw4[objt] == loc) &&
X ((obimpr[objt] & 1) == 1))
X *plce = 4;
X}
X
Xburden(ncarrd, nweigh, kcarrd, kweigh)
X int *ncarrd, *nweigh, *kcarrd, *kweigh;
X{
X int i;
X /*
X * calculate weight and number of objects on adventurer and in knapsack
X */
X
X
X *ncarrd = 0;
X *nweigh = 0;
X for (i = 1; i <= MOVMAX; i++) {
X if (obloc[i] != 1000)
X continue;
X *ncarrd += 1;
X *nweigh += obw3[i] / 256;
X }
X *kcarrd = 0;
X *kweigh = 0;
X for (i = 1; i <= MOVMAX; i++) {
X if (i == ZKNAPS || obloc[i] != (2000 + ZKNAPS))
X continue;
X *kcarrd += 1;
X *kweigh += obw3[i] / 256;
X }
X}
X
Xgetobj(don, doa)
X int don, doa;
X{
X /*
X * search table for object return object number if found and unambiguous
X * return 0 if not found return -1 if ambiguous
X */
X
X int result, i, g1, g2, ggg, ddd, sum;
X int aplce, bplce, cplce, dplce, fplce, gplce, mplce, nplce, oplce, pplce;
X int splce, tplce;
X result = 0;
X for (i = 1; i <= OBJMAX; i++) {
X
X if (don != obnoun[i])
X continue;
X if ((doa == abs(obadjv[i]) && doa != BEAUTI && doa !=
X VENDIN) || (doa == 0 && obadjv[i] < 0)) {
X result = i;
X return (result);
X } else if ((doa == 0 && obadjv[i] > 0) || (doa == VENDIN &&
X don == MACHIN) || (doa == BEAUTI && don == BIRD)) {
X if (don == FISH) {
X if (obloc[CFISH] != 0)
X result = CFISH;
X else
X result = DFISH;
X } else if (don == PANTS) {
X itsher(RPANT, &g1);
X itsher(LPANT, &g2);
X if (g1 != 0 && g2 == 0)
X result = RPANT;
X else if (g1 == 0 && g2 != 0)
X result = LPANT;
X else if ((wrdnum[0] == TAKE && prepdo == OFF) ||
X wrdnum[0] == REMOVE) {
X if (g1 == 2)
X result = RPANT;
X else
X result = LPANT;
X } else if (wrdnum[0] == DROP)
X if (((g1 == 1) || (g1 == 3)) && g2 != 1 && g2 != 3)
X result = RPANT;
X if (((g2 == 1) || (g2 == 3)) && g1 != 1 && g1 != 3)
X result = LPANT;
X else
X result = -1;
X } else if (don == SHIRT) {
X itsher(RSHIRT, &g1);
X itsher(GSHIRT, &g2);
X if (g1 != 0 && g2 == 0)
X result = RSHIRT;
X else if (g1 == 0 && g2 != 0)
X result = GSHIRT;
X else if ((wrdnum[0] == TAKE && prepdo == OFF) ||
X wrdnum[0] == REMOVE) {
X if (g1 == 2)
X result = RSHIRT;
X else
X result = GSHIRT;
X } else if (wrdnum[0] == DROP) {
X if (((g1 == 1) || (g1 == 3)) && g2 != 1 && g2 != 3)
X result = RSHIRT;
X if (((g2 == 1) || (g2 == 3)) && g1 != 1 && g1 != 3)
X result = GSHIRT;
X } else
X result = -1;
X } else if (don == DOOR) {
X if (loc == 41 || loc == 135)
X result = MDOOR;
X else if (loc == 85 || loc == 136)
X result = GDOOR;
X else if (loc == 47 || loc == 51)
X result = RDOOR;
X else if (loc == 165 || loc == 166)
X result = ODOOR;
X else if (loc == 173)
X result = PDOOR;
X else if (loc == 175)
X result = BDOOR;
X else
X result = -1;
X } else if (don == CARTRI) {
X itsher(ZCART, &tplce);
X itsher(CCART, &cplce);
X if (tplce > 0 && cplce <= 0)
X result = ZCART;
X else if (tplce <= 0 && cplce > 0)
X result = CCART;
X else
X result = -1;
X } else if (don == PHOTOG) {
X itsher(PPHOTO, &pplce);
X itsher(MPHOTO, &mplce);
X itsher(OPHOTO, &oplce);
X itsher(APHOTO, &aplce);
X itsher(FPHOTO, &fplce);
X pplce = (pplce < 1) ? pplce : 1;
X mplce = (mplce < 1) ? mplce : 1;
X oplce = (oplce < 1) ? oplce : 1;
X aplce = (aplce < 1) ? aplce : 1;
X fplce = (fplce < 1) ? fplce : 1;
X sum = pplce + mplce + oplce + aplce + fplce;
X {
X if (sum == 0)
X result = 0;
X else if (sum > 1)
X result = -1;
X else {
X if (pplce != 0)
X result = PPHOTO;
X if (mplce != 0)
X result = MPHOTO;
X if (oplce != 0)
X result = OPHOTO;
X if (aplce != 0)
X result = APHOTO;
X if (fplce != 0)
X result = FPHOTO;
X }
X }
X } else if (don == BIRD) {
X if (loc == 65 || loc == 66)
X result = RBIRD;
X else if (loc == 78 || loc == 79)
X result = XBIRD;
X else if (loc == 77 || loc == 80)
X result = YBIRD;
X else if (loc == 75 || loc == 76)
X result = ZBIRD;
X else
X result = 0;
X } else if (don == BUTTON) {
X if (loc == 146 || loc == 134)
X result = -1;
X else if (loc == 143)
X result = RDBUTT;
X else if (loc == 169)
X result = GBUTTO;
X else
X result = 0;
X } else if (don == CABLE || don == DISC) {
X if (don == CABLE) {
X ddd = DCABLE;
X ggg = GCABLE;
X } else {
X ddd = BDISC;
X ggg = GDISC;
X }
X itsher(ddd, &dplce);
X itsher(ggg, &gplce);
X if (dplce == 0 && gplce == 0)
X result = 0;
X else {
X if (wrdnum[0] == DROP) {
X if ((dplce == 1 || dplce == 3) && (gplce != 1
X && gplce != 3))
X result = ddd;
X else if ((gplce == 1 || gplce == 3) &&
X (dplce != 1 && dplce != 3))
X result = ggg;
X else
X result = -1;
X } else if (wrdnum[0] == TAKE) {
X if ((dplce == 4 || dplce == 5) && (gplce != 4
X && gplce != 5))
X result = ddd;
X else if ((gplce == 4 || gplce == 5) &&
X (dplce != 4 && dplce != 5))
X result = ggg;
X else
X result = -1;
X } else {
X if (gplce == 0 && dplce != 0)
X result = ddd;
X else if (dplce == 0 && gplce != 0)
X result = ggg;
X else
X result = -1;
X }
X }
X } else if (don == MACHIN) {
X if (loc == 153)
X result = PMACH;
X else if (loc == 156)
X result = TMACH;
X else if (loc == 158)
X result = NMACH;
X else if (loc == 160)
X result = SMACH;
X else if (loc == 162)
X result = MMACH;
X } else if (don == SLOT) {
X if (loc == 146)
X result = RSLOT;
X else if (loc == 156)
X result = TSLOT;
X else if (loc == 158)
X result = NSLOT;
X else if (loc == 160)
X result = SSLOT;
X else if (loc == 162)
X result = MSLOT;
X } else if (don == COIN) {
X if (loc < 153)
X result = SCOIN;
X else {
X itsher(SCOIN, &splce);
X itsher(BCOIN, &bplce);
X itsher(CCOIN, &cplce);
X itsher(NCOIN, &nplce);
X itsher(PCOIN, &pplce);
X pplce = (pplce < 1) ? pplce : 1;
X nplce = (nplce < 1) ? nplce : 1;
X cplce = (cplce < 1) ? cplce : 1;
X bplce = (bplce < 1) ? bplce : 1;
X splce = (splce < 1) ? splce : 1;
X sum = pplce + nplce + cplce + bplce + splce;
X if (sum == 0)
X result = 0;
X else if (sum > 1)
X result = -1;
X else {
X if (splce != 0)
X result = SCOIN;
X if (bplce != 0)
X result = BCOIN;
X if (cplce != 0)
X result = CCOIN;
X if (nplce != 0)
X result = NCOIN;
X if (pplce != 0)
X result = PCOIN;
X }
X }
X } else
X result = -1;
X return (result);
X }
X }
X return (result);
X}
X static char strng1[] = " I can't do that to item on your list.";
X static char strng2[] = " Item number on your list is ambiguous";
X
Xcnvobj()
X{
X char cnum[4];
X int result, many, i, k, n, p, z;
X
X /*
X * this routine searches the list of objects and compares with the list
X * of d.o.'s if an object exists and is unambiguous it's entry in dobjs
X * is replaced by its object number otherwise its entry in dobjs is set
X * to zero the entries in dobsj are then squeezed up if the result was
X * totally unambiguous cnvobj is .true.
X */
X
X result = 1;
X n = 0;
X if (allflg)
X n = 1;
X many = 0;
X if ((butflg && dobjs[2] != 0) || ((!butflg) &&
X dobjs[1] != 0))
X many = 1;
X k = 0;
X z = -1;
X for (i = n; i < 12; i++) {
X k += 1;
X if (dobjs[i] == 0)
X break;
X p = getobj(dobjs[i], doadjs[i]);
X if (p > 0) {
X z += 1;
X dobjs[z] = p;
X } else if (p == 0) {
X if (many == 1) {
X numcvt(k, cnum);
X strng1[28] = cnum[2];
X strng1[29] = cnum[3];
X linout(strng1, 44);
X } else
X speak(422);
X } else {
X result = 0;
X if (many == 1) {
X numcvt(k, cnum);
X strng2[16] = cnum[2];
X strng2[17] = cnum[3];
X linout(strng2, 44);
X } else
X speak(70);
X speak(250);
X }
X }
X while (++z < 30)
X dobjs[z] = 0;
X return (result);
X}
X
Xgetall()
X{
X
X int temp[30], i, k, d, m;
X /*
X * routine to get "all" or "all but" objects it only works on moveable
X * objects because the only verbs which call it work only on those
X * objects (drop,take, put)
X */
X
X for (i = 0; i < 30; i++) {
X temp[i] = dobjs[i];
X dobjs[i] = 0;
X }
X k = 0;
X for (i = 1; i <= MOVMAX; i++) {
X itsher(i, &d);
X if (d == 0)
X continue;
X for (m = 0; m < 30; m++)
X if (temp[m] == i)
X goto endloop;
X if (k == 29) {
X speak(106);
X return;
X }
X dobjs[k++] = i;
Xendloop:
X ;
X }
X}
X
X
Xrdinit()
X{
X long t;
X long tloc;
X long time();
X int ti;
X t = time(&tloc);
X ti =( (int) t) & 32767;
X srand(ti);
X}
X
Xqrand()
X{
X return ((rand() & 16383) / 4);
X}
X
X
Xpct(q)
X int q;
X{
X int j;
X
X j = rand();
X return ((q * 327) > (j & 32767));
X}
X
Xyesx(spk)
X int spk;
X{
X char ans[90];
X /* ask question, and wait for reply from him */
X
X
X speak(spk);
X more = 0;
X while (1) {
X linout("?", 2001);
X gets(ans);
X more = 1;
X if (strcmp(ans, "Y") == 0 || strcmp(ans, "YES") == 0
X || strcmp(ans, "y") == 0 || strcmp(ans, "yes") == 0)
X return (1);
X else if (strcmp(ans, "N") == 0 || strcmp(ans, "NO") == 0
X || strcmp(ans, "n") == 0 || strcmp(ans, "no") == 0)
X return (0);
X else
X speak(102);
X }
X}
X
Xgetln()
X{
X /* write a prompt, then read a line from the terminal */
X
X int i, lastpos;
X linout(">", 7001);
X
X gets(inbuf);
X eolflg = 0;
X lastpos = strlen(inbuf);
X lastpos = (lastpos > 78) ? 78 : lastpos;
X for (i = lastpos; i < 83; i++)
X inbuf[i] = '.';
X more = 1;
X inbuf[127] = lastpos;
X}
X
X
Xcarerr(x, z)
X int x, z;
X{
X /*
X * this nifty routine put a caret on the terminal at the indicated
X * position of a line and then outputs a message
X */
X /* if not the first sentence on a line, rewrite line. */
X
X if (clause != 1) {
X linout(" ", 1001);
X linout(inbuf, inbuf[127]);
X }
X if (x > 0) {
X xindnt = x;
X linout("^", 1);
X xindnt = 0;
X } else {
X if (clause != 1) {
X xindnt = lptr - 1;
X linout("*", 1);
X xindnt = 0;
X speak(423);
X }
X }
X speak(z);
X}
X
Xlinout(ustring, num)
X char *ustring;
X int num;
X
X{
X int num1, i;
X char buff[80];
X char *cptr;
X
X cptr = buff;
X num1 = num % 1000;
X for (i = 0; i < xindnt; i++)
X *cptr++ = ' ';
X
X for (i = 0; i < num1; i++)
X *cptr++ = *ustring++;
X
X *cptr++ = '\0';
X if (num < 1000) {
X if(more == 19 && nomor == 0) {
X i = strlen(buff);
X for( ; i < 74; i++)
X buff[i] = ' ';
X strcpy(&buff[74],"MORE");
X printf("%1s", buff);
X gets(buff);
X more = 0;
X }
X else {
X printf("%1s\n", buff);
X more += 1;
X }
X }
X else
X printf("%1s", buff);
X}
X
X
Xvsuspe(inout)
X int inout;
X{
X short sbuffer[256];
X int result, filedes, i, iret;
X short *sbptr, *iptr;
X result = 0;
X
X if (inout != 1) {
X /* "suspend" or "save" */
X
X filedes = creat(filenm, 0600);
X if (filedes == -1) {
X linout("I failed to create your save file.", 34);
X return (result);
X }
X sbptr = sbuffer;
X *sbptr++ = horflg;
X for (i = 0; i < 6; i++)
X *sbptr++ = wirelc[i];
X *sbptr++ = turns;
X *sbptr++ = loc;
X *sbptr++ = oldloc;
X *sbptr++ = oldlc2;
X *sbptr++ = brfflg;
X *sbptr++ = deadf;
X *sbptr++ = dirty;
X *sbptr++ = nonext;
X *sbptr++ = spcloc;
X *sbptr++ = fshlif;
X *sbptr++ = noshoe;
X *sbptr++ = daytim;
X *sbptr++ = martim;
X for (i = 0; i < 9; i++)
X *sbptr++ = marflg[i];
X *sbptr++ = oextim;
X *sbptr++ = rdietm;
X *sbptr++ = rvtim;
X *sbptr++ = gvtim;
X *sbptr++ = eattim;
X *sbptr++ = easttm;
X *sbptr++ = filmtm;
X *sbptr++ = screef;
X *sbptr++ = eastsc;
X *sbptr++ = cactsc;
X *sbptr++ = diesc;
X *sbptr++ = filmst;
X *sbptr++ = machst;
X *sbptr++ = dial1;
X *sbptr++ = dial2;
X *sbptr++ = dial1x;
X *sbptr++ = dial2x;
X *sbptr++ = bonus;
X *sbptr++ = jackpo;
X *sbptr++ = lpill;
X *sbptr++ = pbstat;
X *sbptr++ = decset;
X *sbptr++ = raset;
X *sbptr++ = dcombi;
X *sbptr++ = chaset;
X *sbptr++ = guardl;
X *sbptr++ = fimage;
X write(filedes, sbuffer, 64*sizeof(short));
X sbptr = sbuffer;
X iptr = locdat;
X for (i = 0; i <= LOCNUM; i++)
X *sbptr++ = *iptr++;
X write(filedes, sbuffer, 256*sizeof(short));
X sbptr = sbuffer;
X iptr = obimpr;
X for (i = 0; i <= OBJMAX; i++)
X *sbptr++ = *iptr++;
X write(filedes, sbuffer, 256*sizeof(short));
X sbptr = sbuffer;
X iptr = obloc;
X for (i = 0; i <= OBJMAX; i++)
X *sbptr++ = *iptr++;
X write(filedes, sbuffer, 256*sizeof(short));
X close(filedes);
X return (result);
X } else {
X /* "restore" */
X
X filedes = open(filenm, 0);
X if (filedes == -1)
X goto lab1;
X iret = read(filedes, sbuffer, 64*sizeof(short));
X if (iret != 64*sizeof(short))
X goto lab1;
X sbptr = sbuffer;
X horflg = *sbptr++;
X for (i = 0; i < 6; i++)
X wirelc[i] = *sbptr++;
X turns = *sbptr++;
X loc = *sbptr++;
X oldloc = *sbptr++;
X oldlc2 = *sbptr++;
X brfflg = *sbptr++;
X deadf = *sbptr++;
X dirty = *sbptr++;
X nonext = *sbptr++;
X spcloc = *sbptr++;
X fshlif = *sbptr++;
X noshoe = *sbptr++;
X daytim = *sbptr++;
X martim = *sbptr++;
X for (i = 0; i < 9; i++)
X marflg[i] = *sbptr++;
X oextim = *sbptr++;
X rdietm = *sbptr++;
X rvtim = *sbptr++;
X gvtim = *sbptr++;
X eattim = *sbptr++;
X easttm = *sbptr++;
X filmtm = *sbptr++;
X screef = *sbptr++;
X eastsc = *sbptr++;
X cactsc = *sbptr++;
X diesc = *sbptr++;
X filmst = *sbptr++;
X machst = *sbptr++;
X dial1 = *sbptr++;
X dial2 = *sbptr++;
X dial1x = *sbptr++;
X dial2x = *sbptr++;
X bonus = *sbptr++;
X jackpo = *sbptr++;
X lpill = *sbptr++;
X pbstat = *sbptr++;
X decset = *sbptr++;
X raset = *sbptr++;
X dcombi = *sbptr++;
X chaset = *sbptr++;
X guardl = *sbptr++;
X fimage = *sbptr++;
X iret = read(filedes, sbuffer, 256*sizeof(short));
X if (iret != 256*sizeof(short))
X goto lab1;
X sbptr = sbuffer;
X iptr = locdat;
X for (i = 0; i <= LOCNUM; i++)
X *iptr++ = *sbptr++;
X iret = read(filedes, sbuffer, 256*sizeof(short));
X if (iret != 256*sizeof(short))
X goto lab1;
X sbptr = sbuffer;
X iptr = obimpr;
X for (i = 0; i <= OBJMAX; i++)
X *iptr++ = *sbptr++;
X iret = read(filedes, sbuffer, 256*sizeof(short));
X if (iret != 256*sizeof(short))
X goto lab1;
X sbptr = sbuffer;
X iptr = obloc;
X for (i = 0; i <= OBJMAX; i++)
X *iptr++ = *sbptr++;
X close(filedes);
X result = 1;
X chaser = 0;
X linout(" ", 1);
X return (result);
X }
Xlab1:
X linout("Restore failed.", 15);
X return (result);
X}
END_OF_helper.c
if test 26257 -ne `wc -c <helper.c`; then
echo shar: \"helper.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 7 \(of 7\).
cp /dev/null ark7isdone
MISSING=""
for I in 1 2 3 4 5 6 7 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 7 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0