修改全局结构体变量USER的成员名
This commit is contained in:
@@ -956,7 +956,7 @@ do--function saveRecording()
|
|||||||
os.date("%Y/%m/%d %A %H:%M:%S\n")..
|
os.date("%Y/%m/%d %A %H:%M:%S\n")..
|
||||||
GAME.curModeName.."\n"..
|
GAME.curModeName.."\n"..
|
||||||
VERSION_NAME.."\n"..
|
VERSION_NAME.."\n"..
|
||||||
(USER.name or"Player")
|
(USER.username or"Player")
|
||||||
local fileBody=
|
local fileBody=
|
||||||
GAME.seed.."\n"..
|
GAME.seed.."\n"..
|
||||||
JSON.encode(GAME.setting).."\n"..
|
JSON.encode(GAME.setting).."\n"..
|
||||||
|
|||||||
@@ -222,8 +222,8 @@ GAME={--Global game data
|
|||||||
RANKS=FILE.load("conf/unlock")or{sprint_10l=0}--Ranks of modes
|
RANKS=FILE.load("conf/unlock")or{sprint_10l=0}--Ranks of modes
|
||||||
USER=FILE.load("conf/user")or{--User infomation
|
USER=FILE.load("conf/user")or{--User infomation
|
||||||
--Network infos
|
--Network infos
|
||||||
name=false,
|
username=false,
|
||||||
id=false,
|
uid=false,
|
||||||
authToken=false,
|
authToken=false,
|
||||||
|
|
||||||
--Local data
|
--Local data
|
||||||
|
|||||||
@@ -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].uid==USER.id then
|
if PLY_NET[i].uid==USER.uid 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])
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ function NET.getUserInfo(id,ifDetail)
|
|||||||
WS.send("user",JSON.encode{
|
WS.send("user",JSON.encode{
|
||||||
action=1,
|
action=1,
|
||||||
data={
|
data={
|
||||||
id=id or USER.id,
|
id=id or USER.uid,
|
||||||
detailed=ifDetail or false,
|
detailed=ifDetail or false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -97,8 +97,8 @@ function NET.storeUserInfo(res)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Get own name
|
--Get own name
|
||||||
if res.id==USER.id then
|
if res.id==USER.uid then
|
||||||
USER.name=res.username
|
USER.username=res.username
|
||||||
FILE.save(USER,"conf/user")
|
FILE.save(USER,"conf/user")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ function NET.createRoom()
|
|||||||
action=1,
|
action=1,
|
||||||
data={
|
data={
|
||||||
type="classic",
|
type="classic",
|
||||||
name=(USER.name or"???").."'s room",
|
name=(USER.username or"???").."'s room",
|
||||||
password=nil,
|
password=nil,
|
||||||
config=dumpBasicConfig(),
|
config=dumpBasicConfig(),
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ end
|
|||||||
function NET.wsConnectPlay()
|
function NET.wsConnectPlay()
|
||||||
if _lock("connectPlay")then
|
if _lock("connectPlay")then
|
||||||
WS.connect("play","/play",JSON.encode{
|
WS.connect("play","/play",JSON.encode{
|
||||||
id=USER.id,
|
id=USER.uid,
|
||||||
accessToken=NET.accessToken,
|
accessToken=NET.accessToken,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -165,7 +165,7 @@ end
|
|||||||
function NET.wsConnectStream()
|
function NET.wsConnectStream()
|
||||||
if _lock("connectStream")then
|
if _lock("connectStream")then
|
||||||
WS.connect("stream","/stream",JSON.encode{
|
WS.connect("stream","/stream",JSON.encode{
|
||||||
uid=USER.id,
|
uid=USER.uid,
|
||||||
accessToken=NET.accessToken,
|
accessToken=NET.accessToken,
|
||||||
rid=NET.rsid,
|
rid=NET.rsid,
|
||||||
})
|
})
|
||||||
@@ -243,7 +243,7 @@ function NET.updateWS_user()
|
|||||||
if res.type=="Connect"then
|
if res.type=="Connect"then
|
||||||
NET.login=true
|
NET.login=true
|
||||||
if res.id then
|
if res.id then
|
||||||
USER.id=res.id
|
USER.uid=res.id
|
||||||
USER.authToken=res.authToken
|
USER.authToken=res.authToken
|
||||||
FILE.save(USER,"conf/user","q")
|
FILE.save(USER,"conf/user","q")
|
||||||
SCN.back()
|
SCN.back()
|
||||||
@@ -251,7 +251,7 @@ function NET.updateWS_user()
|
|||||||
LOG.print(text.loginSuccessed)
|
LOG.print(text.loginSuccessed)
|
||||||
|
|
||||||
--Get self infos
|
--Get self infos
|
||||||
NET.getUserInfo(USER.id)
|
NET.getUserInfo(USER.uid)
|
||||||
elseif res.action==0 then--Get accessToken
|
elseif res.action==0 then--Get accessToken
|
||||||
NET.accessToken=res.accessToken
|
NET.accessToken=res.accessToken
|
||||||
LOG.print(text.accessSuccessed)
|
LOG.print(text.accessSuccessed)
|
||||||
@@ -296,8 +296,8 @@ function NET.updateWS_play()
|
|||||||
--Create room
|
--Create room
|
||||||
TABLE.clear(PLY_NET)
|
TABLE.clear(PLY_NET)
|
||||||
ins(PLY_NET,{
|
ins(PLY_NET,{
|
||||||
uid=USER.id,
|
uid=USER.uid,
|
||||||
name=USER.name,
|
name=USER.username,
|
||||||
conf=dumpBasicConfig(),
|
conf=dumpBasicConfig(),
|
||||||
sid=data.sid,
|
sid=data.sid,
|
||||||
ready=data.ready,
|
ready=data.ready,
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ function PLY.newPlayer(id,mini)
|
|||||||
P.type="human"
|
P.type="human"
|
||||||
P.sound=true
|
P.sound=true
|
||||||
|
|
||||||
P.userID=USER.id
|
P.userID=USER.uid
|
||||||
P.subID=-1
|
P.subID=-1
|
||||||
|
|
||||||
loadGameEnv(P)
|
loadGameEnv(P)
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ local loadingThread=coroutine.wrap(function()
|
|||||||
WS.connect("app","/app")
|
WS.connect("app","/app")
|
||||||
if USER.authToken then
|
if USER.authToken then
|
||||||
WS.connect("user","/user",JSON.encode{
|
WS.connect("user","/user",JSON.encode{
|
||||||
id=USER.id,
|
id=USER.uid,
|
||||||
authToken=USER.authToken,
|
authToken=USER.authToken,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ function scene.socketRead(cmd,data)
|
|||||||
COLOR.sky,data.message or"[_]",
|
COLOR.sky,data.message or"[_]",
|
||||||
}
|
}
|
||||||
elseif cmd=="Config"then
|
elseif cmd=="Config"then
|
||||||
if tostring(USER.id)~=data.uid then
|
if tostring(USER.uid)~=data.uid then
|
||||||
for i=1,#PLY_NET do
|
for i=1,#PLY_NET do
|
||||||
if PLY_NET[i].uid==data.uid then
|
if PLY_NET[i].uid==data.uid then
|
||||||
PLY_NET[i].conf=data.config
|
PLY_NET[i].conf=data.config
|
||||||
@@ -173,7 +173,7 @@ function scene.socketRead(cmd,data)
|
|||||||
resetGameData("qn")
|
resetGameData("qn")
|
||||||
end
|
end
|
||||||
elseif cmd=="Ready"then
|
elseif cmd=="Ready"then
|
||||||
if data.uid==USER.id then
|
if data.uid==USER.uid then
|
||||||
PLAYERS[1].ready=true
|
PLAYERS[1].ready=true
|
||||||
SFX.play("reach",.6)
|
SFX.play("reach",.6)
|
||||||
else
|
else
|
||||||
@@ -205,7 +205,7 @@ function scene.socketRead(cmd,data)
|
|||||||
elseif cmd=="Die"then
|
elseif cmd=="Die"then
|
||||||
LOG.print("One player failed",COLOR.sky)
|
LOG.print("One player failed",COLOR.sky)
|
||||||
elseif cmd=="Stream"then
|
elseif cmd=="Stream"then
|
||||||
if data.uid==USER.id then
|
if data.uid==USER.uid then
|
||||||
LOG.print("SELF STREAM")
|
LOG.print("SELF STREAM")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user