How to read a signed integer from ByteArray

Post here your questions about the C++ API for SFS2X

Moderators: Lapo, Bax, MBagnati

Post Reply
meodemsao
Posts: 3
Joined: 30 May 2017, 07:44

How to read a signed integer from ByteArray

Post by meodemsao »

Hi all,

I have problem while reading a signed integer from server. In the SFS2X C++, the function "boost::shared_ptr <ByteArray> btrd->ReadInt" is always return a positive value.

Hope everyone to help for me to solve this problem

Thank in advanced!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to read a signed integer from ByteArray

Post by Lapo »

Hello,
I was able to reproduce the problem. There seem to be an issue with type conversion.
We're working on releasing a patch soon.

Stay tuned.
Lapo
--
gotoAndPlay()
...addicted to flash games
meodemsao
Posts: 3
Joined: 30 May 2017, 07:44

Re: How to read a signed integer from ByteArray

Post by meodemsao »

After some testcase, the function ReadInt only has problem with 64-bit arch. In the 32-bit arch, it's work well
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to read a signed integer from ByteArray

Post by Lapo »

Yes, it's due to the variability of type sizes such as int / long int etc... which on 32bit platforms use 4 bytes and on 64bit systems use 8 bytes.

I'll report back when it's fixed.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to read a signed integer from ByteArray

Post by Lapo »

UPDATE:
we have fixed the problem and should be able to publish a new update on Monday (tomorrow is national holiday over here).

I will post the link here when it's online.
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to read a signed integer from ByteArray

Post by Lapo »

UPDATE 2:
We have released an update of the API that fixes this issue:
http://smartfoxserver.com/download/sfs2x#p=client

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
meodemsao
Posts: 3
Joined: 30 May 2017, 07:44

Re: How to read a signed integer from ByteArray

Post by meodemsao »

Bravo

Thank in advanced
Post Reply