From be4fa5d2e526102e50d937f55606a0cb8c3ba77a Mon Sep 17 00:00:00 2001 From: redfast00 Date: Wed, 19 Jan 2022 21:33:41 +0100 Subject: [PATCH] Add fallback when seeding random --- lib/obus_module.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/obus_module.cpp b/lib/obus_module.cpp index bd758f5..8440166 100644 --- a/lib/obus_module.cpp +++ b/lib/obus_module.cpp @@ -166,7 +166,9 @@ bool loopPuzzle(obus_can::message* message, void (*callback_game_start)(uint8_t callback_state(message->gamestatus.time_left, message->gamestatus.strikes, message->gamestatus.max_strikes, message->gamestatus.puzzle_modules_left); break; case OBUS_MSGTYPE_C_INFOSTART: - randomSeed(message->infostart.seed); + // randomSeed has no effect when called with 0 as seed, so we use + // a fallback value that is unlikely to collide with other frequently used seeds + randomSeed(message->infostart.seed ? message->infostart.seed : 0xFFFFFFFF); break; default: break;