From ab2d7de6546a2cdd188b7b13b0b22879abbcc06e Mon Sep 17 00:00:00 2001 From: MEUNIER Thibaud Date: Tue, 1 Jan 2019 14:57:29 +0100 Subject: [PATCH] =?UTF-8?q?mieux=20g=C3=A9rer=20le=20hasard=20pour=20les?= =?UTF-8?q?=20couleurs=20de=20bloc=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blockchain/inc/block.php | 2 +- methode/hashes/robot.sh | 2 +- methode/hashes2hashes/robot.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/blockchain/inc/block.php b/blockchain/inc/block.php index f9b73ca..cfadeb1 100644 --- a/blockchain/inc/block.php +++ b/blockchain/inc/block.php @@ -268,7 +268,7 @@ class blockchain ]; $color = $couleur; - if ($color == -1) $color = rand(0,count($color_tab)-1); + if (($color == -1) || ($color > (count($color_tab)-1))) $color = rand(0,count($color_tab)-1); // Rajout des HASHES $white = imagecolorallocate($vImage, 254, 254, 254); diff --git a/methode/hashes/robot.sh b/methode/hashes/robot.sh index 8d5945b..3c62516 100755 --- a/methode/hashes/robot.sh +++ b/methode/hashes/robot.sh @@ -15,7 +15,7 @@ for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt` do if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] then - php robot.php $BLOCK $((RANDOM % 6)) + php robot.php $BLOCK 99999 fi done diff --git a/methode/hashes2hashes/robot.php b/methode/hashes2hashes/robot.php index a8b6a01..668bcfe 100644 --- a/methode/hashes2hashes/robot.php +++ b/methode/hashes2hashes/robot.php @@ -53,7 +53,7 @@ for($i=0; $i<$nb_max; $i++) $block_hash = $the_block->prev_block; $hash=DATA_PATH.'/hashes/'.$the_block->hash.'.png'; - if ($final_hash == 'default') $final_hash = $hash; + if ($final_hash == 'default') $final_hash = $the_block->hash; if (file_exists($hash)) {