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:
committed by
Michał Janiszewski
parent
e2184f3e32
commit
3003393c87
@@ -28,6 +28,7 @@
|
|||||||
#include "core/String.hpp"
|
#include "core/String.hpp"
|
||||||
#include "FileClassifier.h"
|
#include "FileClassifier.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
|
#include "object/ObjectManager.h"
|
||||||
#include "object/ObjectRepository.h"
|
#include "object/ObjectRepository.h"
|
||||||
#include "OpenRCT2.h"
|
#include "OpenRCT2.h"
|
||||||
#include "ParkImporter.h"
|
#include "ParkImporter.h"
|
||||||
@@ -77,6 +78,7 @@ namespace OpenRCT2
|
|||||||
|
|
||||||
// Services
|
// Services
|
||||||
IObjectRepository * _objectRepository = nullptr;
|
IObjectRepository * _objectRepository = nullptr;
|
||||||
|
IObjectManager * _objectManager = nullptr;
|
||||||
ITrackDesignRepository * _trackDesignRepository = nullptr;
|
ITrackDesignRepository * _trackDesignRepository = nullptr;
|
||||||
IScenarioRepository * _scenarioRepository = nullptr;
|
IScenarioRepository * _scenarioRepository = nullptr;
|
||||||
|
|
||||||
@@ -188,6 +190,7 @@ namespace OpenRCT2
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
_objectRepository = CreateObjectRepository(_env);
|
_objectRepository = CreateObjectRepository(_env);
|
||||||
|
_objectManager = CreateObjectManager(_objectRepository);
|
||||||
_trackDesignRepository = CreateTrackDesignRepository(_env);
|
_trackDesignRepository = CreateTrackDesignRepository(_env);
|
||||||
_scenarioRepository = CreateScenarioRepository(_env);
|
_scenarioRepository = CreateScenarioRepository(_env);
|
||||||
|
|
||||||
|
|||||||
@@ -547,16 +547,14 @@ private:
|
|||||||
|
|
||||||
static std::unique_ptr<ObjectManager> _objectManager;
|
static std::unique_ptr<ObjectManager> _objectManager;
|
||||||
|
|
||||||
|
IObjectManager * CreateObjectManager(IObjectRepository * objectRepository)
|
||||||
|
{
|
||||||
|
_objectManager = std::unique_ptr<ObjectManager>(new ObjectManager(objectRepository));
|
||||||
|
return _objectManager.get();
|
||||||
|
}
|
||||||
|
|
||||||
IObjectManager * GetObjectManager()
|
IObjectManager * GetObjectManager()
|
||||||
{
|
{
|
||||||
if (_objectManager == nullptr)
|
|
||||||
{
|
|
||||||
IObjectRepository * objectRepository = GetObjectRepository();
|
|
||||||
if (objectRepository != nullptr)
|
|
||||||
{
|
|
||||||
_objectManager = std::unique_ptr<ObjectManager>(new ObjectManager(objectRepository));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _objectManager.get();
|
return _objectManager.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ extern "C"
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
class Object;
|
interface IObjectRepository;
|
||||||
struct ObjectRepositoryItem;
|
class Object;
|
||||||
|
struct ObjectRepositoryItem;
|
||||||
|
|
||||||
interface IObjectManager
|
interface IObjectManager
|
||||||
{
|
{
|
||||||
@@ -54,6 +55,7 @@ interface IObjectManager
|
|||||||
virtual std::vector<const ObjectRepositoryItem *> GetPackableObjects() abstract;
|
virtual std::vector<const ObjectRepositoryItem *> GetPackableObjects() abstract;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IObjectManager * CreateObjectManager(IObjectRepository * objectRepository);
|
||||||
IObjectManager * GetObjectManager();
|
IObjectManager * GetObjectManager();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user