1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 15:23:01 +01:00

Allow re-creation of object manager

Removing lazy initialisation of it.
This commit is contained in:
Ted John
2017-06-22 18:56:32 +01:00
committed by Michał Janiszewski
parent e2184f3e32
commit 3003393c87
3 changed files with 13 additions and 10 deletions

View File

@@ -28,6 +28,7 @@
#include "core/String.hpp"
#include "FileClassifier.h"
#include "network/network.h"
#include "object/ObjectManager.h"
#include "object/ObjectRepository.h"
#include "OpenRCT2.h"
#include "ParkImporter.h"
@@ -77,6 +78,7 @@ namespace OpenRCT2
// Services
IObjectRepository * _objectRepository = nullptr;
IObjectManager * _objectManager = nullptr;
ITrackDesignRepository * _trackDesignRepository = nullptr;
IScenarioRepository * _scenarioRepository = nullptr;
@@ -188,6 +190,7 @@ namespace OpenRCT2
// }
_objectRepository = CreateObjectRepository(_env);
_objectManager = CreateObjectManager(_objectRepository);
_trackDesignRepository = CreateTrackDesignRepository(_env);
_scenarioRepository = CreateScenarioRepository(_env);

View File

@@ -547,16 +547,14 @@ private:
static std::unique_ptr<ObjectManager> _objectManager;
IObjectManager * CreateObjectManager(IObjectRepository * objectRepository)
{
_objectManager = std::unique_ptr<ObjectManager>(new ObjectManager(objectRepository));
return _objectManager.get();
}
IObjectManager * GetObjectManager()
{
if (_objectManager == nullptr)
{
IObjectRepository * objectRepository = GetObjectRepository();
if (objectRepository != nullptr)
{
_objectManager = std::unique_ptr<ObjectManager>(new ObjectManager(objectRepository));
}
}
return _objectManager.get();
}

View File

@@ -33,6 +33,7 @@ extern "C"
#ifdef __cplusplus
interface IObjectRepository;
class Object;
struct ObjectRepositoryItem;
@@ -54,6 +55,7 @@ interface IObjectManager
virtual std::vector<const ObjectRepositoryItem *> GetPackableObjects() abstract;
};
IObjectManager * CreateObjectManager(IObjectRepository * objectRepository);
IObjectManager * GetObjectManager();
#endif