Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarRoot.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-03-25 03:46:21 +1100
committerKae <80987908+Novaenia@users.noreply.github.com>2024-03-25 03:46:21 +1100
commit560ae08424956bb495bc2453973467d138029c7c (patch)
treef506d79185388e7217af75a43074884f17349cb2 /source/game/StarRoot.cpp
parentff6e349aef9c5504896d1249b2d4a3b862c37d09 (diff)
Add support for directly setting image assets and processing Image userdata
Diffstat (limited to 'source/game/StarRoot.cpp')
-rw-r--r--source/game/StarRoot.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/source/game/StarRoot.cpp b/source/game/StarRoot.cpp
index e22f184..4d67563 100644
--- a/source/game/StarRoot.cpp
+++ b/source/game/StarRoot.cpp
@@ -60,25 +60,19 @@ namespace {
unsigned const RootLoadThreads = 4;
}
-atomic<Root*> Root::s_singleton;
-
Root* Root::singletonPtr() {
- return s_singleton.load();
+ return dynamic_cast<Root*>(s_singleton.load());
}
Root& Root::singleton() {
- auto ptr = s_singleton.load();
+ auto ptr = singletonPtr();
if (!ptr)
throw RootException("Root::singleton() called with no Root instance available");
else
return *ptr;
}
-Root::Root(Settings settings) {
- Root* oldRoot = nullptr;
- if (!s_singleton.compare_exchange_strong(oldRoot, this))
- throw RootException("Singleton Root has been constructed twice");
-
+Root::Root(Settings settings) : RootBase() {
m_settings = std::move(settings);
if (m_settings.runtimeConfigFile)
m_runtimeConfigFile = toStoragePath(*m_settings.runtimeConfigFile);