From: Holger Schemel Date: Sun, 11 Feb 2024 13:26:39 +0000 (+0100) Subject: added random number initialization function for native BD engine X-Git-Tag: 4.4.0.0-test-1~387 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=dc7bcae20949adb40e3bf797eab98ecb286a2453;p=rocksndiamonds.git added random number initialization function for native BD engine --- diff --git a/src/game_bd/export_bd.h b/src/game_bd/export_bd.h index deb7d692..7c122930 100644 --- a/src/game_bd/export_bd.h +++ b/src/game_bd/export_bd.h @@ -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 diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index 991523c5..fdc5cf0c 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -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; +} diff --git a/src/tools.c b/src/tools.c index cdb7b4cb..7c8f8252 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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);