From 1a52864c4e97493444835cdc605f3f6f9c935d02 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Mar 2025 09:31:28 +0700 Subject: [PATCH] Throw an exception when xoshiro seed is completely zero --- .../dbotthepony/mc/otm/core/util/Xoshiro256SSRandom.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Xoshiro256SSRandom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Xoshiro256SSRandom.kt index 472c89b27..8f368e7e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Xoshiro256SSRandom.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Xoshiro256SSRandom.kt @@ -17,6 +17,15 @@ class Xoshiro256SSRandom( ) : RandomGenerator, RandomSource { private val gaussian = MarsagliaPolarGaussian(this) + init { + require( + s0 != 0L || + s1 != 0L || + s2 != 0L || + s3 != 0L + ) { "Xoshiro can't operate with seed being entirely zero" } + } + constructor(seed: Long) : this(1L, 2L, 3L, 4L) { setSeed(seed) }