realXtend / tundra

realXtend Tundra SDK, a 3D virtual world application platform.
www.realxtend.org
Apache License 2.0
84 stars 70 forks source link

Make our string Attributes accept longer values than 255 chars correctly #731

Open jonnenauha opened 10 years ago

jonnenauha commented 10 years ago

For AssetReference 255 might be enough but when you push custom data strings to EC_DynamicComponent as eg. QVariantList and its longer than 255 chars it will break the client parsing of this data.

Attribute String type uses QString under the hood which now has max length of u16 and send the data at UTF8. AssetReference, AssetReferenceList, QVariant and QVariantList uses the kNet DataSerializer::AddString which makes the lenght u8. However this is not checked in any way once the lenght is inserted into the data, even if its longer the whole data is pushed after it.

Either we should cap the string pushed after the lenght to 255 or we should change all these string types to use u16 lenght and preferably also UTF8.

I think swapping this thing under the hood will actually not break anything if the server and the client are on the same version. Old clients connecting to new servers (or new clients to old servers) of course will break completely.

I suggest that we swap out the string versioning at some major release. Currently this is problematic only for scripts that add long data strings with the mentioned types to EC_DynamicComponent. But once someone gets over 255 chars on asset references it will break a whole lot more than that.

jonnenauha commented 10 years ago

As noted by @cadaver VLE should preferably be used for all string types. Currently its not used for any. EntityActions have VLE but that is a separate thing.