Converter Series: Reading in Titles

To convert the ownership of European territories is a little tricky. Before it can be done, the converter has to have a list of the relevant nations. Those more-or-less map to titles in CK2. So the first step is to import titles.

What’s also important about titles is the relationship among them. In CK2, characters will often be vassals of other characters. In the save file, this is represented as titles potentially having a liege. This is true even in the cases where both the vassal and the liege title are held by the same character. In effect, there’s a nice tree structure relating titles (actually, it’s a collection of trees, which is called a forest).

To create a representation of these relationships, each title will need the following data: its name, its liege (if any), and its vassals (if any). So I create a class (CK2Title) that has all those. The liege is a bit tricky, because the save file only has the name of the liege title, but we want to have access to the liege CK2Title. And until all titles are imported, we can’t be assured we can look up the CK2Title from the name. So the class stores both the liege name and a pointer to the liege CK2Title. With all the functions I can guess are relevant, the class ends up declared as

class CK2Title
{
   public:
      void     init(Object*);
      void     addLiege(CK2Title*);
      void     addVassal(CK2Title*);
      string   getTitleString();
      string   getLiegeString();
   private:
      string            titleString;
      string            liegeString;
      CK2Title*         liege;
      vector<CK2Title>  vassals;
};

CK2World is updated to identify all the titles in the save, (they all start with “e_”, “k_”, “d_”, “c_”, or “b_”, which makes this easy), create a new CK2Title for each, and save all of these titles (in a vector).

Once all the titles have been read in, relating them is easy. Just loop through all of them and get the liege name. If there isn’t one, the title is independent and thus should be related to an EU3 country. If there is one, loop through the titles until you find the one with the same name, then add it as a liege (the CK2Title adding a liege then tells the liege CK2Title “add me as a vassal).

Yes, there’s a major flaw with that process. Points to you if you can figure it out (it’s more obvious when you run the code). It’ll be addressed in a a post or two.

Next up, doing something useful with all of those titles.

 

Relevant Repository Links:
Read in titles
Create tree of vassal/liege relationships

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>