From b6cdf0725e35cf5ea347540022acffc6d3a869b6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 22 Mar 2019 01:12:31 -1100 Subject: [PATCH] Test --- src/cc/gamescc.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index b600a8c3a..d083e2292 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -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 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) ) { hash = jbits256(jitem(params,0),0); @@ -56,15 +56,9 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) playerid++; if ( playerid == 0x100 ) { - for (i=0; i<8; i++) - hash.uints[i] ^= 0xffffffff; + invertflag = 1; playerid--; } - for (i=0; i<8; i++) - { - if ( ((1 << i) & playerid) != 0 ) - seed ^= hash.uints[i]; - } } else { @@ -74,6 +68,8 @@ UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) seeds[i] = (seeds[i]*11109 + 13849); } 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("result","success"));