From ae05cc1f6816560481cabb33d2e38041a5ce8f8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:22:50 -1100 Subject: [PATCH] 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); } }