forked from VoxeLibre/VoxeLibre
Quiet debug prints, add automatic indexing around players
This commit is contained in:
parent
8c51188521
commit
6e5c47ac59
|
@ -33,7 +33,7 @@ local function process_dirty_block()
|
|||
|
||||
-- If we are starting
|
||||
if not remaining_indexers then
|
||||
print("Starting to index "..vector.to_string(minetest.get_position_from_hash(processing_block)))
|
||||
--print("Starting to index "..vector.to_string(minetest.get_position_from_hash(processing_block)))
|
||||
remaining_indexers = #mod.indexers
|
||||
|
||||
-- Use a 3x3x3 for indexing, to allow access to neighbors
|
||||
|
@ -73,7 +73,7 @@ local function process_dirty_block()
|
|||
return vl_map_index.pack_index(indexer.index(data)), data.indexer, data.map_block.hash
|
||||
end
|
||||
local function finish(result, indexer, map_block_hash)
|
||||
storage:set_string(mod.indexers[indexer].name..tostring(vector.to_string(minetest.get_position_from_hash(map_block_hash))),tostring(result))
|
||||
storage:set_string(mod.indexers[indexer].name..vector.to_string(minetest.get_position_from_hash(map_block_hash)),tostring(result))
|
||||
index_in_process = false
|
||||
decompress_queue[#decompress_queue + 1] = {map_block_hash, indexer, result}
|
||||
end
|
||||
|
@ -81,7 +81,7 @@ local function process_dirty_block()
|
|||
-- Run the indexer
|
||||
index_in_process = true
|
||||
block_data.indexer = indexer
|
||||
print("Running index "..mod.indexers[indexer].name)
|
||||
--print("Running index "..mod.indexers[indexer].name)
|
||||
call_async(process, finish, block_data)
|
||||
|
||||
return true
|
||||
|
@ -111,8 +111,32 @@ function mod.flag_position_hash_dirty(pos_hash)
|
|||
local pos = minetest.get_position_from_hash(pos_hash)
|
||||
mod.flag_position_dirty(pos)
|
||||
end
|
||||
function mod.index_around_entity(pos, distance)
|
||||
-- Returns true if all indexes have been generated for map_block
|
||||
function mod.has_index(map_block)
|
||||
for i = 1,#mod.indexers do
|
||||
if not storage:contains(mod.indexers[i].name..vector.to_string(map_block)) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
function mod.ensure_indexed(map_block)
|
||||
if not mod.has_index(map_block) then
|
||||
dirty_blocks[minetest.hash_node_position(map_block)] = 0
|
||||
end
|
||||
end
|
||||
function mod.index_around_entity(pos, distance)
|
||||
local center = mod.map_block(pos)
|
||||
local blocks = math.ceil(distance / MINETEST_BLOCK_SIZE)
|
||||
|
||||
for z = -blocks,blocks do
|
||||
for y = -blocks,blocks do
|
||||
for x = -blocks,blocks do
|
||||
mod.ensure_indexed(vector.add(center, vector.new(x,y,z)))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Flag any map block that has nodes placed or dug for an update
|
||||
|
@ -146,6 +170,7 @@ local function run_indexer()
|
|||
|
||||
local last_player_block = last_player_blocks[player_name]
|
||||
if not last_player_block or last_player_block ~= map_block then
|
||||
print("Indexing around "..player_name)
|
||||
mod.index_around_entity(player_pos, 128)
|
||||
end
|
||||
last_player_blocks[player_name] = map_block
|
||||
|
|
Loading…
Reference in New Issue