diff options
| author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2026-06-03 01:15:29 +0200 |
|---|---|---|
| committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2026-06-03 01:15:29 +0200 |
| commit | f08683a3775989e749237cd001a8eaf3193d1684 (patch) | |
| tree | fbda564309b9f0f7c66c0bd68a2e8c5f08ff27f3 /client.lua | |
| parent | cc5b2f31a7abe46147284de869368a0a2c4bcff4 (diff) | |
| download | r6p-f08683a3775989e749237cd001a8eaf3193d1684.tar.xz | |
add main menu
Diffstat (limited to 'client.lua')
| -rw-r--r-- | client.lua | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -8,7 +8,7 @@ local client = {} local function create_client(secret) local clt = {} - clt.host = enet.host_create() -- enet.host_create("10.75.98.51:58901") + clt.host = enet.host_create() clt.secret = secret return clt end @@ -20,7 +20,11 @@ local function connect(clt, addr) end function client.join(invite, match_addr) - local invite_dec = base64.decode(invite) + local decode_succ, invite_dec = pcall(base64.decode, invite) + if not decode_succ then + return nil, "invalid_invite" + end + local game_id = invite_dec:sub(1, common.gameid_len) local secret = invite_dec:sub(common.gameid_len+1) @@ -93,7 +97,7 @@ end function client.status(clt) if clt.status == "wait_match" and clt.match_req+3 < socket.gettime() then clt.status = "timeout_match" - elseif clt.status == "wait_server" and clt.match_req+5 < socket.gettime() then + elseif clt.status == "wait_server" and clt.server_req+5 < socket.gettime() then clt.status = "timeout_server" end @@ -113,6 +117,9 @@ function client.status(clt) end function client.close(clt) + if clt.match then clt.match:disconnect() end + if clt.server then clt.server:disconnect() end + clt.host:service() clt.host:destroy() end |
