From d680ebf55f6425ece668bb0d375b4413b4451230 Mon Sep 17 00:00:00 2001 From: Sara Date: Tue, 11 Jun 2024 09:09:11 +0200 Subject: [PATCH] fix: rng is now reference counted --- game_root.cpp | 4 ++-- game_root.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/game_root.cpp b/game_root.cpp index d36f8a8..2b9a753 100644 --- a/game_root.cpp +++ b/game_root.cpp @@ -166,7 +166,7 @@ void GameRoot3D::unregister_spawn_point(SpawnPoint3D *spawn_point) { void GameRoot3D::place_player_at_spawnpoint(IPlayer *player) { if(this->spawn_points.is_empty()) return; - SpawnPoint3D *spawn_point = this->spawn_points[rng.randi() % this->spawn_points.size()]; + SpawnPoint3D *spawn_point = this->spawn_points[rng->randi() % this->spawn_points.size()]; player->spawn_at_position(spawn_point->get_global_transform()); } @@ -253,7 +253,7 @@ gd::Ref GameRoot3D::get_game_state_prototype() const { } gd::RandomNumberGenerator &GameRoot3D::get_rng() { - return this->rng; + return *this->rng.ptr(); } void GameRoot3D::grab_singleton() { diff --git a/game_root.hpp b/game_root.hpp index 9015ae9..029342f 100644 --- a/game_root.hpp +++ b/game_root.hpp @@ -142,7 +142,7 @@ private: * * `&get_rng()` */ - gd::RandomNumberGenerator rng{}; + gd::Ref rng{}; /*! All currently active levels. * * Each identified by their resource paths.