* enemies, or no enemies but 2 others. */
{
int spk = ACTSPK[verb];
- int i = ATDWRF(game.loc);
+ int d = ATDWRF(game.loc);
if (obj == 0) {
- if (i > 0)
+ if (d > 0)
obj=DWARF;
if (HERE(SNAKE))obj=obj*NOBJECTS+SNAKE;
if (AT(DRAGON) && game.prop[DRAGON] == 0)obj=obj*NOBJECTS+DRAGON;
if (obj == DRAGON)spk=ALREADY_DEAD;
if (obj == TROLL)spk=ROCKY_TROLL;
if (obj == OGRE)spk=OGRE_DOFGE;
- if (obj == OGRE && i > 0) {
+ if (obj == OGRE && d > 0) {
RSPEAK(spk);
RSPEAK(KNIFE_THROWN);
DSTROY(OGRE);
int k=0;
- for (i=1; i < PIRATE; i++) {
+ for (int i=1; i < PIRATE; i++) {
if (game.dloc[i] == game.loc) {
++k;
game.dloc[i] = LOC_61;
RSPEAK(spk);
return GO_TERMINATE;
}
-
+
static int inven(token_t obj)
/* Inventory. If object, treat same as find. Else report on current burden. */
{
- int i;
int spk=NO_CARRY;
- for (i=1; i<=NOBJECTS; i++) {
+ for (int i=1; i<=NOBJECTS; i++) {
if (i == BEAR || !TOTING(i))
continue;
if (spk == NO_CARRY)
return GO_TOP;
else
return GO_CLEAROBJ;
- }
+ }
}
static int listen(void)
/* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
{
- int i, k;
+ int k;
int spk=ALL_SILENT;
k=LOCSND[game.loc];
if (k != 0) {
spk=ARB_0;
}
SETPRM(1,game.zzword,0);
- for (i=1; i<=NOBJECTS; i++) {
+ for (int i=1; i<=NOBJECTS; i++) {
if (!HERE(i) || OBJSND[i] == 0 || game.prop[i] < 0)
continue;
PSPEAK(i,OBJSND[i]+game.prop[i]);
#include <stdbool.h>
#include <unistd.h>
-/* hard limit, will be propagated to database.h */
-#define NOBJECTS 100
-
// Global variables for use in functions below that can gradually disappear as code is cleaned up
static long LNLENG;
static long LNPOSN;
}
static void MAPLIN(FILE *OPENED) {
- size_t i;
/* Read a line of input, from the specified input source,
* translate the chars to integers in the range 0-126 and store
* them in the common array "INLINE". Integer values are as follows:
while (!feof(OPENED) && INLINE[1] == '#');
LNLENG = 0;
- for (i = 1; i < sizeof(INLINE) && INLINE[i] != 0; ++i)
+ for (size_t i = 1; i < sizeof(INLINE) && INLINE[i] != 0; ++i)
{
char val = INLINE[i];
INLINE[i] = ascii_to_advent[(unsigned)val];
static void write_file(FILE* header_file)
{
- int i, MAXDIE;
- for (i=0; i<=4; i++) {
+ int MAXDIE;
+ for (int i=0; i<=4; i++) {
long x = 2*i+81;
if(RTEXT[x] != 0)
MAXDIE=i+1;
void initialise(void)
{
- int i, k;
if (oldstyle)
printf("Initialising...\n");
- for (i=1; i<=NOBJECTS; i++) {
+ for (int i=1; i<=NOBJECTS; i++) {
game.place[i]=0;
game.prop[i]=0;
game.link[i+NOBJECTS]=game.link[i]=0;
}
- for (i=1; i<=LOCSIZ; i++) {
+ for (int i=1; i<=LOCSIZ; i++) {
game.abbrev[i]=0;
if (!(locations[i].description.big == 0 || KEY[i] == 0)) {
- k=KEY[i];
+ int k=KEY[i];
if(MOD(labs(TRAVEL[k]),1000) == 1)COND[i]=2;
}
game.atloc[i]=0;
* This also sets up "game.place" and "fixed" as copies of "PLAC" and
* "FIXD". Also, since two-placed objects are typically best
* described last, we'll drop them first. */
- for (i=1; i<=NOBJECTS; i++) {
- k=NOBJECTS + 1 - i;
+ for (int i=1; i<=NOBJECTS; i++) {
+ int k=NOBJECTS + 1 - i;
if(FIXD[k] > 0) {
DROP(k+NOBJECTS,FIXD[k]);
DROP(k,PLAC[k]);
}
}
- for (i=1; i<=NOBJECTS; i++) {
- k=NOBJECTS + 1 - i;
+ for (int i=1; i<=NOBJECTS; i++) {
+ int k=NOBJECTS + 1 - i;
game.fixed[k]=FIXD[k];
if(PLAC[k] != 0 && FIXD[k] <= 0)
DROP(k,PLAC[k]);
* they are described. game.tally keeps track of how many are
* not yet found, so we know when to close the cave. */
game.tally=0;
- for (i=MINTRS; i<=MAXTRS; i++) {
+ for (int i=MINTRS; i<=MAXTRS; i++) {
if(object_descriptions[i].inventory != 0)
game.prop[i]= -1;
game.tally=game.tally-game.prop[i];
/* Clear the hint stuff. game.hintlc[i] is how long he's been at LOC
* with cond bit i. game.hinted[i] is true iff hint i has been
* used. */
- for (i=1; i<=HNTMAX; i++) {
+ for (int i=1; i<=HNTMAX; i++) {
game.hinted[i]=false;
game.hintlc[i]=0;
}
* loc stored in game.chloc2. */
game.chloc = LOC_114;
game.chloc2 = LOC_140;
- for (i=1; i<=NDWARVES; i++) {
+ for (int i=1; i<=NDWARVES; i++) {
game.dseen[i]=false;
}
game.dflag=0;
++game.hintlc[hint];
/* Come here if he's been long enough at required loc(s) for some
* unused hint. */
- if (game.hintlc[hint] >= HINTS[hint][1])
+ if (game.hintlc[hint] >= HINTS[hint][1])
{
int i;
{
copy[i + 1] = 's';
packed_to_token(PARMS[pi], parameters[pi]);
- for (int i = 0; i < strlen(parameters[pi]); ++i)
+ for (int j = 0; j < strlen(parameters[pi]); ++j)
{
- parameters[pi][i] = tolower(parameters[pi][i]);
+ parameters[pi][j] = tolower(parameters[pi][j]);
}
}
{
copy[i + 1] = 's';
packed_to_token(PARMS[pi], parameters[pi]);
- for (int i = 0; i < strlen(parameters[pi]); ++i)
+ for (int j = 0; j < strlen(parameters[pi]); ++j)
{
- parameters[pi][i] = tolower(parameters[pi][i]);
+ parameters[pi][j] = tolower(parameters[pi][j]);
}
parameters[pi][0] = toupper(parameters[pi][0]);
}
* (Thus "STEPS", which is a motion verb as well as an object, may be located
* as an object.) And it also means the KTAB value is taken modulo 1000. */
{
- long i, lexeme;
+ long lexeme;
- for (i=1; i<=TABSIZ; i++) {
+ for (long i=1; i<=TABSIZ; i++) {
if (KTAB[i] == -1) {
lexeme= -1;
if (init < 0)
return(lexeme);
BUG(5);
}
- if (init >= 0 && KTAB[i]/1000 != init)
+ if (init >= 0 && KTAB[i]/1000 != init)
continue;
if (ATAB[i] == id) {
lexeme=KTAB[i];
* there (or if dwarves not active yet), -1 if all dwarves are dead. Ignore
* the pirate (6th dwarf). */
{
- long at, i;
+ long at;
at =0;
if (game.dflag < 2)
return(at);
at = -1;
- for (i=1; i<=NDWARVES-1; i++) {
+ for (long i=1; i<=NDWARVES-1; i++) {
if (game.dloc[i] == where)
return i;
if (game.dloc[i] != 0)
void score(long mode)
/* mode is <0 if scoring, >0 if quitting, =0 if died or won */
{
- long i, k, score = 0, mxscor = 0;
+ long score = 0, mxscor = 0;
/* The present scoring algorithm is as follows:
* Objective: Points: Present total possible:
/* First tally up the treasures. Must be in building and not broken.
* Give the poor guy 2 points just for finding each treasure. */
- for (i=MINTRS; i<=MAXTRS; i++) {
+ for (long i=MINTRS; i<=MAXTRS; i++) {
if(object_descriptions[i].inventory != 0) {
- k=12;
+ long k=12;
if(i == CHEST)k=14;
if(i > CHEST)k=16;
if(game.prop[i] >= 0)
mxscor += 2;
/* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
- for (i=1; i<=HNTMAX; i++) {
+ for (long i=1; i<=HNTMAX; i++) {
if(game.hinted[i])
score=score-HINTS[i][2];
}
SETPRM(1,score,mxscor);
SETPRM(3,game.turns,game.turns);
RSPEAK(TOTAL_SCORE);
- for (i=1; i<=CLSSES; i++) {
+ for (long i=1; i<=CLSSES; i++) {
if(CVAL[i] >= score) {
newspeak(class_messages[i]);
i=CVAL[i]+1-score;