Tuesday, April 3, 2012

Diary of an Indie Dev #4

Have been working for a client today.  I needed to come up with a schema that persisted how the player uses their inventory items.  I couldn't really determine how many items they might have and so I need an unlimited file system.

I came up with using a Varchar of 10000 bytes for now on the server, and the choices the user makes are put into a hash table.  When it's times to serialize the data I convert the hash table to xml and then the resultant xml to string for upload to the varchar for each player.

It reverses and when I get it back I convert to xml, iterate through the child elements and rebuild the hashtable which implemented all the users choices again when they log in later.

Here's a snippet of the xml generated [ note for NDA reasons I changed the values ].  It's extensible too.  The item child can have anything inside it, such a sound effect, or hit points if I choose to add more later, without the need to rebuild the database.  ( EDIT:  Doesn't work so well at the moment as the http POST it trying to interpret my XML - Need a way to cloak it )



   
        

   

No comments: