From b3bcf04c8c90e6b7e3467ced6a9ad6e4aa0bdc9d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 24 Jan 2016 23:15:23 -0300 Subject: [PATCH] test --- iguana/pangea_api.c | 12 +++++++++--- iguana/pangea_hand.c | 12 +++++++++--- includes/iguana_apideclares.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/iguana/pangea_api.c b/iguana/pangea_api.c index b8278b886..d015df1bd 100755 --- a/iguana/pangea_api.c +++ b/iguana/pangea_api.c @@ -469,19 +469,25 @@ int32_t pangea_hexmsg(struct supernet_info *myinfo,void *data,int32_t len,char * { if ( tablecmds[i].cmdbits == cmdbits ) { - printf("PANGEA.(%s)\n",tablecmds[i].cmdstr); allocsize = pangea_allocsize(tp,0); if ( tp->G.allocsize < allocsize ) { tp = pangea_tablealloc(tp); category_infoset(tp->G.gamehash,tp->G.tablehash,tp); } + if ( strcmp(tablecmds[i].cmdstr,"newhand") == 0 ) + { + tp->G.numactive = pm->turni; + tp->G.numcards = 52; + if ( tp->G.minplayers == 0 ) + tp->G.minplayers = tp->G.maxplayers = tp->G.numactive; + } + printf("PANGEA.(%s) numactive.%d minplayers.%d\n",tablecmds[i].cmdstr,tp->G.numactive,tp->G.minplayers); (*tablecmds[i].func)(myinfo,pm,tp,pm->serialized,(int32_t)(pm->sig.allocsize - sizeof(*pm))); break; } } } - printf("ERROR >>>>>>> (%s) cant parse\n",(char *)pm->serialized); } } else if ( 0 ) @@ -671,7 +677,7 @@ INT_AND_ARRAY(pangea,host,minplayers,params) return(pangea_jsondatacmd(myinfo,tablehash,(struct pangea_msghdr *)space,json,"host",myinfo->ipaddr)); } -HASH_AND_ARRAY(pangea,join,tablehash,params) +HASH_AND_STRING(pangea,join,tablehash,handle) { uint8_t space[sizeof(struct pangea_msghdr) + 4096]; return(pangea_jsondatacmd(myinfo,tablehash,(struct pangea_msghdr *)space,json,"join",myinfo->ipaddr)); diff --git a/iguana/pangea_hand.c b/iguana/pangea_hand.c index d76c01cb8..6e30fe8a4 100755 --- a/iguana/pangea_hand.c +++ b/iguana/pangea_hand.c @@ -139,14 +139,17 @@ uint32_t pangea_rank(struct supernet_info *myinfo,struct table_info *tp,int32_t int32_t pangea_newdeck(struct supernet_info *myinfo,struct table_info *tp) { bits256 *playerpubs; int32_t i,j,n,datalen,button; struct hand_info *hand = &tp->hand; + if ( tp->G.N < tp->G.numactive ) + tp->G.N = tp->G.numactive; button = (tp->numhands % tp->G.N); pangea_clearhand(tp); playerpubs = &hand->cardpubs[tp->G.numcards + 1]; for (j=n=0; jG.N; j++) { i = (j + button) % tp->G.N; - if ( tp->G.P[i].balance > 0 ) + //if ( tp->G.P[i].balance > 0 ) playerpubs[n++] = tp->G.P[i].playerpub; + char str[65]; printf("(%d of %d %s) ",i,tp->G.N,bits256_str(str,tp->G.P[i].playerpub)); } if ( n < tp->G.minplayers ) { @@ -156,7 +159,7 @@ int32_t pangea_newdeck(struct supernet_info *myinfo,struct table_info *tp) hand->checkprod = hand->cardpubs[tp->G.numcards] = cards777_initdeck(tp->priv.outcards,hand->cardpubs,tp->G.numcards,n,playerpubs,0); datalen = (tp->G.numcards + 1 + n) * sizeof(bits256); pangea_sendcmd(myinfo,tp,"newhand",-1,hand->cardpubs[0].bytes,datalen,n,n); - PNACL_message("host sends NEWDECK checkprod.%llx numhands.%d\n",(long long)hand->checkprod.txid,tp->numhands); + printf("host sends NEWDECK checkprod.%llx numhands.%d\n",(long long)hand->checkprod.txid,tp->numhands); return(0); } @@ -177,7 +180,10 @@ void pangea_newhand(PANGEA_HANDARGS) { if ( (ind= pangea_Pind(tp,pubkeys[numcards + 1 + i])) < 0 ) { - printf("illegal pubkey, cant find player[%d]\n",i); + char str[65],str2[65]; int32_t j; + for (j=0; jG.P[j].playerpub),bits256_str(str2,pubkeys[numcards + 1 + i])); + printf("illegal pubkey, cant find player[%d] (%s)\n",i,bits256_str(str,pubkeys[numcards + 1 + i])); return; } tp->active[i] = &tp->G.P[ind]; diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index 6f53a9b75..11682fd23 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -20,7 +20,7 @@ HASH_AND_ARRAY(pangea,history,tableid,params);*/ INT_AND_ARRAY(pangea,host,minplayers,params); ZERO_ARGS(pangea,lobby); -HASH_AND_ARRAY(pangea,join,tablehash,params); +HASH_AND_STRING(pangea,join,tablehash,handle); HASH_AND_ARRAY(pangea,start,tablehash,params); ZERO_ARGS(SuperNET,help);