Test
This commit is contained in:
@@ -36,7 +36,7 @@ UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastf
|
|||||||
|
|
||||||
UniValue games_rng(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; uint16_t seeds[4]; uint64_t seed; bits256 hash;
|
UniValue result(UniValue::VOBJ); int32_t i,invertflag=0,n,playerid=0; uint16_t seeds[4]; uint64_t seed; bits256 hash;
|
||||||
if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) )
|
if ( params != 0 && ((n= cJSON_GetArraySize(params)) == 2 || n == 3) )
|
||||||
{
|
{
|
||||||
hash = jbits256(jitem(params,0),0);
|
hash = jbits256(jitem(params,0),0);
|
||||||
@@ -56,15 +56,9 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
|||||||
playerid++;
|
playerid++;
|
||||||
if ( playerid == 0x100 )
|
if ( playerid == 0x100 )
|
||||||
{
|
{
|
||||||
for (i=0; i<8; i++)
|
invertflag = 1;
|
||||||
hash.uints[i] ^= 0xffffffff;
|
|
||||||
playerid--;
|
playerid--;
|
||||||
}
|
}
|
||||||
for (i=0; i<8; i++)
|
|
||||||
{
|
|
||||||
if ( ((1 << i) & playerid) != 0 )
|
|
||||||
seed ^= hash.uints[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -74,6 +68,8 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
|||||||
seeds[i] = (seeds[i]*11109 + 13849);
|
seeds[i] = (seeds[i]*11109 + 13849);
|
||||||
}
|
}
|
||||||
seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0];
|
seed = ((uint64_t)seeds[3] << 48) | ((uint64_t)seeds[2] << 24) | ((uint64_t)seeds[1] << 16) | seeds[0];
|
||||||
|
if ( invertflag != 0 )
|
||||||
|
seed ^= -1;
|
||||||
}
|
}
|
||||||
result.push_back(Pair("seed",seed));
|
result.push_back(Pair("seed",seed));
|
||||||
result.push_back(Pair("result","success"));
|
result.push_back(Pair("result","success"));
|
||||||
|
|||||||
Reference in New Issue
Block a user