/* Light. Applicable only to lamp and urn. */
L8070: if(HERE(LAMP) && PROP[LAMP] == 0 && LIMIT >= 0)OBJ=LAMP;
- if(HERE(URN) && PROP[URN] == 1)OBJ=OBJ*100+URN;
- if(OBJ == 0 || OBJ > 100) return(8000);
+ if(HERE(URN) && PROP[URN] == 1)OBJ=OBJ*NOBJECTS+URN;
+ if(OBJ == 0 || OBJ > NOBJECTS) return(8000);
L9070: if(OBJ == URN) goto L9073;
if(OBJ != LAMP) return(2011);
/* Extinguish. Lamp, urn, dragon/volcano (nice try). */
L8080: if(HERE(LAMP) && PROP[LAMP] == 1)OBJ=LAMP;
- if(HERE(URN) && PROP[URN] == 2)OBJ=OBJ*100+URN;
- if(OBJ == 0 || OBJ > 100) return(8000);
+ if(HERE(URN) && PROP[URN] == 2)OBJ=OBJ*NOBJECTS+URN;
+ if(OBJ == 0 || OBJ > NOBJECTS) return(8000);
L9080: if(OBJ == URN) goto L9083;
if(OBJ == LAMP) goto L9086;
/* Inventory. If object, treat same as find. Else report on current burden. */
L8200: SPK=98;
- /* 8201 */ for (I=1; I<=100; I++) {
+ /* 8201 */ for (I=1; I<=NOBJECTS; I++) {
if(I == BEAR || !TOTING(I)) goto L8201;
if(SPK == 98)RSPEAK(99);
BLKLIN=false;
/* Read. Print stuff based on objtxt. Oyster (?) is special case. */
-L8270: for (I=1; I<=100; I++) {
- if(HERE(I) && OBJTXT[I] != 0 && PROP[I] >= 0)OBJ=OBJ*100+I;
+L8270: for (I=1; I<=NOBJECTS; I++) {
+ if(HERE(I) && OBJTXT[I] != 0 && PROP[I] >= 0)OBJ=OBJ*NOBJECTS+I;
} /* end loop */
- if(OBJ > 100 || OBJ == 0 || DARK(0)) return(8000);
+ if(OBJ > NOBJECTS || OBJ == 0 || DARK(0)) return(8000);
L9270: if(DARK(0)) goto L5190;
if(OBJTXT[OBJ] == 0 || PROP[OBJ] < 0) return(2011);
SAVARR(ATLOC,LOCSIZ);
SAVARR(DLOC,6);
SAVARR(DSEEN,6);
- SAVARR(FIXED,100);
+ SAVARR(FIXED,NOBJECTS);
SAVARR(HINTED,HNTSIZ);
SAVARR(HINTLC,HNTSIZ);
SAVARR(LINK,200);
SAVARR(ODLOC,6);
- SAVARR(PLACE,100);
- SAVARR(PROP,100);
+ SAVARR(PLACE,NOBJECTS);
+ SAVARR(PROP,NOBJECTS);
SAVWRD(KK,K);
if(K != 0) goto L8318;
K=NUL;
if(K < 0) return(2012);
SPK=0;
L8332: SETPRM(1,ZZWORD,0);
- /* 8335 */ for (I=1; I<=100; I++) {
+ /* 8335 */ for (I=1; I<=NOBJECTS; I++) {
if(!HERE(I) || OBJSND[I] == 0 || PROP[I] < 0) goto L8335;
PSPEAK(I,OBJSND[I]+PROP[I]);
SPK=0;
K=2-PROP[RUG];
PROP[RUG]=K;
if(K == 2)K=PLAC[SAPPH];
- MOVE(RUG+100,K);
+ MOVE(RUG+NOBJECTS,K);
goto L9021;
L9024: if(OBJ != COINS || !HERE(VEND)) goto L9025;
L9026: if(OBJ != BEAR || !AT(TROLL)) goto L9027;
RSPEAK(163);
MOVE(TROLL,0);
- MOVE(TROLL+100,0);
+ MOVE(TROLL+NOBJECTS,0);
MOVE(TROLL2,PLAC[TROLL]);
- MOVE(TROLL2+100,FIXD[TROLL]);
+ MOVE(TROLL2+NOBJECTS,FIXD[TROLL]);
JUGGLE(CHASM);
PROP[TROLL]=2;
goto L9021;
I=ATDWRF(LOC);
if(OBJ != 0) goto L9124;
if(I > 0)OBJ=DWARF;
- if(HERE(SNAKE))OBJ=OBJ*100+SNAKE;
- if(AT(DRAGON) && PROP[DRAGON] == 0)OBJ=OBJ*100+DRAGON;
- if(AT(TROLL))OBJ=OBJ*100+TROLL;
- if(AT(OGRE))OBJ=OBJ*100+OGRE;
- if(HERE(BEAR) && PROP[BEAR] == 0)OBJ=OBJ*100+BEAR;
- if(OBJ > 100) return(8000);
+ if(HERE(SNAKE))OBJ=OBJ*NOBJECTS+SNAKE;
+ if(AT(DRAGON) && PROP[DRAGON] == 0)OBJ=OBJ*NOBJECTS+DRAGON;
+ if(AT(TROLL))OBJ=OBJ*NOBJECTS+TROLL;
+ if(AT(OGRE))OBJ=OBJ*NOBJECTS+OGRE;
+ if(HERE(BEAR) && PROP[BEAR] == 0)OBJ=OBJ*NOBJECTS+BEAR;
+ if(OBJ > NOBJECTS) return(8000);
if(OBJ != 0) goto L9124;
/* CAN'T ATTACK BIRD OR MACHINE BY THROWING AXE. */
if(HERE(BIRD) && VERB != THROW)OBJ=BIRD;
- if(HERE(VEND) && VERB != THROW)OBJ=OBJ*100+VEND;
+ if(HERE(VEND) && VERB != THROW)OBJ=OBJ*NOBJECTS+VEND;
/* CLAM AND OYSTER BOTH TREATED AS CLAM FOR INTRANSITIVE CASE; NO HARM DONE. */
- if(HERE(CLAM) || HERE(OYSTER))OBJ=100*OBJ+CLAM;
- if(OBJ > 100) return(8000);
+ if(HERE(CLAM) || HERE(OYSTER))OBJ=NOBJECTS*OBJ+CLAM;
+ if(OBJ > NOBJECTS) return(8000);
L9124: if(OBJ == BIRD) {
SPK=137;
if(CLOSED) return(2011);
PROP[DRAGON]=1;
PROP[RUG]=0;
K=(PLAC[DRAGON]+FIXD[DRAGON])/2;
- MOVE(DRAGON+100,-1);
- MOVE(RUG+100,0);
+ MOVE(DRAGON+NOBJECTS,-1);
+ MOVE(RUG+NOBJECTS,0);
MOVE(DRAGON,K);
MOVE(RUG,K);
DROP(BLOOD,K);
- for (OBJ=1; OBJ<=100; OBJ++) {
+ for (OBJ=1; OBJ<=NOBJECTS; OBJ++) {
if(PLACE[OBJ] == PLAC[DRAGON] || PLACE[OBJ] == FIXD[DRAGON])MOVE(OBJ,K);
/*etc*/ ;
} /* end loop */
/* Snarf a treasure for the troll. */
DROP(OBJ,0);
MOVE(TROLL,0);
- MOVE(TROLL+100,0);
+ MOVE(TROLL+NOBJECTS,0);
DROP(TROLL2,PLAC[TROLL]);
- DROP(TROLL2+100,FIXD[TROLL]);
+ DROP(TROLL2+NOBJECTS,FIXD[TROLL]);
JUGGLE(CHASM);
return(2011);
}
#include <stdbool.h>
#include <unistd.h>
+/* hard limit, will be propagated to database.h */
+#define NOBJECTS 100
+
const char advent_to_ascii[] = {0, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 46, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 35, 36, 38, 47, 58, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96, 123, 124, 125, 126, 0};
/* Rendered from the now-gone MPINIT() function */
const char ascii_to_advent[] = {0, 74, 75, 76, 77, 78, 79, 80, 81, 82, 0, 0, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 0, 1, 2, 106, 107, 63, 108, 3, 4, 5, 6, 7, 8, 9, 10, 109, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 110, 111, 112, 113, 114, 115, 116, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 117, 118, 119, 120, 121, 122, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 123, 124, 125, 126, 83};
long TRNVLS;
long TABNDX;
long HNTMAX;
-long PTEXT[101];
+long PTEXT[NOBJECTS+1];
long RTEXT[RTXSIZ + 1];
long CTEXT[CLSMAX + 1];
-long OBJSND[101];
-long OBJTXT[101];
+long OBJSND[NOBJECTS+1];
+long OBJTXT[NOBJECTS+1];
long STEXT[LOCSIZ + 1];
long LTEXT[LOCSIZ + 1];
long COND[LOCSIZ + 1];
long TRAVEL[TRVSIZ + 1];
long KTAB[TABSIZ + 1];
long ATAB[TABSIZ + 1];
-long PLAC[101];
-long FIXD[101];
+long PLAC[NOBJECTS+1];
+long FIXD[NOBJECTS+1];
long ACTSPK[VRBSIZ + 1];
long HINTS[HNTSIZ + 1][5];
* section 14. We also clear COND (see description of section 9 for details). */
for (int I=1; I<=300; I++) {
- if(I <= 100) PTEXT[I] = 0;
+ if(I <= NOBJECTS) PTEXT[I] = 0;
if(I <= RTXSIZ) RTEXT[I] = 0;
if(I <= CLSMAX) CTEXT[I] = 0;
- if(I <= 100) OBJSND[I] = 0;
- if(I <= 100) OBJTXT[I] = 0;
+ if(I <= NOBJECTS) OBJSND[I] = 0;
+ if(I <= NOBJECTS) OBJTXT[I] = 0;
if(I > LOCSIZ) break;
STEXT[I] = 0;
LTEXT[I] = 0;
}
if(SECT == 5)
{
- if(LOC > 0 && LOC <= 100)PTEXT[LOC]=LINUSE;
+ if(LOC > 0 && LOC <= NOBJECTS)PTEXT[LOC]=LINUSE;
continue;
}
if(LOC > LOCSIZ)BUG(10);
/* Finish constructing internal data format */
-/* Having read in the database, certain things are now constructed. PROPS are
- * set to zero. We finish setting up COND by checking for forced-motion travel
- * entries. The PLAC and FIXD arrays are used to set up ATLOC(N) as the first
- * object at location N, and LINK(OBJ) as the next object at the same location
- * as OBJ. (OBJ>100 indicates that FIXED(OBJ-100)=LOC; LINK(OBJ) is still the
- * correct link to use.) ABB is zeroed; it controls whether the abbreviated
- * description is printed. Counts modulo 5 unless "LOOK" is used. */
+/* Having read in the database, certain things are now constructed.
+ * PROPS are set to zero. We finish setting up COND by checking for
+ * forced-motion travel entries. The PLAC and FIXD arrays are used
+ * to set up ATLOC(N) as the first object at location N, and
+ * LINK(OBJ) as the next object at the same location as OBJ.
+ * (OBJ>NOBJECTS indicates that FIXED(OBJ-NOBJECTS)=LOC; LINK(OBJ) is
+ * still the correct link to use.) ABB is zeroed; it controls
+ * whether the abbreviated description is printed. Counts modulo 5
+ * unless "LOOK" is used. */
void write_0d(FILE* c_file, FILE* header_file, long single, char* varname)
{
void write_files(FILE* c_file, FILE* header_file)
{
// preprocessor defines for the header
+ fprintf(header_file, "#define NOBJECTS %d\n", NOBJECTS);
fprintf(header_file, "#define RTXSIZ 277\n");
fprintf(header_file, "#define CLSMAX 12\n");
fprintf(header_file, "#define LOCSIZ 185\n");
write_0d(c_file, header_file, TRNVLS, "TRNVLS");
write_0d(c_file, header_file, TABNDX, "TABNDX");
write_0d(c_file, header_file, HNTMAX, "HNTMAX");
- write_1d(c_file, header_file, PTEXT, 100 + 1, "PTEXT");
+ write_1d(c_file, header_file, PTEXT, NOBJECTS + 1, "PTEXT");
write_1d(c_file, header_file, RTEXT, RTXSIZ + 1, "RTEXT");
write_1d(c_file, header_file, CTEXT, CLSMAX + 1, "CTEXT");
- write_1d(c_file, header_file, OBJSND, 100 + 1, "OBJSND");
- write_1d(c_file, header_file, OBJTXT, 100 + 1, "OBJTXT");
+ write_1d(c_file, header_file, OBJSND, NOBJECTS + 1, "OBJSND");
+ write_1d(c_file, header_file, OBJTXT, NOBJECTS + 1, "OBJTXT");
write_1d(c_file, header_file, STEXT, LOCSIZ + 1, "STEXT");
write_1d(c_file, header_file, LTEXT, LOCSIZ + 1, "LTEXT");
write_1d(c_file, header_file, COND, LOCSIZ + 1, "COND");
write_1d(c_file, header_file, TRAVEL, TRVSIZ + 1, "TRAVEL");
write_1d(c_file, header_file, KTAB, TABSIZ + 1, "KTAB");
write_1d(c_file, header_file, ATAB, TABSIZ + 1, "ATAB");
- write_1d(c_file, header_file, PLAC, 100 + 1, "PLAC");
- write_1d(c_file, header_file, FIXD, 100 + 1, "FIXD");
+ write_1d(c_file, header_file, PLAC, NOBJECTS + 1, "PLAC");
+ write_1d(c_file, header_file, FIXD, NOBJECTS + 1, "FIXD");
write_1d(c_file, header_file, ACTSPK, VRBSIZ + 1, "ACTSPK");
write_hints(c_file, header_file, HINTS, HNTSIZ + 1, 5, "HINTS");
}
*/
/* Current limits:
- * 12500 words of message text (LINES, LINSIZ).
+ * 12600 words of message text (LINES, LINSIZ).
* 885 travel options (TRAVEL, TRVSIZ).
* 330 vocabulary words (KTAB, ATAB, TABSIZ).
* 185 locations (LTEXT, STEXT, KEY, COND, ABB, ATLOC, LOCSND, LOCSIZ).
* 300 locations
* 100 objects */
+/* Note: the object count limit has been abstracted as NOBJECTS */
/* Description of the database format
*
* prop value is N/100. The N/100 is used only to distinguish multiple
* messages from multi-line messages; the prop info actually requires all
* messages for an object to be present and consecutive. Properties which
- * produce no message should be given the message ">$<".
+ * produce no message should be given the message ">$<". (The magic value
+ * 100 is now mostly abstracted out as NOBJECTS.)
* Section 6: Arbitrary messages. Same format as sections 1, 2, and 5, except
* the numbers bear no relation to anything (except for special verbs
* in section 4).
PLACE[I]=0;
PROP[I]=0;
LINK[I]=0;
- {long x = I+100; LINK[x]=0;}
+ {long x = I+NOBJECTS; LINK[x]=0;}
} /* end loop */
/* 1102 */ for (I=1; I<=LOCSIZ; I++) {
* "PLAC" and "FIXD". Also, since two-placed objects are typically best
* described last, we'll drop them first. */
- /* 1106 */ for (I=1; I<=100; I++) {
- K=101-I;
+ /* 1106 */ for (I=1; I<=NOBJECTS; I++) {
+ K=NOBJECTS + 1 - I;
if(FIXD[K] <= 0) goto L1106;
- DROP(K+100,FIXD[K]);
+ DROP(K+NOBJECTS,FIXD[K]);
DROP(K,PLAC[K]);
L1106: /*etc*/ ;
} /* end loop */
- for (I=1; I<=100; I++) {
- K=101-I;
+ for (I=1; I<=NOBJECTS; I++) {
+ K=NOBJECTS + 1 - I;
FIXED[K]=FIXD[K];
if(PLAC[K] != 0 && FIXD[K] <= 0)DROP(K,PLAC[K]);
} /* end loop */
#include "database.h"
long ABB[186], ATLOC[186], BLKLIN = true, DFLAG,
- DLOC[7], FIXED[101], HOLDNG,
+ DLOC[7], FIXED[NOBJECTS+1], HOLDNG,
LINK[201], LNLENG, LNPOSN,
- PARMS[26], PLACE[101],
+ PARMS[26], PLACE[NOBJECTS+1],
SETUP = 0;
char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129];
MESSAG, MIRROR, MXSCOR,
NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
ODLOC[7], OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
- PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[101], PYRAM,
+ PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[NOBJECTS+1], PYRAM,
RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STICK,
STREAM, TALLY, THRESH, THROW, TK[21], TRIDNT,
I=ATLOC[LOC];
L2004: if(I == 0) goto L2012;
OBJ=I;
- if(OBJ > 100)OBJ=OBJ-100;
+ if(OBJ > NOBJECTS)OBJ=OBJ-NOBJECTS;
if(OBJ == STEPS && TOTING(NUGGET)) goto L2008;
if(PROP[OBJ] >= 0) goto L2006;
if(CLOSED) goto L2008;
L2603: if(!CLOSED) goto L2605;
if(PROP[OYSTER] < 0 && TOTING(OYSTER))PSPEAK(OYSTER,1);
- for (I=1; I<=100; I++) {
+ for (I=1; I<=NOBJECTS; I++) {
if(TOTING(I) && PROP[I] < 0)PROP[I]= -1-PROP[I];
} /* end loop */
L2605: WZDARK=DARK(0);
L10: LL=LL/1000;
L11: NEWLOC=LL/1000;
- K=MOD(NEWLOC,100);
+ K=MOD(NEWLOC,100); /* ESR: an instance of NOBJECTS? */
if(NEWLOC <= 300) goto L13;
if(PROP[K] != NEWLOC/100-3) goto L16;
L12: if(TRAVEL[KK] < 0)BUG(25);
LL=NEWLOC;
goto L11;
-L13: if(NEWLOC <= 100) goto L14;
+L13: if(NEWLOC <= 100) goto L14; /* ESR: an instance of NOBJECTS? */
if(TOTING(K) || (NEWLOC > 200 && AT(K))) goto L16;
goto L12;
* table must include "useless" entries going through passage, which can never
* be used for actual motion, but can be spotted by "go back". */
-L30100: NEWLOC=99+100-LOC;
+L30100: NEWLOC=99+100-LOC; /* ESR: an instance of NOBJECTS? */
if(HOLDNG == 0 || (HOLDNG == 1 && TOTING(EMRALD))) return true;
NEWLOC=LOC;
RSPEAK(117);
PSPEAK(TROLL,1);
PROP[TROLL]=0;
MOVE(TROLL2,0);
- MOVE(TROLL2+100,0);
+ MOVE(TROLL2+NOBJECTS,0);
MOVE(TROLL,PLAC[TROLL]);
- MOVE(TROLL+100,FIXD[TROLL]);
+ MOVE(TROLL+NOBJECTS,FIXD[TROLL]);
JUGGLE(CHASM);
NEWLOC=LOC;
return true;
PLACE[WATER]=0;
PLACE[OIL]=0;
if(TOTING(LAMP))PROP[LAMP]=0;
- /* 98 */ for (J=1; J<=100; J++) {
- I=101-J;
+ /* 98 */ for (J=1; J<=NOBJECTS; J++) {
+ I=NOBJECTS + 1 - J;
if(!TOTING(I)) goto L98;
K=OLDLC2;
if(I == LAMP)K=1;
DLOC[I]=0;
} /* end loop */
MOVE(TROLL,0);
- MOVE(TROLL+100,0);
+ MOVE(TROLL+NOBJECTS,0);
MOVE(TROLL2,PLAC[TROLL]);
- MOVE(TROLL2+100,FIXD[TROLL]);
+ MOVE(TROLL2+NOBJECTS,FIXD[TROLL]);
JUGGLE(CHASM);
if(PROP[BEAR] != 3)DSTROY(BEAR);
PROP[CHAIN]=0;
PROP[MIRROR]=PUT(MIRROR,115,0);
FIXED[MIRROR]=116;
- for (I=1; I<=100; I++) {
+ for (I=1; I<=NOBJECTS; I++) {
if(TOTING(I))DSTROY(I);
} /* end loop */
I=PLACE[OBJECT];
J=FIXED[OBJECT];
MOVE(OBJECT,I);
- MOVE(OBJECT+100,J);
+ MOVE(OBJECT+NOBJECTS,J);
return;
}
* are not at any loc, since carry wants to remove objects from ATLOC chains. */
- if(OBJECT > 100) goto L1;
+ if(OBJECT > NOBJECTS) goto L1;
FROM=PLACE[OBJECT];
goto L2;
-L1: {long x = OBJECT-100; FROM=FIXED[x];}
+L1: {long x = OBJECT-NOBJECTS; FROM=FIXED[x];}
L2: if(FROM > 0 && FROM <= 300)CARRY(OBJECT,FROM);
DROP(OBJECT,WHERE);
return;
long TEMP;
/* Start toting an object, removing it from the list of things at its former
- * location. Incr holdng unless it was already being toted. If OBJECT>100
+ * location. Incr holdng unless it was already being toted. If OBJECT>NOBJECTS
* (moving "fixed" second loc), don't change PLACE or HOLDNG. */
- if(OBJECT > 100) goto L5;
+ if(OBJECT > NOBJECTS) goto L5;
if(PLACE[OBJECT] == -1)return;
PLACE[OBJECT]= -1;
HOLDNG=HOLDNG+1;
/* Place an object at a given loc, prefixing it onto the ATLOC list. Decr
* HOLDNG if the object was being toted. */
- if(OBJECT > 100) goto L1;
+ if(OBJECT > NOBJECTS) goto L1;
if(PLACE[OBJECT] == -1)HOLDNG=HOLDNG-1;
PLACE[OBJECT]=WHERE;
goto L2;
-L1: {long x = OBJECT-100; FIXED[x]=WHERE;}
+L1: {long x = OBJECT-NOBJECTS; FIXED[x]=WHERE;}
L2: if(WHERE <= 0)return;
LINK[OBJECT]=ATLOC[WHERE];
ATLOC[WHERE]=OBJECT;