diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | common/chunk.lua | 1 | ||||
-rw-r--r-- | server/map.lua | 8 | ||||
-rw-r--r-- | server/server.lua | 4 |
4 files changed, 11 insertions, 3 deletions
@@ -1,4 +1,5 @@ server/enet.so +server/world/* flamegraph.pl trace* graph*.svg diff --git a/common/chunk.lua b/common/chunk.lua index affdab8..790e5a4 100644 --- a/common/chunk.lua +++ b/common/chunk.lua @@ -39,6 +39,7 @@ function Chunk.from_packet_data(packet) -- since otherwise how would we know it's a chunk packet local cp = coords.ChunkPos:make(packet.u,packet.v) + print("making from packet",packet.u,packet.v) return Chunk:make(cp,packet.tiles) end diff --git a/server/map.lua b/server/map.lua index 335997a..0bb09c7 100644 --- a/server/map.lua +++ b/server/map.lua @@ -2,6 +2,7 @@ local Map = require"common.map".Map local class = require"common.class" local worldgen = require"worldgen" local json = require"common.dkjson" +local Chunk = require"common.chunk".Chunk local MapS = class.extend(Map) function MapS.obtain(self,cp) @@ -17,13 +18,18 @@ function MapS.obtain(self,cp) local f = io.open(cp:filename(),"r") if f then + print("loading from file",cp) local j = json.decode(f:read("a")) - ch = Chunk:from_packet_data(j) + print(j) + for k in pairs(j) do print(k) end + ch = Chunk.from_packet_data(j) f:close() else ch = worldgen.gen_chunk(cp) end + + print(ch.cp.u,ch.cp.v) self:add_chunk(ch) return ch end diff --git a/server/server.lua b/server/server.lua index 725f7f1..e9eef30 100644 --- a/server/server.lua +++ b/server/server.lua @@ -159,10 +159,10 @@ local ntick = 0 local function tick(ntick) - if ntick % 3 == 0 then + if ntick % 30 == 0 then print("saving things...") for cp,ch in map:iter_chunks() do - print(cp) + map:save_chunk(cp) end end end |