add test.open_world
This commit is contained in:
parent
b05c2fc911
commit
cfc16679cb
@ -1,8 +1,20 @@
|
|||||||
|
-- Create/close/open/close world
|
||||||
|
|
||||||
|
-- Open
|
||||||
test.new_world("demo", "2019", "core:default")
|
test.new_world("demo", "2019", "core:default")
|
||||||
assert(world.is_open())
|
assert(world.is_open())
|
||||||
assert(world.get_generator() == "core:default")
|
assert(world.get_generator() == "core:default")
|
||||||
test.sleep(1)
|
test.sleep(1)
|
||||||
assert(world.get_total_time() > 0.0)
|
assert(world.get_total_time() > 0.0)
|
||||||
print(world.get_total_time())
|
print(world.get_total_time())
|
||||||
|
|
||||||
|
-- Close
|
||||||
test.close_world(true)
|
test.close_world(true)
|
||||||
assert(not world.is_open())
|
assert(not world.is_open())
|
||||||
|
|
||||||
|
-- Reopen
|
||||||
|
test.open_world("demo")
|
||||||
|
assert(world.is_open())
|
||||||
|
assert(world.get_total_time() > 0.0)
|
||||||
|
test.tick()
|
||||||
|
test.close_world(true)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ if test then
|
|||||||
test.sleep = sleep
|
test.sleep = sleep
|
||||||
test.name = __VC_TEST_NAME
|
test.name = __VC_TEST_NAME
|
||||||
test.new_world = core.new_world
|
test.new_world = core.new_world
|
||||||
|
test.open_world = core.open_world
|
||||||
test.close_world = core.close_world
|
test.close_world = core.close_world
|
||||||
test.reconfig_packs = core.reconfig_packs
|
test.reconfig_packs = core.reconfig_packs
|
||||||
test.tick = coroutine.yield
|
test.tick = coroutine.yield
|
||||||
|
|||||||
@ -133,10 +133,12 @@ std::unique_ptr<Level> World::load(
|
|||||||
auto playerRoot = files::read_json(file);
|
auto playerRoot = files::read_json(file);
|
||||||
level->players->deserialize(playerRoot);
|
level->players->deserialize(playerRoot);
|
||||||
|
|
||||||
|
if (!playerRoot["players"].empty()) {
|
||||||
if (!playerRoot["players"][0].has("id")) {
|
if (!playerRoot["players"][0].has("id")) {
|
||||||
level->getWorld()->getInfo().nextPlayerId++;
|
level->getWorld()->getInfo().nextPlayerId++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user