diff --git a/Data Files/Changelog.txt b/Data Files/Changelog.txt index 825716d7a..5ef485b6b 100644 --- a/Data Files/Changelog.txt +++ b/Data Files/Changelog.txt @@ -326,4 +326,13 @@ Revision Log Message 320 Map tags for some new 1.09 titles. 321 Merge main to minor 322 Merge main to bugfixes -323 Extra logging for tech group conversion \ No newline at end of file +323 Extra logging for tech group conversion +324 Don't crash if religions tie on multiple criteria. +325 Read titular settlements and allow them to be a character's primary holding. +326 Read dynamic titles and their settlements. +327 Don't erase the buildings from the building map after adding them. +328 If the title specified for HRETitle doesn't exist, don't try to set up the HRE mechanics. +329 Add tax/pop/manpower proxies for family palaces (unused, but silences an error). + Correct manpower proxy for temples. +330 Don't generate EU3 supply for the null tradegood. +331 Merge bugfixes to minor. diff --git a/Source/CK2World/CK2Barony.cpp b/Source/CK2World/CK2Barony.cpp index 57d028701..161f6e8e2 100644 --- a/Source/CK2World/CK2Barony.cpp +++ b/Source/CK2World/CK2Barony.cpp @@ -8,7 +8,7 @@ -CK2Barony::CK2Barony(Object* obj, CK2Title* newTitle, CK2Province* newProvince, const CK2BuildingFactory* buildingFactory, const cultureGroupMapping& cultureGroupMap) +CK2Barony::CK2Barony(Object* obj, CK2Title* newTitle, CK2Province* newProvince, const CK2BuildingFactory* buildingFactory) { title = newTitle; province = newProvince; @@ -22,7 +22,7 @@ CK2Barony::CK2Barony(Object* obj, CK2Title* newTitle, CK2Province* newProvince, string key = (*i)->getKey(); if ( (key.substr(0, 3) == "ca_") || (key.substr(0, 3) == "ct_") || (key.substr(0, 3) == "tp_") ) { - const CK2Building* newBuilding = buildingFactory->getBuilding(key, title->getHolder(), cultureGroupMap); + const CK2Building* newBuilding = buildingFactory->getBuilding(key, title->getHolder()); if (newBuilding != NULL) { buildings.push_back(newBuilding); @@ -106,6 +106,10 @@ void CK2Barony::determineBaseTaxProxy() { baseTaxProxy += 8.0f; } + else if (type == "family_palace") + { + baseTaxProxy += 10.0f; + } else { log("Note! Unhandled barony type %s\n", type.c_str()); @@ -139,6 +143,10 @@ void CK2Barony::determinePopProxy() { popProxy += 8.0f; } + else if (type == "family_palace") + { + popProxy += 10.0f; + } else { log("Note! Unhandled barony type %s\n", type.c_str()); @@ -166,7 +174,11 @@ void CK2Barony::determineManpowerProxy() } else if (type == "temple") { - manpowerProxy += 125; + manpowerProxy += 130; + } + else if (type == "family_palace") + { + manpowerProxy += 50; } else { diff --git a/Source/CK2World/CK2Barony.h b/Source/CK2World/CK2Barony.h index 4c141bee6..b97f6be78 100644 --- a/Source/CK2World/CK2Barony.h +++ b/Source/CK2World/CK2Barony.h @@ -17,7 +17,7 @@ class CK2Province; class CK2Barony { public: - CK2Barony(Object*, CK2Title*, CK2Province*, const CK2BuildingFactory*, const cultureGroupMapping& cultureGroupMap); + CK2Barony(Object*, CK2Title*, CK2Province*, const CK2BuildingFactory*); CK2Title* getTitle() const { return title; }; CK2Province* getProvince() const { return province; }; diff --git a/Source/CK2World/CK2Building.cpp b/Source/CK2World/CK2Building.cpp index 368036d9e..8f484f6d0 100644 --- a/Source/CK2World/CK2Building.cpp +++ b/Source/CK2World/CK2Building.cpp @@ -152,9 +152,12 @@ CK2Building::CK2Building(Object* obj) } -CK2BuildingFactory::CK2BuildingFactory() +map CK2BuildingFactory::buildings; + + +CK2BuildingFactory::CK2BuildingFactory(const cultureGroupMapping* _cultureGroupMap) { - buildings.clear(); + cultureGroupMap = _cultureGroupMap; } @@ -174,7 +177,7 @@ void CK2BuildingFactory::addBuildingTypes(Object* obj) } -const CK2Building* CK2BuildingFactory::getBuilding(string type, const CK2Character* baronyHolder, const cultureGroupMapping& cultureGroupMap) const +const CK2Building* CK2BuildingFactory::getBuilding(string type, const CK2Character* baronyHolder) const { const CK2Building* returnMe = NULL; @@ -197,7 +200,7 @@ const CK2Building* CK2BuildingFactory::getBuilding(string type, const CK2Charact vector acceptableCultureGroups = itr->second->getAcceptableCultureGroups(); for (vector::iterator cultureGroupsItr = acceptableCultureGroups.begin(); cultureGroupsItr < acceptableCultureGroups.end(); cultureGroupsItr++) { - if ( *cultureGroupsItr == cultureGroupMap.find(baronyHolder->getCulture())->second ) + if ( *cultureGroupsItr == cultureGroupMap->find(baronyHolder->getCulture())->second ) { returnMe = itr->second; break; diff --git a/Source/CK2World/CK2Building.h b/Source/CK2World/CK2Building.h index f9d12ee08..9b2a0f030 100644 --- a/Source/CK2World/CK2Building.h +++ b/Source/CK2World/CK2Building.h @@ -45,13 +45,14 @@ class CK2Building class CK2BuildingFactory { public: - CK2BuildingFactory(); + CK2BuildingFactory(const cultureGroupMapping* _cultureGroupMap); - void addBuildingTypes(Object* obj); - const CK2Building* getBuilding(string type, const CK2Character* baronyHolder, const cultureGroupMapping& cultureGroupMap) const; + static void addBuildingTypes(Object* obj); + const CK2Building* getBuilding(string type, const CK2Character* baronyHolder) const; private: - map buildings; + const cultureGroupMapping* cultureGroupMap; + static map buildings; }; diff --git a/Source/CK2World/CK2Character.cpp b/Source/CK2World/CK2Character.cpp index 2f6c3f344..a7ce665cb 100644 --- a/Source/CK2World/CK2Character.cpp +++ b/Source/CK2World/CK2Character.cpp @@ -419,10 +419,14 @@ void CK2Character::setEmployer(map& characters, mapgetCapitalString(); - CK2Barony* homeBarony = baronies[hostCapitalString]; - if (homeBarony != NULL) + map::iterator itr = baronies.find(hostCapitalString); + if (itr != baronies.end()) { - locationNum = homeBarony->getProvince()->getNumber(); + CK2Barony* homeBarony = itr->second; + if (homeBarony != NULL) + { + locationNum = homeBarony->getProvince()->getNumber(); + } } } } diff --git a/Source/CK2World/CK2Province.cpp b/Source/CK2World/CK2Province.cpp index 9dac736d3..49811b78b 100644 --- a/Source/CK2World/CK2Province.cpp +++ b/Source/CK2World/CK2Province.cpp @@ -9,7 +9,7 @@ -CK2Province::CK2Province(Object* obj, map titles, const CK2BuildingFactory* buildingFactory, const cultureGroupMapping& cultureGroupMap) +CK2Province::CK2Province(Object* obj, map titles, const CK2BuildingFactory* buildingFactory) { number = atoi( obj->getKey().c_str() ); @@ -25,7 +25,7 @@ CK2Province::CK2Province(Object* obj, map titles, const CK2Bu log("Error: baron-level title %s is used in your save, but does not exist in your CK2 install.\n", key.c_str()); continue; } - CK2Barony* newBarony = new CK2Barony( leaves[i], title->second, this, buildingFactory, cultureGroupMap); + CK2Barony* newBarony = new CK2Barony( leaves[i], title->second, this, buildingFactory); if (newBarony->getTitle()->getHolder()->getCapitalString() == newBarony->getTitle()->getTitleString()) { newBarony->getTitle()->getHolder()->setCapital(this); diff --git a/Source/CK2World/CK2Province.h b/Source/CK2World/CK2Province.h index cb098d8ab..aabae30d4 100644 --- a/Source/CK2World/CK2Province.h +++ b/Source/CK2World/CK2Province.h @@ -18,7 +18,7 @@ class CK2Religion; class CK2Province { public: - CK2Province(Object*, map, const CK2BuildingFactory* buildingFactory, const cultureGroupMapping& cultureGroupMap); + CK2Province(Object*, map, const CK2BuildingFactory* buildingFactory); int getNumber() const { return number; }; vector getBaronies() const { return baronies; }; diff --git a/Source/CK2World/CK2Title.cpp b/Source/CK2World/CK2Title.cpp index e802397a2..10e6b07f2 100644 --- a/Source/CK2World/CK2Title.cpp +++ b/Source/CK2World/CK2Title.cpp @@ -5,6 +5,7 @@ #include "CK2Title.h" #include "CK2Dynasty.h" #include "CK2History.h" +#include "CK2Barony.h" #include "..\Log.h" #include #include "..\Configuration.h" @@ -28,11 +29,14 @@ CK2Title::CK2Title(string _titleString) deJureLiege = NULL; independent = true; inHRE = false; + active = false; dstCountry = NULL; + settlement = NULL; + dynamic = false; } -void CK2Title::init(Object* obj, map& characters) +void CK2Title::init(Object* obj, map& characters, const CK2BuildingFactory* buildingFactory) { titleString = obj->getKey(); holder = NULL; @@ -117,6 +121,33 @@ void CK2Title::init(Object* obj, map& characters) deJureLiegeString = deJureLiegeString.substr(1, deJureLiegeString.size() - 2); } + active = true; + vector activeObjs = obj->getValue("active"); + if (activeObjs.size() > 0) + { + if (activeObjs[0]->getLeaf() == "no") + active = false; + } + + vector dynObjs = obj->getValue("dynamic"); + if (dynObjs.size() > 0) + { + if (dynObjs[0]->getLeaf() == "yes") + dynamic = true; + } + + vector settlementObjs = obj->getValue("settlement"); + if (settlementObjs.size() > 0) + { + settlement = new CK2Barony(settlementObjs[0], this, NULL, buildingFactory); + if (holder != NULL) + { + holder->addHolding(settlement); + if (holder->getPrimaryHolding() == NULL) // if no other capital, a title holding will work + holder->setPrimaryHolding(settlement); + } + } + independent = true; inHRE = false; } diff --git a/Source/CK2World/CK2Title.h b/Source/CK2World/CK2Title.h index cf653c647..e0102555a 100644 --- a/Source/CK2World/CK2Title.h +++ b/Source/CK2World/CK2Title.h @@ -12,13 +12,15 @@ class Object; class CK2World; class CK2Character; class CK2History; +class CK2Barony; +class CK2BuildingFactory; class EU3Country; class CK2Title { public: CK2Title(string _titleString); - void init(Object*, map&); + void init(Object*, map&, const CK2BuildingFactory* buildingFactory); void setLiege(CK2Title*); void addToHRE(); @@ -47,6 +49,8 @@ class CK2Title CK2Title* getDeJureLiege() const { return deJureLiege; }; bool isIndependent() const { return independent; }; bool isInHRE() const { return inHRE; }; + bool isActive() const { return active; }; + bool isDynamic() const { return dynamic; }; EU3Country* getDstCountry() const { return dstCountry; }; bool eatTitle(CK2Title* target, bool checkInheritance); @@ -77,9 +81,13 @@ class CK2Title vector deJureVassals; string deJureLiegeString; CK2Title* deJureLiege; + + CK2Barony* settlement; bool independent; bool inHRE; + bool active; + bool dynamic; EU3Country* dstCountry; }; diff --git a/Source/CK2World/CK2World.cpp b/Source/CK2World/CK2World.cpp index 0c19f80f3..ebde12c89 100644 --- a/Source/CK2World/CK2World.cpp +++ b/Source/CK2World/CK2World.cpp @@ -17,7 +17,7 @@ CK2World::CK2World() { - buildingFactory = new CK2BuildingFactory; + buildingFactory = NULL; version = NULL; endDate = date(); @@ -37,6 +37,8 @@ CK2World::CK2World() void CK2World::init(Object* obj, const cultureGroupMapping& cultureGroupMap) { + buildingFactory = new CK2BuildingFactory(&cultureGroupMap); + // get version vector versionObj = obj->getValue("version"); if (versionObj.size() > 0) @@ -144,11 +146,20 @@ void CK2World::init(Object* obj, const cultureGroupMapping& cultureGroupMap) map::iterator titleItr = potentialTitles.find(key); if (titleItr == potentialTitles.end()) { - log("\t\tWarning: tried to create title %s, but it is not a potential title.\n", key.c_str()); - continue; + CK2Title* dynTitle = new CK2Title(key); + dynTitle->init(leaves[i], characters, buildingFactory); + if (!dynTitle->isDynamic()) + { + log("\t\tWarning: tried to create title %s, but it is neither a potential title nor a dynamic title.\n", key.c_str()); + continue; + } + titles.insert( make_pair(dynTitle->getTitleString(), dynTitle) ); + } + else + { + titleItr->second->init(leaves[i], characters, buildingFactory); + titles.insert( make_pair(titleItr->second->getTitleString(), titleItr->second) ); } - titleItr->second->init(leaves[i], characters); - titles.insert( make_pair(titleItr->second->getTitleString(), titleItr->second) ); } } @@ -166,7 +177,7 @@ void CK2World::init(Object* obj, const cultureGroupMapping& cultureGroupMap) string key = leaves[i]->getKey(); if (atoi(key.c_str()) > 0) { - CK2Province* newProvince = new CK2Province(leaves[i], titles, buildingFactory, cultureGroupMap); + CK2Province* newProvince = new CK2Province(leaves[i], titles, buildingFactory); provinces.insert( make_pair(atoi(key.c_str()), newProvince) ); vector newBaronies = newProvince->getBaronies(); @@ -270,7 +281,7 @@ void CK2World::init(Object* obj, const cultureGroupMapping& cultureGroupMap) void CK2World::addBuildingTypes(Object* obj) { - buildingFactory->addBuildingTypes(obj); + CK2BuildingFactory::addBuildingTypes(obj); } diff --git a/Source/EU3World/EU3Province.cpp b/Source/EU3World/EU3Province.cpp index 4fb87bd32..e4773a41a 100644 --- a/Source/EU3World/EU3Province.cpp +++ b/Source/EU3World/EU3Province.cpp @@ -664,7 +664,6 @@ void EU3Province::determineReligion(const religionMapping& religionMap, const ve vector tiedReligions2; if (tie == true) { - topReligion = NULL; topCount = 0; for (map::iterator countsItr = religionCounts2.begin(); countsItr != religionCounts2.end(); countsItr++) { @@ -693,7 +692,6 @@ void EU3Province::determineReligion(const religionMapping& religionMap, const ve if (tie == true) { - topReligion = NULL; topCount = 0; for (map::iterator countsItr = religionCounts3.begin(); countsItr != religionCounts3.end(); countsItr++) { @@ -1165,7 +1163,8 @@ void EU3Province::determineGoodsDemand(const tradeGoodMapping& tradeGoodMap, con void EU3Province::addSupplyContribution(map& goodsSupply) { - goodsSupply[tradeGood] += supply / 100; + if (!tradeGood.empty()) + goodsSupply[tradeGood] += supply / 100; } diff --git a/Source/EU3World/EU3World.cpp b/Source/EU3World/EU3World.cpp index 02b9a6500..d46c3d7d0 100644 --- a/Source/EU3World/EU3World.cpp +++ b/Source/EU3World/EU3World.cpp @@ -1334,6 +1334,9 @@ void EU3World::determineMapSpread() void EU3World::convertHRE() { + if (srcWorld->getHRETitle() == NULL) + return; + hreEmperor = srcWorld->getHRETitle()->getHolder()->getPrimaryTitle()->getDstCountry(); map hreMembers = srcWorld->getHREMembers(); vector potentialElectors;