mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
refactor
This commit is contained in:
parent
5fe5c6b27a
commit
5ffc054d75
16 changed files with 212 additions and 126 deletions
|
|
@ -132,13 +132,18 @@ static void show_content_missing(
|
|||
menus::show(engine, "reports/missing_content", {std::move(root)});
|
||||
}
|
||||
|
||||
static bool loadWorldContent(Engine* engine, const fs::path& folder) {
|
||||
return menus::call(engine, [engine, folder]() {
|
||||
static bool load_world_content(Engine* engine, const fs::path& folder) {
|
||||
if (engine->isHeadless()) {
|
||||
engine->loadWorldContent(folder);
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
return menus::call(engine, [engine, folder]() {
|
||||
engine->loadWorldContent(folder);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void loadWorld(Engine* engine, const std::shared_ptr<WorldFiles>& worldFiles) {
|
||||
static void load_world(Engine* engine, const std::shared_ptr<WorldFiles>& worldFiles) {
|
||||
try {
|
||||
auto content = engine->getContent();
|
||||
auto& packs = engine->getContentPacks();
|
||||
|
|
@ -160,7 +165,12 @@ static void loadWorld(Engine* engine, const std::shared_ptr<WorldFiles>& worldFi
|
|||
void EngineController::openWorld(const std::string& name, bool confirmConvert) {
|
||||
auto paths = engine->getPaths();
|
||||
auto folder = paths->getWorldsFolder() / fs::u8path(name);
|
||||
if (!loadWorldContent(engine, folder)) {
|
||||
auto worldFile = folder / fs::u8path("world.json");
|
||||
if (!fs::exists(worldFile)) {
|
||||
throw std::runtime_error(worldFile.u8string() + " does not exists");
|
||||
}
|
||||
|
||||
if (!load_world_content(engine, folder)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +202,7 @@ void EngineController::openWorld(const std::string& name, bool confirmConvert) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
loadWorld(engine, std::move(worldFiles));
|
||||
load_world(engine, std::move(worldFiles));
|
||||
}
|
||||
|
||||
inline uint64_t str2seed(const std::string& seedstr) {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
using namespace scripting;
|
||||
|
||||
static int l_uptime(lua::State* L) {
|
||||
return lua::pushnumber(L, engine->getUptime());
|
||||
return lua::pushnumber(L, engine->getTime().getTime());
|
||||
}
|
||||
|
||||
static int l_delta(lua::State* L) {
|
||||
return lua::pushnumber(L, engine->getDelta());
|
||||
return lua::pushnumber(L, engine->getTime().getDelta());
|
||||
}
|
||||
|
||||
const luaL_Reg timelib[] = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue