Quote from: Blizzard on March 16, 2011, 03:36:31 am
You're wrong. We will also have to store other objects (such as a Game_Map containing Game_Events, Game_Events containing Game_EventCommands, etc.). A dictionary based format would be universal but also the hardest to implement.
I'm saying that we could abstract those objects to messages with arbitrary names containing raw data like numbers, strings, arrays, and hashes.
messages would be able to reference other messages in the file though
here's what I'm thinking.
you open a file and read the first 4 bytes. this long value is the ID of the first message in the file the next byte read is a type identifier 0-255 (I can't see us needing more that 255 types.)
for the purposes of this explanation lets say that a value of 1 indicates an integer, 2 a floating point number, 3 a string, 4 an array, 5 a hash, 6 an object, and 7 a reference to.
lets say the second byte read had a value of 6. the loader would then read the next 4 bytes to get a long value that was the length in bytes of the string that was the name of the message. it would then read that many bytes to get the name of the message.
the loader would then pass the io stream to a handler that is registered for that message name. the handler would read outs it's data and return the object it created from it. the loader would read the next byte after the message handler had returned assuming that the byte indicated an end to the current message which would be indicated by a value of 255 if it isn't 255 the loader know something went wrong. it would then read the next 4 bytes as the ID of the next message. and it would continue until it had read all the messages in the file. the las message should be the top level object the was dumped and would be returned as such.
this operates in a similar fashion to how my RMPY format works in that any object referenced in the currently read message should have been stated previously in the file. it requires that a handler be written for the dumping and loading of each user defined object you want to load and dump but it ends up being extremely portable
I don't see any problems that could arise. of course, I'm not a professorial so feel free to correct me I'll take it as a learning experience.