diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 51046fb6..e4475c93 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -1154,6 +1154,8 @@ do USER.id=res.id USER.authToken=res.authToken NET.getAccessToken() + else + SCN.back() end FILE.save(USER,"conf/user","q") LOG.print(text.loginSuccessed) @@ -1164,12 +1166,14 @@ do USER.accessToken=res.accessToken LOG.print(text.accessSuccessed) NET.wsConnectPlay() + NET.unlock("accessToken") elseif res.action==1 then--Get userInfo if res.id==USER.id then--Own USER.name=res.username USER.motto=res.motto USER.avatar=res.avatar FILE.save(USER,"conf/user") + NET.unlock("getSelfInfo") else--Others LOG.print("Get user info: "..USER.id) end @@ -1202,11 +1206,13 @@ do local res=JSON.decode(message) if res then if res.message=="Connected"then + NET.unlock("connectPlay") SCN.go("net_menu") elseif res.action==0 then--Fetch rooms NET.roomList=res.roomList elseif res.action==2 then--Join room loadGame("netBattle",true,true) + NET.unlock("enterRoom") elseif res.action==3 then--Leave room SCN.back() end diff --git a/parts/net.lua b/parts/net.lua index bd51566e..3883b3c3 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -5,28 +5,48 @@ local NET={ roomList=false, } +--Lock & Unlock submodule +local locks={} +function NET.lock(name,T) + if locks[name]and TIME()