Fixed a semi-bug (undefined behaviour) in undead_cannot_memorise().
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1302 c06c8d41-db1a-0410-9941-cceddc491573
KOSAQXB3KF6VAYTG2TOTHGJBB3F7AL6O32EMCXPVZJ5WHQX6XR5AC
bool spell_typematch(int which_spell, unsigned int which_discipline);
unsigned int get_spell_type( int which_spell ); //jmf: simplification of above
bool spell_typematch(spell_type which_spell, unsigned int which_discipline);
unsigned int get_spell_type( spell_type which_spell );
// this will probably be used often, so rather than use malloc/free
// (which may lead to memory fragmentation) I'll just use a static
// array of characters -- if/when the String changeover takes place,
// this will all shift, no doubt {dlb}
/*
const char *spell_title( int which_spell )
{
static char this_title[41] = ""; // this is generous, to say the least {dlb}
strncpy(this_title, seekspell(which_spell)->title, 41);
// truncation better than overrun {dlb}
return ( this_title );
} // end spell_title()
*/
if (book_rarity(mitm[p].sub_type) == 100)
continue;
if (mitm[p].sub_type != BOOK_DESTRUCTION &&
mitm[p].sub_type != BOOK_MANUAL &&
book_rarity(mitm[p].sub_type) != 100 &&
one_chance_in(10))
{
mitm[p].sub_type = coinflip() ? BOOK_WIZARDRY : BOOK_POWER;
}
if (one_chance_in(10))
{
if (coinflip())
mitm[p].sub_type = BOOK_WIZARDRY;
else
mitm[p].sub_type = BOOK_POWER;
}
if (random2(item_level + 1) + 1 >= book_rarity(mitm[p].sub_type)
|| one_chance_in(100))
{
break;
}
else
{
mitm[p].sub_type = BOOK_DESTRUCTION;
continue;
}
mitm[p].sub_type = BOOK_DESTRUCTION; // continue trying
while (mitm[p].sub_type == BOOK_DESTRUCTION
|| mitm[p].sub_type == BOOK_MANUAL);
if (book_rarity(mitm[p].sub_type) == 100)
goto create_book;
while (mitm[p].sub_type == BOOK_DESTRUCTION ||
mitm[p].sub_type == BOOK_MANUAL ||
book_rarity(mitm[p].sub_type) == 100);