修改全局结构体变量USER的成员名

This commit is contained in:
MrZ626
2021-04-06 14:53:52 +08:00
parent 24e97e10c8
commit 202559211c
7 changed files with 19 additions and 19 deletions

View File

@@ -956,7 +956,7 @@ do--function saveRecording()
os.date("%Y/%m/%d %A %H:%M:%S\n")..
GAME.curModeName.."\n"..
VERSION_NAME.."\n"..
(USER.name or"Player")
(USER.username or"Player")
local fileBody=
GAME.seed.."\n"..
JSON.encode(GAME.setting).."\n"..

View File

@@ -222,8 +222,8 @@ GAME={--Global game data
RANKS=FILE.load("conf/unlock")or{sprint_10l=0}--Ranks of modes
USER=FILE.load("conf/user")or{--User infomation
--Network infos
name=false,
id=false,
username=false,
uid=false,
authToken=false,
--Local data

View File

@@ -10,7 +10,7 @@ return{
PLY.newPlayer(1)
local N=2
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
else
PLY.newRemotePlayer(N,false,PLY_NET[i])

View File

@@ -77,7 +77,7 @@ function NET.getUserInfo(id,ifDetail)
WS.send("user",JSON.encode{
action=1,
data={
id=id or USER.id,
id=id or USER.uid,
detailed=ifDetail or false,
},
})
@@ -97,8 +97,8 @@ function NET.storeUserInfo(res)
end
--Get own name
if res.id==USER.id then
USER.name=res.username
if res.id==USER.uid then
USER.username=res.username
FILE.save(USER,"conf/user")
end
@@ -124,7 +124,7 @@ function NET.createRoom()
action=1,
data={
type="classic",
name=(USER.name or"???").."'s room",
name=(USER.username or"???").."'s room",
password=nil,
config=dumpBasicConfig(),
}
@@ -149,7 +149,7 @@ end
function NET.wsConnectPlay()
if _lock("connectPlay")then
WS.connect("play","/play",JSON.encode{
id=USER.id,
id=USER.uid,
accessToken=NET.accessToken,
})
end
@@ -165,7 +165,7 @@ end
function NET.wsConnectStream()
if _lock("connectStream")then
WS.connect("stream","/stream",JSON.encode{
uid=USER.id,
uid=USER.uid,
accessToken=NET.accessToken,
rid=NET.rsid,
})
@@ -243,7 +243,7 @@ function NET.updateWS_user()
if res.type=="Connect"then
NET.login=true
if res.id then
USER.id=res.id
USER.uid=res.id
USER.authToken=res.authToken
FILE.save(USER,"conf/user","q")
SCN.back()
@@ -251,7 +251,7 @@ function NET.updateWS_user()
LOG.print(text.loginSuccessed)
--Get self infos
NET.getUserInfo(USER.id)
NET.getUserInfo(USER.uid)
elseif res.action==0 then--Get accessToken
NET.accessToken=res.accessToken
LOG.print(text.accessSuccessed)
@@ -296,8 +296,8 @@ function NET.updateWS_play()
--Create room
TABLE.clear(PLY_NET)
ins(PLY_NET,{
uid=USER.id,
name=USER.name,
uid=USER.uid,
name=USER.username,
conf=dumpBasicConfig(),
sid=data.sid,
ready=data.ready,

View File

@@ -408,7 +408,7 @@ function PLY.newPlayer(id,mini)
P.type="human"
P.sound=true
P.userID=USER.id
P.userID=USER.uid
P.subID=-1
loadGameEnv(P)

View File

@@ -183,7 +183,7 @@ local loadingThread=coroutine.wrap(function()
WS.connect("app","/app")
if USER.authToken then
WS.connect("user","/user",JSON.encode{
id=USER.id,
id=USER.uid,
authToken=USER.authToken,
})
end

View File

@@ -162,7 +162,7 @@ function scene.socketRead(cmd,data)
COLOR.sky,data.message or"[_]",
}
elseif cmd=="Config"then
if tostring(USER.id)~=data.uid then
if tostring(USER.uid)~=data.uid then
for i=1,#PLY_NET do
if PLY_NET[i].uid==data.uid then
PLY_NET[i].conf=data.config
@@ -173,7 +173,7 @@ function scene.socketRead(cmd,data)
resetGameData("qn")
end
elseif cmd=="Ready"then
if data.uid==USER.id then
if data.uid==USER.uid then
PLAYERS[1].ready=true
SFX.play("reach",.6)
else
@@ -205,7 +205,7 @@ function scene.socketRead(cmd,data)
elseif cmd=="Die"then
LOG.print("One player failed",COLOR.sky)
elseif cmd=="Stream"then
if data.uid==USER.id then
if data.uid==USER.uid then
LOG.print("SELF STREAM")
return
end