From aa5a85f4da4cc5dfb012085e55ffcc4bddeb7c4f Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 14 Dec 2018 18:17:42 -0800 Subject: [PATCH 1/4] displacing pet long worm Salvage part of an old patch. Swapping places with any long worm, even a baby one, always failed with "You stop. Foo is in the way!" This lets you swap places with tame baby long worms, and adult ones if they have no tail (which won't happen unless there are more than 32 long worms on the current level--even if a long worm appears to be only a head, there is normally a hidden tail segment at the same location). --- src/uhitm.c | 59 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/uhitm.c b/src/uhitm.c index 0412bb599..01c423593 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 uhitm.c $NHDT-Date: 1543892215 2018/12/04 02:56:55 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.195 $ */ +/* NetHack 3.6 uhitm.c $NHDT-Date: 1544840256 2018/12/15 02:17:36 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.196 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -101,7 +101,7 @@ attack_checks(mtmp, wep) register struct monst *mtmp; struct obj *wep; /* uwep for attack(), null for kick_monster() */ { - char qbuf[QBUFSZ]; + int glyph; /* if you're close enough to attack, alert any waiting monster */ mtmp->mstrategy &= ~STRAT_WAITMASK; @@ -124,6 +124,12 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ return FALSE; } + /* cache the shown glyph; + cases which might change it (by placing or removing + 'rembered, unseen monster' glyph or revealing a mimic) + always return without further reference to this */ + glyph = glyph_at(bhitpos.x, bhitpos.y); + /* Put up an invisible monster marker, but with exceptions for * monsters that hide and monsters you've been warned about. * The former already prints a warning message and @@ -132,8 +138,8 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ * happening two turns in a row. The latter shows a glyph on * the screen, so you know something is there. */ - if (!canspotmon(mtmp) && !glyph_is_warning(glyph_at(bhitpos.x, bhitpos.y)) - && !glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph) + if (!canspotmon(mtmp) + && !glyph_is_warning(glyph) && !glyph_is_invisible(glyph) && !(!Blind && mtmp->mundetected && hides_under(mtmp->data))) { pline("Wait! There's %s there you can't see!", something); map_invisible(bhitpos.x, bhitpos.y); @@ -146,17 +152,23 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK)) u.ustuck = mtmp; } + /* #H7329 - if hero is on engraved "Elbereth", this will end up + * assessing an alignment penalty and removing the engraving + * even though no attack actually occurs. Since it also angers + * peacefuls, we're operating as if an attack attempt did occur + * and the Elbereth behavior is consistent. + */ wakeup(mtmp, TRUE); /* always necessary; also un-mimics mimics */ return TRUE; } if (mtmp->m_ap_type && !Protection_from_shape_changers && !sensemon(mtmp) - && !glyph_is_warning(glyph_at(bhitpos.x, bhitpos.y))) { + && !glyph_is_warning(glyph)) { /* If a hidden mimic was in a square where a player remembers * some (probably different) unseen monster, the player is in * luck--he attacks it even though it's hidden. */ - if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) { + if (glyph_is_invisible(glyph)) { seemimic(mtmp); return FALSE; } @@ -165,11 +177,11 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ } if (mtmp->mundetected && !canseemon(mtmp) - && !glyph_is_warning(glyph_at(bhitpos.x, bhitpos.y)) + && !glyph_is_warning(glyph) && (hides_under(mtmp->data) || mtmp->data->mlet == S_EEL)) { mtmp->mundetected = mtmp->msleeping = 0; newsym(mtmp->mx, mtmp->my); - if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) { + if (glyph_is_invisible(glyph)) { seemimic(mtmp); return FALSE; } @@ -197,14 +209,16 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ wakeup(mtmp, TRUE); } - if (flags.confirm && mtmp->mpeaceful && !Confusion && !Hallucination - && !Stunned) { + if (flags.confirm && mtmp->mpeaceful + && !Confusion && !Hallucination && !Stunned) { /* Intelligent chaotic weapons (Stormbringer) want blood */ if (wep && wep->oartifact == ART_STORMBRINGER) { override_confirmation = TRUE; return FALSE; } if (canspotmon(mtmp)) { + char qbuf[QBUFSZ]; + Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp)); if (!paranoid_query(ParanoidHit, qbuf)) { context.move = 0; @@ -329,23 +343,26 @@ register struct monst *mtmp; /* Intelligent chaotic weapons (Stormbringer) want blood */ if (is_safepet(mtmp) && !context.forcefight) { if (!uwep || uwep->oartifact != ART_STORMBRINGER) { - /* there are some additional considerations: this won't work + /* There are some additional considerations: this won't work * if in a shop or Punished or you miss a random roll or * if you can walk thru walls and your pet cannot (KAA) or - * if your pet is a long worm (unless someone does better). - * there's also a chance of displacing a "frozen" monster. + * if your pet is a long worm with a tail. + * There's also a chance of displacing a "frozen" monster: * sleeping monsters might magically walk in their sleep. */ - boolean foo = (Punished || !rn2(7) || is_longworm(mtmp->data)), + boolean foo = (Punished || !rn2(7) + || (is_longworm(mtmp->data) && mtmp->wormno)), inshop = FALSE; char *p; - for (p = in_rooms(mtmp->mx, mtmp->my, SHOPBASE); *p; p++) - if (tended_shop(&rooms[*p - ROOMOFFSET])) { - inshop = TRUE; - break; - } - + /* only check for in-shop if don't already have reason to stop */ + if (!foo) { + for (p = in_rooms(mtmp->mx, mtmp->my, SHOPBASE); *p; p++) + if (tended_shop(&rooms[*p - ROOMOFFSET])) { + inshop = TRUE; + break; + } + } if (inshop || foo || (IS_ROCK(levl[u.ux][u.uy].typ) && !passes_walls(mtmp->data))) { char buf[BUFSZ]; @@ -895,7 +912,7 @@ int dieroll; if (resists_ston(mon)) break; /* note: hp may be <= 0 even if munstoned==TRUE */ - return (boolean) (!DEADMONSTER(mon)); + return (boolean) !DEADMONSTER(mon); #if 0 } else if (touch_petrifies(mdat)) { ; /* maybe turn the corpse into a statue? */ From 436f8a9fde7beea6c45f9eeb10c65746449262f5 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 14 Dec 2018 18:51:07 -0800 Subject: [PATCH 2/4] tty status condition: Cf, Hl, Rd While the fuzzer was running, amidst the continual screen updating I caught a glimpse of "Cn" and was puzzled about how the hero became cancelled. I quickly realized it actually meant confused, but I think "Cf" is a better abbreviation for that. I've also changed "Ha" to "Hl" for hallucination and "Ri" to "Rd" for riding. The rest is formatting. --- win/tty/wintty.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index b5c4451df..f335ff03c 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 wintty.c $NHDT-Date: 1526909614 2018/05/21 13:33:34 $ $NHDT-Branch: NetHack-3.6.2 $:$NHDT-Revision: 1.167 $ */ +/* NetHack 3.6 wintty.c $NHDT-Date: 1544842261 2018/12/15 02:51:01 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.188 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -3512,31 +3512,30 @@ static struct tty_status_fields static int hpbar_percent, hpbar_color; static struct condition_t { long mask; - const char *text[3]; /* 3: potential display values, progressively - * smaller */ + const char *text[3]; /* 3: potential display vals, progressively shorter */ } conditions[] = { /* The sequence order of these matters */ - { BL_MASK_STONE, {"Stone", "Ston", "Sto"}}, - { BL_MASK_SLIME, {"Slime", "Slim", "Slm"}}, - { BL_MASK_STRNGL, {"Strngl", "Stngl", "Str"}}, - { BL_MASK_FOODPOIS, {"FoodPois", "Fpois", "Poi"}}, - { BL_MASK_TERMILL, {"TermIll" , "Ill", "Ill"}}, - { BL_MASK_BLIND, {"Blind", "Blnd", "Bl"}}, - { BL_MASK_DEAF, {"Deaf", "Def", "Df"}}, - { BL_MASK_STUN, {"Stun", "Stun", "St"}}, - { BL_MASK_CONF, {"Conf", "Cnf", "Cn"}}, - { BL_MASK_HALLU, {"Hallu", "Hal", "Ha"}}, - { BL_MASK_LEV, {"Lev", "Lev", "Lv"}}, - { BL_MASK_FLY, {"Fly", "Fly", "Fl"}}, - { BL_MASK_RIDE, {"Ride", "Rid", "Ri"}}, + { BL_MASK_STONE, { "Stone", "Ston", "Sto" } }, + { BL_MASK_SLIME, { "Slime", "Slim", "Slm" } }, + { BL_MASK_STRNGL, { "Strngl", "Stngl", "Str" } }, + { BL_MASK_FOODPOIS, { "FoodPois", "Fpois", "Poi" } }, + { BL_MASK_TERMILL, { "TermIll" , "Ill", "Ill" } }, + { BL_MASK_BLIND, { "Blind", "Blnd", "Bl" } }, + { BL_MASK_DEAF, { "Deaf", "Def", "Df" } }, + { BL_MASK_STUN, { "Stun", "Stun", "St" } }, + { BL_MASK_CONF, { "Conf", "Cnf", "Cf" } }, + { BL_MASK_HALLU, { "Hallu", "Hal", "Hl" } }, + { BL_MASK_LEV, { "Lev", "Lev", "Lv" } }, + { BL_MASK_FLY, { "Fly", "Fly", "Fl" } }, + { BL_MASK_RIDE, { "Ride", "Rid", "Rd" } }, }; static const char *encvals[3][6] = { - { "", "Burdened", "Stressed", "Strained", "Overtaxed", "Overloaded"}, - { "", "Burden", "Stress", "Strain", "Overtax", "Overload" }, - { "", "Brd", "Strs", "Strn", "Ovtx", "Ovld" } + { "", "Burdened", "Stressed", "Strained", "Overtaxed", "Overloaded" }, + { "", "Burden", "Stress", "Strain", "Overtax", "Overload" }, + { "", "Brd", "Strs", "Strn", "Ovtx", "Ovld" } }; #define MAX_PER_ROW 15 -static enum statusfields fieldorder[2][MAX_PER_ROW] = { /* 2: two status lines */ +static enum statusfields fieldorder[2][MAX_PER_ROW] = { /* 2: 2 status lines */ { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN, BL_SCORE, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH }, From 16cda0882cc82d128cacf3397b4d4f93856c409d Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 14 Dec 2018 23:08:41 -0500 Subject: [PATCH 3/4] fix up PDCurses cursor placement for prompts --- sys/share/pcunix.c | 43 +------ sys/winnt/windmain.c | 199 +++++++++++++++++++++++++++++- win/curses/cursdial.c | 9 +- win/curses/cursmain.c | 6 + win/curses/cursmesg.c | 6 +- win/win32/vs2017/NetHack.vcxproj | 1 - win/win32/vs2017/NetHackW.vcxproj | 1 - 7 files changed, 222 insertions(+), 43 deletions(-) diff --git a/sys/share/pcunix.c b/sys/share/pcunix.c index bb746ca92..f1cf7144e 100644 --- a/sys/share/pcunix.c +++ b/sys/share/pcunix.c @@ -9,15 +9,15 @@ #include "wintty.h" #include -#if defined(WIN32) || defined(MSDOS) +#if defined(MSDOS) #include #endif -#if defined(WIN32) || defined(MSDOS) +#if defined(MSDOS) extern char orgdir[]; #endif -#if defined(WIN32) && defined(TTY_GRAPHICS) +#if defined(TTY_GRAPHICS) extern void NDECL(backsp); extern void NDECL(clear_screen); #endif @@ -49,7 +49,7 @@ int fd; return(0); } #else -#if (defined(MICRO) || defined(WIN32)) && !defined(NO_FSTAT) +#if (defined(MICRO)) && !defined(NO_FSTAT) if(fstat(fd, &buf)) { if(moves > 1) pline("Cannot get status of saved level? "); else pline("Cannot get status of saved game."); @@ -126,28 +126,7 @@ getlock() #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); #endif -#if defined(WIN32) || defined(HOLD_LOCKFILE_OPEN) -#if defined(HOLD_LOCKFILE_OPEN) - if (errno == EACCES) { -#define OOPS_BUFSZ 512 - char oops[OOPS_BUFSZ]; - Strcpy( - oops, - "\nThere are files from a game in progress under your name."); - Strcat(oops, "\nThe files are locked or inaccessible."); - Strcat(oops, " Is the other game still running?\n"); - if (strlen(fq_lock) < ((OOPS_BUFSZ - 16) - strlen(oops))) - Sprintf(eos(oops), "Cannot open %s", fq_lock); - Strcat(oops, "\n"); - unlock_file(HLOCK); - error(oops); - } else -#endif - error("Bad directory or name: %s\n%s\n", fq_lock, - strerror(errno)); -#else perror(fq_lock); -#endif unlock_file(HLOCK); error("Cannot open %s", fq_lock); } @@ -197,10 +176,6 @@ getlock() if (c == 'y' || c == 'Y') #ifndef SELF_RECOVER if (eraseoldlocks()) { -#if defined(WIN32) && defined(TTY_GRAPHICS) - if (WINDOWPORT("tty")) - clear_screen(); /* display gets fouled up otherwise */ -#endif goto gotlock; } else { unlock_file(HLOCK); @@ -211,7 +186,7 @@ getlock() } #else /*SELF_RECOVER*/ if (recover_savefile()) { -#if defined(WIN32) && defined(TTY_GRAPHICS) +#if defined(TTY_GRAPHICS) if (WINDOWPORT("tty")) clear_screen(); /* display gets fouled up otherwise */ #endif @@ -241,13 +216,7 @@ gotlock: #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); #endif -#if defined(WIN32) - error("cannot creat file (%s.)\n%s\n%s\"%s\" exists?\n", fq_lock, - strerror(ern), " Are you sure that the directory", - fqn_prefix[LEVELPREFIX]); -#else error("cannot creat file (%s.)", fq_lock); -#endif } else { if (write(fd, (char *) &hackpid, sizeof(hackpid)) != sizeof(hackpid)) { @@ -270,7 +239,6 @@ gotlock: } #endif /* PC_LOCKING */ -#ifndef WIN32 void regularize(s) /* @@ -290,7 +258,6 @@ register char *s; *lp == '|' || *lp >= 127 || (*lp >= '[' && *lp <= ']')) *lp = '_'; } -#endif /* WIN32 */ #ifdef __EMX__ void diff --git a/sys/winnt/windmain.c b/sys/winnt/windmain.c index 15ae95d87..b70cd456d 100644 --- a/sys/winnt/windmain.c +++ b/sys/winnt/windmain.c @@ -9,6 +9,11 @@ #include "dlb.h" #include #include +#include + +#if 0 +#include "wintty.h" +#endif #if !defined(SAFEPROCS) #error You must #define SAFEPROCS to build windmain.c @@ -26,8 +31,15 @@ E char chosen_windowtype[WINTYPELEN]; /* flag.h */ #if defined(MSWIN_GRAPHICS) E void NDECL(mswin_destroy_reg); #endif +#ifdef TTY_GRAPHICS +extern void NDECL(backsp); +extern void NDECL(clear_screen); +#endif #undef E +#ifdef PC_LOCKING +static int NDECL(eraseoldlocks); +#endif int NDECL(windows_nhgetch); void NDECL(windows_nhbell); int FDECL(windows_nh_poskey, (int *, int *, int *)); @@ -45,6 +57,14 @@ HANDLE hStdOut; #if defined(MSWIN_GRAPHICS) char default_window_sys[] = "mswin"; #endif +#ifdef WANT_GETHDATE +static struct stat hbuf; +#endif +#include +#if defined(WIN32) || defined(MSDOS) +#endif + +extern char orgdir[]; /* * __MINGW32__ Note @@ -724,4 +744,181 @@ char *outbuf; Strcpy(outbuf, "\033"); } -/*pcmain.c*/ +#ifdef PC_LOCKING +static int +eraseoldlocks() +{ + register int i; + + /* cannot use maxledgerno() here, because we need to find a lock name + * before starting everything (including the dungeon initialization + * that sets astral_level, needed for maxledgerno()) up + */ + for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) { + /* try to remove all */ + set_levelfile_name(lock, i); + (void) unlink(fqname(lock, LEVELPREFIX, 0)); + } + set_levelfile_name(lock, 0); +#ifdef HOLD_LOCKFILE_OPEN + really_close(); +#endif + if (unlink(fqname(lock, LEVELPREFIX, 0))) + return 0; /* cannot remove it */ + return (1); /* success! */ +} + +void +getlock() +{ + register int fd, c, ci, ct, ern; + int fcmask = FCMASK; + char tbuf[BUFSZ]; + const char *fq_lock; +#define OOPS_BUFSZ 512 + char oops[OOPS_BUFSZ]; + + /* we ignore QUIT and INT at this point */ + if (!lock_file(HLOCK, LOCKPREFIX, 10)) { + wait_synch(); +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) + chdirx(orgdir, 0); +#endif + error("Quitting."); + } + + /* regularize(lock); */ /* already done in pcmain */ + Sprintf(tbuf, "%s", fqname(lock, LEVELPREFIX, 0)); + set_levelfile_name(lock, 0); + fq_lock = fqname(lock, LEVELPREFIX, 1); + if ((fd = open(fq_lock, 0)) == -1) { + if (errno == ENOENT) + goto gotlock; /* no such file */ +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) + chdirx(orgdir, 0); +#endif +#if defined(HOLD_LOCKFILE_OPEN) + if (errno == EACCES) { + Strcpy( + oops, + "\nThere are files from a game in progress under your name."); + Strcat(oops, "\nThe files are locked or inaccessible."); + Strcat(oops, " Is the other game still running?\n"); + if (strlen(fq_lock) < ((OOPS_BUFSZ - 16) - strlen(oops))) + Sprintf(eos(oops), "Cannot open %s", fq_lock); + Strcat(oops, "\n"); + unlock_file(HLOCK); + raw_print(oops); + } else +#endif + error("Bad directory or name: %s\n%s\n", fq_lock, + strerror(errno)); + unlock_file(HLOCK); + Sprintf(oops, "Cannot open %s", fq_lock); + raw_print(oops); + nethack_exit(EXIT_FAILURE); + } + + (void) nhclose(fd); + + if (iflags.window_inited || WINDOWPORT("curses")) { +#ifdef SELF_RECOVER + c = yn("There are files from a game in progress under your name. " + "Recover?"); +#else + pline("There is already a game in progress under your name."); + pline("You may be able to use \"recover %s\" to get it back.\n", + tbuf); + c = yn("Do you want to destroy the old game?"); +#endif + } else { + c = 'n'; + ct = 0; +#ifdef SELF_RECOVER + raw_print("There are files from a game in progress under your name. " + "Recover? [yn]"); +#else + raw_print("\nThere is already a game in progress under your name.\n"); + raw_print("If this is unexpected, you may be able to use \n"); + raw_print("\"recover %s\" to get it back.", tbuf); + raw_print("\nDo you want to destroy the old game? [yn] "); +#endif + while ((ci = nhgetch()) != '\n') { + if (ct > 0) { + raw_print("\b \b"); + ct = 0; + c = 'n'; + } + if (ci == 'y' || ci == 'n' || ci == 'Y' || ci == 'N') { + ct = 1; + c = ci; + } + } + } + if (c == 'y' || c == 'Y') +#ifndef SELF_RECOVER + if (eraseoldlocks()) { + if (WINDOWPORT("tty")) + clear_screen(); /* display gets fouled up otherwise */ + goto gotlock; + } else { + unlock_file(HLOCK); +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) + chdirx(orgdir, 0); +#endif + raw_print("Couldn't destroy old game."); + } +#else /*SELF_RECOVER*/ + if (recover_savefile()) { + if (WINDOWPORT("tty")) + clear_screen(); /* display gets fouled up otherwise */ + goto gotlock; + } else { + unlock_file(HLOCK); +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) + chdirx(orgdir, 0); +#endif + raw_print("Couldn't recover old game."); + } +#endif /*SELF_RECOVER*/ + else { + unlock_file(HLOCK); +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) + chdirx(orgdir, 0); +#endif + Sprintf(oops, "%s", "Cannot start a new game."); + raw_print(oops); + } + +gotlock: + fd = creat(fq_lock, fcmask); + if (fd == -1) + ern = errno; + unlock_file(HLOCK); + if (fd == -1) { +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) + chdirx(orgdir, 0); +#endif + Sprintf(oops, "cannot creat file (%s.)\n%s\n%s\"%s\" exists?\n", fq_lock, + strerror(ern), " Are you sure that the directory", + fqn_prefix[LEVELPREFIX]); + raw_print(oops); + } else { + if (write(fd, (char *) &hackpid, sizeof(hackpid)) + != sizeof(hackpid)) { +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) + chdirx(orgdir, 0); +#endif + error("cannot write lock (%s)", fq_lock); + } + if (nhclose(fd) == -1) { +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) + chdirx(orgdir, 0); +#endif + error("cannot close lock (%s)", fq_lock); + } + } +} +#endif /* PC_LOCKING */ + +/*windmain.c*/ diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index 2e63b6f82..41d8e9ffa 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -164,6 +164,7 @@ curses_character_input_dialog(const char *prompt, const char *choices, CHAR_P def) { WINDOW *askwin = NULL; + WINDOW *message_window; int answer, count, maxwidth, map_height, map_width; char *linestr; char askstr[BUFSZ + QBUFSZ]; @@ -180,6 +181,9 @@ curses_character_input_dialog(const char *prompt, const char *choices, map_width = term_cols; } +#ifdef PDCURSES + message_window = curses_get_nhwin(MESSAGE_WIN); +#endif maxwidth = map_width - 2; if (choices != NULL) { @@ -241,8 +245,11 @@ curses_character_input_dialog(const char *prompt, const char *choices, /*curses_stupid_hack = 0; */ while (1) { +#ifdef PDCURSES + answer = wgetch(message_window); +#else answer = getch(); - +#endif if (answer == ERR) { answer = def; break; diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 62abc71f1..f2ab82542 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -619,7 +619,13 @@ raw_print(str) -- Print directly to a screen, or otherwise guarantee that void curses_raw_print(const char *str) { +#ifdef PDCURSES + WINDOW *win = curses_get_nhwin(MESSAGE_WIN); + + curses_message_win_puts(str, FALSE); +#else puts(str); +#endif } /* diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index dd0f6e349..98e3677d1 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -143,7 +143,7 @@ curses_block(boolean noscroll) { int height, width, ret = 0; WINDOW *win = curses_get_nhwin(MESSAGE_WIN); - char *resp = " \n\033"; /* space, enter, esc */ + char *resp = " \r\n\033"; /* space, enter, esc */ curses_get_window_size(MESSAGE_WIN, &height, &width); @@ -429,7 +429,11 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer) wmove(win, my, mx); curs_set(1); wrefresh(win); +#ifdef PDCURSES + ch = wgetch(win); +#else ch = getch(); +#endif curs_set(0); switch(ch) { case '\033': /* DOESCAPE */ diff --git a/win/win32/vs2017/NetHack.vcxproj b/win/win32/vs2017/NetHack.vcxproj index 9f193832a..1e114f64f 100644 --- a/win/win32/vs2017/NetHack.vcxproj +++ b/win/win32/vs2017/NetHack.vcxproj @@ -152,7 +152,6 @@ - diff --git a/win/win32/vs2017/NetHackW.vcxproj b/win/win32/vs2017/NetHackW.vcxproj index d1ede9f0a..79a25df44 100644 --- a/win/win32/vs2017/NetHackW.vcxproj +++ b/win/win32/vs2017/NetHackW.vcxproj @@ -147,7 +147,6 @@ - From be9d974c4da0a240ca2e93cf26a2796d804a597b Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 15 Dec 2018 02:17:15 -0500 Subject: [PATCH 4/4] Makefile.msc update --- sys/winnt/Makefile.msc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index d3bcd140c..21817c661 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -248,8 +248,7 @@ CURSESOBJ= $(O)cursdial.o $(O)cursinit.o $(O)cursinvt.o $(O)cursmain.o \ $(O)cursmesg.o $(O)cursmisc.o $(O)cursstat.o $(O)curswins.o !ENDIF -SOBJ = $(O)winnt.o $(O)pcsys.o $(O)pcunix.o \ - $(SOUND) $(O)nhlan.o +SOBJ = $(O)winnt.o $(O)pcsys.o $(SOUND) $(O)nhlan.o OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \ $(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \ @@ -1511,14 +1510,10 @@ $(O)\curswins.c: $(WCURSES)\curswins.c $(WCURSES)\curswins.h $(INCL)\wincurs.h $(O)tos.o: ..\sys\atari\tos.c $(HACK_H) $(INCL)\tcap.h @$(CC) $(cflagsBuild) -Fo$@ ..\sys\atari\tos.c -$(O)pcmain.o: ..\sys\share\pcmain.c $(HACK_H) $(INCL)\dlb.h - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcmain.c $(O)pcsys.o: ..\sys\share\pcsys.c $(HACK_H) @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcsys.c $(O)pctty.o: ..\sys\share\pctty.c $(HACK_H) @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pctty.c -$(O)pcunix.o: ..\sys\share\pcunix.c $(HACK_H) - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcunix.c $(O)random.o: ..\sys\share\random.c $(HACK_H) @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\random.c $(O)ioctl.o: ..\sys\share\ioctl.c $(HACK_H) $(INCL)\tcap.h