named-fruit manipulation

Add some new routines for dealing with fruit.  I had hoped they would
let the existing fruit handling be simplified quite a bit, but the
improvement wasn't great.  However, they're also groundwork for fixing
an old bug.
This commit is contained in:
PatR
2017-07-03 18:57:50 -07:00
parent fa2fbb64c8
commit ca84c8e0ff
5 changed files with 187 additions and 65 deletions

View File

@@ -2471,14 +2471,15 @@ int final;
/* named fruit debugging (doesn't really belong here...); to enable,
include 'fruit' in DEBUGFILES list (even though it isn't a file...) */
if (wizard && explicitdebug("fruit")) {
int fcount = 0;
struct fruit *f;
char buf2[BUFSZ];
reorder_fruit(TRUE); /* sort by fruit index, from low to high;
* this modifies the ffruit chain, so could
* possibly mask or even introduce a problem,
* but it does useful sanity checking */
for (f = ffruit; f; f = f->nextf) {
Sprintf(buf, "Fruit %d ", ++fcount);
Sprintf(buf2, "%s (id %d)", f->fname, f->fid);
enl_msg(buf, "is ", "was ", buf2, "");
Sprintf(buf, "Fruit #%d ", f->fid);
enl_msg(buf, "is ", "was ", f->fname, "");
}
enl_msg("The current fruit ", "is ", "was ", pl_fruit, "");
Sprintf(buf, "%d", flags.made_fruit);