Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Commit

Permalink
Use basetax and manpower proxies to try to break ties in religion con…
Browse files Browse the repository at this point in the history
…version
  • Loading branch information
Idhrendur committed Aug 22, 2012
1 parent cbb6672 commit 2de1b2a
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Data Files/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,5 @@ Revision Log Message
176 Make a bunch of province conversion things configurable
177 Don't bother mapping wastelands to wastelands
178 Map CK2 religions to CK2 religion groups
179 Map CK2 cultures to CK2 culture groups, then disallow wrong culture buildings
179 Map CK2 cultures to CK2 culture groups, then disallow wrong culture buildings
180 Use basetax and manpower proxies to try to break ties in religion conversion
90 changes: 86 additions & 4 deletions Source/EU3World/EU3Province.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,19 @@ void EU3Province::determineReligion(const religionMapping& religionMap, const ve
{

map<string, double> religionCounts;
map<string, double> religionCounts2;
map<string, double> religionCounts3;
for (vector<CK2Province*>::const_iterator provItr = srcProvinces.begin(); provItr < srcProvinces.end(); provItr++)
{
double popProxy = 0.0f;
double popProxy = 0.0f;
double baseTaxProxy = 0.0f;
double manpowerProxy = 0.0f;
vector<CK2Barony*> baronies = (*provItr)->getBaronies();
for (vector<CK2Barony*>::iterator baronyItr = baronies.begin(); baronyItr != baronies.end(); baronyItr++)
{
popProxy += (*baronyItr)->getPopProxy();
popProxy += (*baronyItr)->getPopProxy();
baseTaxProxy += (*baronyItr)->getBaseTaxProxy();
manpowerProxy += (*baronyItr)->getManpowerProxy();
}


Expand All @@ -563,6 +569,26 @@ void EU3Province::determineReligion(const religionMapping& religionMap, const ve
{
religionCounts[_religion] = popProxy;
}

countsItr = religionCounts2.find(_religion);
if (countsItr != religionCounts2.end())
{
countsItr->second += baseTaxProxy;
}
else
{
religionCounts2[_religion] = baseTaxProxy;
}

countsItr = religionCounts3.find(_religion);
if (countsItr != religionCounts3.end())
{
countsItr->second += manpowerProxy;
}
else
{
religionCounts3[_religion] = manpowerProxy;
}
}

string topReligion;
Expand All @@ -586,11 +612,67 @@ void EU3Province::determineReligion(const religionMapping& religionMap, const ve
}
}

if (tie)
vector<string> tiedReligions2;
if (tie == true)
{
log("\tError: tied for religions in province %d, and no method to distinguish.\n", num);
topReligion = "";
topCount = 0;
vector<string> tiedReligions2;
for (map<string, double>::iterator countsItr = religionCounts2.begin(); countsItr != religionCounts2.end(); countsItr++)
{
for (vector<string>::iterator cultureItr = tiedReligions.begin(); cultureItr != tiedReligions.end(); cultureItr++)
{
if (countsItr->first == *cultureItr)
{
if (countsItr->second > topCount)
{
topReligion = countsItr->first;
topCount = countsItr->second;
tiedReligions2.clear();
tiedReligions2.push_back(countsItr->first);
tie = false;
}
else if (countsItr->second == topCount)
{
tiedReligions2.push_back(countsItr->first);
tie = true;
}
break;
}
}
}
}

if (tie == true)
{
topReligion = "";
topCount = 0;
for (map<string, double>::iterator countsItr = religionCounts3.begin(); countsItr != religionCounts3.end(); countsItr++)
{
for (vector<string>::iterator religionItr = tiedReligions2.begin(); religionItr != tiedReligions2.end(); religionItr++)
{
if (countsItr->first == *religionItr)
{
if (countsItr->second > topCount)
{
topReligion = countsItr->first;
topCount = countsItr->second;
tie = false;
}
else if (countsItr->second == topCount)
{
tie = true;
}
break;
}
}
}
}

if (tie == true)
{
log("\tWarning: could not decide on religion for EU3 province %d due to ties.\n", num);
}

const CK2Title* rulerTitle = srcOwner;
if (srcOwner != NULL)
Expand Down

0 comments on commit 2de1b2a

Please sign in to comment.