80 lines
1.8 KiB
Plaintext
80 lines
1.8 KiB
Plaintext
LuaDistributesValhallaGeneral = {}
|
|
|
|
LuaDistributesValhallaGeneral.sysID = 0
|
|
LuaDistributesValhallaGeneral.cmdID = 0
|
|
|
|
function LuaDistributesValhallaGeneral.ExtraPacket(memStream)
|
|
-- print('ExtraPacket:'..memStream.Length)
|
|
|
|
local binaryReader = CS.BinaryMessageHandle.GetLuaPacketReader(memStream)
|
|
local sysID = binaryReader:ReadByte()
|
|
local cmdID = binaryReader:ReadByte()
|
|
packet = LuaDistributesValhallaGeneral.ReadPacket(binaryReader)
|
|
|
|
return packet
|
|
end
|
|
|
|
function LuaDistributesValhallaGeneral.SendPacket(packet)
|
|
local message = CS.BinaryMessageHandle.CreateMessage(LuaDistributesValhallaGeneral.sysID, LuaDistributesValhallaGeneral.cmdID)
|
|
if(packet['guid'] == nil) then
|
|
packet['guid'] = 0
|
|
end
|
|
message:WriteLong(packet['guid'])
|
|
|
|
if(packet['id'] == nil) then
|
|
packet['id'] = 0
|
|
end
|
|
message:WriteInt(packet['id'])
|
|
|
|
if(packet['level'] == nil) then
|
|
packet['level'] = 0
|
|
end
|
|
message:WriteInt(packet['level'])
|
|
|
|
if(packet['exp'] == nil) then
|
|
packet['exp'] = 0
|
|
end
|
|
message:WriteInt(packet['exp'])
|
|
|
|
if(packet['star'] == nil) then
|
|
packet['star'] = 0
|
|
end
|
|
message:WriteInt(packet['star'])
|
|
|
|
if(equips == nil) then
|
|
equips = {}
|
|
end
|
|
message:WriteInt(#packet['equips'])
|
|
for k,v in ipairs(packet['equips']) do
|
|
require "LuaDistributesGeneralEquip"
|
|
LuaDistributesGeneralEquip.WritePacket(v, binaryWriter)
|
|
|
|
end
|
|
|
|
|
|
message:Send()
|
|
end
|
|
|
|
function LuaDistributesValhallaGeneral.ReadPacket(binaryReader)
|
|
|
|
local packet = {}
|
|
packet['guid'] = binaryReader:ReadInt64()
|
|
|
|
packet['id'] = binaryReader:ReadInt32()
|
|
|
|
packet['level'] = binaryReader:ReadInt32()
|
|
|
|
packet['exp'] = binaryReader:ReadInt32()
|
|
|
|
packet['star'] = binaryReader:ReadInt32()
|
|
|
|
packet['equips'] = {}
|
|
local equipsCnt = binaryReader:ReadInt32()
|
|
for i=1,equipsCnt,1 do
|
|
require "LuaDistributesGeneralEquip"
|
|
packet['equips'][i] = LuaDistributesGeneralEquip.ReadPacket(binaryReader)
|
|
|
|
end
|
|
|
|
return packet
|
|
end |