继续完善联网,调整玩家数据初始化过程
This commit is contained in:
@@ -97,7 +97,7 @@ function NET.storeUserInfo(res)
|
||||
|
||||
--Get own name
|
||||
if res.id==USER.id then
|
||||
USER.name=res.name
|
||||
USER.name=res.username
|
||||
FILE.save(USER,"conf/user")
|
||||
end
|
||||
|
||||
@@ -293,6 +293,15 @@ function NET.updateWS_play()
|
||||
elseif res.action==2 then--Player join
|
||||
if res.type=="Self"then
|
||||
--Create room
|
||||
TABLE.clear(PLY_NET)
|
||||
local d=res.data
|
||||
table.insert(PLY_NET,{
|
||||
conf=dumpBasicConfig(),
|
||||
username=USER.name,
|
||||
uid=USER.id,
|
||||
sid=d.sid,
|
||||
ready=d.ready,
|
||||
})
|
||||
loadGame("netBattle",true,true)
|
||||
_unlock("enterRoom")
|
||||
else
|
||||
|
||||
@@ -134,6 +134,9 @@ local function newEmptyPlayer(id,mini)
|
||||
P.atker,P.atking,P.lastRecv={}
|
||||
|
||||
--Network-related
|
||||
P.userName="_"
|
||||
P.userID=-1
|
||||
P.subID=-1
|
||||
P.ready=false
|
||||
|
||||
P.dropDelay,P.lockDelay=0,0
|
||||
@@ -405,6 +408,9 @@ function PLY.newPlayer(id,mini)
|
||||
P.type="human"
|
||||
P.sound=true
|
||||
|
||||
P.userID=USER.id
|
||||
P.subID=-1
|
||||
|
||||
loadGameEnv(P)
|
||||
applyGameEnv(P)
|
||||
end
|
||||
|
||||
@@ -150,14 +150,23 @@ function scene.socketRead(cmd,data)
|
||||
COLOR.Y,text.joinRoom,
|
||||
}
|
||||
end
|
||||
local L=data.players
|
||||
for i=1,#L do
|
||||
if data.players then
|
||||
for _,p in next,data.players do
|
||||
ins(PLY_NET,{
|
||||
sid=p.sid,
|
||||
uid=p.uid,
|
||||
username=p.username,
|
||||
conf=p.config,
|
||||
ready=p.ready,
|
||||
})
|
||||
end
|
||||
else
|
||||
ins(PLY_NET,{
|
||||
sid=L[i].sid,
|
||||
uid=L[i].uid,
|
||||
username=L[i].username,
|
||||
conf=L[i].config,
|
||||
ready=L[i].ready,
|
||||
sid=data.sid,
|
||||
uid=data.uid,
|
||||
username=data.username,
|
||||
conf=data.config,
|
||||
ready=data.ready,
|
||||
})
|
||||
end
|
||||
playerInitialized=true
|
||||
|
||||
Reference in New Issue
Block a user