From ececb31307204b471bac462feecf14b8bbd01cb8 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 11 Feb 2021 16:19:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E5=B9=BD?= =?UTF-8?q?=E7=81=B5=E7=8E=A9=E5=AE=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/modes/netBattle.lua | 13 ++++++++----- parts/scenes/net_game.lua | 7 +------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/parts/modes/netBattle.lua b/parts/modes/netBattle.lua index 117ae853..400d9b9d 100644 --- a/parts/modes/netBattle.lua +++ b/parts/modes/netBattle.lua @@ -5,11 +5,14 @@ return{ }, load=function(playerData) PLY.newPlayer(1) - if playerData[1]then - PLAYERS[1].subID=playerData[1].sid - end - for i=2,#playerData do - PLY.newRemotePlayer(i,false,playerData[i]) + local N=2 + for i=1,#playerData do + if playerData[i].id==tostring(USER.id)then + PLAYERS[1].subID=playerData[1].sid + else + PLY.newRemotePlayer(N,false,playerData[i]) + N=N+1 + end end end, } \ No newline at end of file diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index 65cdb028..a1999e0e 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -165,12 +165,7 @@ function scene.socketRead(mes) end for i=1,#args do local L=splitStr(args[i],",") - L={name=L[1],id=L[2],sid=L[3],conf=L[4],ready=L[5]=="1"} - if tostring(USER.id)~=L.id then - ins(playerData,L) - else - ins(playerData,1,L) - end + ins(playerData,{name=L[1],id=L[2],sid=L[3],conf=L[4],ready=L[5]=="1"}) end playerInitialized=true SFX.play("click")