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.
559 lines
11 KiB
C
559 lines
11 KiB
C
/* NetHack 3.7 wc_chainin.c $NHDT-Date: 1596498323 2020/08/03 23:45:23 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.12 $ */
|
|
/* Copyright (c) Kenneth Lorber, 2012 */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
/* -chainin is an internal processor that changes the flow from window_procs
|
|
* to chain_procs. */
|
|
|
|
#include "hack.h"
|
|
|
|
struct chainin_data {
|
|
struct chain_procs *nprocs;
|
|
void *ndata;
|
|
|
|
int linknum;
|
|
};
|
|
|
|
/* Normally, a processor gets this information from the first parm of each
|
|
* call, but here we are keeping the original API, so that parm doesn't exist,
|
|
* so we use this instead. */
|
|
static struct chainin_data *cibase;
|
|
|
|
void *
|
|
chainin_procs_chain(cmd, n, me, nextprocs, nextdata)
|
|
int cmd;
|
|
int n;
|
|
void *me;
|
|
void *nextprocs;
|
|
void *nextdata;
|
|
{
|
|
struct chainin_data *tdp = 0;
|
|
|
|
switch (cmd) {
|
|
case WINCHAIN_ALLOC:
|
|
tdp = (struct chainin_data *) alloc(sizeof *tdp);
|
|
tdp->nprocs = 0;
|
|
tdp->ndata = 0;
|
|
tdp->linknum = n;
|
|
cibase = 0;
|
|
break;
|
|
case WINCHAIN_INIT:
|
|
tdp = me;
|
|
tdp->nprocs = nextprocs;
|
|
tdp->ndata = nextdata;
|
|
break;
|
|
default:
|
|
panic("chainin_procs_chain: bad cmd\n");
|
|
/*NOTREACHED*/
|
|
}
|
|
return tdp;
|
|
}
|
|
|
|
/* XXX if we don't need this, take it out of the table */
|
|
void
|
|
chainin_procs_init(dir)
|
|
int dir UNUSED;
|
|
{
|
|
}
|
|
|
|
/***
|
|
*** winprocs
|
|
***/
|
|
|
|
void
|
|
chainin_init_nhwindows(argcp, argv)
|
|
int *argcp;
|
|
char **argv;
|
|
{
|
|
(*cibase->nprocs->win_init_nhwindows)(cibase->ndata, argcp, argv);
|
|
}
|
|
|
|
void
|
|
chainin_player_selection()
|
|
{
|
|
(*cibase->nprocs->win_player_selection)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_askname()
|
|
{
|
|
(*cibase->nprocs->win_askname)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_get_nh_event()
|
|
{
|
|
(*cibase->nprocs->win_get_nh_event)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_exit_nhwindows(str)
|
|
const char *str;
|
|
{
|
|
(*cibase->nprocs->win_exit_nhwindows)(cibase->ndata, str);
|
|
}
|
|
|
|
void
|
|
chainin_suspend_nhwindows(str)
|
|
const char *str;
|
|
{
|
|
(*cibase->nprocs->win_suspend_nhwindows)(cibase->ndata, str);
|
|
}
|
|
|
|
void
|
|
chainin_resume_nhwindows()
|
|
{
|
|
(*cibase->nprocs->win_resume_nhwindows)(cibase->ndata);
|
|
}
|
|
|
|
winid
|
|
chainin_create_nhwindow(type)
|
|
int type;
|
|
{
|
|
winid rv;
|
|
|
|
rv = (*cibase->nprocs->win_create_nhwindow)(cibase->ndata, type);
|
|
|
|
return rv;
|
|
}
|
|
|
|
void
|
|
chainin_clear_nhwindow(window)
|
|
winid window;
|
|
{
|
|
(*cibase->nprocs->win_clear_nhwindow)(cibase->ndata, window);
|
|
}
|
|
|
|
void
|
|
chainin_display_nhwindow(window, blocking)
|
|
winid window;
|
|
BOOLEAN_P blocking;
|
|
{
|
|
(*cibase->nprocs->win_display_nhwindow)(cibase->ndata, window, blocking);
|
|
}
|
|
|
|
void
|
|
chainin_destroy_nhwindow(window)
|
|
winid window;
|
|
{
|
|
(*cibase->nprocs->win_destroy_nhwindow)(cibase->ndata, window);
|
|
}
|
|
|
|
void
|
|
chainin_curs(window, x, y)
|
|
winid window;
|
|
int x;
|
|
int y;
|
|
{
|
|
(*cibase->nprocs->win_curs)(cibase->ndata, window, x, y);
|
|
}
|
|
|
|
void
|
|
chainin_putstr(window, attr, str)
|
|
winid window;
|
|
int attr;
|
|
const char *str;
|
|
{
|
|
(*cibase->nprocs->win_putstr)(cibase->ndata, window, attr, str);
|
|
}
|
|
|
|
void
|
|
chainin_putmixed(window, attr, str)
|
|
winid window;
|
|
int attr;
|
|
const char *str;
|
|
{
|
|
(*cibase->nprocs->win_putmixed)(cibase->ndata, window, attr, str);
|
|
}
|
|
|
|
void
|
|
chainin_display_file(fname, complain)
|
|
const char *fname;
|
|
boolean complain;
|
|
{
|
|
(*cibase->nprocs->win_display_file)(cibase->ndata, fname, complain);
|
|
}
|
|
|
|
void
|
|
chainin_start_menu(window, mbehavior)
|
|
winid window;
|
|
unsigned long mbehavior;
|
|
{
|
|
(*cibase->nprocs->win_start_menu)(cibase->ndata, window, mbehavior);
|
|
}
|
|
|
|
void
|
|
chainin_add_menu(window, glyph, identifier, ch, gch, attr, str, itemflags)
|
|
winid window; /* window to use, must be of type NHW_MENU */
|
|
int glyph; /* glyph to display with item (unused) */
|
|
const anything *identifier; /* what to return if selected */
|
|
char ch; /* keyboard accelerator (0 = pick our own) */
|
|
char gch; /* group accelerator (0 = no group) */
|
|
int attr; /* attribute for string (like tty_putstr()) */
|
|
const char *str; /* menu string */
|
|
unsigned int itemflags; /* flags such as item is marked as selected
|
|
MENU_ITEMFLAGS_SELECTED */
|
|
{
|
|
(*cibase->nprocs->win_add_menu)(cibase->ndata, window, glyph, identifier,
|
|
ch, gch, attr, str, itemflags);
|
|
}
|
|
|
|
void
|
|
chainin_end_menu(window, prompt)
|
|
winid window;
|
|
const char *prompt;
|
|
{
|
|
(*cibase->nprocs->win_end_menu)(cibase->ndata, window, prompt);
|
|
}
|
|
|
|
int
|
|
chainin_select_menu(window, how, menu_list)
|
|
winid window;
|
|
int how;
|
|
menu_item **menu_list;
|
|
{
|
|
int rv;
|
|
|
|
rv = (*cibase->nprocs->win_select_menu)(cibase->ndata, window, how,
|
|
(void *) menu_list);
|
|
|
|
return rv;
|
|
}
|
|
|
|
char
|
|
chainin_message_menu(let, how, mesg)
|
|
char let;
|
|
int how;
|
|
const char *mesg;
|
|
{
|
|
char rv;
|
|
|
|
rv = (*cibase->nprocs->win_message_menu)(cibase->ndata, let, how, mesg);
|
|
|
|
return rv;
|
|
}
|
|
|
|
void
|
|
chainin_update_inventory()
|
|
{
|
|
(*cibase->nprocs->win_update_inventory)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_mark_synch()
|
|
{
|
|
(*cibase->nprocs->win_mark_synch)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_wait_synch()
|
|
{
|
|
(*cibase->nprocs->win_wait_synch)(cibase->ndata);
|
|
}
|
|
|
|
#ifdef CLIPPING
|
|
void
|
|
chainin_cliparound(x, y)
|
|
int x;
|
|
int y;
|
|
{
|
|
(*cibase->nprocs->win_cliparound)(cibase->ndata, x, y);
|
|
}
|
|
#endif
|
|
|
|
#ifdef POSITIONBAR
|
|
void
|
|
chainin_update_positionbar(posbar)
|
|
char *posbar;
|
|
{
|
|
(*cibase->nprocs->win_update_positionbar)(cibase->ndata, posbar);
|
|
}
|
|
#endif
|
|
|
|
/* XXX can we decode the glyph in a meaningful way? */
|
|
void
|
|
chainin_print_glyph(window, x, y, glyph, bkglyph, glyphmod)
|
|
winid window;
|
|
xchar x, y;
|
|
int glyph, bkglyph;
|
|
int glyphmod[NUM_GLYPHMOD];
|
|
{
|
|
(*cibase->nprocs->win_print_glyph)(cibase->ndata, window, x, y, glyph, bkglyph, glyphmod);
|
|
}
|
|
|
|
void
|
|
chainin_raw_print(str)
|
|
const char *str;
|
|
{
|
|
(*cibase->nprocs->win_raw_print)(cibase->ndata, str);
|
|
}
|
|
|
|
void
|
|
chainin_raw_print_bold(str)
|
|
const char *str;
|
|
{
|
|
(*cibase->nprocs->win_raw_print_bold)(cibase->ndata, str);
|
|
}
|
|
|
|
int
|
|
chainin_nhgetch()
|
|
{
|
|
int rv;
|
|
|
|
rv = (*cibase->nprocs->win_nhgetch)(cibase->ndata);
|
|
|
|
return rv;
|
|
}
|
|
|
|
int
|
|
chainin_nh_poskey(x, y, mod)
|
|
int *x;
|
|
int *y;
|
|
int *mod;
|
|
{
|
|
int rv;
|
|
|
|
rv = (*cibase->nprocs->win_nh_poskey)(cibase->ndata, x, y, mod);
|
|
|
|
return rv;
|
|
}
|
|
|
|
void
|
|
chainin_nhbell()
|
|
{
|
|
(*cibase->nprocs->win_nhbell)(cibase->ndata);
|
|
}
|
|
|
|
int
|
|
chainin_doprev_message()
|
|
{
|
|
int rv;
|
|
|
|
rv = (*cibase->nprocs->win_doprev_message)(cibase->ndata);
|
|
|
|
return rv;
|
|
}
|
|
|
|
char
|
|
chainin_yn_function(query, resp, def)
|
|
const char *query, *resp;
|
|
char def;
|
|
{
|
|
int rv;
|
|
|
|
rv = (*cibase->nprocs->win_yn_function)(cibase->ndata, query, resp, def);
|
|
|
|
return rv;
|
|
}
|
|
|
|
void
|
|
chainin_getlin(query, bufp)
|
|
const char *query;
|
|
char *bufp;
|
|
{
|
|
(*cibase->nprocs->win_getlin)(cibase->ndata, query, bufp);
|
|
}
|
|
|
|
int
|
|
chainin_get_ext_cmd()
|
|
{
|
|
int rv;
|
|
|
|
rv = (*cibase->nprocs->win_get_ext_cmd)(cibase->ndata);
|
|
|
|
return rv;
|
|
}
|
|
|
|
void
|
|
chainin_number_pad(state)
|
|
int state;
|
|
{
|
|
(*cibase->nprocs->win_number_pad)(cibase->ndata, state);
|
|
}
|
|
|
|
void
|
|
chainin_delay_output()
|
|
{
|
|
(*cibase->nprocs->win_delay_output)(cibase->ndata);
|
|
}
|
|
|
|
#ifdef CHANGE_COLOR
|
|
void
|
|
chainin_change_color(color, value, reverse)
|
|
int color;
|
|
long value;
|
|
int reverse;
|
|
{
|
|
(*cibase->nprocs->win_change_color)(cibase->ndata, color, value, reverse);
|
|
}
|
|
|
|
#ifdef MAC
|
|
void
|
|
chainin_change_background(bw)
|
|
int bw;
|
|
{
|
|
(*cibase->nprocs->win_change_background)(cibase->ndata, bw);
|
|
}
|
|
|
|
short
|
|
chainin_set_font_name(window, font)
|
|
winid window;
|
|
char *font;
|
|
{
|
|
short rv;
|
|
|
|
rv = (*cibase->nprocs->win_set_font_name)(cibase->ndata, window, font);
|
|
|
|
return rv;
|
|
}
|
|
#endif
|
|
|
|
char *
|
|
trace_get_color_string()
|
|
{
|
|
char *rv;
|
|
|
|
rv = (*cibase->nprocs->win_get_color_string)(cibase->ndata);
|
|
|
|
return rv;
|
|
}
|
|
|
|
#endif
|
|
|
|
/* other defs that really should go away (they're tty specific) */
|
|
void
|
|
chainin_start_screen()
|
|
{
|
|
(*cibase->nprocs->win_start_screen)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_end_screen()
|
|
{
|
|
(*cibase->nprocs->win_end_screen)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_outrip(tmpwin, how, when)
|
|
winid tmpwin;
|
|
int how;
|
|
time_t when;
|
|
{
|
|
(*cibase->nprocs->win_outrip)(cibase->ndata, tmpwin, how, when);
|
|
}
|
|
|
|
void
|
|
chainin_preference_update(pref)
|
|
const char *pref;
|
|
{
|
|
(*cibase->nprocs->win_preference_update)(cibase->ndata, pref);
|
|
}
|
|
|
|
char *
|
|
chainin_getmsghistory(init)
|
|
boolean init;
|
|
{
|
|
char *rv;
|
|
|
|
rv = (*cibase->nprocs->win_getmsghistory)(cibase->ndata, init);
|
|
|
|
return rv;
|
|
}
|
|
|
|
void
|
|
chainin_putmsghistory(msg, is_restoring)
|
|
const char *msg;
|
|
boolean is_restoring;
|
|
{
|
|
(*cibase->nprocs->win_putmsghistory)(cibase->ndata, msg, is_restoring);
|
|
}
|
|
|
|
void
|
|
chainin_status_init()
|
|
{
|
|
(*cibase->nprocs->win_status_init)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_status_finish()
|
|
{
|
|
(*cibase->nprocs->win_status_finish)(cibase->ndata);
|
|
}
|
|
|
|
void
|
|
chainin_status_enablefield(fieldidx, nm, fmt, enable)
|
|
int fieldidx;
|
|
const char *nm;
|
|
const char *fmt;
|
|
boolean enable;
|
|
{
|
|
(*cibase->nprocs->win_status_enablefield)(cibase->ndata, fieldidx, nm,
|
|
fmt, enable);
|
|
}
|
|
|
|
void
|
|
chainin_status_update(idx, ptr, chg, percent, color, colormasks)
|
|
int idx, chg, percent, color;
|
|
genericptr_t ptr;
|
|
unsigned long *colormasks;
|
|
{
|
|
(*cibase->nprocs->win_status_update)(cibase->ndata, idx, ptr, chg,
|
|
percent, color, colormasks);
|
|
}
|
|
|
|
boolean
|
|
chainin_can_suspend()
|
|
{
|
|
boolean rv;
|
|
|
|
rv = (*cibase->nprocs->win_can_suspend)(cibase->ndata);
|
|
|
|
return rv;
|
|
}
|
|
|
|
struct window_procs chainin_procs = {
|
|
"-chainin", 0, /* wincap */
|
|
0, /* wincap2 */
|
|
/*
|
|
XXX problem - the above need to come from the real window port, possibly
|
|
modified. May need to do something to call an additional init fn later
|
|
or if this is the only place like this the choose_windows fn can do the
|
|
fixup
|
|
(but not if the value can be modified by the stack?) TBD
|
|
*/
|
|
chainin_init_nhwindows,
|
|
chainin_player_selection, chainin_askname, chainin_get_nh_event,
|
|
chainin_exit_nhwindows, chainin_suspend_nhwindows,
|
|
chainin_resume_nhwindows, chainin_create_nhwindow, chainin_clear_nhwindow,
|
|
chainin_display_nhwindow, chainin_destroy_nhwindow, chainin_curs,
|
|
chainin_putstr, chainin_putmixed, chainin_display_file,
|
|
chainin_start_menu, chainin_add_menu, chainin_end_menu,
|
|
chainin_select_menu, chainin_message_menu, chainin_update_inventory,
|
|
chainin_mark_synch, chainin_wait_synch,
|
|
#ifdef CLIPPING
|
|
chainin_cliparound,
|
|
#endif
|
|
#ifdef POSITIONBAR
|
|
chainin_update_positionbar,
|
|
#endif
|
|
chainin_print_glyph, chainin_raw_print, chainin_raw_print_bold,
|
|
chainin_nhgetch, chainin_nh_poskey, chainin_nhbell,
|
|
chainin_doprev_message, chainin_yn_function, chainin_getlin,
|
|
chainin_get_ext_cmd, chainin_number_pad, chainin_delay_output,
|
|
#ifdef CHANGE_COLOR
|
|
chainin_change_color,
|
|
#ifdef MAC
|
|
chainin_change_background, chainin_set_font_name,
|
|
#endif
|
|
chainin_get_color_string,
|
|
#endif
|
|
|
|
chainin_start_screen, chainin_end_screen,
|
|
|
|
chainin_outrip, chainin_preference_update, chainin_getmsghistory,
|
|
chainin_putmsghistory,
|
|
chainin_status_init, chainin_status_finish, chainin_status_enablefield,
|
|
chainin_status_update,
|
|
chainin_can_suspend,
|
|
};
|