Skip to content

Commit ef4bf2e

Browse files
committed
Fix: consume_tin() bypassed is_edible()
Draugr race cannot eat anything except non-veggie corpses and eggs, meaning no processed foods, which includes anything in a tin. Players could bypass that rule by using a tin opener to open a tin. This commit closes that loophole, and forces consume_tin() to check whether the contents are edible or not. This isn't the most elegant solution - currently this treats all tins in any state as off-limits to Draugr. Which is fine for now, because any food found within a tin is technically processed/preserved. In the future, I think it'd be neat to allow Draugr to eat meat from a tin if its contents were rotten (side note: food sense [from spell/as a Hobbit] should be able to tell if the food inside a tin is rotten or not before eating it).
1 parent 30dd5b6 commit ef4bf2e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

doc/evilhack-changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -3527,4 +3527,5 @@ The following changes to date are:
35273527
(player is a knight) would stay tame
35283528
- Fix: noncorporeal monsters were affected by knockback
35293529
- Fix: monster could go berserk if temporarily sleeping or paralyzed
3530+
- Fix: consume_tin() bypassed is_edible()
35303531

src/eat.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,15 @@ const char *mesg;
15431543
what = the(what);
15441544

15451545
pline("It smells like %s.", what);
1546-
if (yn("Eat it?") == 'n') {
1546+
if (!is_edible(tin)) {
1547+
You("cannot eat that!");
1548+
if (flags.verbose)
1549+
You("discard the open tin.");
1550+
if (!Hallucination)
1551+
tin->dknown = tin->known = 1;
1552+
tin = costly_tin(COST_OPEN);
1553+
goto use_up_tin;
1554+
} else if (yn("Eat it?") == 'n') {
15471555
if (flags.verbose)
15481556
You("discard the open tin.");
15491557
if (!Hallucination)
@@ -1590,7 +1598,13 @@ const char *mesg;
15901598
tin->dknown = tin->known = 1;
15911599
}
15921600

1593-
if (yn("Eat it?") == 'n') {
1601+
if (!is_edible(tin)) {
1602+
You("cannot eat that!");
1603+
if (flags.verbose)
1604+
You("discard the open tin.");
1605+
tin = costly_tin(COST_OPEN);
1606+
goto use_up_tin;
1607+
} else if (yn("Eat it?") == 'n') {
15941608
if (flags.verbose)
15951609
You("discard the open tin.");
15961610
tin = costly_tin(COST_OPEN);

0 commit comments

Comments
 (0)