Refactor/RNG system (#476)

* Extract rng manipulation to its own file

* clang format

* Get CPU cycles since game start to use for RNG

* change a few things

* clang format

* Implement suggestions from @ricfehr3

* clang format

* Fix rebase issue

* clang format

* Create RngInfo struct to hold seed and step

* clang format

* Make a note about rng_restore system not having been tested properly yet

* Apply suggestions from @ricfehr3

Co-authored-by: Rickey <ric@rf3.xyz>

* clang format

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: Rickey <ric@rf3.xyz>
This commit is contained in:
Geralt
2026-05-22 04:47:48 +02:00
committed by GitHub
parent e3f680d6d0
commit c2844a5d32
14 changed files with 162 additions and 57 deletions
+4 -3
View File
@@ -17,6 +17,7 @@
#include "joker.h"
#include "layout.h"
#include "list.h"
#include "random.h"
#include "save.h"
#include "soundbank.h"
#include "timer.h"
@@ -196,7 +197,7 @@ static inline int game_shop_get_rand_available_joker_id(void)
return UNDEFINED;
int matching_joker_ids[jokers_avail_size];
int fallback_random_idx = get_rand() % jokers_avail_size;
int fallback_random_idx = rng_get_u32() % jokers_avail_size;
int fallback_random_joker_id = UNDEFINED;
int match_count = 0;
@@ -215,8 +216,8 @@ static inline int game_shop_get_rand_available_joker_id(void)
}
}
int selected_joker_id =
(match_count > 0) ? matching_joker_ids[get_rand() % match_count] : fallback_random_joker_id;
int selected_joker_id = (match_count > 0) ? matching_joker_ids[rng_get_u32() % match_count]
: fallback_random_joker_id;
return selected_joker_id;
}