diff --git a/CK2ToEU3.vcxproj b/CK2ToEU3.vcxproj index 71c72f100..a4d5ec922 100644 --- a/CK2ToEU3.vcxproj +++ b/CK2ToEU3.vcxproj @@ -123,6 +123,7 @@ + diff --git a/CK2ToEU3.vcxproj.filters b/CK2ToEU3.vcxproj.filters index a21f18a6a..707fce037 100644 --- a/CK2ToEU3.vcxproj.filters +++ b/CK2ToEU3.vcxproj.filters @@ -173,5 +173,8 @@ EU3World + + CK2World + \ No newline at end of file diff --git a/Data Files/Changelog.txt b/Data Files/Changelog.txt index 95ed00007..65cae8f48 100644 --- a/Data Files/Changelog.txt +++ b/Data Files/Changelog.txt @@ -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 \ No newline at end of file +215 Apply change 213 to test configs +216 Convert tech \ No newline at end of file diff --git a/Source/CK2World/CK2Province.cpp b/Source/CK2World/CK2Province.cpp index 1a1ec0c5b..7d69a330e 100644 --- a/Source/CK2World/CK2Province.cpp +++ b/Source/CK2World/CK2Province.cpp @@ -47,4 +47,28 @@ CK2Province::CK2Province(Object* obj, map titles, const CK2Bu { religion = ""; } + + techLevels.clear(); + vector techObj = obj->getValue("technology"); + if (techObj.size() > 0) + { + vector levelObj = techObj[0]->getValue("level"); + if (levelObj.size() > 0) + { + vector levelStrings = levelObj[0]->getTokens(); + for (unsigned int i = 0; i < levelStrings.size(); i++) + { + techLevels.push_back( atoi(levelStrings[i].c_str()) ); + } + } + vector progressObj = techObj[0]->getValue("progress"); + if (progressObj.size() > 0) + { + vector progressStrings = progressObj[0]->getTokens(); + for (unsigned int i = 0; i < progressStrings.size(); i++) + { + techLevels[i] += 0.1 * atoi(progressStrings[i].c_str()); + } + } + } } \ No newline at end of file diff --git a/Source/CK2World/CK2Province.h b/Source/CK2World/CK2Province.h index 3f6ff407b..ddd363f64 100644 --- a/Source/CK2World/CK2Province.h +++ b/Source/CK2World/CK2Province.h @@ -19,15 +19,17 @@ class CK2Province public: CK2Province(Object*, map, const CK2BuildingFactory* buildingFactory, const religionGroupMapping& religionGroupMap, const cultureGroupMapping& cultureGroupMap); - int getNumber() const { return number; }; - vector getBaronies() const { return baronies; }; - string getCulture() const { return culture; }; - string getReligion() const { return religion; }; + int getNumber() const { return number; }; + vector getBaronies() const { return baronies; }; + string getCulture() const { return culture; }; + string getReligion() const { return religion; }; + vector getTechLevels() const { return techLevels; } ; private: int number; vector baronies; string culture; string religion; + vector techLevels; }; diff --git a/Source/CK2World/CK2Techs.h b/Source/CK2World/CK2Techs.h new file mode 100644 index 000000000..57e229609 --- /dev/null +++ b/Source/CK2World/CK2Techs.h @@ -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_ \ No newline at end of file diff --git a/Source/CK2World/CK2World.cpp b/Source/CK2World/CK2World.cpp index d362bacaf..54c948f0f 100644 --- a/Source/CK2World/CK2World.cpp +++ b/Source/CK2World/CK2World.cpp @@ -10,6 +10,7 @@ #include "CK2Character.h" #include "CK2Dynasty.h" #include "CK2Trait.h" +#include "CK2Techs.h" @@ -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 CK2World::getAverageTechLevels() const +{ + vector avgTechLevels; + avgTechLevels.resize(TECH_LEGALISM); + for (unsigned int i = 0; i < TECH_LEGALISM; i++) + { + avgTechLevels[i] = 0.0f; + } + for(map::const_iterator provItr = provinces.begin(); provItr != provinces.end(); provItr++) + { + vector 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; +} diff --git a/Source/CK2World/CK2World.h b/Source/CK2World/CK2World.h index 6b6d305bb..de453fda7 100644 --- a/Source/CK2World/CK2World.h +++ b/Source/CK2World/CK2World.h @@ -38,6 +38,8 @@ class CK2World map getIndependentTitles() const { return independentTitles; }; map getAllTitles() const { return titles; }; map getProvinces() const { return provinces; }; + + vector getAverageTechLevels() const; private: CK2BuildingFactory* buildingFactory; diff --git a/Source/Convert.cpp b/Source/Convert.cpp index 7aab8840e..a8845e16e 100644 --- a/Source/Convert.cpp +++ b/Source/Convert.cpp @@ -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"); diff --git a/Source/EU3World/EU3Country.cpp b/Source/EU3World/EU3Country.cpp index 3d8283ce3..e24f9c263 100644 --- a/Source/EU3World/EU3Country.cpp +++ b/Source/EU3World/EU3Country.cpp @@ -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" @@ -728,4 +729,79 @@ double EU3Country::getProductionEffeciency() } return PE; +} + +void EU3Country::determineTechLevels(const vector& avgTechLevels, const EU3Tech* techData) +{ + vector techLevels; + for (unsigned int i = 0; i <= TECH_LEGALISM; i++) + { + techLevels.push_back(0.0f); + } + int numProvinces = 0; + for (vector::iterator itr = provinces.begin(); itr < provinces.end(); itr++) + { + vector srcProvinces = (*itr)->getSrcProvinces(); + for (vector::iterator itr2 = srcProvinces.begin(); itr2 < srcProvinces.end(); itr2++) + { + vector 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); } \ No newline at end of file diff --git a/Source/EU3World/EU3Country.h b/Source/EU3World/EU3Country.h index bee34ed6a..d6422b4ce 100644 --- a/Source/EU3World/EU3Country.h +++ b/Source/EU3World/EU3Country.h @@ -33,6 +33,7 @@ class EU3Country void determineEconomy(const cultureGroupMapping& cultureGroups, const map& unitPrices); double getTradeEffeciency(); double getProductionEffeciency(); + void determineTechLevels(const vector& avgTechLevels, const EU3Tech* techData); void addProvince(EU3Province* province) { provinces.push_back(province); }; void setTechGroup(string _techGroup) { techGroup = _techGroup; }; diff --git a/Source/EU3World/EU3World.cpp b/Source/EU3World/EU3World.cpp index c0306260d..5068c058c 100644 --- a/Source/EU3World/EU3World.cpp +++ b/Source/EU3World/EU3World.cpp @@ -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 avgTechLevels = srcWorld.getAverageTechLevels(); + double highestLearningScore = 0.0f; for (countryMapping::iterator countryItr = countryMap.begin(); countryItr != countryMap.end(); countryItr++) { @@ -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); } } diff --git a/Source/EU3World/EU3World.h b/Source/EU3World/EU3World.h index 09b3e9ab0..1608a5204 100644 --- a/Source/EU3World/EU3World.h +++ b/Source/EU3World/EU3World.h @@ -51,7 +51,7 @@ class EU3World void convertProvinces(provinceMapping&, map&, 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);