summaryrefslogtreecommitdiff
path: root/server/server.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-01-31 23:51:25 +0000
committerubq323 <ubq323@ubq323.website>2023-01-31 23:51:25 +0000
commit04664ee48de5fc8b06a584e20a4b75c41dafa558 (patch)
tree49192241d64897fb34f75a92dbab1e11d706fa22 /server/server.lua
parent82c4e04fa6b27a1e9cb5469d7847aef80e5a22bd (diff)
add sending of tile changes, between players. server remembers all changes made. also add better debug screen
Diffstat (limited to 'server/server.lua')
-rw-r--r--server/server.lua15
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