pbc icon indicating copy to clipboard operation
pbc copied to clipboard

关于Message repeated int32 int64的数据解析错误问题

Open hina90 opened this issue 7 years ago • 1 comments

在使用xlua+pbc的过程中遇到一个问题: message ActorData { uint64 ActorId = 1; repeated int64 PropertyValues = 2; repeated int32 PropertyRates = 3; repeated uint32 SkillIds = 4; } 嵌套message中的 repeated int64 和 int32类型的值数组解析出来的数据解析会不正确,比如PropertyValues ,PropertyRates ,SkillIds 服务器传过来的是三个值的数据,但lua-pbc解析出来的table只有一个值,而且这个值也不正确。例如:服务器数据 PropertyValues = 1 , lua-pbc解析出来的数据是{1=12321}
有遇到过相同问题解决过的吗?

hina90 avatar Apr 12 '18 07:04 hina90

proto 3 的确有这个问题,可以通过加packed选项来解决,如

message ActorData
{
    uint64 ActorId = 1;
    repeated int64 PropertyValues = 2 [packed = true];
    repeated int32 PropertyRates = 3 [packed = true];
    repeated uint32 SkillIds = 4 [packed = true];
}

wond4 avatar Nov 14 '18 10:11 wond4