mextra tweaks (trunk only)

Add new_mname/free_mname functions to make monster name handling be
more like the other extended data and to hide mextra details a bit more.
Add some casts where int and unsigned are being intermixed.  Simplify
christen_monst(); it ought to be changed to have type `void' but I wanted
to avoid modifying another ten or so files.
This commit is contained in:
nethack.rankin
2006-01-08 06:19:42 +00:00
parent 0bdb1fba28
commit 039e051323
6 changed files with 80 additions and 74 deletions

View File

@@ -297,13 +297,12 @@ genericptr_t buffer;
(void) memcpy((genericptr_t)&lth, (genericptr_t)spot, sizeof(int));
spot += sizeof(int);
if (lth) {
if (!mtmp->mextra) mtmp->mextra = newmextra();
MNAME(mtmp) = (char *)alloc(lth);
new_mname(mtmp, lth);
(void) memcpy((genericptr_t)MNAME(mtmp),
(genericptr_t)spot, lth);
spot += lth;
}
/* obtain the length of the egd (guard) structure */
/* obtain the length of the egd (vault guard) structure */
(void) memcpy((genericptr_t)&lth, (genericptr_t)spot, sizeof(int));
spot += sizeof(int);
if (lth) {
@@ -371,8 +370,7 @@ boolean ghostly;
/* read the length of the name and the name */
mread(fd, (genericptr_t) &buflen, sizeof(buflen));
if (buflen > 0) {
if (!mtmp->mextra) mtmp->mextra = newmextra();
MNAME(mtmp) = (char *)alloc(buflen);
new_mname(mtmp, buflen);
mread(fd, (genericptr_t) MNAME(mtmp), buflen);
}