diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 33c83b19..38e16886 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -715,7 +715,7 @@ do--function resetGameData(args) end return S end - function resetGameData(args,playerData,seed) + function resetGameData(args,seed) if not args then args=""end if PLAYERS[1]and not GAME.replaying and(GAME.frame>400 or GAME.result)then mergeStat(STAT,PLAYERS[1].stat) @@ -744,7 +744,7 @@ do--function resetGameData(args) end destroyPlayers() - GAME.curMode.load(playerData) + GAME.curMode.load() initPlayerPosition(args:find("q")) restoreVirtualkey() if GAME.modeEnv.task then diff --git a/parts/globalTables.lua b/parts/globalTables.lua index d26a094a..9a8e96b9 100644 --- a/parts/globalTables.lua +++ b/parts/globalTables.lua @@ -144,6 +144,7 @@ end --Game tables PLAYERS={}--Players data PLY_ALIVE={} +PLY_NET={} FIELD={}--Field(s) for custom game BAG={}--Sequence for custom game MISSION={}--Clearing mission for custom game diff --git a/parts/modes/netBattle.lua b/parts/modes/netBattle.lua index aaadc2e8..c290f52e 100644 --- a/parts/modes/netBattle.lua +++ b/parts/modes/netBattle.lua @@ -5,14 +5,14 @@ return{ freshLimit=15, noMod=true, }, - load=function(playerData) + load=function() PLY.newPlayer(1) local N=2 - for i=1,#playerData do - if playerData[i].id==tostring(USER.id)then - PLAYERS[1].subID=playerData[1].sid + for i=1,#PLY_NET do + if PLY_NET[i].id==tostring(USER.id)then + PLAYERS[1].subID=PLY_NET[1].sid else - PLY.newRemotePlayer(N,false,playerData[i]) + PLY.newRemotePlayer(N,false,PLY_NET[i]) N=N+1 end end diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index 65b9de34..35114f30 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -2,7 +2,6 @@ local data=love.data local gc=love.graphics local tc=love.touch -local playerData local ins,rem=table.insert,table.remove local SCR=SCR @@ -11,6 +10,8 @@ local onVirtualkey=onVirtualkey local pressVirtualkey=pressVirtualkey local updateVirtualkey=updateVirtualkey +local PLY_NET=PLY_NET + local hideChatBox local textBox=WIDGET.newTextBox{name="texts",x=340,y=80,w=600,h=550,hide=function()return hideChatBox end} local function switchChat() @@ -39,8 +40,8 @@ function scene.sceneInit() playerInitialized=false textBox:clear() - playerData={} - resetGameData("n",playerData) + while #PLY_NET>0 do rem(PLY_NET)end + resetGameData("n") noTouch=not SETTING.VKSwitch playing=false lastUpstreamTime=0 @@ -160,12 +161,12 @@ function scene.socketRead(mes) end for i=1,#args do 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 playerInitialized=true SFX.play("click") if not playing then - resetGameData("qn",playerData) + resetGameData("qn") end elseif cmd=="L"then textBox:push{ @@ -173,9 +174,9 @@ function scene.socketRead(mes) COLOR.dY,"#"..args[2].." ", COLOR.Y,text.leaveRoom, } - for i=1,#playerData do - if playerData[i].id==args[2]then - rem(playerData,i) + for i=1,#PLY_NET do + if PLY_NET[i].id==args[2]then + rem(PLY_NET,i) break end end @@ -202,14 +203,14 @@ function scene.socketRead(mes) } elseif cmd=="C"then if tostring(USER.id)~=args[2]then - for i=1,#playerData do - if playerData[i].id==args[2]then - playerData[i].conf=args[4] - playerData[i].p:setConf(args[4]) + for i=1,#PLY_NET do + if PLY_NET[i].id==args[2]then + PLY_NET[i].conf=args[4] + PLY_NET[i].p:setConf(args[4]) return end end - resetGameData("qn",playerData) + resetGameData("qn") end elseif cmd=="S"then if playing and args[1]~=PLAYERS[1].subID then @@ -238,16 +239,16 @@ function scene.socketRead(mes) playing=true lastUpstreamTime=0 upstreamProgress=1 - resetGameData("n",playerData,tonumber(args[1])) + resetGameData("n",tonumber(args[1])) else LOG.print("Redundant signal: B(begin)",30,COLOR.green) end elseif cmd=="F"then playing=false - resetGameData("n",playerData) - for i=1,#playerData do - if playerData[i].sid==args[1]then - TEXT.show(text.champion:gsub("$1",playerData[i].name.."#"..playerData[i].id),640,260,80,"zoomout",.26) + resetGameData("n") + for i=1,#PLY_NET do + if PLY_NET[i].sid==args[1]then + TEXT.show(text.champion:gsub("$1",PLY_NET[i].name.."#"..PLY_NET[i].id),640,260,80,"zoomout",.26) break end end