From 1490cf19a950d99b045fe68d7151a6cd54c57e27 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sun, 18 Jun 2023 03:31:03 +0100 Subject: add handshaking system, and refactor server a bit --- client/game.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'client/game.lua') diff --git a/client/game.lua b/client/game.lua index 50b74f9..31e02b8 100644 --- a/client/game.lua +++ b/client/game.lua @@ -342,12 +342,16 @@ local function draw() end local connected = false +local sent_hshake = false function SCENE.update(dt) if connected then return update(dt) else handle_net() - if peer:state() == "connected" and local_player then + if peer:state() == "connected" and not sent_hshake then + peer:send(json.encode{t='handshake',username=username}) + sent_hshake = true + elseif peer:state() == "connected" and local_player then connected = true msgbox.add("connected to "..SERVER_HOSTNAME..":8473") msgbox.add("press F1 for controls help") @@ -363,7 +367,7 @@ function SCENE.draw() end end -function SCENE.load() +function SCENE.load(username) love.keyboard.setKeyRepeat(true) -- require"profile".start(10,io.open("./trace","w")) host = enet.host_create() -- cgit v1.2.3