Converter Series: A Question of Structure

Since this is where I started defining it, I should explain the overall structure of my code at this stage.

Both CK2 and EU3 data are stored in their own classes. The top level ones are called CK2World and EU3World, respectively. Each will contain pointers to appropriate classes for titles, nations, provinces, characters, and whatever else is necessary. Pointers allow me to easily establish complex relationships among all the data (at this point, I already had a notion of the complexity of relationships just among the characters: everyone needs to know who their parents, children, spouses, lieges, and vassals are. At least).

The CK2 classes will generally know how to set all their own data if you give them the correct portion of the parsed save. Part of setting that data will be creating all instances of their sub-objects, and passing the correct part of the save to that piece, which will figure out its own details. It will be a straightforward application of object-oriented programming, and the structured nature of the save file will make it easy to determine all the right classes.

The EU3 classes will be a little more complex. It many cases, handing them a pointer to the corresponding CK2 items will be enough. But other cases will involve analyzing lots of data. It’s hard to plan too much in advance. What will be clever about the EU3 classes is each knows how to output itself. Part of that will involve telling any sub-structures to output themselves. So the overall structure of the EU3 classes will be defined by the structure of the outputted save (itself constrained by what EU3 will successfully input).

At this point, I create the EU3World class and program its output() function. This function just calls a temporary function (helpfully placed in temp.h and temp.cpp) that outputs the header that makes for a minimal working save. We’ll eventually have to figure out the details of this header, as it has all kinds of id numbers, but for now there’s no need. The main() function of the converter creates an instance of the EU3World class and tells it to output itself to a save.

And testing shows that we get a working save. A very boring working save:

Relevant repository links:
Output a minimal yet functional EU3 save

Leave a Reply

XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>