cloudwu / pbc

A protocol buffers library for C
MIT License
1.62k stars 568 forks source link

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

Open hina90 opened 6 years ago

hina90 commented 6 years ago

在使用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}
有遇到过相同问题解决过的吗?

wond4 commented 5 years ago

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];
}