MMO Journey: Week 10 (binary message hell)

I managed to get the client into the world, and in the process ended up re-writing basically all of the game message classes.  I was doing some horrible things previously, storing the message data as binary byte(C#)/char(C++) arrays and reading/writing directly from those arrays when accessing pieces of the message data.

It slowly became obvious that this was a horribly wrong thing to do, and after some research I realized this problem could be solved perfectly by using structs for the message data.  Once I added a struct in each message class to represent the raw data, that data became was very well defined and could be loaded in/out of the struct as needed using memcpy (C++) or marshaling (C#).  This also had a nice side effect of causing all the message data to be properly aligned, which wasn't happening previously (using raw byte/char arrays).

This was a short update, but since I settled on that solution and am moving on to getting two clients connected and rendering each other I figured it was worth a post.

Current code stats (counted using CLOC):

component       blank     comment     code
--------------------------------------------
------
client (C#)     266       155         1073 (+196)
server (C++)    141       47          561  (+126)
web (Ruby/CSS)  122       57          529  (+8)
--------------------------------------------------
Total           529       259         2163 (+330)

Previous entry
Next entry

Comments