注释后加空格

联网稍微推进
This commit is contained in:
MrZ_26
2022-10-03 02:43:51 +08:00
parent 06f4bb4e1a
commit f8d17b23b6
121 changed files with 1628 additions and 1622 deletions

View File

@@ -302,9 +302,7 @@ function NET.room.chat(mes,rid)
}) })
end end
function NET.room.create(roomName,description,capacity,roomType,roomData,password) function NET.room.create(roomName,description,capacity,roomType,roomData,password)
if not TASK.lock('enterRoom',2) then return end if not TASK.lock('enterRoom',6) then return end
NET.roomState.private=not not password
NET.roomState.capacity=capacity
wsSend(1301,{ wsSend(1301,{
capacity=capacity, capacity=capacity,
info={ info={
@@ -314,9 +312,14 @@ function NET.room.create(roomName,description,capacity,roomType,roomData,passwor
description=description, description=description,
}, },
data=roomData, data=roomData,
password=password, password=password,
}) })
WAIT{
quit=function()
TASK.unlock('enterRoom')
end,
timeout=1e99,
}
end end
function NET.room.getData(rid) function NET.room.getData(rid)
wsSend(1302,{ wsSend(1302,{
@@ -341,7 +344,7 @@ function NET.room.setInfo(info,rid)
}) })
end end
function NET.room.enter(rid,password) function NET.room.enter(rid,password)
if TASK.lock('enterRoom',6) then if not TASK.lock('enterRoom',6) then return end
SFX.play('reach',.6) SFX.play('reach',.6)
wsSend(1306,{ wsSend(1306,{
data={ data={
@@ -350,7 +353,6 @@ function NET.room.enter(rid,password)
} }
}) })
end end
end
function NET.room.kick(pid,rid) function NET.room.kick(pid,rid)
wsSend(1307,{ wsSend(1307,{
playerId=pid,-- Host playerId=pid,-- Host
@@ -361,7 +363,7 @@ function NET.room.leave()
wsSend(1308) wsSend(1308)
end end
function NET.room.fetch() function NET.room.fetch()
if TASK.lock('fetchRoom',3) then if not TASK.lock('fetchRoom',3) then return end
wsSend(1309,{ wsSend(1309,{
data={ data={
pageIndex=0, pageIndex=0,
@@ -369,9 +371,8 @@ function NET.room.fetch()
} }
}) })
end end
end
function NET.room.setPW(pw,rid) function NET.room.setPW(pw,rid)
if TASK.lock('fetchRoom',3) then if not TASK.lock('setRoomPW',2) then return end
wsSend(1310,{ wsSend(1310,{
data={ data={
password=pw, password=pw,
@@ -379,7 +380,6 @@ function NET.room.setPW(pw,rid)
} }
}) })
end end
end
function NET.room.remove(rid) function NET.room.remove(rid)
wsSend(1311,{ wsSend(1311,{
roomId=rid-- Admin roomId=rid-- Admin
@@ -450,26 +450,34 @@ function NET.updateWS()
elseif res.action==1100 then-- TODO elseif res.action==1100 then-- TODO
elseif res.action==1101 then-- TODO elseif res.action==1101 then-- TODO
elseif res.action==1102 then-- TODO elseif res.action==1102 then-- TODO
elseif res.action==1201 then-- TODO elseif res.action==1201 then-- Finish
elseif res.action==1202 then-- TODO elseif res.action==1202 then-- Join group
elseif res.action==1203 then-- TODO elseif res.action==1203 then-- Set ready
elseif res.action==1204 then-- TODO elseif res.action==1204 then-- Set host
elseif res.action==1205 then-- TODO elseif res.action==1205 then-- Set state
elseif res.action==1206 then-- TODO elseif res.action==1206 then-- Stream
elseif res.action==1207 then-- TODO elseif res.action==1207 then-- Set playing
elseif res.action==1301 then-- TODO elseif res.action==1301 then-- Create room
elseif res.action==1302 then-- TODO TASK.unlock('enterRoom')
elseif res.action==1303 then-- TODO -- NET.roomState=...
elseif res.action==1304 then-- TODO -- SCN.go('net_game')
elseif res.action==1305 then-- TODO WAIT.interrupt()
elseif res.action==1306 then-- TODO elseif res.action==1302 then-- Get room data
elseif res.action==1307 then-- TODO elseif res.action==1303 then-- Set room data
elseif res.action==1308 then-- TODO elseif res.action==1304 then-- Get room info
elseif res.action==1305 then-- Set room info
elseif res.action==1306 then-- Enter room
TASK.unlock('enterRoom')
-- NET.roomState=...
-- SCN.go('net_game')
WAIT.interrupt()
elseif res.action==1307 then-- Kick room
elseif res.action==1308 then-- Leave room
elseif res.action==1309 then-- Fetch rooms elseif res.action==1309 then-- Fetch rooms
TASK.unlock('fetchRoom') TASK.unlock('fetchRoom')
if res.data then SCN.scenes.net_rooms.widgetList.roomList:setList(res.data) end if res.data then SCN.scenes.net_rooms.widgetList.roomList:setList(res.data) end
elseif res.action==1310 then-- TODO elseif res.action==1310 then-- Set password
elseif res.action==1311 then-- TODO elseif res.action==1311 then-- Remove room
end end
else else
WS.alert('user') WS.alert('user')
@@ -492,7 +500,7 @@ end
-- Save -- Save
function NET.uploadSave() function NET.uploadSave()
if TASK.lock('uploadSave',8) then if not TASK.lock('uploadSave',8) then return end
wsSend({data={sections={ wsSend({data={sections={
{section=1,data=STRING.packTable(STAT)}, {section=1,data=STRING.packTable(STAT)},
{section=2,data=STRING.packTable(RANKS)}, {section=2,data=STRING.packTable(RANKS)},
@@ -504,13 +512,11 @@ function NET.uploadSave()
}}}) }}})
MES.new('info',"Uploading") MES.new('info',"Uploading")
end end
end
function NET.downloadSave() function NET.downloadSave()
if TASK.lock('downloadSave',8) then if not TASK.lock('downloadSave',8) then return end
wsSend({data={sections={1,2,3,4,5,6,7}}}) wsSend({data={sections={1,2,3,4,5,6,7}}})
MES.new('info',"Downloading") MES.new('info',"Downloading")
end end
end
function NET.loadSavedData(sections) function NET.loadSavedData(sections)
for _,sec in next,sections do for _,sec in next,sections do
if sec.section==1 then if sec.section==1 then