80 lines
1.9 KiB
Plaintext
80 lines
1.9 KiB
Plaintext
LuaDistributesAchievementNode = {}
|
|
|
|
LuaDistributesAchievementNode.sysID = 0
|
|
LuaDistributesAchievementNode.cmdID = 0
|
|
|
|
function LuaDistributesAchievementNode.ExtraPacket(memStream)
|
|
-- -- print('ExtraPacket:'..memStream.Length)
|
|
|
|
local binaryReader = CS.BinaryMessageHandle.GetLuaPacketReader(memStream)
|
|
local sysID = binaryReader:ReadByte()
|
|
local cmdID = binaryReader:ReadByte()
|
|
packet = LuaDistributesAchievementNode.ReadPacket(binaryReader)
|
|
|
|
return packet
|
|
end
|
|
|
|
function LuaDistributesAchievementNode.SendPacket(packet)
|
|
local message = CS.BinaryMessageHandle.CreateMessage(LuaDistributesAchievementNode.sysID, LuaDistributesAchievementNode.cmdID)
|
|
if(packet['nodeId'] == nil) then
|
|
packet['nodeId'] = 0
|
|
end
|
|
message:WriteInt(packet['nodeId'])
|
|
|
|
if(packet['rewardState'] == nil) then
|
|
packet['rewardState'] = 0
|
|
end
|
|
message:WriteInt(packet['rewardState'])
|
|
|
|
if(subList == nil) then
|
|
subList = {}
|
|
end
|
|
message:WriteInt(#packet['subList'])
|
|
for k,v in ipairs(packet['subList']) do
|
|
require "LuaDistributesAchievementSubNode"
|
|
LuaDistributesAchievementSubNode.WritePacket(v, binaryWriter)
|
|
|
|
end
|
|
|
|
if(packet['progress'] == nil) then
|
|
packet['progress'] = 0
|
|
end
|
|
message:WriteInt(packet['progress'])
|
|
|
|
if(packet['totalProgress'] == nil) then
|
|
packet['totalProgress'] = 0
|
|
end
|
|
message:WriteInt(packet['totalProgress'])
|
|
|
|
if(packet['redPoint'] == nil) then
|
|
packet['redPoint'] = 0
|
|
end
|
|
message:WriteInt(packet['redPoint'])
|
|
|
|
|
|
message:Send()
|
|
end
|
|
|
|
function LuaDistributesAchievementNode.ReadPacket(binaryReader)
|
|
|
|
local packet = {}
|
|
packet['nodeId'] = binaryReader:ReadInt32()
|
|
|
|
packet['rewardState'] = binaryReader:ReadInt32()
|
|
|
|
packet['subList'] = {}
|
|
local subListCnt = binaryReader:ReadInt32()
|
|
for i=1,subListCnt,1 do
|
|
require "LuaDistributesAchievementSubNode"
|
|
packet['subList'][i] = LuaDistributesAchievementSubNode.ReadPacket(binaryReader)
|
|
|
|
end
|
|
packet['progress'] = binaryReader:ReadInt32()
|
|
|
|
packet['totalProgress'] = binaryReader:ReadInt32()
|
|
|
|
packet['redPoint'] = binaryReader:ReadInt32()
|
|
|
|
|
|
return packet
|
|
end |