To make the whole affair easier, I am using TinyXML, which I definitely give a big . Now instead of calling LoadHeightMap(magic number 1, magic number 2, etc) from main, I simply give my heightmap c-tor a filename and have it load in all the necessary settings from an XML file. I also do this for setting up my window, and plan to in several other places as I expand on this project. Not having to recompile every time I change the starting size of the window or the distance between samples in my heightmap is a great thing.
I also restructured it a bit. Now my heightmap class resides within a more general Map class, which will hold a texture, unit info, movement squares, and the like. Took a little longer then expected, but worth it I suspect.
I've tried to set up all my XML saving and loading close to how (as I understad it) C# does things. I have an ISerializable inteface declaired thusly:
class ISerializable{public: bool Write(const std::string &filename) { return (*this) << filename; } bool Read(const std::string &filename) { return (*this) >> filename; }protected: //write (serialize) to file virtual bool operator<<(const std::string &filename) = 0; //read (deserialize) from file virtual bool operator>>(const std::string &filename) = 0;};
Now, every class I want to have load from an XML file merely has to derive from ISerializable and provide its own << and >> operators. I know some people may be mad at me for using the stream operators in an unusual way (ie, not: ostream& operator<<(ostream &, Object &obj) and the like), and I was a bit reluctant to do it at first myself, but I just like the way it looks in the end.
Don't know how much more work I'll do tonight. One of my recently graduated friends just got a job in the industry so we're throwing him a big party. It promises to be a good time. Maybe I'll tell you lucky readers about it tomorrow, if I remember any of it [wink].
Edit: Don't forget to add me to your GGE friends [grin]!