more followup (trunk only)
make the handling recognition use an int instead of string.
This commit is contained in:
23
include/rm.h
23
include/rm.h
@@ -241,21 +241,28 @@ struct textlist {
|
|||||||
struct textlist *next; /* next in list */
|
struct textlist *next; /* next in list */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* special symbol set handling types (callbacks, etc.)
|
||||||
|
* Must match the order of the known_handlers strings
|
||||||
|
* in drawing.c
|
||||||
|
*/
|
||||||
|
#define H_UNK 0
|
||||||
|
#define H_IBM 1
|
||||||
|
#define H_DEC 2
|
||||||
|
|
||||||
#ifdef REINCARNATION
|
#ifdef REINCARNATION
|
||||||
#define ROGUEHANDLING(H) ((Is_rogue_level(&u.uz) && roguehandling && \
|
#define ROGUEHANDLING(ht) (Is_rogue_level(&u.uz) && roguehandling == (ht))
|
||||||
!strcmpi(roguehandling,H)))
|
#define SYMHANDLING(ht) (ROGUEHANDLING(ht) || \
|
||||||
#define SYMHANDLING(H) (ROGUEHANDLING(H) || \
|
(!Is_rogue_level(&u.uz) && symhandling == (ht)))
|
||||||
(!Is_rogue_level(&u.uz) && symhandling && \
|
|
||||||
!strcmpi(symhandling,H)))
|
|
||||||
#else
|
#else
|
||||||
#define SYMHANDLING(H) (symhandling && !strcmpi(symhandling,H))
|
#define SYMHANDLING(ht) (symhandling == (ht))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
|
extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
|
||||||
extern uchar showsyms[MAXPCHARS];
|
extern uchar showsyms[MAXPCHARS];
|
||||||
extern const struct symdef def_warnsyms[WARNCOUNT];
|
extern const struct symdef def_warnsyms[WARNCOUNT];
|
||||||
extern char *symset, *symhandling; /* from drawing.c */
|
extern char *symset, *roguesymset; /* from drawing.c */
|
||||||
extern char *roguesymset, *roguehandling; /* from drawing.c */
|
extern int symhandling, roguehandling; /* from drawing.c */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Graphics sets for display symbols
|
* Graphics sets for display symbols
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
#define C(n)
|
#define C(n)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *symset = 0, *symhandling = 0; /* from drawing.c */
|
char *symset = 0, *roguesymset = 0;
|
||||||
char *roguesymset = 0, *roguehandling = 0; /* from drawing.c */
|
int symhandling = 0, roguehandling = 0;
|
||||||
|
|
||||||
uchar oc_syms[MAXOCLASSES] = DUMMY; /* the current object display symbols */
|
uchar oc_syms[MAXOCLASSES] = DUMMY; /* the current object display symbols */
|
||||||
uchar showsyms[MAXPCHARS] = DUMMY; /* the current feature display symbols */
|
uchar showsyms[MAXPCHARS] = DUMMY; /* the current feature display symbols */
|
||||||
@@ -380,14 +380,14 @@ int nondefault;
|
|||||||
* the Is_Roguelevel checks in those macros.
|
* the Is_Roguelevel checks in those macros.
|
||||||
*/
|
*/
|
||||||
#ifdef PC9800
|
#ifdef PC9800
|
||||||
if (symhandling && !strcmpi(symhandling,"IBM")
|
if (symhandling == H_IBM
|
||||||
&& ibmgraphics_mode_callback)
|
&& ibmgraphics_mode_callback)
|
||||||
(*ibmgraphics_mode_callback)();
|
(*ibmgraphics_mode_callback)();
|
||||||
else if (!symset && ascgraphics_mode_callback)
|
else if (!symset && ascgraphics_mode_callback)
|
||||||
(*ascgraphics_mode_callback)();
|
(*ascgraphics_mode_callback)();
|
||||||
#endif
|
#endif
|
||||||
#ifdef TERMLIB
|
#ifdef TERMLIB
|
||||||
if (symhandling && !strcmp(symhandling,"DEC")
|
if (symhandling == H_DEC
|
||||||
&& decgraphics_mode_callback)
|
&& decgraphics_mode_callback)
|
||||||
(*decgraphics_mode_callback)();
|
(*decgraphics_mode_callback)();
|
||||||
#endif
|
#endif
|
||||||
@@ -538,6 +538,20 @@ int val;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If you are adding code somewhere to be able to recognize
|
||||||
|
* particular types of symset "handling", define a
|
||||||
|
* H_XXX macro in include/rm.h and add the name
|
||||||
|
* to this array at the matching offset.
|
||||||
|
*/
|
||||||
|
const char *known_handling[] = {
|
||||||
|
"UNKNOWN", /* H_UNK */
|
||||||
|
"IBM", /* H_IBM */
|
||||||
|
"DEC", /* H_DEC */
|
||||||
|
(const char *)0,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct symparse loadsyms[] = {
|
struct symparse loadsyms[] = {
|
||||||
{SYM_CONTROL, 0, "start"},
|
{SYM_CONTROL, 0, "start"},
|
||||||
{SYM_CONTROL, 0, "begin"},
|
{SYM_CONTROL, 0, "begin"},
|
||||||
|
|||||||
58
src/files.c
58
src/files.c
@@ -2422,8 +2422,9 @@ read_wizkit()
|
|||||||
#endif /*WIZARD*/
|
#endif /*WIZARD*/
|
||||||
|
|
||||||
#ifdef ASCIIGRAPH
|
#ifdef ASCIIGRAPH
|
||||||
extern struct symparse loadsyms[]; /* drawing.c */
|
|
||||||
extern struct textlist *symset_list; /* options.c */
|
extern struct textlist *symset_list; /* options.c */
|
||||||
|
extern struct symparse loadsyms[]; /* drawing.c */
|
||||||
|
extern const char *known_handling[]; /* drawing.c */
|
||||||
static int symset_count = 0; /* for pick-list building only */
|
static int symset_count = 0; /* for pick-list building only */
|
||||||
static boolean chosen_symset_start = FALSE, chosen_symset_end = FALSE;
|
static boolean chosen_symset_start = FALSE, chosen_symset_end = FALSE;
|
||||||
|
|
||||||
@@ -2560,12 +2561,15 @@ boolean rogueflag;
|
|||||||
if (!strcmpi(bufp, symsetname)) { /* desired one? */
|
if (!strcmpi(bufp, symsetname)) { /* desired one? */
|
||||||
chosen_symset_start = TRUE;
|
chosen_symset_start = TRUE;
|
||||||
#ifdef REINCARNATION
|
#ifdef REINCARNATION
|
||||||
if (rogueflag)
|
if (rogueflag) {
|
||||||
init_r_symbols();
|
init_r_symbols();
|
||||||
else
|
roguehandling = H_UNK;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (!rogueflag) {
|
||||||
init_l_symbols();
|
init_l_symbols();
|
||||||
free_symhandling(rogueflag);
|
symhandling = H_UNK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -2594,42 +2598,32 @@ boolean rogueflag;
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_OVL void
|
|
||||||
free_symhandling(rogueflag)
|
|
||||||
boolean rogueflag;
|
|
||||||
{
|
|
||||||
if (rogueflag) {
|
|
||||||
#ifdef REINCARNATION
|
|
||||||
if (roguehandling) {
|
|
||||||
free((genericptr_t)roguehandling);
|
|
||||||
roguehandling = (char *)0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
if (symhandling) {
|
|
||||||
free((genericptr_t)symhandling);
|
|
||||||
symhandling = (char *)0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC_OVL void
|
STATIC_OVL void
|
||||||
set_symhandling(handling, rogueflag)
|
set_symhandling(handling, rogueflag)
|
||||||
char *handling;
|
char *handling;
|
||||||
boolean rogueflag;
|
boolean rogueflag;
|
||||||
{
|
{
|
||||||
char *new_handling;
|
int i = 0;
|
||||||
|
|
||||||
free_symhandling(rogueflag);
|
|
||||||
if (!handling) return;
|
|
||||||
new_handling = (char *)alloc(strlen(handling)+1);
|
|
||||||
Strcpy(new_handling, handling);
|
|
||||||
#ifdef REINCARNATION
|
#ifdef REINCARNATION
|
||||||
if (rogueflag)
|
if (rogueflag) roguehandling = H_UNK;
|
||||||
roguehandling = new_handling;
|
|
||||||
#endif
|
#endif
|
||||||
if (!rogueflag)
|
if (!rogueflag) symhandling = H_UNK;
|
||||||
symhandling = new_handling;
|
while (known_handling[i]) {
|
||||||
|
if (!strcmpi(known_handling[i], handling)) {
|
||||||
|
#ifdef REINCARNATION
|
||||||
|
if (rogueflag) {
|
||||||
|
roguehandling = i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (!rogueflag) {
|
||||||
|
symhandling = i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /*ASCIIGRAPH*/
|
#endif /*ASCIIGRAPH*/
|
||||||
|
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ int explcolors[] = {
|
|||||||
|
|
||||||
#ifdef ROGUE_COLOR
|
#ifdef ROGUE_COLOR
|
||||||
# if defined(USE_TILES) && defined(MSDOS)
|
# if defined(USE_TILES) && defined(MSDOS)
|
||||||
#define HAS_ROGUE_IBM_GRAPHICS (ROGUEHANDLING("IBM") && !iflags.grmode)
|
#define HAS_ROGUE_IBM_GRAPHICS (ROGUEHANDLING(H_IBM) && !iflags.grmode)
|
||||||
# else
|
# else
|
||||||
#define HAS_ROGUE_IBM_GRAPHICS (ROGUEHANDLING("IBM"))
|
#define HAS_ROGUE_IBM_GRAPHICS (ROGUEHANDLING(H_IBM))
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace)
|
|||||||
UINT mswin_charset()
|
UINT mswin_charset()
|
||||||
{
|
{
|
||||||
CHARSETINFO cis;
|
CHARSETINFO cis;
|
||||||
if( SYMHANDLING("IBM") )
|
if( SYMHANDLING(H_IBM) )
|
||||||
if( TranslateCharsetInfo((DWORD*)GetOEMCP(), &cis, TCI_SRCCODEPAGE) )
|
if( TranslateCharsetInfo((DWORD*)GetOEMCP(), &cis, TCI_SRCCODEPAGE) )
|
||||||
return cis.ciCharset;
|
return cis.ciCharset;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ tty_decgraphics_termcap_fixup()
|
|||||||
* Do not select NA ASCII as the primary font since people may
|
* Do not select NA ASCII as the primary font since people may
|
||||||
* reasonably be using the UK character set.
|
* reasonably be using the UK character set.
|
||||||
*/
|
*/
|
||||||
if (SYMHANDLING("DEC")) xputs("\033)0");
|
if (SYMHANDLING(H_DEC)) xputs("\033)0");
|
||||||
#ifdef PC9800
|
#ifdef PC9800
|
||||||
init_hilite();
|
init_hilite();
|
||||||
#endif
|
#endif
|
||||||
@@ -449,19 +449,19 @@ tty_start_screen()
|
|||||||
xputs(TI);
|
xputs(TI);
|
||||||
xputs(VS);
|
xputs(VS);
|
||||||
#ifdef PC9800
|
#ifdef PC9800
|
||||||
if (!SYMHANDLING("IBM"))
|
if (!SYMHANDLING(H_IBM))
|
||||||
tty_ascgraphics_hilite_fixup();
|
tty_ascgraphics_hilite_fixup();
|
||||||
/* set up callback in case option is not set yet but toggled later */
|
/* set up callback in case option is not set yet but toggled later */
|
||||||
ascgraphics_mode_callback = tty_ascgraphics_hilite_fixup;
|
ascgraphics_mode_callback = tty_ascgraphics_hilite_fixup;
|
||||||
# ifdef ASCIIGRAPH
|
# ifdef ASCIIGRAPH
|
||||||
if (SYMHANDLING("IBM")) init_hilite();
|
if (SYMHANDLING(H_IBM)) init_hilite();
|
||||||
/* set up callback in case option is not set yet but toggled later */
|
/* set up callback in case option is not set yet but toggled later */
|
||||||
ibmgraphics_mode_callback = init_hilite;
|
ibmgraphics_mode_callback = init_hilite;
|
||||||
# endif
|
# endif
|
||||||
#endif /* PC9800 */
|
#endif /* PC9800 */
|
||||||
|
|
||||||
#ifdef TERMLIB
|
#ifdef TERMLIB
|
||||||
if (SYMHANDLING("DEC")) tty_decgraphics_termcap_fixup();
|
if (SYMHANDLING(H_DEC)) tty_decgraphics_termcap_fixup();
|
||||||
/* set up callback in case option is not set yet but toggled later */
|
/* set up callback in case option is not set yet but toggled later */
|
||||||
decgraphics_mode_callback = tty_decgraphics_termcap_fixup;
|
decgraphics_mode_callback = tty_decgraphics_termcap_fixup;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2402,7 +2402,7 @@ int in_ch;
|
|||||||
register char ch = (char)in_ch;
|
register char ch = (char)in_ch;
|
||||||
|
|
||||||
# if defined(ASCIIGRAPH) && !defined(NO_TERMS)
|
# if defined(ASCIIGRAPH) && !defined(NO_TERMS)
|
||||||
if (SYMHANDLING("IBM") || iflags.eight_bit_tty) {
|
if (SYMHANDLING(H_IBM) || iflags.eight_bit_tty) {
|
||||||
/* IBM-compatible displays don't need other stuff */
|
/* IBM-compatible displays don't need other stuff */
|
||||||
(void) putchar(ch);
|
(void) putchar(ch);
|
||||||
} else if (ch & 0x80) {
|
} else if (ch & 0x80) {
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace)
|
|||||||
UINT mswin_charset()
|
UINT mswin_charset()
|
||||||
{
|
{
|
||||||
CHARSETINFO cis;
|
CHARSETINFO cis;
|
||||||
if( SYMHANDLING("IBM") )
|
if( SYMHANDLING(H_IBM) )
|
||||||
if( TranslateCharsetInfo((DWORD*)GetOEMCP(), &cis, TCI_SRCCODEPAGE) )
|
if( TranslateCharsetInfo((DWORD*)GetOEMCP(), &cis, TCI_SRCCODEPAGE) )
|
||||||
return cis.ciCharset;
|
return cis.ciCharset;
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user