diff options
author | ubq323 <ubq323@ubq323.website> | 2023-06-18 03:31:03 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-06-18 03:31:03 +0100 |
commit | 1490cf19a950d99b045fe68d7151a6cd54c57e27 (patch) | |
tree | c05a14cd80f8ff2623da0e47cc274ba85b6d96d1 /client/game.lua | |
parent | d5e264125994b6e5943ffb42f607362b3e79bcba (diff) |
add handshaking system, and refactor server a bit
Diffstat (limited to 'client/game.lua')
-rw-r--r-- | client/game.lua | 8 |
1 files changed, 6 insertions, 2 deletions
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() |