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

Commit

Permalink
Convert tech
Browse files Browse the repository at this point in the history
  • Loading branch information
Idhrendur committed Oct 27, 2012
1 parent 38c2d5f commit 8a48fc0
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 8 deletions.
1 change: 1 addition & 0 deletions CK2ToEU3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<ClInclude Include="Source\CK2World\CK2Dynasty.h" />
<ClInclude Include="Source\CK2World\CK2History.h" />
<ClInclude Include="Source\CK2World\CK2Province.h" />
<ClInclude Include="Source\CK2World\CK2Techs.h" />
<ClInclude Include="Source\CK2World\CK2Title.h" />
<ClInclude Include="Source\CK2World\CK2Trait.h" />
<ClInclude Include="Source\CK2World\CK2Version.h" />
Expand Down
3 changes: 3 additions & 0 deletions CK2ToEU3.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,8 @@
<ClInclude Include="Source\EU3World\EU3Tech.h">
<Filter>EU3World</Filter>
</ClInclude>
<ClInclude Include="Source\CK2World\CK2Techs.h">
<Filter>CK2World</Filter>
</ClInclude>
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion Data Files/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,5 @@ Revision Log Message
212 ROTW Tech levels (European ones are completely wrong)
213 Change economy option defaults to historical
214 1.06 saves don't lose muslim buildings when converted by a 1.07 install
215 Apply change 213 to test configs
215 Apply change 213 to test configs
216 Convert tech
24 changes: 24 additions & 0 deletions Source/CK2World/CK2Province.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,28 @@ CK2Province::CK2Province(Object* obj, map<string, CK2Title*> titles, const CK2Bu
{
religion = "";
}

techLevels.clear();
vector<Object*> techObj = obj->getValue("technology");
if (techObj.size() > 0)
{
vector<Object*> levelObj = techObj[0]->getValue("level");
if (levelObj.size() > 0)
{
vector<string> levelStrings = levelObj[0]->getTokens();
for (unsigned int i = 0; i < levelStrings.size(); i++)
{
techLevels.push_back( atoi(levelStrings[i].c_str()) );
}
}
vector<Object*> progressObj = techObj[0]->getValue("progress");
if (progressObj.size() > 0)
{
vector<string> progressStrings = progressObj[0]->getTokens();
for (unsigned int i = 0; i < progressStrings.size(); i++)
{
techLevels[i] += 0.1 * atoi(progressStrings[i].c_str());
}
}
}
}
10 changes: 6 additions & 4 deletions Source/CK2World/CK2Province.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ class CK2Province
public:
CK2Province(Object*, map<string, CK2Title*>, const CK2BuildingFactory* buildingFactory, const religionGroupMapping& religionGroupMap, const cultureGroupMapping& cultureGroupMap);

int getNumber() const { return number; };
vector<CK2Barony*> getBaronies() const { return baronies; };
string getCulture() const { return culture; };
string getReligion() const { return religion; };
int getNumber() const { return number; };
vector<CK2Barony*> getBaronies() const { return baronies; };
string getCulture() const { return culture; };
string getReligion() const { return religion; };
vector<double> getTechLevels() const { return techLevels; } ;
private:
int number;
vector<CK2Barony*> baronies;
string culture;
string religion;
vector<double> techLevels;
};


Expand Down
40 changes: 40 additions & 0 deletions Source/CK2World/CK2Techs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef CK2TECHS_H
#define CK2TECHS_H_



enum TechTypes {
// Military techs
TECH_BOWS,
TECH_LIGHT_ARMOUR,
TECH_HEAVY_ARMOUR,
TECH_INFANTRY_MELEE_WEAPONS,
TECH_CAVALRY_MELEE_WEAPONS,
TECH_SIEGE_EQUIPMENT,
TECH_CASTLES,
TECH_TACTICS,

// Economy techs
TECH_CASTLE_TAXES,
TECH_CITY_TAXES,
TECH_TEMPLE_TAXES,
TECH_CASTLE_CONSTRUCTION,
TECH_CITY_CONSTRUCTION,
TECH_TEMPLE_CONSTRUCTION,
TECH_FORTIFICATIONS_CONSTRUCTION,
TECH_CONSTRUCTION,

// Culture techs
TECH_NOBLE_CUSTOMS,
TECH_POPULAR_CUSTOMS,
TECH_RELIGIOUS_CUSTOMS,
TECH_MAJESTY,
TECH_SPIRITUAL_ART,
TECH_CULTURE_FLEX,
TECH_RELIGION_FLEX,
TECH_LEGALISM
};



#endif CK2TECHS_H_
26 changes: 26 additions & 0 deletions Source/CK2World/CK2World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "CK2Character.h"
#include "CK2Dynasty.h"
#include "CK2Trait.h"
#include "CK2Techs.h"



Expand Down Expand Up @@ -267,3 +268,28 @@ void CK2World::removeDeadTitles()
log("\tThere are a total of %d independent titles\n", independentTitles.size());
log("\tThere are a total of %d hre members\n", hreMembers.size());
}


vector<double> CK2World::getAverageTechLevels() const
{
vector<double> avgTechLevels;
avgTechLevels.resize(TECH_LEGALISM);
for (unsigned int i = 0; i < TECH_LEGALISM; i++)
{
avgTechLevels[i] = 0.0f;
}
for(map<int, CK2Province*>::const_iterator provItr = provinces.begin(); provItr != provinces.end(); provItr++)
{
vector<double> currentTechLevels = provItr->second->getTechLevels();
for (unsigned int i = 0; i < TECH_LEGALISM; i++)
{
avgTechLevels[i] += currentTechLevels[i];
}
}
for (unsigned int i = 0; i < TECH_LEGALISM; i++)
{
avgTechLevels[i] /= provinces.size();
}

return avgTechLevels;
}
2 changes: 2 additions & 0 deletions Source/CK2World/CK2World.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class CK2World
map<string, CK2Title*> getIndependentTitles() const { return independentTitles; };
map<string, CK2Title*> getAllTitles() const { return titles; };
map<int, CK2Province*> getProvinces() const { return provinces; };

vector<double> getAverageTechLevels() const;
private:
CK2BuildingFactory* buildingFactory;

Expand Down
2 changes: 1 addition & 1 deletion Source/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ int main(int argc, char * argv[])

log("Converting tech.\n");
printf("Converting tech.\n");
destWorld.convertTech(countryMap, religionMap);
destWorld.convertTech(countryMap, religionMap, srcWorld);

log("Converting governments.\n");
printf("Converting governments.\n");
Expand Down
76 changes: 76 additions & 0 deletions Source/EU3World/EU3Country.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "..\CK2World\CK2History.h"
#include "..\CK2World\CK2Character.h"
#include "..\CK2World\CK2Barony.h"
#include "..\CK2World\CK2Techs.h"
#include "EU3Ruler.h"
#include "EU3History.h"
#include "EU3Province.h"
Expand Down Expand Up @@ -728,4 +729,79 @@ double EU3Country::getProductionEffeciency()
}

return PE;
}

void EU3Country::determineTechLevels(const vector<double>& avgTechLevels, const EU3Tech* techData)
{
vector<double> techLevels;
for (unsigned int i = 0; i <= TECH_LEGALISM; i++)
{
techLevels.push_back(0.0f);
}
int numProvinces = 0;
for (vector<EU3Province*>::iterator itr = provinces.begin(); itr < provinces.end(); itr++)
{
vector<CK2Province*> srcProvinces = (*itr)->getSrcProvinces();
for (vector<CK2Province*>::iterator itr2 = srcProvinces.begin(); itr2 < srcProvinces.end(); itr2++)
{
vector<double> provinceTechLevels = (*itr2)->getTechLevels();
for (unsigned int i = 0; i <= TECH_LEGALISM; i++)
{
techLevels[i] += provinceTechLevels[i];
}
numProvinces++;
}
}
for (unsigned int i = 0; i <= TECH_LEGALISM; i++)
{
if (numProvinces > 0)
{
techLevels[i] /= numProvinces;
techLevels[i] -= avgTechLevels[i];
}
}


double oldLandTech =
techLevels[TECH_BOWS] +
techLevels[TECH_LIGHT_ARMOUR] +
techLevels[TECH_HEAVY_ARMOUR] +
techLevels[TECH_INFANTRY_MELEE_WEAPONS] +
techLevels[TECH_CAVALRY_MELEE_WEAPONS] +
techLevels[TECH_SIEGE_EQUIPMENT] +
techLevels[TECH_CASTLES] +
techLevels[TECH_TACTICS];
double oldNavalTech =
techLevels[TECH_BOWS] +
techLevels[TECH_LIGHT_ARMOUR] +
techLevels[TECH_HEAVY_ARMOUR] +
techLevels[TECH_INFANTRY_MELEE_WEAPONS] +
techLevels[TECH_SIEGE_EQUIPMENT] +
techLevels[TECH_TACTICS];
double oldTradeTech =
techLevels[TECH_CASTLE_TAXES] +
techLevels[TECH_CITY_TAXES] +
techLevels[TECH_TEMPLE_TAXES];
double oldProdTech =
techLevels[TECH_CASTLE_CONSTRUCTION] +
techLevels[TECH_CITY_CONSTRUCTION] +
techLevels[TECH_TEMPLE_CONSTRUCTION] +
techLevels[TECH_FORTIFICATIONS_CONSTRUCTION] +
techLevels[TECH_CONSTRUCTION];
double oldGovTech =
techLevels[TECH_TEMPLE_TAXES] +
techLevels[TECH_NOBLE_CUSTOMS] +
techLevels[TECH_POPULAR_CUSTOMS] +
techLevels[TECH_RELIGIOUS_CUSTOMS] +
techLevels[TECH_MAJESTY] +
techLevels[TECH_SPIRITUAL_ART] +
techLevels[TECH_CULTURE_FLEX] +
techLevels[TECH_RELIGION_FLEX] +
techLevels[TECH_LEGALISM];

governmentTech = techData->getGovernmentTech("western") + (oldGovTech / 9);
productionTech = techData->getProductionTech("western") + (oldProdTech / 9);
tradeTech = techData->getTradeTech("western") + (oldTradeTech / 9);
navalTech = techData->getNavalTech("western") + (oldNavalTech / 9);
landTech = techData->getLandTech("western") + (oldLandTech / 9);
}
1 change: 1 addition & 0 deletions Source/EU3World/EU3Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class EU3Country
void determineEconomy(const cultureGroupMapping& cultureGroups, const map<string, double>& unitPrices);
double getTradeEffeciency();
double getProductionEffeciency();
void determineTechLevels(const vector<double>& avgTechLevels, const EU3Tech* techData);

void addProvince(EU3Province* province) { provinces.push_back(province); };
void setTechGroup(string _techGroup) { techGroup = _techGroup; };
Expand Down
6 changes: 5 additions & 1 deletion Source/EU3World/EU3World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,10 @@ void EU3World::convertAdvisors(inverseProvinceMapping& inverseProvinceMap, provi
}


void EU3World::convertTech(countryMapping& countryMap, const religionGroupMapping& religionGroupMap)
void EU3World::convertTech(countryMapping& countryMap, const religionGroupMapping& religionGroupMap, const CK2World& srcWorld)
{
vector<double> avgTechLevels = srcWorld.getAverageTechLevels();

double highestLearningScore = 0.0f;
for (countryMapping::iterator countryItr = countryMap.begin(); countryItr != countryMap.end(); countryItr++)
{
Expand Down Expand Up @@ -807,6 +809,8 @@ void EU3World::convertTech(countryMapping& countryMap, const religionGroupMappin
countryItr->second->setTechGroup("western");
log("\t%s is in tech group western.\n", countryItr->second->getTag().c_str());
}

countryItr->second->determineTechLevels(avgTechLevels, techData);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/EU3World/EU3World.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class EU3World
void convertProvinces(provinceMapping&, map<int, CK2Province*>&, countryMapping&, cultureMapping& cultureMap, religionMapping& religionMap, continentMapping& continentMap, adjacencyMapping& adjacencyMap, const tradeGoodMapping& tradeGoodMap, const religionGroupMapping& EU3ReligionGroup);
void addAcceptedCultures();
void convertAdvisors(inverseProvinceMapping&, provinceMapping&, CK2World&);
void convertTech(countryMapping& countryMap, const religionGroupMapping& religionGroupMap);
void convertTech(countryMapping& countryMap, const religionGroupMapping& religionGroupMap, const CK2World& srcWorld);
void convertGovernments(const religionGroupMapping& religionGroupMap);
void convertEconomies(const cultureGroupMapping& cultureGroups, const tradeGoodMapping& tradeGoodMap);

Expand Down

0 comments on commit 8a48fc0

Please sign in to comment.