This commit is contained in:
jl777
2019-03-26 05:44:39 -11:00
parent e34fc6b510
commit e495123a5d
2 changed files with 69 additions and 68 deletions

View File

@@ -1559,72 +1559,4 @@ UniValue games_fund(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
#endif
gamesevent games_readevent(struct games_state *rs)
{
gamesevent ch = -1; int32_t c;
if ( rs != 0 && rs->guiflag == 0 )
{
static uint32_t counter;
if ( rs->ind < rs->numkeys )
{
ch = rs->keystrokes[rs->ind++];
if ( 0 )
{
static FILE *fp; static int32_t counter;
if ( fp == 0 )
fp = fopen("log","wb");
if ( fp != 0 )
{
fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed);
fflush(fp);
counter++;
}
}
return(ch);
}
if ( rs->replaydone != 0 && counter++ < 3 )
fprintf(stderr,"replay finished but readchar called\n");
rs->replaydone = (uint32_t)time(NULL);
return(0);
}
if ( rs == 0 || rs->guiflag != 0 )
{
c = getch();
switch ( c )
{
case KEY_LEFT:
c = 'h';
break;
case KEY_RIGHT:
c = 'l';
break;
case KEY_UP:
c = 'k';
break;
case KEY_DOWN:
c = 'j';
break;
}
ch = c;
if (ch == 3)
{
//_quit();
return(27);
}
/*if ( rs != 0 && rs->guiflag != 0 )
{
if ( rs->num < sizeof(rs->buffered) )
{
rs->buffered[rs->num++] = ch;
if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 )
{
rs->needflush = (uint32_t)time(NULL);
//fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered));
//sleep(3);
}
} else fprintf(stderr,"buffer filled without flushed\n");
}*/
} else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs);
return(ch);
}

View File

@@ -732,6 +732,75 @@ void *gamesiterate(struct games_state *rs)
return(tg);
}
gamesevent games_readevent(struct games_state *rs)
{
gamesevent ch = -1; int32_t c;
if ( rs != 0 && rs->guiflag == 0 )
{
static uint32_t counter;
if ( rs->ind < rs->numkeys )
{
ch = rs->keystrokes[rs->ind++];
if ( 0 )
{
static FILE *fp; static int32_t counter;
if ( fp == 0 )
fp = fopen("log","wb");
if ( fp != 0 )
{
fprintf(fp,"%d: (%c) seed.%llu\n",counter,c,(long long)rs->origseed);
fflush(fp);
counter++;
}
}
return(ch);
}
if ( rs->replaydone != 0 && counter++ < 3 )
fprintf(stderr,"replay finished but readchar called\n");
rs->replaydone = (uint32_t)time(NULL);
return(0);
}
if ( rs == 0 || rs->guiflag != 0 )
{
c = getch();
switch ( c )
{
case KEY_LEFT:
c = 'h';
break;
case KEY_RIGHT:
c = 'l';
break;
case KEY_UP:
c = 'k';
break;
case KEY_DOWN:
c = 'j';
break;
}
ch = c;
if (ch == 3)
{
//_quit();
return(27);
}
/*if ( rs != 0 && rs->guiflag != 0 )
{
if ( rs->num < sizeof(rs->buffered) )
{
rs->buffered[rs->num++] = ch;
if ( rs->num > (sizeof(rs->buffered)*9)/10 && rs->needflush == 0 )
{
rs->needflush = (uint32_t)time(NULL);
//fprintf(stderr,"needflush.%u %d of %d\n",rs->needflush,rs->num,(int32_t)sizeof(rs->buffered));
//sleep(3);
}
} else fprintf(stderr,"buffer filled without flushed\n");
}*/
} else fprintf(stderr,"readchar rs.%p non-gui error?\n",rs);
return(ch);
}
#ifdef STANDALONE
/*
Main tetris game!