net_game场景的playerData变量改为全局PLY_NET

This commit is contained in:
MrZ626
2021-04-03 00:47:23 +08:00
parent 2f2e4f389f
commit 7286d4ffe0
4 changed files with 27 additions and 25 deletions

View File

@@ -715,7 +715,7 @@ do--function resetGameData(args)
end end
return S return S
end end
function resetGameData(args,playerData,seed) function resetGameData(args,seed)
if not args then args=""end if not args then args=""end
if PLAYERS[1]and not GAME.replaying and(GAME.frame>400 or GAME.result)then if PLAYERS[1]and not GAME.replaying and(GAME.frame>400 or GAME.result)then
mergeStat(STAT,PLAYERS[1].stat) mergeStat(STAT,PLAYERS[1].stat)
@@ -744,7 +744,7 @@ do--function resetGameData(args)
end end
destroyPlayers() destroyPlayers()
GAME.curMode.load(playerData) GAME.curMode.load()
initPlayerPosition(args:find("q")) initPlayerPosition(args:find("q"))
restoreVirtualkey() restoreVirtualkey()
if GAME.modeEnv.task then if GAME.modeEnv.task then

View File

@@ -144,6 +144,7 @@ end
--Game tables --Game tables
PLAYERS={}--Players data PLAYERS={}--Players data
PLY_ALIVE={} PLY_ALIVE={}
PLY_NET={}
FIELD={}--Field(s) for custom game FIELD={}--Field(s) for custom game
BAG={}--Sequence for custom game BAG={}--Sequence for custom game
MISSION={}--Clearing mission for custom game MISSION={}--Clearing mission for custom game

View File

@@ -5,14 +5,14 @@ return{
freshLimit=15, freshLimit=15,
noMod=true, noMod=true,
}, },
load=function(playerData) load=function()
PLY.newPlayer(1) PLY.newPlayer(1)
local N=2 local N=2
for i=1,#playerData do for i=1,#PLY_NET do
if playerData[i].id==tostring(USER.id)then if PLY_NET[i].id==tostring(USER.id)then
PLAYERS[1].subID=playerData[1].sid PLAYERS[1].subID=PLY_NET[1].sid
else else
PLY.newRemotePlayer(N,false,playerData[i]) PLY.newRemotePlayer(N,false,PLY_NET[i])
N=N+1 N=N+1
end end
end end

View File

@@ -2,7 +2,6 @@ local data=love.data
local gc=love.graphics local gc=love.graphics
local tc=love.touch local tc=love.touch
local playerData
local ins,rem=table.insert,table.remove local ins,rem=table.insert,table.remove
local SCR=SCR local SCR=SCR
@@ -11,6 +10,8 @@ local onVirtualkey=onVirtualkey
local pressVirtualkey=pressVirtualkey local pressVirtualkey=pressVirtualkey
local updateVirtualkey=updateVirtualkey local updateVirtualkey=updateVirtualkey
local PLY_NET=PLY_NET
local hideChatBox local hideChatBox
local textBox=WIDGET.newTextBox{name="texts",x=340,y=80,w=600,h=550,hide=function()return hideChatBox end} local textBox=WIDGET.newTextBox{name="texts",x=340,y=80,w=600,h=550,hide=function()return hideChatBox end}
local function switchChat() local function switchChat()
@@ -39,8 +40,8 @@ function scene.sceneInit()
playerInitialized=false playerInitialized=false
textBox:clear() textBox:clear()
playerData={} while #PLY_NET>0 do rem(PLY_NET)end
resetGameData("n",playerData) resetGameData("n")
noTouch=not SETTING.VKSwitch noTouch=not SETTING.VKSwitch
playing=false playing=false
lastUpstreamTime=0 lastUpstreamTime=0
@@ -160,12 +161,12 @@ function scene.socketRead(mes)
end end
for i=1,#args do for i=1,#args do
local L=SPLITSTR(args[i],",") local L=SPLITSTR(args[i],",")
ins(playerData,{name=L[1],id=L[2],sid=L[3],conf=L[4],ready=L[5]=="1"}) ins(PLY_NET,{name=L[1],id=L[2],sid=L[3],conf=L[4],ready=L[5]=="1"})
end end
playerInitialized=true playerInitialized=true
SFX.play("click") SFX.play("click")
if not playing then if not playing then
resetGameData("qn",playerData) resetGameData("qn")
end end
elseif cmd=="L"then elseif cmd=="L"then
textBox:push{ textBox:push{
@@ -173,9 +174,9 @@ function scene.socketRead(mes)
COLOR.dY,"#"..args[2].." ", COLOR.dY,"#"..args[2].." ",
COLOR.Y,text.leaveRoom, COLOR.Y,text.leaveRoom,
} }
for i=1,#playerData do for i=1,#PLY_NET do
if playerData[i].id==args[2]then if PLY_NET[i].id==args[2]then
rem(playerData,i) rem(PLY_NET,i)
break break
end end
end end
@@ -202,14 +203,14 @@ function scene.socketRead(mes)
} }
elseif cmd=="C"then elseif cmd=="C"then
if tostring(USER.id)~=args[2]then if tostring(USER.id)~=args[2]then
for i=1,#playerData do for i=1,#PLY_NET do
if playerData[i].id==args[2]then if PLY_NET[i].id==args[2]then
playerData[i].conf=args[4] PLY_NET[i].conf=args[4]
playerData[i].p:setConf(args[4]) PLY_NET[i].p:setConf(args[4])
return return
end end
end end
resetGameData("qn",playerData) resetGameData("qn")
end end
elseif cmd=="S"then elseif cmd=="S"then
if playing and args[1]~=PLAYERS[1].subID then if playing and args[1]~=PLAYERS[1].subID then
@@ -238,16 +239,16 @@ function scene.socketRead(mes)
playing=true playing=true
lastUpstreamTime=0 lastUpstreamTime=0
upstreamProgress=1 upstreamProgress=1
resetGameData("n",playerData,tonumber(args[1])) resetGameData("n",tonumber(args[1]))
else else
LOG.print("Redundant signal: B(begin)",30,COLOR.green) LOG.print("Redundant signal: B(begin)",30,COLOR.green)
end end
elseif cmd=="F"then elseif cmd=="F"then
playing=false playing=false
resetGameData("n",playerData) resetGameData("n")
for i=1,#playerData do for i=1,#PLY_NET do
if playerData[i].sid==args[1]then if PLY_NET[i].sid==args[1]then
TEXT.show(text.champion:gsub("$1",playerData[i].name.."#"..playerData[i].id),640,260,80,"zoomout",.26) TEXT.show(text.champion:gsub("$1",PLY_NET[i].name.."#"..PLY_NET[i].id),640,260,80,"zoomout",.26)
break break
end end
end end