This commit is contained in:
jl777
2019-02-06 01:20:44 -11:00
parent 94f104121e
commit 694ba9a629
2 changed files with 37 additions and 35 deletions

View File

@@ -159,6 +159,37 @@ int32_t flushkeystrokes(struct rogue_state *rs)
rs->num = 0; rs->num = 0;
return(0); return(0);
} }
int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num)
{
struct rogue_state *rs; FILE *fp; int32_t i;
rs = (struct rogue_state *)calloc(1,sizeof(*rs));
rs->seed = seed;
rs->keystrokes = keystrokes;
rs->numkeys = num;
rs->sleeptime = 1;
uint32_t starttime = (uint32_t)time(NULL);
rogueiterate(rs);
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime);
sleep(2);
starttime = (uint32_t)time(NULL);
for (i=0; i<100; i++)
{
memset(rs,0,sizeof(*rs));
rs->seed = seed;
rs->keystrokes = keystrokes;
rs->numkeys = num;
rs->sleeptime = 0;
rogueiterate(rs);
}
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime);
sleep(1);
if ( (fp= fopen("checkfile","wb")) != 0 )
save_file(rs,fp,0);
free(rs);
return(0);
}
#endif #endif
long get_filesize(FILE *fp) long get_filesize(FILE *fp)
@@ -204,40 +235,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
} }
if ( num > 0 ) if ( num > 0 )
{ {
rs = (struct rogue_state *)calloc(1,sizeof(*rs)); rogue_replay2(seed,keystrokes,num);
rs->seed = seed;
rs->keystrokes = keystrokes;
rs->numkeys = num;
rs->sleeptime = 1;
uint32_t starttime = (uint32_t)time(NULL);
rogueiterate(rs);
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime);
sleep(2);
starttime = (uint32_t)time(NULL);
for (i=0; i<2000; i++)
{
memset(rs,0,sizeof(*rs));
rs->seed = seed;
rs->keystrokes = keystrokes;
rs->numkeys = num;
rs->sleeptime = 0;
rogueiterate(rs);
}
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime);
sleep(1);
if ( (fp= fopen("checkfile","wb")) != 0 )
{
save_file(rs,fp,0);
if ( 0 && (fp= fopen("checkfile","rb")) != 0 )
{
for (i=0; i<0x150; i++)
fprintf(stderr,"%02x",fgetc(fp));
fprintf(stderr," first part rnd.%d\n",rnd(1000));
fclose(fp);
}
}
free(rs);
mvaddstr(LINES - 2, 0, (char *)"replay completed"); mvaddstr(LINES - 2, 0, (char *)"replay completed");
endwin(); endwin();
} }

View File

@@ -617,6 +617,8 @@ UniValue rogue_highlander(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
return(result); return(result);
} }
int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num);
UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{ {
// detect if last to bailout // detect if last to bailout
@@ -640,9 +642,11 @@ UniValue rogue_bailout(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
result.push_back(Pair("gametxid",gametxid.GetHex())); result.push_back(Pair("gametxid",gametxid.GetHex()));
if ( rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid) == 0 ) if ( rogue_isvalidgame(cp,gametx,buyin,maxplayers,gametxid) == 0 )
{ {
if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 ) if ( rogue_findbaton(cp,&keystrokes,numkeys,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr) == 0 && keystrokes != 0 )
{ {
fprintf(stderr,"found baton %s numkeys.%d\n",batontxid.ToString().c_str(),numkeys); fprintf(stderr,"found baton %s numkeys.%d\n",batontxid.ToString().c_str(),numkeys);
rogue_replay2(4419709268196762041,keystrokes,numkeys);
free(keystrokes);
} }
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
} }