66 lines
1.6 KiB
Plaintext
66 lines
1.6 KiB
Plaintext
|
LuaDistributesMatrixInfo = {}
|
||
|
|
||
|
LuaDistributesMatrixInfo.sysID = 0
|
||
|
LuaDistributesMatrixInfo.cmdID = 0
|
||
|
|
||
|
function LuaDistributesMatrixInfo.ExtraPacket(memStream)
|
||
|
-- print('ExtraPacket:'..memStream.Length)
|
||
|
|
||
|
local binaryReader = CS.BinaryMessageHandle.GetLuaPacketReader(memStream)
|
||
|
local sysID = binaryReader:ReadByte()
|
||
|
local cmdID = binaryReader:ReadByte()
|
||
|
packet = LuaDistributesMatrixInfo.ReadPacket(binaryReader)
|
||
|
|
||
|
return packet
|
||
|
end
|
||
|
|
||
|
function LuaDistributesMatrixInfo.SendPacket(packet)
|
||
|
local message = CS.BinaryMessageHandle.CreateMessage(LuaDistributesMatrixInfo.sysID, LuaDistributesMatrixInfo.cmdID)
|
||
|
if(packet['id'] == nil) then
|
||
|
packet['id'] = 0
|
||
|
end
|
||
|
message:WriteInt(packet['id'])
|
||
|
|
||
|
if(packet['facility'] == nil) then
|
||
|
packet['facility'] = 0
|
||
|
end
|
||
|
message:WriteInt(packet['facility'])
|
||
|
|
||
|
if(packet['level'] == nil) then
|
||
|
packet['level'] = 0
|
||
|
end
|
||
|
message:WriteInt(packet['level'])
|
||
|
|
||
|
if(battleGenerals == nil) then
|
||
|
battleGenerals = {}
|
||
|
end
|
||
|
message:WriteInt(#packet['battleGenerals'])
|
||
|
for k,v in ipairs(packet['battleGenerals']) do
|
||
|
require "LuaDistributesMatrixGeneral"
|
||
|
LuaDistributesMatrixGeneral.WritePacket(v, binaryWriter)
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
message:Send()
|
||
|
end
|
||
|
|
||
|
function LuaDistributesMatrixInfo.ReadPacket(binaryReader)
|
||
|
|
||
|
local packet = {}
|
||
|
packet['id'] = binaryReader:ReadInt32()
|
||
|
|
||
|
packet['facility'] = binaryReader:ReadInt32()
|
||
|
|
||
|
packet['level'] = binaryReader:ReadInt32()
|
||
|
|
||
|
packet['battleGenerals'] = {}
|
||
|
local battleGeneralsCnt = binaryReader:ReadInt32()
|
||
|
for i=1,battleGeneralsCnt,1 do
|
||
|
require "LuaDistributesMatrixGeneral"
|
||
|
packet['battleGenerals'][i] = LuaDistributesMatrixGeneral.ReadPacket(binaryReader)
|
||
|
|
||
|
end
|
||
|
|
||
|
return packet
|
||
|
end
|