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

@@ -155,6 +155,8 @@ monster or object detection found semi-dead vault guard at <0,0> while
traversing fmon list; monster detection gave misleading feedback
(blank map instead of 'strange feeling') if there were no other
monsters on level; likewise object detection and guard's minvent
squadprob[] in mkroom.c was defined with 5 elements but initialized only 4
resulting in giant ants sometimes
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository

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];