Quit handling

This commit is contained in:
jl777
2019-02-17 22:22:50 -11:00
parent 0d262ff7e2
commit ae05cc1f68
4 changed files with 15 additions and 24 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}
}