对战传输的玩家配置信息格式简化和修复一个问题(未使用所以从未触发)
This commit is contained in:
@@ -665,7 +665,7 @@ do--function dumpBasicConfig()
|
||||
"dropFX","moveFX","shakeFX",
|
||||
"text","highCam","nextPos",
|
||||
|
||||
--Not necessary graphic
|
||||
--Unnecessary graphic
|
||||
-- "grid","smooth",
|
||||
-- "lockFX","clearFX","splashFX","atkFX",
|
||||
-- "score",
|
||||
@@ -675,7 +675,7 @@ do--function dumpBasicConfig()
|
||||
for _,key in next,gameSetting do
|
||||
S[key]=SETTING[key]
|
||||
end
|
||||
return data.encode("string","base64",JSON.encode(S))
|
||||
return JSON.encode(S)
|
||||
end
|
||||
end
|
||||
do--function resetGameData(args)
|
||||
|
||||
@@ -346,7 +346,7 @@ function NET.updateWS_play()
|
||||
username=p.username,
|
||||
sid=p.sid,
|
||||
ready=p.ready,
|
||||
conf=p.config,
|
||||
config=p.config,
|
||||
})
|
||||
end
|
||||
end
|
||||
@@ -359,7 +359,7 @@ function NET.updateWS_play()
|
||||
username=d.username,
|
||||
sid=d.sid,
|
||||
ready=d.ready,
|
||||
conf=d.config,
|
||||
config=d.config,
|
||||
})
|
||||
SCN.socketRead("Join",res.data)
|
||||
end
|
||||
@@ -395,7 +395,7 @@ function NET.updateWS_play()
|
||||
if tostring(USER.uid)~=d.uid then
|
||||
for i=1,#PLY_NET do
|
||||
if PLY_NET[i].uid==d.uid then
|
||||
PLY_NET[i].conf=d.config
|
||||
PLY_NET[i].config=d.config
|
||||
PLY_NET[i].p:setConf(d.config)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -234,11 +234,9 @@ local function loadGameEnv(P)--Load gameEnv
|
||||
end
|
||||
end
|
||||
local function loadRemoteEnv(P,confStr)--Load gameEnv
|
||||
local _,conf=pcall(love.data.decode,"string","base64",confStr)
|
||||
if _ then
|
||||
conf=JSON.decode(conf)
|
||||
else
|
||||
conf={}
|
||||
confStr=JSON.decode(confStr)
|
||||
if not confStr then
|
||||
confStr={}
|
||||
LOG.print("Bad conf from "..P.username.."#"..P.uid)
|
||||
end
|
||||
|
||||
@@ -249,8 +247,8 @@ local function loadRemoteEnv(P,confStr)--Load gameEnv
|
||||
for k,v in next,gameEnv0 do
|
||||
if GAME.modeEnv[k]~=nil then
|
||||
v=GAME.modeEnv[k] --Mode setting
|
||||
elseif conf[k]~=nil then
|
||||
v=conf[k] --Game setting
|
||||
elseif confStr[k]~=nil then
|
||||
v=confStr[k] --Game setting
|
||||
elseif SETTING[k]~=nil then
|
||||
v=SETTING[k] --Global setting
|
||||
end
|
||||
@@ -385,7 +383,7 @@ function PLY.newRemotePlayer(id,mini,data)
|
||||
P.uid=data.uid
|
||||
P.username=data.username
|
||||
P.sid=data.sid
|
||||
loadRemoteEnv(P,data.conf)
|
||||
loadRemoteEnv(P,data.config)
|
||||
|
||||
applyGameEnv(P)
|
||||
end
|
||||
|
||||
@@ -214,9 +214,9 @@ function Player:setRS(RSname)
|
||||
end
|
||||
|
||||
function Player:setConf(confStr)
|
||||
local _,conf=pcall(love.data.decode,"string","base64",confStr)
|
||||
if _ then
|
||||
for k,v in next,conf do
|
||||
confStr=JSON.decode(confStr)
|
||||
if confStr then
|
||||
for k,v in next,confStr do
|
||||
if not GAME.modeEnv[k]then
|
||||
self.gameEnv[k]=v
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user