[DM-dev] cool idea for an extendible file format
Brought to you by:
acdalton,
henningsen
From: Stephan B. <st...@wa...> - 2001-09-07 00:30:45
|
Pete, I think I just had one of the most brilliant ideas I've ever had... I just completely solved all problems regarding file parsing and how to get the data to the dungeon in not only a simple way, but an extendable and easily maintanably way. I can't write the code here because I don't know the syntax for function pointers (and too tired to look it up), but it'd go like this: Create a map with string keys and function pointer values. The functions must match this signature: void funcname( string input_data, DMGrid *grid ); input_data == the string information parsed from the saved data. It is sent to the object in it's raw, unparsed format (only the value, not the key). This allows the registered function to do whatever it wants to. This makes the file format extremely extendable: 1) register and write your function. 2) add function to pointer map. 3) add lines like this in your input files: mynewtypeofdungeonobject=custom|parsing|is|possible The callback function sends the parsed data, and a grid to render the object to. Generic rendering support is already in DungeonElement, so can be re-used by these callbacks. got that? ----- st...@wa... http://qub.sourceforge.net - http://gwm.rootonfire.org http://byoo.rootonfire.org - http://dungeonmaker.sourceforge.net "Now I'm not normally the kind of person who likes to trespass, but sometimes you just find yourself over the line." -- Bob Dylan |