added random number initialization function for native BD engine
authorHolger Schemel <info@artsoft.org>
Sun, 11 Feb 2024 13:26:39 +0000 (14:26 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 18 Feb 2024 14:57:43 +0000 (15:57 +0100)
src/game_bd/export_bd.h
src/game_bd/main_bd.c
src/tools.c

index deb7d692d2786251517cfb4fdb643a731ce4a496..7c12293076a2b7c13d4f50b89e7becf382e0a2e7 100644 (file)
@@ -95,4 +95,6 @@ void setLevelInfoToDefaults_BD_Ext(int, int);
 void setLevelInfoToDefaults_BD(void);
 boolean LoadNativeLevel_BD(char *, int, boolean);
 
+unsigned int InitEngineRandom_BD(int);
+
 #endif // EXPORT_BD_H
index 991523c5539e8d616a81508080a982c9543285a4..fdc5cf0c0a6350f576ac309400ad14bb768536e7 100644 (file)
@@ -187,3 +187,16 @@ boolean checkGameRunning_BD(void)
 {
   return (game_bd.game != NULL && game_bd.game->state_counter == GAME_INT_CAVE_RUNNING);
 }
+
+unsigned int InitEngineRandom_BD(int seed)
+{
+  if (seed == NEW_RANDOMIZE)
+  {
+    // get randomly selected seed to render the cave
+    seed = g_random_int_range(0, GD_CAVE_SEED_MAX);
+  }
+
+  game_bd.random_seed = seed;
+
+  return (unsigned int)seed;
+}
index cdb7b4cb70bc20bf5a75af60be8df3387c9f7890..7c8f825217ccc2459c94bef3b181412ba99aa228 100644 (file)
@@ -9678,7 +9678,9 @@ boolean isActivePlayer_EM(int player_nr)
 
 unsigned int InitRND(int seed)
 {
-  if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+  if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
+    return InitEngineRandom_BD(seed);
+  else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
     return InitEngineRandom_EM(seed);
   else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
     return InitEngineRandom_SP(seed);