mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Nuking forrests with remoteMap no longer produces lagspikes
This commit is contained in:
1 parent
dd9130dc8b
commit
72d5f06381
2 files changed
+17
-9
No files matched your search
@@ -26,18 +26,27 @@ function write_file(data)
|
||||
must_write_initstuff = false
|
||||
writeout_initial_stuff()
|
||||
end
|
||||
|
||||
game.write_file("remoteMap.txt", data, true)
|
||||
stringsToWriteNextTick = stringsToWriteNextTick .. data .. '\n'
|
||||
-- game.write_file("remoteMap.txt", data, true)
|
||||
end
|
||||
|
||||
function dump_cached_writes()
|
||||
game.write_file("remoteMap.txt", stringsToWriteNextTick, true)
|
||||
end
|
||||
|
||||
function complain(text)
|
||||
print(text)
|
||||
game.forces["player"].print(text)
|
||||
if false then -- only print during development
|
||||
print(text)
|
||||
game.forces["player"].print(text)
|
||||
end
|
||||
end
|
||||
|
||||
local todo_next_tick = {}
|
||||
function on_tick(event)
|
||||
dump_cached_writes()
|
||||
stringsToWriteNextTick = ''
|
||||
if #todo_next_tick > 0 then
|
||||
print("on_tick executing "..#todo_next_tick.." stored callbacks")
|
||||
complain("on_tick executing "..#todo_next_tick.." stored callbacks")
|
||||
for _,func in ipairs(todo_next_tick) do
|
||||
func()
|
||||
end
|
||||
@@ -45,10 +54,8 @@ function on_tick(event)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function writeout_objects(surface, area)
|
||||
--if my_client_id ~= 1 then return end
|
||||
header = "objects "..area.left_top.x..","..area.left_top.y..";"..area.right_bottom.x..","..area.right_bottom.y..": "
|
||||
line = ''
|
||||
for idx, ent in pairs(surface.find_entities(area)) do
|
||||
if area.left_top.x <= ent.position.x and ent.position.x < area.right_bottom.x and area.left_top.y <= ent.position.y and ent.position.y < area.right_bottom.y then
|
||||
@@ -99,6 +106,7 @@ script.on_event(defines.events.on_tick, on_tick)
|
||||
script.on_event(defines.events.on_biter_base_built, on_some_entity_created) --entity
|
||||
script.on_event(defines.events.on_built_entity, on_some_entity_created) --created_entity
|
||||
script.on_event(defines.events.on_robot_built_entity, on_some_entity_created) --created_entity
|
||||
script.on_event(defines.events.on_player_rotated_entity, on_some_entity_created) --created_entity
|
||||
|
||||
script.on_event(defines.events.on_entity_died, on_some_entity_deleted) --entity
|
||||
script.on_event(defines.events.on_player_mined_entity, on_some_entity_deleted) --entity
|
||||
|
||||
Reference in new issue
Block a user