From 91a22ac34a3e6dc8536298537796e101424a430c Mon Sep 17 00:00:00 2001 From: ubq323 Date: Tue, 31 Jan 2023 00:30:47 +0000 Subject: terrain data is sent from server to client --- server/server.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'server') diff --git a/server/server.lua b/server/server.lua index 12d70e5..42ed41d 100644 --- a/server/server.lua +++ b/server/server.lua @@ -1,5 +1,6 @@ local enet = require"enet" local json = require"common.dkjson" +local Chunk = require"common.chunk".Chunk local unpack = unpack or table.unpack math.randomseed(os.time()) @@ -56,6 +57,8 @@ local function player_move_packet(player,x,y) return json.encode{t="move",id=player.id,x=x,y=y} end +local the_chunk = Chunk.gen() + while true do local ev = host:service(100) if ev then @@ -64,6 +67,7 @@ while true do table.insert(playerlist,player) print("connect",player.peer,player.id) player.peer:send(player_you_packet(player)) + player.peer:send(the_chunk:data_packet()) for i,otherplayer in ipairs(playerlist) do if otherplayer ~= player then -- cgit v1.2.3