Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
b3bcf04c8c
  1. 12
      iguana/pangea_api.c
  2. 12
      iguana/pangea_hand.c
  3. 2
      includes/iguana_apideclares.h

12
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));

12
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; j<tp->G.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; j<n; j++)
printf("(j%d %s vs %s)",j,bits256_str(str,tp->G.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];

2
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);

Loading…
Cancel
Save