diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/server.lua | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/server/server.lua b/server/server.lua index 42ed41d..ff3c3eb 100644 --- a/server/server.lua +++ b/server/server.lua @@ -2,6 +2,7 @@ local enet = require"enet" local json = require"common.dkjson" local Chunk = require"common.chunk".Chunk local unpack = unpack or table.unpack +local coords = require"common.coords" math.randomseed(os.time()) @@ -94,12 +95,24 @@ while true do local x,y = j.x,j.y player.pos[1] = x player.pos[2] = y - print(player.id,"-->",player.pos[1],player.pos[2]) + -- print(player.id,"-->",player.pos[1],player.pos[2]) for i,otherplayer in ipairs(playerlist) do if otherplayer ~= player then otherplayer.peer:send(player_move_packet(player,x,y)) end end + elseif op == "settile" then + local h = coords.Hex.make(j.q,j.r) + the_chunk:set_at(h,j.tile) + print(player.id,"settile",h,j.tile) + for i,otherplayer in ipairs(playerlist) do + if otherplayer ~= player then + -- same packet structure s2c as c2s + -- when multiple chunks exist and players only get info + -- about stuff near to them, that won't be the case any more + otherplayer.peer:send(ev.data) + end + end end end |