| 77 | } |
| 78 | |
| 79 | std::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 | |
| 113 | Handle::WorldHandle GameSession::registerWorld(std::unique_ptr<World::WorldInstance> pWorldInstance) |
| 114 | { |
no test coverage detected