联网推进39,修改对战房间进房消息
This commit is contained in:
@@ -2,7 +2,6 @@ local Player=require"parts/player/player"
|
||||
local prepareSequence=require"parts/player/prepareSequence"
|
||||
local gameEnv0=require"parts/player/gameEnv0"
|
||||
|
||||
local mt=love.math
|
||||
local rnd,max=math.random,math.max
|
||||
local ins=table.insert
|
||||
|
||||
@@ -106,7 +105,7 @@ local function newEmptyPlayer(id,mini)
|
||||
P.keyRec=true--If calculate keySpeed
|
||||
P.draw=PLY.draw.norm
|
||||
end
|
||||
P.randGen=mt.newRandomGenerator(GAME.seed)
|
||||
P.randGen=love.math.newRandomGenerator(GAME.seed)
|
||||
|
||||
P.alive=true
|
||||
P.control=false
|
||||
@@ -219,6 +218,7 @@ local function loadGameEnv(P)--Load gameEnv
|
||||
end
|
||||
end
|
||||
local function loadRemoteEnv(P,conf)--Load gameEnv
|
||||
conf=conf and json.decode(love.data.decode("string","base64",conf))or{}
|
||||
P.gameEnv={}--Current game setting environment
|
||||
local ENV=P.gameEnv
|
||||
local GAME,SETTING=GAME,SETTING
|
||||
@@ -372,7 +372,7 @@ function PLY.newRemotePlayer(id,mini,playerData)
|
||||
P.subID=playerData.sid
|
||||
P.ready=playerData.ready
|
||||
|
||||
loadRemoteEnv(P,playerData.conf or{})
|
||||
loadRemoteEnv(P,playerData.conf)
|
||||
applyGameEnv(P)
|
||||
prepareSequence(P)
|
||||
end
|
||||
|
||||
@@ -225,6 +225,7 @@ function Player.setRS(P,RSname)
|
||||
end
|
||||
|
||||
function Player.setConf(P,conf)
|
||||
conf=json.decode(love.data.decode("string","base64",conf))
|
||||
for k,v in next,conf do
|
||||
if not GAME.modeEnv[k]then
|
||||
P.gameEnv[k]=v
|
||||
@@ -339,7 +340,6 @@ function Player.ifoverlap(P,bk,x,y)
|
||||
end
|
||||
end
|
||||
function Player.attack(P,R,send,time,line,fromStream)
|
||||
print(string.format("P%d attack P%d with %d lines, %d frames, line data:%d",P.id,R.id,send,time,line))
|
||||
if GAME.net then
|
||||
if P.type=="human"then--Local player attack others
|
||||
ins(GAME.rep,GAME.frame+1)
|
||||
@@ -367,7 +367,6 @@ function Player.attack(P,R,send,time,line,fromStream)
|
||||
end
|
||||
end
|
||||
function Player.receive(P,A,send,time,line)
|
||||
print(string.format("P%d was attacked by P%d's %d lines, %d frames, line data:%d",P.id,A.id,send,time,line))
|
||||
P.lastRecv=A
|
||||
local B=P.atkBuffer
|
||||
if B.sum<26 then
|
||||
|
||||
@@ -387,7 +387,7 @@ function update.remote_alive(P,dt)
|
||||
elseif event<=64 then--Release key
|
||||
P:releaseKey(event-32)
|
||||
elseif event>0x2000000000000 then--Sending lines
|
||||
local sid=event%0x100
|
||||
local sid=tostring(event%0x100)
|
||||
local amount=int(event/0x100)%0x100
|
||||
local time=int(event/0x10000)%0x10000
|
||||
local line=int(event/0x100000000)%0x10000
|
||||
@@ -403,7 +403,7 @@ function update.remote_alive(P,dt)
|
||||
end
|
||||
elseif event>0x1000000000000 then--Receiving lines
|
||||
local L=PLAYERS.alive
|
||||
local sid=event%0x100
|
||||
local sid=tostring(event%0x100)
|
||||
for i=1,#L do
|
||||
if L[i].subID==sid then
|
||||
P:receive(
|
||||
|
||||
Reference in New Issue
Block a user