Exception GetDouble when number has no decimals (Unity C#)

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Tatanan
Posts: 112
Joined: 07 Jan 2014, 12:12
Contact:

Exception GetDouble when number has no decimals (Unity C#)

Postby Tatanan » 27 Nov 2016, 11:14

Hi,

InvalidCastException: Cannot cast from source type to destination type. is been thrown when try to get a double when it have no decimals.

This is an example sequence:
1-> A sends an ExtensionRequest. action.PutDouble(0.0,"x");
2-> Extension (server side) gets the action and sends it to B. trace( action.getDouble("x")) -> 0.0
3 -> B receives the action but when tries to get "x" value from it, the exception is thrown. If I Debug the action this is what I get:
3.1 -> Debug.Log (action.GetData("x").Data) -> 0
3.2 -> Debug.Log (action.GetData("x").Data.GetType()) -> System.Int32

If x value is 0.3 [ action.PutDouble(0.3,"x")] , it works fine.

This issue happens on server version 2.12.0 and C# client API version 1.7.0.

Thanks
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Exception GetDouble when number has no decimals (Unity C#)

Postby Lapo » 28 Nov 2016, 15:01

Thanks for reporting. Oddly enough we could not replicate the issue in our dev environment but we could with an SFS2X 2.12 from the website.

Not sure what is it about. Still investigating.

Stay tuned.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Exception GetDouble when number has no decimals (Unity C#)

Postby Lapo » 28 Nov 2016, 16:44

UPDATE: found the issue.
There seem to be a different json library in the release than that we use in dev. However they have the same exact same name, which left us puzzled. In any case testing the two it is definitely the cause of the problem.

Please download the correct library from here and replace the same file under SFS2X/lib/. Then restart the server and test again.

Let us know.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Exception GetDouble when number has no decimals (Unity C#)

Postby Lapo » 05 Dec 2016, 09:07

Any news?
Did you try the provided jar file?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Tatanan
Posts: 112
Joined: 07 Jan 2014, 12:12
Contact:

Re: Exception GetDouble when number has no decimals (Unity C#)

Postby Tatanan » 06 Dec 2016, 10:43

It seems that works.
I highly recommend release patch as soon as possible.

Thanks
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Exception GetDouble when number has no decimals (Unity C#)

Postby Lapo » 06 Dec 2016, 11:30

Thanks for the feedback. The patch will be out later today.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 20 guests