pmnames mons gender naming plus a window port interface change

add MALE, FEMALE, and gender-neutral names for individual monster species
to the mons array. The gender-neutral name (NEUTRAL) is mandatory, the
MALE and FEMALE versions are not.

replace code uses of the mname field of permonst with one of the three
potentially-available gender-specific names.

consolidate some separate mons entries that differed only by species into a
single mons entry (caveman, cavewoman and priest,priestess etc.)

consolidate several "* lord" and "* queen/* king" monst entries into
their single species, and allow both genders on some where it makes some
sense (there is probably more work and cleanup to come out of this at some
point, and the chosen gender-neutral name variations are not cast in stone
if someone has better suggestions).

related function or macro additions:
    pmname(pm, gender) to get the gender variation of the permonst name. It
    guards against monsters that haven't got anything except NEUTRAL naming
    and falls back to the NEUTRAL version if FEMALE and MALE versions are
    missing.

    Ugender to obtain the current hero gender.
    Mgender(mtmp) to obtain the gender of a monster

While the code can safely refer directly to pmnames[NEUTRAL] safely in the
code because it always exists, the other two (pmnames[MALE] and
pmnames[FEMALE] may not exist so use:
    pmname(ptr, gidx)
      where -ptr is a permonst *
            -gidx is an index into the pmnames array field of the
             permonst struct
pmname() checks for a valid index and checks for null-pointers for
pmnames[MALE] and pmnames[FEMALE], and will fall back to pmnames[NEUTRAL] if
the pointer requested if the requested variation is unavailable, or if the
gidx is out-of-range.

Allow code to specify makemon flags to request female or male (via MM_MALE
and MM_FEMALE flags respectively)to makedefs, since the species alone doesn't
distinguish male/female anymore. Specifying MM_MALE or MM_FEMALE won't
override the pm M2_MALE and M2_FEMALE flags on a mons[] entry.

male and female tiles have been added to win/share/monsters.txt.
The majority are duplicated placeholders except for those that were
separate mons entries before. Perhaps someone will contribute artwork in the
future to make the male and female variations visually distinguishable.

tilemapping via has the MALE tile indexes in the glyph2tile[]
array produced at build time. If a window port has information that the
FEMALE tile is required, it just has to increment the index returned
from the glyph2tile[] array by 1.

statues already preserved gender of the monster through STATUE_FEMALE
and STATUE_MALE, so ensure that pmnames takes that into consideration.

I expect some refinement will be required after broad play-testing puts it to
the test.

    consolidate caveman,cavewoman and priest,priestess monst.c entries etc

This commit will require a bump of editlevel in patchlevel.h because it alters
the index numbers of the monsters due to the consolidation of some. Those
index numbers are saved in some other structures, even though the mons[] array
itself is not part of the savefile.

Window Port Interface Change

Also add a parameter to print_glyph to convey additional information beyond
the glyph to the window ports. Every single window port was calling back to
mapglyph for the information anyway, so just included it in the interface and
produce the information right in the display core.

The mapglyph() function uses will be eliminated, although there are still some
in the code yet to be dealt with.

win32, tty, x11, Qt, msdos window ports have all had adjustments done to
utilize the new parameter instead of calling mapglyph, but some of those
window ports have not been thoroughly tested since the changes.

Interface change additional info:

    print_glyph(window, x, y, glyph, bkglyph, *glyphmod)
            -- Print the glyph at (x,y) on the given window.  Glyphs are
               integers at the interface, mapped to whatever the window-
               port wants (symbol, font, color, attributes, ...there's
               a 1-1 map between glyphs and distinct things on the map).
            -- bkglyph is a background glyph for potential use by some
               graphical or tiled environments to allow the depiction
               to fall against a background consistent with the grid
               around x,y. If bkglyph is NO_GLYPH, then the parameter
               should be ignored (do nothing with it).
                -- glyphmod provides extended information about the glyph
               that window ports can use to enhance the display in
               various ways.
                    unsigned int glyphmod[NUM_GLYPHMOD]
               where:
                    glyphmod[GM_TTYCHAR]  is the text characters associated
                                          with the original NetHack display.

                    glyphmod[GM_FLAGS]    are the special flags that denote
                                          additional information that window
                                          ports can use.

                    glyphmod[GM_COLOR] is the text character
                                       color associated with the original
                                       NetHack display.

Support for including the glyphmod info in the display glyph buffer
alongside the glyph itself was added and is the default operation.
That can be turned off by defining UNBUFFERED_GLYPHMOD at compile time.
With UNBUFFERED_GLYPHMOD operation, a call will be placed to map_glyphmod()
immediately prior to every print_glyph() call.
This commit is contained in:
nhmall
2020-12-26 11:23:23 -05:00
parent 62e6064a54
commit 0c3b9642e4
113 changed files with 9561 additions and 1259 deletions
+2 -2
View File
@@ -180,7 +180,7 @@ static NEARDATA struct artifact artilist[] = {
A("The Sceptre of Might", MACE,
(SPFX_NOGEN | SPFX_RESTR | SPFX_INTEL | SPFX_DALIGN), 0, 0, PHYS(5, 0),
DFNS(AD_MAGM), NO_CARY, CONFLICT, A_LAWFUL, PM_CAVEMAN, NON_PM, 2500L,
DFNS(AD_MAGM), NO_CARY, CONFLICT, A_LAWFUL, PM_CAVE_DWELLER, NON_PM, 2500L,
NO_COLOR),
#if 0 /* OBSOLETE */
@@ -210,7 +210,7 @@ A("The Palantir of Westernesse", CRYSTAL_BALL,
A("The Mitre of Holiness", HELM_OF_BRILLIANCE,
(SPFX_NOGEN | SPFX_RESTR | SPFX_DFLAG2 | SPFX_INTEL | SPFX_PROTECT), 0,
M2_UNDEAD, NO_ATTK, NO_DFNS, CARY(AD_FIRE), ENERGY_BOOST, A_LAWFUL,
PM_PRIEST, NON_PM, 2000L, NO_COLOR),
PM_CLERIC, NON_PM, 2000L, NO_COLOR),
A("The Longbow of Diana", BOW,
(SPFX_NOGEN | SPFX_RESTR | SPFX_INTEL | SPFX_REFLECT), SPFX_ESP, 0,
+3
View File
@@ -524,6 +524,9 @@ struct trapinfo {
typedef struct {
xchar gnew; /* perhaps move this bit into the rm structure. */
int glyph;
#ifndef UNBUFFERED_GLYPHMOD
unsigned glyphmod[NUM_GLYPHMOD];
#endif
} gbuf_entry;
enum vanq_order_modes {
+23
View File
@@ -475,4 +475,27 @@ enum explosion_types {
#define glyph_is_unexplored(glyph) ((glyph) == GLYPH_UNEXPLORED)
#define glyph_is_nothing(glyph) ((glyph) == GLYPH_NOTHING)
/* flags for map_glyphmod */
/* mgflags for altering map_glyphmod() internal behaviour */
#define MG_FLAG_NORMAL 0x00
#define MG_FLAG_NOOVERRIDE 0x01
#define MG_FLAG_RETURNIDX 0x02
/* Special mapped glyph flags encoded in glyphmod[GM_FLAGS] by map_glyphmod() */
#define MG_CORPSE 0x0001
#define MG_INVIS 0x0002
#define MG_DETECT 0x0004
#define MG_PET 0x0008
#define MG_RIDDEN 0x0010
#define MG_STATUE 0x0020
#define MG_OBJPILE 0x0040 /* more than one stack of objects */
#define MG_BW_LAVA 0x0080 /* 'black & white lava': highlight lava if it
can't be distringuished from water by color */
#define MG_BW_ICE 0x0100 /* similar for ice vs floor */
#define MG_NOTHING 0x0200 /* char represents GLYPH_NOTHING */
#define MG_UNEXPL 0x0400 /* char represents GLYPH_UNEXPLORED */
#define MG_FEMALE 0x0800 /* represents a female mon,detected mon,pet,ridden */
#define MG_BADXY 0x1000 /* bad coordinates were passed */
#endif /* DISPLAY_H */
+9 -4
View File
@@ -374,6 +374,7 @@ E void NDECL(reglyph_darkroom);
E void NDECL(set_wall_state);
E void FDECL(unset_seenv, (struct rm *, int, int, int, int));
E int FDECL(warning_of, (struct monst *));
E void FDECL(map_glyphmod, (XCHAR_P, XCHAR_P, int, unsigned, unsigned *));
/* ### do.c ### */
@@ -415,8 +416,8 @@ E char *FDECL(coord_desc, (int, int, char *, CHAR_P));
E boolean FDECL(getpos_menu, (coord *, int));
E int FDECL(getpos, (coord *, BOOLEAN_P, const char *));
E void FDECL(getpos_sethilite, (void (*f)(int), boolean (*d)(int,int)));
E void FDECL(new_mname, (struct monst *, int));
E void FDECL(free_mname, (struct monst *));
E void FDECL(new_mgivenname, (struct monst *, int));
E void FDECL(free_mgivenname, (struct monst *));
E void FDECL(new_oname, (struct obj *, int));
E void FDECL(free_oname, (struct obj *));
E const char *FDECL(safe_oname, (struct obj *));
@@ -457,6 +458,10 @@ E struct monst *FDECL(christen_orc, (struct monst *, const char *,
const char *));
E const char *FDECL(noveltitle, (int *));
E const char *FDECL(lookup_novel, (const char *, int *));
#ifndef PMNAME_MACROS
E int FDECL(Mgender, (struct monst *));
E const char *FDECL(pmname, (struct permonst *, int));
#endif /* PMNAME_MACROS */
/* ### do_wear.c ### */
@@ -1516,8 +1521,8 @@ E boolean FDECL(dmgtype, (struct permonst *, int));
E int FDECL(max_passive_dmg, (struct monst *, struct monst *));
E boolean FDECL(same_race, (struct permonst *, struct permonst *));
E int FDECL(monsndx, (struct permonst *));
E int FDECL(name_to_mon, (const char *));
E int FDECL(name_to_monplus, (const char *, const char **));
E int FDECL(name_to_mon, (const char *, int *));
E int FDECL(name_to_monplus, (const char *, const char **, int *));
E int FDECL(name_to_monclass, (const char *, int *));
E int FDECL(gender, (struct monst *));
E int FDECL(pronoun_gender, (struct monst *, unsigned));
+7 -20
View File
@@ -79,24 +79,6 @@ enum dismount_types {
DISMOUNT_BYCHOICE = 6
};
/* mgflags for mapglyph() */
#define MG_FLAG_NORMAL 0x00
#define MG_FLAG_NOOVERRIDE 0x01
/* Special returns from mapglyph() */
#define MG_CORPSE 0x0001
#define MG_INVIS 0x0002
#define MG_DETECT 0x0004
#define MG_PET 0x0008
#define MG_RIDDEN 0x0010
#define MG_STATUE 0x0020
#define MG_OBJPILE 0x0040 /* more than one stack of objects */
#define MG_BW_LAVA 0x0080 /* 'black & white lava': highlight lava if it
can't be distringuished from water by color */
#define MG_BW_ICE 0x0100 /* similar for ice vs floor */
#define MG_NOTHING 0x0200 /* char represents GLYPH_NOTHING */
#define MG_UNEXPL 0x0400 /* char represents GLYPH_UNEXPLORED */
/* sellobj_state() states */
#define SELL_NORMAL (0)
#define SELL_DELIBERATE (1)
@@ -216,6 +198,9 @@ typedef struct {
#define SYM_OFF_X (SYM_OFF_W + WARNCOUNT)
#define SYM_MAX (SYM_OFF_X + MAXOTHER)
/* glyphmod entries */
enum { GM_FLAGS, GM_TTYCHAR, GM_COLOR, NUM_GLYPHMOD };
#include "rect.h"
#include "region.h"
#include "decl.h"
@@ -293,10 +278,12 @@ typedef struct sortloot_item Loot;
#define MM_ASLEEP 0x002000L /* monsters should be generated asleep */
#define MM_NOGRP 0x004000L /* suppress creation of monster groups */
#define MM_NOTAIL 0x008000L /* if a long worm, don't give it a tail */
#define MM_MALE 0x010000L /* male variation */
#define MM_FEMALE 0x020000L /* female variation */
/* if more MM_ flag masks are added, skip or renumber the GP_ one(s) */
#define GP_ALLOW_XY 0x010000L /* [actually used by enexto() to decide whether
#define GP_ALLOW_XY 0x040000L /* [actually used by enexto() to decide whether
* to make an extra call to goodpos()] */
#define GP_ALLOW_U 0x020000L /* don't reject hero's location */
#define GP_ALLOW_U 0x080000L /* don't reject hero's location */
/* flags for make_corpse() and mkcorpstat() */
#define CORPSTAT_NONE 0x00
+3 -3
View File
@@ -175,7 +175,7 @@ struct edog {
** mextra.h -- collection of all monster extensions
*/
struct mextra {
char *mname;
char *mgivenname;
struct egd *egd;
struct epri *epri;
struct eshk *eshk;
@@ -186,7 +186,7 @@ struct mextra {
* or an alignment mask for one posing as an altar */
};
#define MNAME(mon) ((mon)->mextra->mname)
#define MGIVENNAME(mon) ((mon)->mextra->mgivenname)
#define EGD(mon) ((mon)->mextra->egd)
#define EPRI(mon) ((mon)->mextra->epri)
#define ESHK(mon) ((mon)->mextra->eshk)
@@ -194,7 +194,7 @@ struct mextra {
#define EDOG(mon) ((mon)->mextra->edog)
#define MCORPSENM(mon) ((mon)->mextra->mcorpsenm)
#define has_mname(mon) ((mon)->mextra && MNAME(mon))
#define has_mgivenname(mon) ((mon)->mextra && MGIVENNAME(mon))
#define has_egd(mon) ((mon)->mextra && EGD(mon))
#define has_epri(mon) ((mon)->mextra && EPRI(mon))
#define has_eshk(mon) ((mon)->mextra && ESHK(mon))
+3
View File
@@ -205,6 +205,9 @@ enum ms_sounds {
#define G_GONE (G_GENOD | G_EXTINCT)
#define MV_KNOWS_EGG 0x08 /* player recognizes egg of this monster type */
enum mgender { MALE, FEMALE, NEUTRAL,
NUM_MGENDERS };
/* *INDENT-ON* */
/* clang-format on */
#endif /* MONFLAG_H */
+5 -1
View File
@@ -184,7 +184,7 @@ struct monst {
#define DEADMONSTER(mon) ((mon)->mhp < 1)
#define is_starting_pet(mon) ((mon)->m_id == g.context.startingpet_mid)
#define is_vampshifter(mon) \
((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LORD \
((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LEADER \
|| (mon)->cham == PM_VLAD_THE_IMPALER)
#define vampshifted(mon) (is_vampshifter((mon)) && !is_vampire((mon)->data))
@@ -220,4 +220,8 @@ struct monst {
#define montoostrong(monindx, lev) (mons[monindx].difficulty > lev)
#define montooweak(monindx, lev) (mons[monindx].difficulty < lev)
#ifdef PMNAME_MACROS
#define Mgender(mon) ((mon)->female ? FEMALE : MALE)
#endif
#endif /* MONST_H */
+1 -1
View File
@@ -17,7 +17,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files.
*/
#define EDITLEVEL 29
#define EDITLEVEL 30
/*
* Development status possibilities.
+5 -1
View File
@@ -40,7 +40,7 @@ struct attack {
#include "monflag.h"
struct permonst {
const char *mname; /* full name */
const char *pmnames[NUM_MGENDERS];
char mlet; /* symbol */
schar mlevel, /* base monster level */
mmove, /* move speed */
@@ -78,4 +78,8 @@ extern NEARDATA struct permonst mons[]; /* the master list of monster types */
/* mons[SPECIAL_PM] through mons[NUMMONS-1], inclusive, are
never generated randomly and cannot be polymorphed into */
#ifdef PMNAME_MACROS
#define pmname(pm,g) ((((g) == MALE || (g) == FEMALE) && (pm)->pmnames[g]) \
? (pm)->pmnames[g] : (pm)->pmnames[NEUTRAL])
#endif
#endif /* PERMONST_H */
+2 -1
View File
@@ -453,7 +453,8 @@ E void NDECL(X11_wait_synch);
#ifdef CLIPPING
E void FDECL(X11_cliparound, (int, int));
#endif
E void FDECL(X11_print_glyph, (winid, XCHAR_P, XCHAR_P, int, int));
E void FDECL(X11_print_glyph, (winid, XCHAR_P, XCHAR_P,
int, int, unsigned *));
E void FDECL(X11_raw_print, (const char *));
E void FDECL(X11_raw_print_bold, (const char *));
E int NDECL(X11_nhgetch);
+1 -1
View File
@@ -90,7 +90,7 @@ extern void curses_mark_synch(void);
extern void curses_wait_synch(void);
extern void curses_cliparound(int x, int y);
extern void curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y,
int glyph, int bkglyph);
int glyph, int bkglyph, unsigned *glyphmod);
extern void curses_raw_print(const char *str);
extern void curses_raw_print_bold(const char *str);
extern int curses_nhgetch(void);
+2 -1
View File
@@ -84,7 +84,8 @@ E void FDECL(Gem_cliparound, (int, int));
#ifdef POSITIONBAR
E void FDECL(Gem_update_positionbar, (char *));
#endif
E void FDECL(Gem_print_glyph, (winid, XCHAR_P, XCHAR_P, int, int));
E void FDECL(Gem_print_glyph, (winid, XCHAR_P, XCHAR_P,
int, int, unsigned *));
E void FDECL(Gem_raw_print, (const char *));
E void FDECL(Gem_raw_print_bold, (const char *));
E int NDECL(Gem_nhgetch);
+6 -3
View File
@@ -45,7 +45,8 @@ struct window_procs {
#ifdef POSITIONBAR
void FDECL((*win_update_positionbar), (char *));
#endif
void FDECL((*win_print_glyph), (winid, XCHAR_P, XCHAR_P, int, int));
void FDECL((*win_print_glyph), (winid, XCHAR_P, XCHAR_P,
int, int, unsigned *));
void FDECL((*win_raw_print), (const char *));
void FDECL((*win_raw_print_bold), (const char *));
int NDECL((*win_nhgetch));
@@ -345,7 +346,8 @@ struct chain_procs {
#ifdef POSITIONBAR
void FDECL((*win_update_positionbar), (CARGS, char *));
#endif
void FDECL((*win_print_glyph), (CARGS, winid, XCHAR_P, XCHAR_P, int, int));
void FDECL((*win_print_glyph), (CARGS, winid, XCHAR_P, XCHAR_P,
int, int, unsigned *));
void FDECL((*win_raw_print), (CARGS, const char *));
void FDECL((*win_raw_print_bold), (CARGS, const char *));
int FDECL((*win_nhgetch), (CARGS));
@@ -420,7 +422,8 @@ extern void FDECL(safe_cliparound, (int, int));
#ifdef POSITIONBAR
extern void FDECL(safe_update_positionbar, (char *));
#endif
extern void FDECL(safe_print_glyph, (winid, XCHAR_P, XCHAR_P, int, int));
extern void FDECL(safe_print_glyph, (winid, XCHAR_P, XCHAR_P,
int, int, unsigned *));
extern void FDECL(safe_raw_print, (const char *));
extern void FDECL(safe_raw_print_bold, (const char *));
extern int NDECL(safe_nhgetch);
+1 -1
View File
@@ -211,7 +211,7 @@ E void FDECL(tty_cliparound, (int, int));
#ifdef POSITIONBAR
E void FDECL(tty_update_positionbar, (char *));
#endif
E void FDECL(tty_print_glyph, (winid, XCHAR_P, XCHAR_P, int, int));
E void FDECL(tty_print_glyph, (winid, XCHAR_P, XCHAR_P, int, int, unsigned *));
E void FDECL(tty_raw_print, (const char *));
E void FDECL(tty_raw_print_bold, (const char *));
E int NDECL(tty_nhgetch);
+1
View File
@@ -479,5 +479,6 @@ struct you {
}; /* end of `struct you' */
#define Upolyd (u.umonnum != u.umonster)
#define Ugender ((Upolyd ? u.mfemale : flags.female) ? 1 : 0)
#endif /* YOU_H */