MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / createWorld

Method createWorld

src/engine/GameSession.cpp:79–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79std::unique_ptr<World::WorldInstance> GameSession::createWorld(const std::string& _worldFile,
80 const json& worldJson,
81 const json& scriptEngine,
82 const json& dialogManager,
83 const json& logManager)
84{
85 std::string worldFile = _worldFile;
86
87 std::unique_ptr<World::WorldInstance> pWorldInstance = std::make_unique<World::WorldInstance>(m_Engine);
88 World::WorldInstance& world = *pWorldInstance;
89
90 if (!worldJson.empty())
91 {
92 worldFile = worldJson["zenfile"];
93 }
94 if (!worldFile.empty())
95 {
96 std::vector<uint8_t> zenData;
97 m_Engine.getVDFSIndex().getFileData(worldFile, zenData);
98
99 if (zenData.empty())
100 {
101 LogWarn() << "Failed to find world file: " << worldFile;
102 return nullptr;
103 }
104 }
105 if (!world.init(worldFile, worldJson, scriptEngine, dialogManager, logManager)) // expensive operation
106 {
107 LogError() << "Failed to init world file: " << worldFile;
108 return nullptr;
109 }
110 return pWorldInstance;
111}
112
113Handle::WorldHandle GameSession::registerWorld(std::unique_ptr<World::WorldInstance> pWorldInstance)
114{

Callers 3

switchToWorldMethod · 0.80
startNewGameMethod · 0.80
loadSaveGameSlotMethod · 0.80

Calls 2

emptyMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected