fixes
This commit is contained in:
parent
56a8226028
commit
8730b03a52
@ -12,5 +12,5 @@ function on_open()
|
||||
name=settings.generator_name(k)
|
||||
}))
|
||||
end
|
||||
panel:add("<button padding='10' onclick='menu:back()'>@Back</button>")
|
||||
panel:add("<button onclick='menu:back()'>@Back</button>")
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
</textbox>
|
||||
<label>@Seed</label>
|
||||
<textbox id='seed_box' placeholder='-' padding='4'></textbox>
|
||||
<button onclick='menu.page="generators"' id='generator_btn'>
|
||||
<button onclick='save_state() menu.page="generators"' id='generator_btn'>
|
||||
@World generator
|
||||
</button>
|
||||
<button onclick='create_world()' margin='1,20,1,1'>
|
||||
|
||||
@ -4,6 +4,11 @@ function world_name_validator(name)
|
||||
return name:match("^[%w-\\.\\ ]+$") ~= nil and not world.exists(name)
|
||||
end
|
||||
|
||||
function save_state()
|
||||
settings.name = document.name_box.text
|
||||
settings.seed = document.seed_box.text
|
||||
end
|
||||
|
||||
function settings.generator_name(id)
|
||||
local prefix, name = parse_path(id)
|
||||
if prefix == "core" then
|
||||
@ -19,7 +24,9 @@ function create_world()
|
||||
end
|
||||
local name = document.name_box.text
|
||||
local seed = document.seed_box.text
|
||||
core.new_world(name, seed, settings.generator)
|
||||
local generator = settings.generator
|
||||
session.reset_entry('new_world')
|
||||
core.new_world(name, seed, generator)
|
||||
end
|
||||
|
||||
function on_open()
|
||||
@ -31,5 +38,7 @@ function on_open()
|
||||
gui.str("World generator", "world"),
|
||||
settings.generator_name(settings.generator)
|
||||
)
|
||||
document.name_box.text = settings.name or ''
|
||||
document.seed_box.text = settings.seed or ''
|
||||
document.seed_box.placeholder = tostring(math.random()):sub(3)
|
||||
end
|
||||
|
||||
@ -219,7 +219,7 @@ void WorldRegions::closeRegFile(glm::ivec3 coord) {
|
||||
}
|
||||
|
||||
// Marks regfile as used and unmarks when shared_ptr dies
|
||||
std::shared_ptr<regfile> WorldRegions::getRegFile(glm::ivec3 coord) {
|
||||
std::shared_ptr<regfile> WorldRegions::getRegFile(glm::ivec3 coord, bool create) {
|
||||
{
|
||||
std::lock_guard lock(regFilesMutex);
|
||||
const auto found = openRegFiles.find(coord);
|
||||
@ -230,7 +230,10 @@ std::shared_ptr<regfile> WorldRegions::getRegFile(glm::ivec3 coord) {
|
||||
return useRegFile(found->first);
|
||||
}
|
||||
}
|
||||
return createRegFile(coord);
|
||||
if (create) {
|
||||
return createRegFile(coord);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<regfile> WorldRegions::createRegFile(glm::ivec3 coord) {
|
||||
@ -273,7 +276,7 @@ void WorldRegions::writeRegion(int x, int z, int layer, WorldRegion* entry){
|
||||
fs::path filename = layers[layer].folder/getRegionFilename(x, z);
|
||||
|
||||
glm::ivec3 regcoord(x, z, layer);
|
||||
if (auto regfile = getRegFile(regcoord)) {
|
||||
if (auto regfile = getRegFile(regcoord, false)) {
|
||||
fetchChunks(entry, x, z, regfile.get());
|
||||
|
||||
std::lock_guard lock(regFilesMutex);
|
||||
|
||||
@ -110,7 +110,7 @@ class WorldRegions {
|
||||
|
||||
ubyte* getData(int x, int z, int layer, uint32_t& size);
|
||||
|
||||
std::shared_ptr<regfile> getRegFile(glm::ivec3 coord);
|
||||
std::shared_ptr<regfile> getRegFile(glm::ivec3 coord, bool create=true);
|
||||
void closeRegFile(glm::ivec3 coord);
|
||||
std::shared_ptr<regfile> useRegFile(glm::ivec3 coord);
|
||||
std::shared_ptr<regfile> createRegFile(glm::ivec3 coord);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user