联网推进(修改房间内用户信息相关代码)
This commit is contained in:
@@ -10,7 +10,7 @@ return{
|
|||||||
PLY.newPlayer(1)
|
PLY.newPlayer(1)
|
||||||
local N=2
|
local N=2
|
||||||
for i=1,#PLY_NET do
|
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
|
PLAYERS[1].subID=PLY_NET[1].sid
|
||||||
else
|
else
|
||||||
PLY.newRemotePlayer(N,false,PLY_NET[i])
|
PLY.newRemotePlayer(N,false,PLY_NET[i])
|
||||||
|
|||||||
@@ -295,6 +295,13 @@ function NET.updateWS_play()
|
|||||||
if res.type=="Self"then
|
if res.type=="Self"then
|
||||||
--Create room
|
--Create room
|
||||||
TABLE.clear(PLY_NET)
|
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
|
if data.players then
|
||||||
for _,p in next,data.players do
|
for _,p in next,data.players do
|
||||||
ins(PLY_NET,{
|
ins(PLY_NET,{
|
||||||
@@ -321,7 +328,7 @@ function NET.updateWS_play()
|
|||||||
end
|
end
|
||||||
elseif res.action==3 then--Player leave
|
elseif res.action==3 then--Player leave
|
||||||
for i=1,#PLY_NET do
|
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)
|
rem(PLY_NET,i)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ function PLY.newDemoPlayer(id)
|
|||||||
}
|
}
|
||||||
P:popNext()
|
P:popNext()
|
||||||
end
|
end
|
||||||
function PLY.newRemotePlayer(id,mini,playerData)
|
function PLY.newRemotePlayer(id,mini,data)
|
||||||
local P=newEmptyPlayer(id,mini)
|
local P=newEmptyPlayer(id,mini)
|
||||||
P.type="remote"
|
P.type="remote"
|
||||||
P.update=PLY.update.remote_alive
|
P.update=PLY.update.remote_alive
|
||||||
@@ -382,13 +382,13 @@ function PLY.newRemotePlayer(id,mini,playerData)
|
|||||||
P.stream={}
|
P.stream={}
|
||||||
P.streamProgress=1
|
P.streamProgress=1
|
||||||
|
|
||||||
playerData.p=P
|
data.p=P
|
||||||
P.userName=playerData.name
|
P.userName=data.name
|
||||||
P.userID=playerData.id
|
P.userID=data.uid
|
||||||
P.subID=playerData.sid
|
P.subID=data.sid
|
||||||
P.ready=playerData.ready
|
P.ready=data.ready
|
||||||
|
|
||||||
loadRemoteEnv(P,playerData.conf)
|
loadRemoteEnv(P,data.conf)
|
||||||
applyGameEnv(P)
|
applyGameEnv(P)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ function scene.socketRead(cmd,data)
|
|||||||
elseif cmd=="Config"then
|
elseif cmd=="Config"then
|
||||||
if tostring(USER.id)~=data.uid then
|
if tostring(USER.id)~=data.uid then
|
||||||
for i=1,#PLY_NET do
|
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].conf=data.config
|
||||||
PLY_NET[i].p:setConf(data.config)
|
PLY_NET[i].p:setConf(data.config)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user