Merge pull request #132 from jl777/jl777

sync jl777
This commit is contained in:
ca333
2019-02-18 10:41:12 +01:00
committed by GitHub
6 changed files with 87 additions and 47 deletions

View File

@@ -259,18 +259,22 @@ over:
again = TRUE;
goto over;
}
when 'q': quaff(rs);
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);
return;
after = FALSE;
q_comm = TRUE;
if ( _quit() > 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;
return;
when 'i': after = FALSE; inventory(rs,pack, 0);
when 'I': after = FALSE; picky_inven(rs);
when 'd': drop(rs);

View File

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

View File

@@ -142,6 +142,7 @@ void leave(int);
void my_exit(int st);
void playltchars(void);
void quit(int);
int32_t _quit();
void resetltchars(void);
void set_order(int *order, int numthings);
void tstp(int ignored);

View File

@@ -153,23 +153,26 @@ 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 )
{
//if ( rs->ind == rs->numkeys-1 )
// rs->replaydone = (uint32_t)time(NULL);
//fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]);
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");
rs->replaydone = (uint32_t)time(NULL);
//if ( (rand() & 1) == 0 )
// return(ESCAPE);
//else
if ( counter < 3 || (counter & 1) == 0 )
return('y');
else return(ESCAPE);
@@ -180,7 +183,7 @@ readchar(struct rogue_state *rs)
if (ch == 3)
{
quit(0);
_quit();
return(27);
}
if ( rs != 0 && rs->guiflag != 0 )

View File

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

View File

@@ -613,30 +613,17 @@ playit(struct rogue_state *rs)
endit(0);
}
/*
* quit:
* Have player make certain, then exit.
*/
void
quit(int sig)
int32_t _quit()
{
struct rogue_state *rs = &globalR;
int oy, ox;
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?");
}
if (readchar(rs) == 'y')
getyx(curscr, oy, ox);
msg(rs,"really quit?");
sleep(1);
if ( (c= readchar(rs)) == 'y')
{
if ( rs->guiflag != 0 )
{
@@ -653,11 +640,13 @@ quit(int sig)
else
{
//score(rs,purse, 1, 0);
//fprintf(stderr,"done!\n");
fprintf(stderr,"done! (%c)\n",c);
}
return(1);
}
else
{
fprintf(stderr,"'Q' answer (%c)\n",c);
move(0, 0);
clrtoeol();
status(rs);
@@ -667,9 +656,33 @@ quit(int sig)
mpos = 0;
count = 0;
to_death = FALSE;
return(0);
}
}
/*
* 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