Author Topic: Improve the documentation please!  (Read 5017 times)

Dechcaudron

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Improve the documentation please!
« on: May 14, 2014, 04:32:59 PM »
Ok guys,

so I'm currently surfing the example GCC project, helping myself with the API Documentation. Developers really need something a bit more complete (something would be a good place to start). I know this isn't probably your top priority, but we need to know what everything does in the inside. I'm used to having the C# reference, as well as the UnityEngine API script reference, and well... I really hope you are working on it. Yet, I do understand what open alpha means, so I'll keep on doing my best to understand what everything is.

Keep it up!
Dechcaudron

georgi

  • Administrator
  • Newbie
  • *****
  • Posts: 4
    • View Profile
Re: Improve the documentation please!
« Reply #1 on: May 15, 2014, 10:33:52 AM »
Hi, Dechcaudron,

Thank you for taking the time to contact us and provide us with your insight for our project. Be sure that we are working on improving the quality and completeness of our documentation and as soon as we have that ready we will uploaded it. Our team is confident that our combined efforts with people like you from the community will give GCC a better technical edge.

Best regards,
GCC Team

Dechcaudron

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Improve the documentation please!
« Reply #2 on: May 21, 2014, 04:24:47 PM »
Ok guys,

So I'm having a clarity moment right now and am able to understand EVERYTHING in the engine *.* Although this is my first time working in an online game, I admit I am very impressed by the code itself. It's pure genius in my opinion. I NEED MORE. Is there a way to write/read from/to a server DB in an easy way?

You're awesome,
Dechcaudron

Dechcaudron

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Improve the documentation please!
« Reply #3 on: May 21, 2014, 10:20:46 PM »
Alright, I found out the way it goes. You keep using the SQL I used with mySQL in php a couple years ago. The real question is, how do we store complex objects in the database? Like, I suppose we must be able to store things that derive from the Object class, but how?

Thanks beforehand and sorry for the inconvenience,
Dechcaudron

Antoine

  • Global Moderator
  • Newbie
  • *****
  • Posts: 13
    • View Profile
Re: Improve the documentation please!
« Reply #4 on: May 22, 2014, 08:20:51 AM »
Hi Dechcaudron,

One of the ways you can do that is by using our SerializationManager, you don't need to include any references when using it. The object must inherit from IGameCommand, then you can call Serialize on it, write the serialized content into MemoryStream and flush the byte array in the database. Just beware that if changes are made to the object subsequently, the data stored will be broken/lost.

Other methods you can use are JSON/XML/Binary serialization, but you'll need to include references and/or third party libraries.

We are thinking of implementing JSON serialization in future, just to cope with that matter, but for the time being we recommend using the SerializationManager.
 
Happy coding,
Antoine,
The GCC Team

Dechcaudron

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Improve the documentation please!
« Reply #5 on: May 30, 2014, 12:26:50 PM »
Hi Antoine,

thanks about that. I seemed to make it work like that. How am I supposed to Deserialize with SerializationManager? I don't really understand the way it is implemented. I already have the BinaryReader with the byte array attached to its MemoryStream, but I need more info.

Thanks beforehand,
Dechcaudron

Antoine

  • Global Moderator
  • Newbie
  • *****
  • Posts: 13
    • View Profile
Re: Improve the documentation please!
« Reply #6 on: May 30, 2014, 01:34:53 PM »
Hi Dechcaudron,

Since you already have the data loaded into MemoryStream and a BinaryReader attached to it, you need to instantiate an object from your class, and then call Deserialize on that object with the BinaryReader and a short command (if it applies) as parameters:

Code: [Select]
YourIGameCommandClass someObject = new YourIGameCommandClass();
someObject.Deserialize(theBinaryReader, someShortCommand);

01100011011011110110010001100101,
Antoine,
The GCC Team
« Last Edit: May 30, 2014, 01:39:30 PM by Antoine »

Dechcaudron

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Improve the documentation please!
« Reply #7 on: June 03, 2014, 02:53:14 PM »
Hi Antoine,

I think I get it, but then I could serialize them by calling directly Serialize on the IGameCommand instead of doing it on the SerializeManager. What is the point of the methods Serialize and Deserialize in SerializeManager then?

Thanks beforehand,
Dechcaudron

AMarinov

  • Global Moderator
  • Newbie
  • *****
  • Posts: 17
    • View Profile
Re: Improve the documentation please!
« Reply #8 on: June 03, 2014, 04:31:15 PM »
Hi,

You coulld see the difference just by looking at the methods.
SerializationManager is used to serve serialization and deserialization of multiple objects. It assures that when you send an object from client, the same object and content will be received on the server, in order to achieve this it adds some additional information to the stream.
So, when you call SerializationManager.Deserialize() you will receive an instance of the object you have serialized, loaded with data.
if you deserialize using IGameCommand.Deserialize implementation of specific object, you should create it first, and then call its Deserialize() method to load it with data - and for this you must know in advance what object has been serialized, and its command code.
If that is the case, I would suggest using the second approach - use the IGameCommand methods.
Please note that our serialization logic is entirely oriented toward fast client/server communication, not on storage.
If you alter Serialize/Deserialize implementation of an object and then try to load an old version of this object from database, it will not work.
In general, I would not recommend storing complex objects in binary format unless you are absolutely sure that their structure will never be changed, or you have no problem to loose the content in case of structural change.



Dechcaudron

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Improve the documentation please!
« Reply #9 on: June 03, 2014, 04:56:05 PM »
Hey,

Sorry for being so stubborn. I do understand SerializationManager's Serialize and Deserialize methods way more generic than the ones implemented by our own IGameCommand's. What I still don't understand is, how would the SerializationManager know what kind of IGameCommand it has to call Deserialize on if we just provide it a binary reader and a context (short). It should have to know what kind of deserialization it has to perform, doesn't it?

For example, when I call SerializationManager.Serialize, we pass on to it the instance of the IGameCommand, so it can easily call the appropriate Serialize method. Deserialize just doesn't seem to take into account the kind of IGameCommand it should call Deserialize on. What am I missing?

And regarding the storage part... I understand it is way easier to manage data in complex objects if I store it in a column by primary variable. My idea is that I'll be making a voxel game pretty soon and I will need to store a frightening amount of apparently unordered variables. Storing them all as a whole would be so much easier. I though about implementing a method that would add to Deserialize, taking into account the version(float) of each IGameCommand and deserializing appropriately and converting each of them to the last version. Do you guys think that would be too much pain?

Thanks beforehand, and sorry for the trouble again,
Dechcaudron


AMarinov

  • Global Moderator
  • Newbie
  • *****
  • Posts: 17
    • View Profile
Re: Improve the documentation please!
« Reply #10 on: June 04, 2014, 08:53:39 AM »
Hi Dechcaudron,

About the SerializationManager - it can do what it does by saving additional information about the type it serializes, so when it reads it back, it first reads the type, and then creates and deserializes the according object.

As for the storage part, the idea for saving versions of the objects looks good at first sight, but it also means that you will have to implement separate serialization/deserialization logic for each next version of the object you are going to save, along with the version itself for each such object. This is an unnecessary overhead, so I would recommend you to not use the binary serialization for your case (saving complex object as a single columns in a database) . Use JSON instead, it is generic and human readable. I recommend this library:
https://fastjson.codeplex.com/   - you can get its source code and use it in your game directly.

Regards,
Atanas

Dechcaudron

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Improve the documentation please!
« Reply #11 on: June 04, 2014, 11:07:25 AM »
Hey Atanas,

I got it. Consider the SerializationManager topic closed.

And thank you for the JSON advice. It'll be my friend later today.

Best washes,
Dechcaudron