summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-01-31 00:30:47 +0000
committerubq323 <ubq323@ubq323.website>2023-01-31 00:30:47 +0000
commit91a22ac34a3e6dc8536298537796e101424a430c (patch)
tree2bcdd770d695ff0a3fef8ba33590029754e4cc3f /server
parentb851e37a5a44e2c6a022f1c87c3d2da494ccb0e6 (diff)
terrain data is sent from server to client
Diffstat (limited to 'server')
-rw-r--r--server/server.lua4
1 files changed, 4 insertions, 0 deletions
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