From 92d931f1909dde97190a406811b47247b3eea83d Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Tue, 12 Nov 2024 17:34:23 -0500 Subject: [PATCH] Refresh worm segments when (un)taming Because newsym() would be called only on the head position of the worm, if hilite_pet was on, the segments and head of a long worm would have mismatched highlighting in the immediate aftermath of taming or untaming. --- include/extern.h | 1 + src/dog.c | 8 +++++++- src/worm.c | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/extern.h b/include/extern.h index 4a36834d0..338f19940 100644 --- a/include/extern.h +++ b/include/extern.h @@ -3766,6 +3766,7 @@ extern boolean worm_cross(int, int, int, int); extern int wseg_at(struct monst *, int, int) NO_NNARGS; extern void flip_worm_segs_vertical(struct monst *, int, int) NONNULLARG1; extern void flip_worm_segs_horizontal(struct monst *, int, int) NONNULLARG1; +extern void redraw_worm(struct monst *); /* ### worn.c ### */ diff --git a/src/dog.c b/src/dog.c index a856c4a05..edb747189 100644 --- a/src/dog.c +++ b/src/dog.c @@ -1180,6 +1180,8 @@ tamedog(struct monst *mtmp, struct obj *obj, boolean givemsg) Hallucination ? "approachable" : "friendly"); newsym(mtmp->mx, mtmp->my); + if (mtmp->wormno) + redraw_worm(mtmp); if (attacktype(mtmp->data, AT_WEAP)) { mtmp->weapon_check = NEED_HTH_WEAPON; (void) mon_wield_item(mtmp); @@ -1288,8 +1290,12 @@ abuse_dog(struct monst *mtmp) else growl(mtmp); /* give them a moment's worry */ - if (!mtmp->mtame) + if (!mtmp->mtame) { newsym(mtmp->mx, mtmp->my); + if (mtmp->wormno) { + redraw_worm(mtmp); + } + } } } diff --git a/src/worm.c b/src/worm.c index 479c9d75e..86f1aef4c 100644 --- a/src/worm.c +++ b/src/worm.c @@ -988,4 +988,15 @@ flip_worm_segs_horizontal(struct monst *worm, int minx, int maxx) } } +void +redraw_worm(struct monst *worm) +{ + struct wseg *curr = wtails[worm->wormno]; + + while (curr) { + newsym(curr->wx, curr->wy); + curr = curr->nseg; + } +} + /*worm.c*/