Merge branch 'jl777' into add-nf-token-opret
This commit is contained in:
@@ -157,7 +157,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
||||
{
|
||||
Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey);
|
||||
//fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s)\n",i,(double)utxovalues[i]/COIN,destaddr);
|
||||
std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl;
|
||||
//std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl;
|
||||
if( strcmp(destaddr, myaddr) == 0 )
|
||||
{
|
||||
fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr);
|
||||
|
||||
@@ -38,6 +38,8 @@ command(struct rogue_state *rs)
|
||||
do_fuses(rs,BEFORE);
|
||||
while (ntimes--)
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
return;
|
||||
again = FALSE;
|
||||
if (has_hit)
|
||||
{
|
||||
@@ -117,6 +119,8 @@ command(struct rogue_state *rs)
|
||||
* turn off count for commands which don't make sense
|
||||
* to repeat
|
||||
*/
|
||||
if ( rs->guiflag == 0 && rs->replaydone != 0 )
|
||||
ch = 'Q';
|
||||
switch (ch)
|
||||
{
|
||||
case CTRL('B'): case CTRL('H'): case CTRL('J'):
|
||||
@@ -263,9 +267,10 @@ over:
|
||||
after = FALSE;
|
||||
q_comm = TRUE;
|
||||
quit(0);
|
||||
if ( rs->needflush == 0 )
|
||||
if ( rs->guiflag != 0 && rs->needflush == 0 )
|
||||
rs->needflush = (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);
|
||||
@@ -280,11 +285,11 @@ over:
|
||||
when 'c': call(rs); after = FALSE;
|
||||
|
||||
when '>': after = FALSE; d_level(rs);
|
||||
if ( rs->needflush == 0 )
|
||||
if ( rs->guiflag != 0 && rs->needflush == 0 )
|
||||
rs->needflush = (uint32_t)time(NULL);
|
||||
|
||||
when '<': after = FALSE; u_level(rs);
|
||||
if ( rs->needflush == 0 )
|
||||
if ( rs->guiflag != 0 && rs->needflush == 0 )
|
||||
rs->needflush = (uint32_t)time(NULL);
|
||||
|
||||
when '?': after = FALSE; help(rs);
|
||||
@@ -446,23 +451,23 @@ over:
|
||||
/*
|
||||
* If he ran into something to take, let him pick it up.
|
||||
*/
|
||||
if (take != 0)
|
||||
pick_up(rs,take);
|
||||
if (!running)
|
||||
door_stop = FALSE;
|
||||
if (!after)
|
||||
ntimes++;
|
||||
if (take != 0)
|
||||
pick_up(rs,take);
|
||||
if (!running)
|
||||
door_stop = FALSE;
|
||||
if (!after)
|
||||
ntimes++;
|
||||
}
|
||||
do_daemons(rs,AFTER);
|
||||
do_fuses(rs,AFTER);
|
||||
if (ISRING(LEFT, R_SEARCH))
|
||||
search(rs);
|
||||
search(rs);
|
||||
else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0)
|
||||
teleport(rs);
|
||||
teleport(rs);
|
||||
if (ISRING(RIGHT, R_SEARCH))
|
||||
search(rs);
|
||||
search(rs);
|
||||
else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0)
|
||||
teleport(rs);
|
||||
teleport(rs);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -157,12 +157,16 @@ readchar(struct rogue_state *rs)
|
||||
{
|
||||
if ( rs->ind < rs->numkeys )
|
||||
{
|
||||
if ( rs->ind == rs->numkeys-1 )
|
||||
rs->replaydone = (uint32_t)time(NULL);
|
||||
//if ( rs->ind == rs->numkeys-1 )
|
||||
// rs->replaydone = (uint32_t)time(NULL);
|
||||
//fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]);
|
||||
return(rs->keystrokes[rs->ind++]);
|
||||
}
|
||||
fatal("replay finished but readchar called\n");
|
||||
return(' ');
|
||||
fprintf(stderr,"replay finished but readchar called\n");
|
||||
rs->replaydone = (uint32_t)time(NULL);
|
||||
if ( (rand() & 1) == 0 )
|
||||
return(ESCAPE);
|
||||
else return('y');
|
||||
}
|
||||
if ( rs == 0 || rs->guiflag != 0 )
|
||||
{
|
||||
@@ -277,10 +281,18 @@ wait_for(struct rogue_state *rs,int ch)
|
||||
|
||||
if (ch == '\n')
|
||||
while ((c = readchar(rs)) != '\n' && c != '\r')
|
||||
continue;
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
while (readchar(rs) != ch)
|
||||
continue;
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -146,9 +146,9 @@ int32_t flushkeystrokes(struct rogue_state *rs)
|
||||
uint8_t *OS_fileptr(long *allocsizep,char *fname);
|
||||
#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)
|
||||
|
||||
void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
{
|
||||
char cmd[32768]; int32_t i,n; char *filestr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item;
|
||||
char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item;
|
||||
sprintf(fname,"%s.gameinfo",gametxidstr);
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname);
|
||||
if ( system(cmd) != 0 )
|
||||
@@ -163,16 +163,17 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
item = jitem(array,i);
|
||||
if ( is_cJSON_True(jobj(item,"ismine")) != 0 )
|
||||
if ( is_cJSON_True(jobj(item,"ismine")) != 0 && (statusstr= jstr(item,"status")) != 0 )
|
||||
{
|
||||
fprintf(stderr,"found ismine:true\n");
|
||||
sleep(2);
|
||||
if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 )
|
||||
if ( strcmp(statusstr,"registered") == 0 )
|
||||
{
|
||||
decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr);
|
||||
fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr));
|
||||
rs->restoring = 1;
|
||||
sleep(5);
|
||||
retval = 0;
|
||||
if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 )
|
||||
{
|
||||
decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr);
|
||||
//fprintf(stderr,"set datastr[%d]\n",(int32_t)strlen(datastr));
|
||||
rs->restoring = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,6 +182,7 @@ void rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
}
|
||||
free(filestr);
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
void rogue_progress(uint64_t seed,char *keystrokes,int32_t num) // use seed to lookup gametxid
|
||||
@@ -212,7 +214,11 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu
|
||||
rs->numkeys = num;
|
||||
rs->sleeptime = 0;
|
||||
if ( player != 0 )
|
||||
{
|
||||
rs->P = *player;
|
||||
rs->restoring = 1;
|
||||
fprintf(stderr,"restore player packsize.%d\n",rs->P.packsize);
|
||||
}
|
||||
uint32_t starttime = (uint32_t)time(NULL);
|
||||
rogueiterate(rs);
|
||||
/*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime);
|
||||
@@ -301,7 +307,11 @@ int rogue(int argc, char **argv, char **envp)
|
||||
{
|
||||
rs->seed = atol(argv[1]);
|
||||
strcpy(Gametxidstr,argv[2]);
|
||||
rogue_setplayerdata(rs,Gametxidstr);
|
||||
if ( rogue_setplayerdata(rs,Gametxidstr) < 0 )
|
||||
{
|
||||
fprintf(stderr,"invalid gametxid, or already started\n");
|
||||
return(-1);
|
||||
}
|
||||
} else rs->seed = 777;
|
||||
rs->guiflag = 1;
|
||||
rs->sleeptime = 1; // non-zero to allow refresh()
|
||||
@@ -533,7 +543,7 @@ playit(struct rogue_state *rs)
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
{
|
||||
//fprintf(stderr,"replaydone\n"); sleep(3);
|
||||
fprintf(stderr,"replaydone\n"); sleep(3);
|
||||
return;
|
||||
}
|
||||
if ( rs->sleeptime != 0 )
|
||||
@@ -561,27 +571,38 @@ quit(int sig)
|
||||
{
|
||||
struct rogue_state *rs = &globalR;
|
||||
int oy, ox;
|
||||
|
||||
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?");
|
||||
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')
|
||||
{
|
||||
signal(SIGINT, leave);
|
||||
clear();
|
||||
mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse);
|
||||
move(LINES - 1, 0);
|
||||
if ( rs->sleeptime != 0 )
|
||||
refresh();
|
||||
score(purse, 1, 0);
|
||||
flushkeystrokes(rs);
|
||||
my_exit(0);
|
||||
if ( rs->guiflag != 0 )
|
||||
{
|
||||
signal(SIGINT, leave);
|
||||
clear();
|
||||
mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse);
|
||||
move(LINES - 1, 0);
|
||||
if ( rs->sleeptime != 0 )
|
||||
refresh();
|
||||
score(purse, 1, 0);
|
||||
flushkeystrokes(rs);
|
||||
my_exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"done!\n");
|
||||
score(purse, 1, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -668,9 +689,14 @@ shell(struct rogue_state *rs)
|
||||
void
|
||||
my_exit(int st)
|
||||
{
|
||||
uint32_t counter;
|
||||
resetltchars();
|
||||
if ( globalR.guiflag != 0 )
|
||||
exit(st);
|
||||
else fprintf(stderr,"would have exit.(%d)\n",st);
|
||||
else if ( counter++ < 10 )
|
||||
{
|
||||
fprintf(stderr,"would have exit.(%d)\n",st);
|
||||
globalR.replaydone = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1351,6 +1351,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item)
|
||||
o->_o._o_flags = item->flags;
|
||||
o->_o._o_group = item->group;
|
||||
o->o_flags |= ISKNOW;
|
||||
o->o_flags &= ~ISFOUND;
|
||||
switch ( item->type )
|
||||
{
|
||||
case SCROLL:
|
||||
@@ -1370,6 +1371,9 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item)
|
||||
ws_info[item->which].oi_know = TRUE;
|
||||
break;
|
||||
}
|
||||
char packitemstr[256];
|
||||
strcpy(packitemstr,inv_name(o,FALSE));
|
||||
fprintf(stderr,"packitem.(%s)\n",packitemstr);
|
||||
}
|
||||
|
||||
void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item)
|
||||
|
||||
@@ -808,7 +808,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
{
|
||||
UniValue obj; struct rogue_player P;
|
||||
seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr);
|
||||
fprintf(stderr,"found baton %s numkeys.%d seed.%llu\n",batontxid.ToString().c_str(),numkeys,(long long)seed);
|
||||
fprintf(stderr,"found baton %s numkeys.%d seed.%llu playerdata.%d\n",batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size());
|
||||
memset(&P,0,sizeof(P));
|
||||
if ( playerdata.size() > 0 )
|
||||
{
|
||||
@@ -840,9 +840,12 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
return(cclib_error(result,"highlander must be a winner or last one standing"));
|
||||
cashout += numplayers * buyin;
|
||||
}
|
||||
if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult )
|
||||
CCchange = (inputsum - cashout);
|
||||
mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
|
||||
if ( cashout >= txfee )
|
||||
{
|
||||
if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult )
|
||||
CCchange = (inputsum - cashout);
|
||||
mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
|
||||
}
|
||||
//for (i=0; i<P.packsize; i++)
|
||||
// fprintf(stderr,"object (%s) type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_type,o->_o._o_packch,o->_o._o_packch);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user