attempt to resolve issue #1368

Resolve #1368
This commit is contained in:
nhmall
2025-01-24 17:06:17 -05:00
parent c9abc92dd7
commit 02102de396
3 changed files with 14 additions and 3 deletions

View File

@@ -51,7 +51,7 @@ initedog(struct monst *mtmp)
mtmp->meating = 0;
EDOG(mtmp)->droptime = 0;
EDOG(mtmp)->dropdist = 10000;
EDOG(mtmp)->apport = ACURR(A_CHA);
EDOG(mtmp)->apport = max(1, ACURR(A_CHA));
EDOG(mtmp)->whistletime = 0;
EDOG(mtmp)->hungrytime = 1000 + svm.moves;
EDOG(mtmp)->ogoal.x = -1; /* force error if used before set */

View File

@@ -311,9 +311,16 @@ dog_eat(struct monst *mtmp,
} else {
/* It's a reward if it's DOGFOOD and the player dropped/threw it.
We know the player had it if invlet is set. -dlc */
if (dogfood(mtmp, obj) == DOGFOOD && obj->invlet)
if (dogfood(mtmp, obj) == DOGFOOD && obj->invlet) {
edog->apport += (int) (200L / ((long) edog->dropdist + svm.moves
- edog->droptime));
if (edog->apport <= 0) {
impossible("dog_eat: pet apport <= 0 (%d, %d, %ld, %ld)",
edog->apport, edog->dropdist, edog->droptime,
svm.moves);
edog->apport = 1;
}
}
if (obj->unpaid) {
/* edible item owned by shop has been thrown or kicked
by hero and caught by tame or food-tameable monst */
@@ -399,7 +406,7 @@ dog_invent(struct monst *mtmp, struct edog *edog, int udist)
* Use udist+1 so steed won't cause divide by zero.
*/
if (droppables(mtmp)) {
if (!rn2(udist + 1) || !rn2(edog->apport))
if (!rn2(udist + 1) || (edog->apport && !rn2(edog->apport)))
if (rn2(10) < edog->apport) {
relobj(mtmp, (int) mtmp->minvis, TRUE);
if (edog->apport > 1)

View File

@@ -365,6 +365,10 @@ restmon(NHFILE *nhfp, struct monst *mtmp)
newedog(mtmp);
if (nhfp->structlevel)
Mread(nhfp->fd, EDOG(mtmp), sizeof (struct edog));
/* sanity check to prevent rn2(0) */
if (EDOG(mtmp)->apport <= 0) {
EDOG(mtmp)->apport = 1;
}
}
/* mcorpsenm - obj->corpsenm for mimic posing as corpse or
statue (inline int rather than pointer to something) */