From 0611a8c3a76a4113aed9c0a6629ec75db378098c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 17 Mar 2022 14:30:00 +0200 Subject: [PATCH] Start new game with specified seed in options --- apps/openmw/mwbase/world.hpp | 3 +++ apps/openmw/mwworld/worldimp.cpp | 10 +++++++++- apps/openmw/mwworld/worldimp.hpp | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 23e687be5a..f86f24310a 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -112,6 +112,9 @@ namespace MWBase virtual ~World() {} + virtual void setRandomSeed(uint32_t seed) = 0; + ///< \param seed The seed used when starting a new game. + virtual void startNewGame (bool bypass) = 0; ///< \param bypass Bypass regular game start. diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 16eb5f3b9b..fb48707a8e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -283,6 +283,9 @@ namespace MWWorld MWBase::Environment::get().getWindowManager()->updatePlayer(); mCurrentDate->setup(mGlobalVariables); + + // Initial seed. + mPrng.seed(mRandomSeed); } void World::clear() @@ -557,7 +560,12 @@ namespace MWWorld mProjectileManager->clear(); } - const ESM::Cell *World::getExterior (const std::string& cellName) const + void World::setRandomSeed(uint32_t seed) + { + mRandomSeed = seed; + } + + const ESM::Cell* World::getExterior(const std::string& cellName) const { // first try named cells const ESM::Cell *cell = mStore.get().searchExtByName (cellName); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index eb089f04d7..6eeda94ef3 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -130,6 +130,8 @@ namespace MWWorld std::map mDoorStates; ///< only holds doors that are currently moving. 1 = opening, 2 = closing + uint32_t mRandomSeed{}; + // not implemented World (const World&); World& operator= (const World&); @@ -194,6 +196,8 @@ namespace MWWorld virtual ~World(); + void setRandomSeed(uint32_t seed) override; + void startNewGame (bool bypass) override; ///< \param bypass Bypass regular game start.