It seems to be reproducible for me, I'm not sure if any else has or is 
encountering this problem however. I just got done creating a new message 
and I encountered this same problem again. It only seems to be a problem 
over on the c++ side.

message CreateNetObject {
>   string pid = 1;
>   string spid = 2;
>   enum Type {
>     UNKNOWN = 0;
>     PLAYER_PROJECTILE = 1;
>   }
>   Type type = 3;
>   float xloc  = 4;
>   float yloc  = 5;
>   sint32 zrot  = 6;
> }


The strings overwrite each other when placing data into their associated 
set_pid or set_spid fields.

On Monday, October 10, 2016 at 12:06:35 PM UTC-7, Adam Cozzette wrote:
>
> Is it possible that you renumbered some field numbers in your .proto file 
> and so the code that serialized the message and the code that subsequently 
> parsed it disagree on the field numbers? Or can you reproduce it within a 
> single process without serialization and deserialization?
>
> On Sat, Oct 8, 2016 at 12:37 AM, Chazix <[email protected] <javascript:>> 
> wrote:
>
>> Changing to use a repeated field for my strings seems to have fixed the 
>> problem.
>>
>>     message Connected {
>>>       sint32 xloc = 1; // x spawn world position
>>>       sint32 yloc = 2; // y spawn world position
>>>       sint32 zrot = 3; // z spawn rotation
>>>       // [0] => username
>>>       // [1] => userid
>>>       // [2] => shipcolor
>>>       // [3] => shipname
>>>       repeated string userinfo = 4;
>>>     }
>>>
>>
>> With this I am able to manually add the new strings to the repeated 
>> string list.
>>
>>     server::player::Connected connectMessage;
>>>     connectMessage.set_xloc(stats.m_xPos);
>>>     connectMessage.set_yloc(stats.m_yPos);
>>>     connectMessage.set_zrot(stats.m_zRot);
>>>     // [0] => username
>>>     connectMessage.add_userinfo();
>>>     connectMessage.set_userinfo(0, stats.m_clientName);
>>>     // [1] => userid
>>>     connectMessage.add_userinfo();
>>>     connectMessage.set_userinfo(1, stats.m_clientId);
>>>     // [2] => shipcolor
>>>     connectMessage.add_userinfo();
>>>     connectMessage.set_userinfo(2, stats.m_shipColor);
>>>     // [3] => shipname
>>>     connectMessage.add_userinfo();
>>>     connectMessage.set_userinfo(3, stats.m_shipName);
>>>
>>
>> It definitely allows for a cleaner .proto file, but it's strange that 
>> just using individual strings was causing a problem.
>>
>>
>> On Friday, October 7, 2016 at 2:56:14 PM UTC-7, Chazix wrote:
>>>
>>> Hello,
>>>
>>> I have a message that looks like:
>>>
>>> message Connected {
>>>>   sint32 xloc   = 1; // x spawn world position
>>>>   sint32 yloc   = 2; // y spawn world position
>>>>   sint32 zrot   = 3; // z spawn rotation
>>>>   string sector = 4; // sector name (unsure about this)
>>>>   string name   = 5; // player name
>>>>   string pid    = 6; // player id
>>>>   string scolor = 7; // ship color
>>>>   string sname  = 8; // ship name
>>>> }
>>>
>>>
>>> I am attempting to initialize it within my c++ code like this:
>>>
>>>>
>>>> GameClientStats& stats = gameClient.GetGameClientStats();
>>>> server::player::Connected connectMessage; // send this to this joining 
>>>> client
>>>> connectMessage.set_name(stats.m_clientName);
>>>> connectMessage.set_pid(stats.m_clientId);
>>>> connectMessage.set_scolor(stats.m_shipColor);
>>>> connectMessage.set_sname(stats.m_shipName);
>>>> connectMessage.set_xloc(stats.m_xPos);
>>>> connectMessage.set_yloc(stats.m_yPos);
>>>> connectMessage.set_zrot(stats.m_zRot);
>>>
>>>
>>> For some reason as I set my string parameters, the prior strings before 
>>> it gets set to that string value. So, if I do the set_pid the name field 
>>> will also change to the pid. set_scolor the name & pid will be set to the 
>>> s_color. set_sname the name, pid & scolor will change to be the sname. It 
>>> seems like they are all sharing the same string pointer field location.
>>>
>>> Am I not initializing my message correctly? Or do I need to do something 
>>> differently here? When I Serialize my messages from a coded stream I get my 
>>> expected message, but manual creation doesn't seem to be working with what 
>>> I'm currently trying to do.
>>>
>>> Thank you very much for the information.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to