From 31a369f9855b16d616ba69f7830791e09e96adf2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:49:08 -1100 Subject: [PATCH 01/12] +fprintf in cursesd --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 02a80c470..30cc54ec9 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - //fprintf(stderr,"%s\n",str); + fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); From ab28897a624d29b96d13d0ba5e493e257555c0ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:57:34 -1100 Subject: [PATCH 02/12] Redo chg_str --- src/cc/rogue/misc.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 7db9d073a..8a4d1df94 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -349,17 +349,36 @@ void chg_str(int amt) { //auto jl777: strange compiler error - str_t comp; + uint32_t comp; if (amt == 0) return; - add_str(&pstats.s_str, amt); + //add_str(&pstats.s_str, amt); + pstats.s_str += amt; + if ( pstats.s_str < 3 ) + pstats.s_str = 3; + else if ( pstats.s_str > 31 ) + pstats.s_str = 31; comp = pstats.s_str; if (ISRING(LEFT, R_ADDSTR)) - add_str(&comp, -cur_ring[LEFT]->o_arm); + { + // add_str(&comp, -cur_ring[LEFT]->o_arm); + comp += -cur_ring[LEFT]->o_arm; + if ( comp < 3 ) + comp = 3; + else if ( comp > 31 ) + comp = 31; + } if (ISRING(RIGHT, R_ADDSTR)) - add_str(&comp, -cur_ring[RIGHT]->o_arm); - if (comp > max_stats.s_str) + { + //add_str(&comp, -cur_ring[RIGHT]->o_arm); + comp += -cur_ring[RIGHT]->o_arm; + if ( comp < 3 ) + comp = 3; + else if ( comp > 31 ) + comp = 31; + } + if ( comp > max_stats.s_str ) max_stats.s_str = comp; } From 67879fb99208d901882322d83ef6a9416d9a5602 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:03:55 -1100 Subject: [PATCH 03/12] +chars print --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index c920ee411..7cfa7e59f 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -161,7 +161,7 @@ readchar(struct rogue_state *rs) { //if ( rs->ind == rs->numkeys-1 ) // rs->replaydone = (uint32_t)time(NULL); - //fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); + fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); return(rs->keystrokes[rs->ind++]); } if ( rs->replaydone != 0 && counter++ < 3 ) From 10ad979ac9fe8cdf4862358f4ced79e84c9e51e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:08:13 -1100 Subject: [PATCH 04/12] Test --- src/cc/rogue/command.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 6cc6b0763..22723b6c6 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -259,7 +259,8 @@ over: again = TRUE; goto over; } - when 'q': quaff(rs); + case 'q': quaff(rs); + break; when 'Q': after = FALSE; q_comm = TRUE; From fbdd8a6166c356655a87b0ea8d4cb2c41c742504 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:10:48 -1100 Subject: [PATCH 05/12] Test --- src/cc/rogue/command.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 22723b6c6..5dbc97051 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -262,15 +262,18 @@ over: case 'q': quaff(rs); break; when 'Q': - after = FALSE; - q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); - q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); + if ( rs->sleeptime == 1 ) + { + after = FALSE; + q_comm = TRUE; + quit(0); + if ( rs->guiflag != 0 && rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + q_comm = FALSE; + if ( rs->guiflag != 0 ) + rogue_bailout(rs); + else rs->replaydone = (uint32_t)time(NULL); + } return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); From da2234e121cc9649b367dc0cd18ad9f1e80b3e9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:15:25 -1100 Subject: [PATCH 06/12] Test --- src/cc/rogue/command.c | 21 +++++++++------------ src/cc/rogue/rogue.c | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 5dbc97051..d13be4972 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -262,18 +262,15 @@ over: case 'q': quaff(rs); break; when 'Q': - if ( rs->sleeptime == 1 ) - { - after = FALSE; - q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); - q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); - } + after = FALSE; + q_comm = TRUE; + quit(0); + if ( rs->guiflag != 0 && rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + q_comm = FALSE; + if ( rs->guiflag != 0 ) + rogue_bailout(rs); + else rs->replaydone = (uint32_t)time(NULL); return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 72fe07558..67a99aa14 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -633,9 +633,9 @@ quit(int sig) */ if (!q_comm) mpos = 0; - getyx(curscr, oy, ox); - msg(rs,"really quit?"); } + getyx(curscr, oy, ox); + msg(rs,"really quit?"); if (readchar(rs) == 'y') { if ( rs->guiflag != 0 ) @@ -653,7 +653,7 @@ quit(int sig) else { //score(rs,purse, 1, 0); - //fprintf(stderr,"done!\n"); + fprintf(stderr,"done!\n"); } } else From 0d262ff7e2e0a68520b6d59668fa3f7a9ae5d848 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:17:40 -1100 Subject: [PATCH 07/12] Test --- src/cc/rogue/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 7cfa7e59f..83e0c2ff6 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -161,7 +161,12 @@ readchar(struct rogue_state *rs) { //if ( rs->ind == rs->numkeys-1 ) // rs->replaydone = (uint32_t)time(NULL); - fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); + if ( rs->keystrokes[rs->ind] == 'Q' ) + { + rs->ind++; + fprintf(stderr,"Q.(%c) ",rs->keystrokes[rs->ind]); + return('q'); + } return(rs->keystrokes[rs->ind++]); } if ( rs->replaydone != 0 && counter++ < 3 ) From ae05cc1f6816560481cabb33d2e38041a5ce8f8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:22:50 -1100 Subject: [PATCH 08/12] Quit handling --- src/cc/rogue/command.c | 17 ++++++++++------- src/cc/rogue/extern.h | 2 +- src/cc/rogue/io.c | 13 ------------- src/cc/rogue/rogue.c | 7 ++++--- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d13be4972..d55b93a5b 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -264,14 +264,17 @@ over: when 'Q': after = FALSE; q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); + if ( quit(0) > 0 ) + { + if ( rs->guiflag != 0 ) + { + if (rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + rogue_bailout(rs); + } else rs->replaydone = (uint32_t)time(NULL); + } q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); - return; + return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); when 'd': drop(rs); diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index fc3454830..ff45e0fee 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -141,7 +141,7 @@ void getltchars(void); void leave(int); void my_exit(int st); void playltchars(void); -void quit(int); +int32_t quit(int); void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 83e0c2ff6..576314a42 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -158,23 +158,10 @@ readchar(struct rogue_state *rs) { static uint32_t counter; if ( rs->ind < rs->numkeys ) - { - //if ( rs->ind == rs->numkeys-1 ) - // rs->replaydone = (uint32_t)time(NULL); - if ( rs->keystrokes[rs->ind] == 'Q' ) - { - rs->ind++; - fprintf(stderr,"Q.(%c) ",rs->keystrokes[rs->ind]); - return('q'); - } return(rs->keystrokes[rs->ind++]); - } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); - //if ( (rand() & 1) == 0 ) - // return(ESCAPE); - //else if ( counter < 3 || (counter & 1) == 0 ) return('y'); else return(ESCAPE); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 67a99aa14..bfb4e0277 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -618,8 +618,7 @@ playit(struct rogue_state *rs) * Have player make certain, then exit. */ -void -quit(int sig) +int32_t quit(int sig) { struct rogue_state *rs = &globalR; int oy, ox; @@ -653,8 +652,9 @@ quit(int sig) else { //score(rs,purse, 1, 0); - fprintf(stderr,"done!\n"); + //fprintf(stderr,"done!\n"); } + return(1); } else { @@ -667,6 +667,7 @@ quit(int sig) mpos = 0; count = 0; to_death = FALSE; + return(0); } } From f513e5d1f531de4760c41d09f9f0ece0069d00ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:26:03 -1100 Subject: [PATCH 09/12] Prints --- src/cc/rogue/io.c | 2 ++ src/cc/rogue/rogue.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 576314a42..6e070b2a8 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -158,7 +158,9 @@ readchar(struct rogue_state *rs) { static uint32_t counter; if ( rs->ind < rs->numkeys ) + { return(rs->keystrokes[rs->ind++]); + } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index bfb4e0277..dafcf3f01 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -621,7 +621,7 @@ playit(struct rogue_state *rs) int32_t quit(int sig) { struct rogue_state *rs = &globalR; - int oy, ox; + int oy, ox, c; //fprintf(stderr,"inside quit(%d)\n",sig); if ( rs->guiflag != 0 ) { @@ -635,7 +635,8 @@ int32_t quit(int sig) } getyx(curscr, oy, ox); msg(rs,"really quit?"); - if (readchar(rs) == 'y') + sleep(1); + if ( (c= readchar(rs)) == 'y') { if ( rs->guiflag != 0 ) { @@ -652,12 +653,13 @@ int32_t quit(int sig) else { //score(rs,purse, 1, 0); - //fprintf(stderr,"done!\n"); + fprintf(stderr,"done!\n"); } return(1); } else { + fprintf(stderr,"'Q' answer (%c)\n",c); move(0, 0); clrtoeol(); status(rs); From ef4844d5a3538f097c7b81a311c7409172f46107 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:29:58 -1100 Subject: [PATCH 10/12] _quit --- src/cc/rogue/command.c | 2 +- src/cc/rogue/extern.h | 3 ++- src/cc/rogue/io.c | 2 +- src/cc/rogue/rogue.c | 40 +++++++++++++++++++++++++--------------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d55b93a5b..54d7beb99 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -264,7 +264,7 @@ over: when 'Q': after = FALSE; q_comm = TRUE; - if ( quit(0) > 0 ) + if ( _quit() > 0 ) { if ( rs->guiflag != 0 ) { diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index ff45e0fee..7fba842f3 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -141,7 +141,8 @@ void getltchars(void); void leave(int); void my_exit(int st); void playltchars(void); -int32_t quit(int); +void quit(int); +int32_t _quit(); void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 6e070b2a8..79eadb571 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -174,7 +174,7 @@ readchar(struct rogue_state *rs) if (ch == 3) { - quit(0); + _quit(); return(27); } if ( rs != 0 && rs->guiflag != 0 ) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index dafcf3f01..02feef2ab 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -613,26 +613,13 @@ playit(struct rogue_state *rs) endit(0); } -/* - * quit: - * Have player make certain, then exit. - */ -int32_t quit(int sig) + +int32_t _quit() { struct rogue_state *rs = &globalR; int oy, ox, c; //fprintf(stderr,"inside quit(%d)\n",sig); - if ( rs->guiflag != 0 ) - { - NOOP(sig); - - /* - * Reset the signal in case we got here via an interrupt - */ - if (!q_comm) - mpos = 0; - } getyx(curscr, oy, ox); msg(rs,"really quit?"); sleep(1); @@ -673,6 +660,29 @@ int32_t quit(int sig) } } +/* + * quit: + * Have player make certain, then exit. + */ + +void quit(int sig) +{ + struct rogue_state *rs = &globalR; + int oy, ox, c; + //fprintf(stderr,"inside quit(%d)\n",sig); + if ( rs->guiflag != 0 ) + { + NOOP(sig); + + /* + * Reset the signal in case we got here via an interrupt + */ + if (!q_comm) + mpos = 0; + } + _quit(); +} + /* * leave: * Leave quickly, but curteously From 7be1c552280b7c4347306e064632bdebcf024dba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:33:13 -1100 Subject: [PATCH 11/12] tst --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 02feef2ab..bc576dabf 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -640,7 +640,7 @@ int32_t _quit() else { //score(rs,purse, 1, 0); - fprintf(stderr,"done!\n"); + fprintf(stderr,"done! (%c)\n",c); } return(1); } From 0a11653334e01b49116a47003f57088d99fd5eac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:38:44 -1100 Subject: [PATCH 12/12] test --- src/cc/rogue/io.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 79eadb571..525550e67 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -153,13 +153,22 @@ step_ok(int ch) char readchar(struct rogue_state *rs) { - char ch = -1; + char c,ch = -1; if ( rs != 0 && rs->guiflag == 0 ) { static uint32_t counter; if ( rs->ind < rs->numkeys ) { - return(rs->keystrokes[rs->ind++]); + c = rs->keystrokes[rs->ind++]; + while ( c == 'Q' && rs->ind < rs->numkeys ) + { + fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2); + if ( rs->keystrokes[rs->ind] == 'y' ) + return(c); + rs->ind++; + c = rs->keystrokes[rs->ind++]; + } + return(c); } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n");