diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b05010e82..c381ead1c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -69,14 +69,13 @@ UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); int32_t i,n,playerid=0; uint64_t seed,initseed; bits256 hash; - if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) ) + UniValue result(UniValue::VOBJ); int32_t i,n,playerid=0; uint64_t seed=0,initseed; bits256 hash; + if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 1 || n == 2) ) { hash = jbits256(jitem(params,0),0); - seed = jdouble(jitem(params,1),0); - if ( n == 3 ) + if ( n == 2 ) { - playerid = juint(jitem(params,2),0); + playerid = juint(jitem(params,1),0); if ( playerid >= 0xff ) { result.push_back(Pair("result","error")); @@ -84,14 +83,11 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) return(result); } } - if ( seed == 0 ) + playerid++; + for (i=0; i<8; i++) { - playerid++; - for (i=0; i<8; i++) - { - if ( ((1 << i) & playerid) != 0 ) - seed ^= (uint64_t)hash.uints[i] << ((i&1)*32); - } + if ( ((1 << i) & playerid) != 0 ) + seed ^= (uint64_t)hash.uints[i] << ((i&1)*32); } initseed = seed; seed = _games_rngnext(initseed); diff --git a/src/cc/gamescc.h b/src/cc/gamescc.h index adb318522..a8e472622 100644 --- a/src/cc/gamescc.h +++ b/src/cc/gamescc.h @@ -11,7 +11,7 @@ std::string MYCCLIBNAME = (char *)"gamescc"; #define MYCCNAME "games" #define RPC_FUNCS \ - { (char *)MYCCNAME, (char *)"rng", (char *)"hash,seed,playerid", 2, 3, ' ', EVAL_GAMES }, \ + { (char *)MYCCNAME, (char *)"rng", (char *)"hash,playerid", 1, 2, ' ', EVAL_GAMES }, \ { (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx);