Converter Series: Converting Titles

After the last set of updates, there is a forest of CK2Titles, mapping their relationships. And there’s a vector containing all the independent ones. Time to map them to EU3 tags (tags being a three letter abbreviation identifying a country).

In mapper.h/cpp, I create a typedef for the mapping:
typedef map< string, string > countryMapping; // < sourceTitle, destCountry>
Also a function that will create a mapping given all necessary information:
int initCountryMap(countryMapping& mapping, vector CK2Titles, vector EU3Tags, vector blockedNations, Object* rulesObj);

Note that the converter needs a list of EU3 tags to do the mapping: this allows it to be adaptable to the EU3 install, which may be modded to have more tags. So in EU3World, I add the functions addPotentialCountries(ifstream&, string); and getPotentialTags();; and the member vector potentialCountries;. The first function uses the EU3 data file countries.txt to determine which countries can exist in the game. This data file also mentions which data files correspond to those countries. Both the country tag and the filename are extracted, then a new EU3Country created and saved to the potentialCountries vector. The second function returns a list of tags of those potential nations.

Oh, EU3Country? It’s brand new. All it does at this point is keep track of its tag and its country file. It’ll do much much more down the road, though.

The converter is almost ready to map titles to nations. It just needs one more thing: rules! The mapping rules are placed in county_mappings.txt in the following form:
link = { CK2 = k_england EU3 = ENG } # England => England
This says to map the title k_england to the tag ENG. Straightforward as can be.

That initCountryMap() keeps a pool of available EU3 tags and CK2 titles. At first these pools correspond to all possible tags and all independent titles, respectively. The function goes through the rules in order, and sees if both the title and the tag are in the appropriate pools. If so, it creates a mapping between those two and removes them from their pools.

Eventually, there will be multiple set of rules. So you would have direct mappings, like the one above, then regional mappings, say
link = { CK2 = d_lancaster EU3 = ENG }
That way, if England wasn’t independent in CK2, but the duchy of Lancaster was, Lancaster might be able to use the EU3 tag, helping keep tags in the right region.

After going through all the rules, the function maps any remaining items left in the titles pool to any remaining items in the tags pool, in a completely arbitrary order. However, this is not always desirable, because some tags should only ever be given to appropriately equivalent CK2 nations (Germany and Scandinavia come to mind). So first, it uses a list of ‘blocked’ nations to trim the EU3 tags pool a little.

This list of blocked nations is specified in blocked_nations.txt, which initially consists of the following:
eu3 = REB eu3 = PIR eur = NAT eu3 = GER
In what, again, is a straightforward format. This entry blocks REB (rebels), PIR (pirates), NAT (natives), and GER (Germany).

With these changes, the converter has a mapping between titles and tags. Next up: doing something with that mapping!


Relevant Repository Links:
Country Mappings

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>