setmangry fixes
Some discussion in the newsgroup about nearby peaceful monsters becoming hostile if they observed the hero attacking a peaceful monster made me look at the code and I spotted a couple of problems. An auto array was being initialized in an inner block--some pre-ANSI compilers couldn't handle that. Worse, it was inside a loop and may or may not have resulted in unnecessary setup each iteration. Make it static. Oddly, the array had the same name as a function but `gcc -Wshadow' either didn't notice or didn't care. A more significant problem was that mon->mpeaceful was being set to 0 without checking whether mon->mtame was set, potentially resulting in humanoid pets being both tame and hostile at the same time. This change prevents that but doesn't do anything interesting about pets who observe attacks against peacefuls. (I also wonder why chaotic peacefuls now get upset by seeing other peacefuls be attacked; it seems out of character.) There was also a check for non-humanoid peacefuls seeing another of the same species be attacked, but it was checking for an exact match without regard for littler or bigger incarnations of the same species. I've added the latter. This also reformats a couple of block comments.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 mondata.c $NHDT-Date: 1470966820 2016/08/12 01:53:40 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.61 $ */
|
||||
/* NetHack 3.6 mondata.c $NHDT-Date: 1492733172 2017/04/21 00:06:12 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.62 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1009,6 +1009,32 @@ int montype;
|
||||
return montype;
|
||||
}
|
||||
|
||||
/* determine whether two permonst indices are part of the same progression;
|
||||
existence of progressions with more than one step makes it a bit tricky */
|
||||
boolean
|
||||
big_little_match(montyp1, montyp2)
|
||||
int montyp1, montyp2;
|
||||
{
|
||||
int l, b;
|
||||
|
||||
/* simplest case: both are same pm */
|
||||
if (montyp1 == montyp2)
|
||||
return TRUE;
|
||||
/* assume it isn't possible to grow from one class letter to another */
|
||||
if (mons[montyp1].mlet != mons[montyp2].mlet)
|
||||
return FALSE;
|
||||
/* check whether montyp1 can grow up into montyp2 */
|
||||
for (l = montyp1; (b = little_to_big(l)) != l; l = b)
|
||||
if (b == montyp2)
|
||||
return TRUE;
|
||||
/* check whether montyp2 can grow up into montyp1 */
|
||||
for (l = montyp2; (b = little_to_big(l)) != l; l = b)
|
||||
if (b == montyp1)
|
||||
return TRUE;
|
||||
/* neither grows up to become the other; no match */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the permonst ptr for the race of the monster.
|
||||
* Returns correct pointer for non-polymorphed and polymorphed
|
||||
|
||||
Reference in New Issue
Block a user