-
Notifications
You must be signed in to change notification settings - Fork 1k
Serialization Strategy to serialize an Array #112
Comments
Use BitStream |
Thx BigJoe. I was aware of the possibility of using bitstream, however I was attempting to use VariableDeltaSerializer to reduce the amount of data sent over the network. Using a bit stream would mean that I need to send it each time I serialize and could be costly the bigger the structure gets. |
What mean the bigger structure? |
Well let's say you have a structure that has 1000 elements. If the server adds one element to it, when the serialization function is gonna iterate on it, it's gonna call Serialize(element) 1001 times. Using a bit stream, all the 1001 elements will get written. It theses are uint64 for exemple, it is a lot of data. By using VariableDeltaSerializers, the idea is to call Serialize(element) the same way, but internally, Raknet compares the new value with the old. If it has not changed, it will only write one bit to indicate that nothing changed for that variable. It will do that 1000 times and only on the 1001 th element, it will write the full uint64. This would result in far less data to be sent over the network. |
Delta serializer working with fixed size memory area |
There is no way around that isn't? So I guess that if I want to do what I said, I need to implement my own compression strategy using bitstream. |
We have a system that recursively serialize classes where certain member variables are flagged as replicated. I don't know in advance the type of member variable. It can be a class, a float, etc. It can also be a dynamic container. The programmer that is gonna use a replicated dynamic container would be responsible for it's size. I just want to support the generic case. This is why I'm trying to figure out a way to keep using the VariableDeltaSerializer. |
Hi,
I'm currently using the VariableDeltaSerializer to serialize the variables of my class. One of them however is an array that can change size. We can remove or insert elements to it.
On the serialization side I do something like this:
serializer.Serialize(arraySize)
for (uint64 = 0; i < arraySize; ++i)
{
serializer.Serialize(myArray[i]);
}
When I keep adding elements to the array, eventually I crash in Raknet (see callstack below).
I understand that Raknet keeps internally the data of my structure to verify if the data changed since last serialize. So if I remove an element of the array, it might end up with extra data that is now unused in it's memory since I serialize less.
However, my crash occurs when I keep adding to the array (eventually)
curPage seem to contain unitialized data and doesn't seem valid.
curPage->availableStack[curPage->availableStackSize++]=memoryWithPage;
I am wondering if I'm serializing my array the proper way. I haven't seen exemples using Raknet that serialize dynamic containers.
Thx!
The text was updated successfully, but these errors were encountered: