Null Values in sendXtMessage string-type

You think you've found a bug? Please report it here.

Moderators: Lapo, Bax

Post Reply
ryratt
Posts: 29
Joined: 10 Jun 2008, 00:33

Null Values in sendXtMessage string-type

Post by ryratt »

Not sure if this is considered a bug or if you all didn't want people to be able to send null values in an array, but here goes...

We made an all encompassing function to update the movement of the player on the server, we decided to use a string-type extension parameter so that it sends as little information as possible. We also decided not to have the server update the direction the character is facing if that direction hasn't changed or update the position if it is invalid (ie, an obstruction).

So we made an array. We insert the new coordinates if they have changed, in spot 0, we add the new direction coordinates if they have changed in spot 1. Sometimes 0 will be null, sometimes 1 will be null, other times they'll both be filled.

When I send the array with a null value, I get this error:

Code: Select all

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at it.gotoandplay.smartfoxserver::SmartFoxClient/sendXtMessage()[C:\Program Files\SmartFoxServerPRO_1.6.2\Flash API\Actionscript 3.0\it\gotoandplay\smartfoxserver\SmartFoxClient.as:1974]
I have edited SmartFoxClient so the line it's referring to is this:

Code: Select all

	hdr += paramObj[i].toString() + MSG_STR
So, since I put in my Null value, it can't run toString on it. I am sure I can find a workaround for what I want to do, but I just thought I'd open the discussion up.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Thanks for posting. Yes, actually null values are not supported.
Using an Array usually involves that each position in it has a certain meaning so you should always provide a value. You could establish a convention where a certain value indicates no change
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply