Browse Source

+print

jl777
jl777 5 years ago
parent
commit
21b50727bf
  1. 18
      src/cc/gamescc.cpp
  2. 6
      src/cc/tetris.cpp

18
src/cc/gamescc.cpp

@ -927,7 +927,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven
*keystrokesp = 0;
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 ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 )
@ -946,17 +946,17 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven
if ( matches == 1 )
{
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 ( games_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 )
active = tokenid;
else active = playertxid;
if ( active == zeroid || games_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 )
{
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;
while ( CCgettxout(txid,0,1,0) < 0 )
{
@ -973,7 +973,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven
}
}
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?
{
return(0);
@ -994,17 +994,17 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven
}
numkeys += (int32_t)k.size() / sizeof(gamesevent);
(*keystrokesp) = keystrokes;
//fprintf(stderr,"updated keystrokes.%p[%d]\n",keystrokes,numkeys);
fprintf(stderr,"updated keystrokes.%p[%d]\n",keystrokes,numkeys);
}
}
//fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str());
fprintf(stderr,"n.%d txid.%s\n",n,txid.GetHex().c_str());
if ( ++n >= GAMES_MAXITERATIONS )
{
fprintf(stderr,"games_findbaton n.%d, seems something is wrong\n",n);
return(-5);
}
}
//fprintf(stderr,"set baton %s\n",txid.GetHex().c_str());
fprintf(stderr,"set baton %s\n",txid.GetHex().c_str());
batontxid = txid;
batonvout = 0; // not vini
// how to detect timeout, bailedout, highlander
@ -1017,7 +1017,7 @@ int32_t games_findbaton(struct CCcontract_info *cp,uint256 &playertxid,gameseven
return(-4);
else batonht = pindex->GetHeight();
batonvalue = batontx.vout[0].nValue;
//printf("batonht.%d keystrokes[%d]\n",batonht,numkeys);
printf("batonht.%d keystrokes[%d]\n",batonht,numkeys);
return(0);
} else fprintf(stderr,"couldnt find baton\n");
} else fprintf(stderr,"error with playerdata\n");

6
src/cc/tetris.cpp

@ -90,7 +90,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std:
{
UniValue obj;
seed = games_gamefields(obj,maxplayers,buyin,gametxid,gamesaddr);
//fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str());
fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Games_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str());
memset(&P,0,sizeof(P));
if ( playerdata.size() > 0 )
{
@ -116,7 +116,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std:
fclose(fp);
}
}
//fprintf(stderr,"call replay2\n");
fprintf(stderr,"call replay2\n");
num = games_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0);
newdata.resize(num);
for (i=0; i<num; i++)
@ -124,7 +124,7 @@ gamesevent *games_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std:
newdata[i] = newplayer[i];
((uint8_t *)&endP)[i] = newplayer[i];
}
//fprintf(stderr,"back replay2 gold.%d\n",endP.gold);
fprintf(stderr,"back replay2 gold.%d\n",endP.gold);
if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 )
{
sprintf(str,"zero value character was killed -> no playerdata\n");

Loading…
Cancel
Save