This commit is contained in:
jl777
2019-03-13 09:32:37 -11:00
parent 34fc048c0c
commit 5ac1415bf9

View File

@@ -507,10 +507,11 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke
int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector<uint8_t> checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector<uint8_t> checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0;
batonvalue = numkeys = numplayers = batonht = 0; batonvalue = numkeys = numplayers = batonht = 0;
playertxid = batontxid = zeroid; playertxid = batontxid = zeroid;
*keystrokesp = 0; if ( keystrokesp != 0 )
*keystrokesp = 0;
for (i=0; i<maxplayers; i++) for (i=0; i<maxplayers; i++)
{ {
fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); //fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers);
if ( myIsutxo_spent(spenttxid,gametxid,i+1) >= 0 ) if ( myIsutxo_spent(spenttxid,gametxid,i+1) >= 0 )
{ {
if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 )
@@ -529,17 +530,17 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers);
if ( matches == 1 ) if ( matches == 1 )
{ {
numvouts = matchtx.vout.size(); numvouts = matchtx.vout.size();
fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts);
if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid )
{ {
fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str());
if ( tokenid != zeroid ) if ( tokenid != zeroid )
active = tokenid; active = tokenid;
else active = playertxid; else active = playertxid;
if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 )
{ {
txid = matchtx.GetHash(); txid = matchtx.GetHash();
fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str());
n = 0; n = 0;
while ( CCgettxout(txid,0,1,0) < 0 ) while ( CCgettxout(txid,0,1,0) < 0 )
{ {
@@ -556,7 +557,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers);
} }
} }
txid = spenttxid; txid = spenttxid;
fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini);
if ( spentvini != 0 ) // game is over? if ( spentvini != 0 ) // game is over?
{ {
return(0); return(0);
@@ -581,7 +582,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers);
return(-5); return(-5);
} }
} }
fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str());
batontxid = txid; batontxid = txid;
batonvout = 0; // not vini batonvout = 0; // not vini
// how to detect timeout, bailedout, highlander // how to detect timeout, bailedout, highlander
@@ -594,7 +595,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers);
return(-4); return(-4);
else batonht = pindex->GetHeight(); else batonht = pindex->GetHeight();
batonvalue = batontx.vout[0].nValue; batonvalue = batontx.vout[0].nValue;
printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys);
return(0); return(0);
} else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"couldnt find baton\n");
} else fprintf(stderr,"error with playerdata\n"); } else fprintf(stderr,"error with playerdata\n");