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

Commit

Permalink
Merge bugfixes to minor.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtremenak committed Mar 3, 2013
2 parents 2b3984d + 33bd3f9 commit 24e3466
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 31 deletions.
11 changes: 10 additions & 1 deletion Data Files/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.
18 changes: 15 additions & 3 deletions Source/CK2World/CK2Barony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -166,7 +174,11 @@ void CK2Barony::determineManpowerProxy()
}
else if (type == "temple")
{
manpowerProxy += 125;
manpowerProxy += 130;
}
else if (type == "family_palace")
{
manpowerProxy += 50;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Source/CK2World/CK2Barony.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand Down
11 changes: 7 additions & 4 deletions Source/CK2World/CK2Building.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ CK2Building::CK2Building(Object* obj)
}


CK2BuildingFactory::CK2BuildingFactory()
map<string, const CK2Building*> CK2BuildingFactory::buildings;


CK2BuildingFactory::CK2BuildingFactory(const cultureGroupMapping* _cultureGroupMap)
{
buildings.clear();
cultureGroupMap = _cultureGroupMap;
}


Expand All @@ -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;

Expand All @@ -197,7 +200,7 @@ const CK2Building* CK2BuildingFactory::getBuilding(string type, const CK2Charact
vector<string> acceptableCultureGroups = itr->second->getAcceptableCultureGroups();
for (vector<string>::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;
Expand Down
9 changes: 5 additions & 4 deletions Source/CK2World/CK2Building.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, const CK2Building*> buildings;
const cultureGroupMapping* cultureGroupMap;
static map<string, const CK2Building*> buildings;
};


Expand Down
10 changes: 7 additions & 3 deletions Source/CK2World/CK2Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,14 @@ void CK2Character::setEmployer(map<int, CK2Character*>& characters, map<string,
if (host != NULL)
{
string hostCapitalString = host->getCapitalString();
CK2Barony* homeBarony = baronies[hostCapitalString];
if (homeBarony != NULL)
map<string, CK2Barony*>::iterator itr = baronies.find(hostCapitalString);
if (itr != baronies.end())
{
locationNum = homeBarony->getProvince()->getNumber();
CK2Barony* homeBarony = itr->second;
if (homeBarony != NULL)
{
locationNum = homeBarony->getProvince()->getNumber();
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/CK2World/CK2Province.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@



CK2Province::CK2Province(Object* obj, map<string, CK2Title*> titles, const CK2BuildingFactory* buildingFactory, const cultureGroupMapping& cultureGroupMap)
CK2Province::CK2Province(Object* obj, map<string, CK2Title*> titles, const CK2BuildingFactory* buildingFactory)
{
number = atoi( obj->getKey().c_str() );

Expand All @@ -25,7 +25,7 @@ CK2Province::CK2Province(Object* obj, map<string, CK2Title*> 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);
Expand Down
2 changes: 1 addition & 1 deletion Source/CK2World/CK2Province.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CK2Religion;
class CK2Province
{
public:
CK2Province(Object*, map<string, CK2Title*>, const CK2BuildingFactory* buildingFactory, const cultureGroupMapping& cultureGroupMap);
CK2Province(Object*, map<string, CK2Title*>, const CK2BuildingFactory* buildingFactory);

int getNumber() const { return number; };
vector<CK2Barony*> getBaronies() const { return baronies; };
Expand Down
33 changes: 32 additions & 1 deletion Source/CK2World/CK2Title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "CK2Title.h"
#include "CK2Dynasty.h"
#include "CK2History.h"
#include "CK2Barony.h"
#include "..\Log.h"
#include <algorithm>
#include "..\Configuration.h"
Expand All @@ -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<int, CK2Character*>& characters)
void CK2Title::init(Object* obj, map<int, CK2Character*>& characters, const CK2BuildingFactory* buildingFactory)
{
titleString = obj->getKey();
holder = NULL;
Expand Down Expand Up @@ -117,6 +121,33 @@ void CK2Title::init(Object* obj, map<int, CK2Character*>& characters)
deJureLiegeString = deJureLiegeString.substr(1, deJureLiegeString.size() - 2);
}

active = true;
vector<Object*> activeObjs = obj->getValue("active");
if (activeObjs.size() > 0)
{
if (activeObjs[0]->getLeaf() == "no")
active = false;
}

vector<Object*> dynObjs = obj->getValue("dynamic");
if (dynObjs.size() > 0)
{
if (dynObjs[0]->getLeaf() == "yes")
dynamic = true;
}

vector<Object*> 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;
}
Expand Down
10 changes: 9 additions & 1 deletion Source/CK2World/CK2Title.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, CK2Character*>&);
void init(Object*, map<int, CK2Character*>&, const CK2BuildingFactory* buildingFactory);

void setLiege(CK2Title*);
void addToHRE();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -77,9 +81,13 @@ class CK2Title
vector<CK2Title*> deJureVassals;
string deJureLiegeString;
CK2Title* deJureLiege;

CK2Barony* settlement;

bool independent;
bool inHRE;
bool active;
bool dynamic;

EU3Country* dstCountry;
};
Expand Down
25 changes: 18 additions & 7 deletions Source/CK2World/CK2World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

CK2World::CK2World()
{
buildingFactory = new CK2BuildingFactory;
buildingFactory = NULL;

version = NULL;
endDate = date();
Expand All @@ -37,6 +37,8 @@ CK2World::CK2World()

void CK2World::init(Object* obj, const cultureGroupMapping& cultureGroupMap)
{
buildingFactory = new CK2BuildingFactory(&cultureGroupMap);

// get version
vector<Object*> versionObj = obj->getValue("version");
if (versionObj.size() > 0)
Expand Down Expand Up @@ -144,11 +146,20 @@ void CK2World::init(Object* obj, const cultureGroupMapping& cultureGroupMap)
map<string, CK2Title*>::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) );
}
}

Expand All @@ -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<CK2Barony*> newBaronies = newProvince->getBaronies();
Expand Down Expand Up @@ -270,7 +281,7 @@ void CK2World::init(Object* obj, const cultureGroupMapping& cultureGroupMap)

void CK2World::addBuildingTypes(Object* obj)
{
buildingFactory->addBuildingTypes(obj);
CK2BuildingFactory::addBuildingTypes(obj);
}


Expand Down
5 changes: 2 additions & 3 deletions Source/EU3World/EU3Province.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ void EU3Province::determineReligion(const religionMapping& religionMap, const ve
vector<CK2Religion*> tiedReligions2;
if (tie == true)
{
topReligion = NULL;
topCount = 0;
for (map<CK2Religion*, double>::iterator countsItr = religionCounts2.begin(); countsItr != religionCounts2.end(); countsItr++)
{
Expand Down Expand Up @@ -693,7 +692,6 @@ void EU3Province::determineReligion(const religionMapping& religionMap, const ve

if (tie == true)
{
topReligion = NULL;
topCount = 0;
for (map<CK2Religion*, double>::iterator countsItr = religionCounts3.begin(); countsItr != religionCounts3.end(); countsItr++)
{
Expand Down Expand Up @@ -1165,7 +1163,8 @@ void EU3Province::determineGoodsDemand(const tradeGoodMapping& tradeGoodMap, con

void EU3Province::addSupplyContribution(map<string, double>& goodsSupply)
{
goodsSupply[tradeGood] += supply / 100;
if (!tradeGood.empty())
goodsSupply[tradeGood] += supply / 100;
}


Expand Down
3 changes: 3 additions & 0 deletions Source/EU3World/EU3World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,9 @@ void EU3World::determineMapSpread()

void EU3World::convertHRE()
{
if (srcWorld->getHRETitle() == NULL)
return;

hreEmperor = srcWorld->getHRETitle()->getHolder()->getPrimaryTitle()->getDstCountry();
map<string, CK2Title*> hreMembers = srcWorld->getHREMembers();
vector<CK2Title*> potentialElectors;
Expand Down

0 comments on commit 24e3466

Please sign in to comment.