联网推进(修改房间内用户信息相关代码)

This commit is contained in:
MrZ626
2021-04-06 14:47:29 +08:00
parent 677456456d
commit 24e97e10c8
4 changed files with 17 additions and 10 deletions

View File

@@ -10,7 +10,7 @@ return{
PLY.newPlayer(1)
local N=2
for i=1,#PLY_NET do
if PLY_NET[i].id==tostring(USER.id)then
if PLY_NET[i].uid==USER.id then
PLAYERS[1].subID=PLY_NET[1].sid
else
PLY.newRemotePlayer(N,false,PLY_NET[i])

View File

@@ -295,6 +295,13 @@ function NET.updateWS_play()
if res.type=="Self"then
--Create room
TABLE.clear(PLY_NET)
ins(PLY_NET,{
uid=USER.id,
name=USER.name,
conf=dumpBasicConfig(),
sid=data.sid,
ready=data.ready,
})
if data.players then
for _,p in next,data.players do
ins(PLY_NET,{
@@ -321,7 +328,7 @@ function NET.updateWS_play()
end
elseif res.action==3 then--Player leave
for i=1,#PLY_NET do
if PLY_NET[i].id==data.uid then
if PLY_NET[i].uid==data.uid then
rem(PLY_NET,i)
break
end

View File

@@ -372,7 +372,7 @@ function PLY.newDemoPlayer(id)
}
P:popNext()
end
function PLY.newRemotePlayer(id,mini,playerData)
function PLY.newRemotePlayer(id,mini,data)
local P=newEmptyPlayer(id,mini)
P.type="remote"
P.update=PLY.update.remote_alive
@@ -382,13 +382,13 @@ function PLY.newRemotePlayer(id,mini,playerData)
P.stream={}
P.streamProgress=1
playerData.p=P
P.userName=playerData.name
P.userID=playerData.id
P.subID=playerData.sid
P.ready=playerData.ready
data.p=P
P.userName=data.name
P.userID=data.uid
P.subID=data.sid
P.ready=data.ready
loadRemoteEnv(P,playerData.conf)
loadRemoteEnv(P,data.conf)
applyGameEnv(P)
end

View File

@@ -164,7 +164,7 @@ function scene.socketRead(cmd,data)
elseif cmd=="Config"then
if tostring(USER.id)~=data.uid then
for i=1,#PLY_NET do
if PLY_NET[i].id==data.uid then
if PLY_NET[i].uid==data.uid then
PLY_NET[i].conf=data.config
PLY_NET[i].p:setConf(data.config)
return