How to read a signed integer from ByteArray

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

Moderators: Lapo, Bax, MBagnati

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

How to read a signed integer from ByteArray

Postby meodemsao » 30 May 2017, 07:52

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: 20217
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to read a signed integer from ByteArray

Postby Lapo » 30 May 2017, 10:33

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

Postby meodemsao » 30 May 2017, 12:01

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: 20217
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to read a signed integer from ByteArray

Postby Lapo » 30 May 2017, 14:50

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: 20217
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to read a signed integer from ByteArray

Postby Lapo » 01 Jun 2017, 16:01

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: 20217
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to read a signed integer from ByteArray

Postby Lapo » 06 Jun 2017, 07:25

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

Postby meodemsao » 11 Jul 2017, 16:57

Bravo

Thank in advanced

Return to “SFS2X C++ API”

Who is online

Users browsing this forum: No registered users and 2 guests