From 338214459d6e8ebebcb878f26dd87bd81a8aaada Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Wed, 27 Dec 2017 10:26:06 -0500 Subject: [PATCH] Fix a portability issue with md_hasclreol(). Some games' implementation of md_hasclreol() poked around in ncurses internals, which does not work for some ncurses build configuration. Most games did not actually call md_hasclreol(), so it was removed. There is a standard terminfo function which can retrieve the value of the clr_eol capability, so this was used for rogue5. --- arogue5/mdport.c | 18 ------------------ rogue3/mdport.c | 18 ------------------ rogue3/mdport.h | 1 - rogue4/mdport.c | 14 -------------- rogue5/mdport.c | 8 ++++---- srogue/mdport.c | 18 ------------------ srogue/rogue.h | 1 - urogue/mdport.c | 12 ------------ 8 files changed, 4 insertions(+), 86 deletions(-) diff --git a/arogue5/mdport.c b/arogue5/mdport.c index 28cf09b..22ccb5a 100644 --- a/arogue5/mdport.c +++ b/arogue5/mdport.c @@ -106,24 +106,6 @@ md_init(void) #endif } -int -md_hasclreol(void) -{ -#if defined(clr_eol) -#ifdef NCURSES_VERSION - if (cur_term == NULL) - return(0); - if (cur_term->type.Strings == NULL) - return(0); -#endif - return((clr_eol != NULL) && (*clr_eol != 0)); -#elif defined(__PDCURSES__) - return(TRUE); -#else - return((CE != NULL) && (*CE != 0)); -#endif -} - #ifdef attron # define _puts(s) tputs(s, 0, putchar); # define SO enter_standout_mode diff --git a/rogue3/mdport.c b/rogue3/mdport.c index 63c36a3..0d4ff0b 100644 --- a/rogue3/mdport.c +++ b/rogue3/mdport.c @@ -264,24 +264,6 @@ md_onsignal_autosave(void) #endif } -int -md_hasclreol(void) -{ -#if defined(clr_eol) -#ifdef NCURSES_VERSION - if (cur_term == NULL) - return(0); - if (cur_term->type.Strings == NULL) - return(0); -#endif - return((clr_eol != NULL) && (*clr_eol != 0)); -#elif defined(__PDCURSES__) - return(TRUE); -#else - return((CE != NULL) && (*CE != 0)); -#endif -} - #ifdef _WIN32 static int md_standout_mode = 0; #endif diff --git a/rogue3/mdport.h b/rogue3/mdport.h index b398f62..8834f79 100644 --- a/rogue3/mdport.h +++ b/rogue3/mdport.h @@ -171,7 +171,6 @@ int md_setdsuspchar(int c); int md_shellescape(void); void md_sleep(int s); int md_suspchar(void); -int md_hasclreol(void); int md_unlink(char *file); int md_unlink_open_file(const char *file, FILE *inf); void md_tstpsignal(void); diff --git a/rogue4/mdport.c b/rogue4/mdport.c index e459354..5716501 100644 --- a/rogue4/mdport.c +++ b/rogue4/mdport.c @@ -110,20 +110,6 @@ md_init(void) #endif } -int -md_hasclreol(void) -{ -#ifdef CE - return((CE != NULL) && (*CE != 0)); -#elif defined (clr_eol) - return((clr_eol != NULL) && (*clr_eol != 0)); -#elif !defined(__PDCURSES__) - return(clr_eol != NULL); -#else - return(TRUE); -#endif -} - static int md_standout_mode = 0; void diff --git a/rogue5/mdport.c b/rogue5/mdport.c index 22dfceb..b070f0e 100644 --- a/rogue5/mdport.c +++ b/rogue5/mdport.c @@ -263,13 +263,13 @@ md_onsignal_autosave(void) int md_hasclreol(void) { -#if defined(clr_eol) #ifdef NCURSES_VERSION + char *cap_str; if (cur_term == NULL) return(0); - if (cur_term->type.Strings == NULL) - return(0); -#endif + cap_str = tigetstr("el"); + return (cap_str != NULL); +#elif defined(clr_eol) return((clr_eol != NULL) && (*clr_eol != 0)); #elif defined(__PDCURSES__) return(TRUE); diff --git a/srogue/mdport.c b/srogue/mdport.c index 3b7c2d3..6babad0 100644 --- a/srogue/mdport.c +++ b/srogue/mdport.c @@ -260,24 +260,6 @@ md_onsignal_autosave(void) #endif } -int -md_hasclreol(void) -{ -#if defined(clr_eol) -#ifdef NCURSES_VERSION - if (cur_term == NULL) - return(0); - if (cur_term->type.Strings == NULL) - return(0); -#endif - return((clr_eol != NULL) && (*clr_eol != 0)); -#elif defined(__PDCURSES__) - return(TRUE); -#else - return((CE != NULL) && (*CE != 0)); -#endif -} - #ifdef _WIN32 static int md_standout_mode = 0; #endif diff --git a/srogue/rogue.h b/srogue/rogue.h index 23ade60..061fe16 100644 --- a/srogue/rogue.h +++ b/srogue/rogue.h @@ -67,7 +67,6 @@ int md_setdsuspchar(int c); int md_shellescape(void); void md_sleep(int s); int md_suspchar(void); -int md_hasclreol(void); int md_unlink(char *file); int md_unlink_open_file(const char *file, FILE *inf); void md_tstpsignal(void); diff --git a/urogue/mdport.c b/urogue/mdport.c index 0bdf242..2348933 100644 --- a/urogue/mdport.c +++ b/urogue/mdport.c @@ -103,18 +103,6 @@ md_init() #endif } -int -md_hasclreol() -{ -#ifndef attron - return(!CE); -#elif !defined(__PDCURSES__) - return(clr_eol != NULL); -#else - return(TRUE); -#endif -} - #ifdef attron # define _puts(s) tputs(s, 0, putchar); # define SO enter_standout_mode