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