整理代码,较复杂的单行if-then-end拆成多行

This commit is contained in:
MrZ626
2021-09-03 00:28:08 +08:00
parent 827d0cdf5a
commit 57497dbd74
66 changed files with 703 additions and 261 deletions

View File

@@ -454,7 +454,9 @@ function NET.updateWS_user()
USER.uid=res.uid
USER.authToken=res.authToken
FILE.save(USER,'conf/user')
if SCN.cur=='login'then SCN.back()end
if SCN.cur=='login'then
SCN.back()
end
end
MES.new('check',text.loginSuccessed)
@@ -549,7 +551,9 @@ function NET.updateWS_play()
mode=d.mode,
config=d.config,
}
if SCN.cur=='net_game'then SCN.socketRead('join',d)end
if SCN.cur=='net_game'then
SCN.socketRead('join',d)
end
if NET.roomReadyState=='allReady'then
NET.roomReadyState=false
end
@@ -558,16 +562,22 @@ function NET.updateWS_play()
if not d.uid then
NET.wsclose_stream()
NET.unlock('quit')
if SCN.stack[#SCN.stack-1]=='net_newRoom'then SCN.pop()end
if SCN.stack[#SCN.stack-1]=='net_newRoom'then
SCN.pop()
end
SCN.back()
else
netPLY.remove(d.sid)
_removePlayer(PLAYERS,d.sid)
_removePlayer(PLY_ALIVE,d.sid)
if SCN.cur=='net_game'then SCN.socketRead('leave',d)end
if SCN.cur=='net_game'then
SCN.socketRead('leave',d)
end
end
elseif res.action==4 then--Player talk
if SCN.cur=='net_game'then SCN.socketRead('talk',d)end
if SCN.cur=='net_game'then
SCN.socketRead('talk',d)
end
elseif res.action==5 then--Player change settings
netPLY.setConf(d.uid,d.config)
elseif res.action==6 then--Player change join mode
@@ -579,7 +589,9 @@ function NET.updateWS_play()
NET.roomReadyState='connecting'
NET.wsconn_stream(d.srid)
elseif res.action==9 then--Game finished
if SCN.cur=='net_game'then SCN.socketRead('finish',d)end
if SCN.cur=='net_game'then
SCN.socketRead('finish',d)
end
--d.result: list of {place,survivalTime,uid,score}
for _,p in next,d.result do
@@ -595,7 +607,9 @@ function NET.updateWS_play()
netPLY.resetState()
netPLY.freshPos()
NET.roomState.start=false
if NET.spectate then NET.signal_setMode(2)end
if NET.spectate then
NET.signal_setMode(2)
end
NET.spectate=false
NET.wsclose_stream()
end