squadprob array had 5 elements but only 4 initialized

fixes #335
This commit is contained in:
nhmall
2020-04-21 14:32:14 -04:00
parent 52a15daaf6
commit 23428d0fcc
2 changed files with 8 additions and 8 deletions

View File

@@ -780,15 +780,13 @@ courtmon()
return mkclass(S_KOBOLD, 0);
}
#define NSTYPES (PM_CAPTAIN - PM_SOLDIER + 1)
static const struct {
unsigned pm;
unsigned prob;
} squadprob[NSTYPES] = { { PM_SOLDIER, 80 },
{ PM_SERGEANT, 15 },
{ PM_LIEUTENANT, 4 },
{ PM_CAPTAIN, 1 } };
} squadprob[] = { { PM_SOLDIER, 80 },
{ PM_SERGEANT, 15 },
{ PM_LIEUTENANT, 4 },
{ PM_CAPTAIN, 1 } };
/* return soldier types. */
static struct permonst *
@@ -799,14 +797,14 @@ squadmon()
sel_prob = rnd(80 + level_difficulty());
cpro = 0;
for (i = 0; i < NSTYPES; i++) {
for (i = 0; i < SIZE(squadprob); i++) {
cpro += squadprob[i].prob;
if (cpro > sel_prob) {
mndx = squadprob[i].pm;
goto gotone;
}
}
mndx = squadprob[rn2(NSTYPES)].pm;
mndx = squadprob[rn2(SIZE(squadprob))].pm;
gotone:
if (!(g.mvitals[mndx].mvflags & G_GONE))
return &mons[mndx];