Skip to content

Commit

Permalink
Fix for Imperator::Character::getCulture() causing crashes (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Aug 10, 2021
1 parent 4fa3df3 commit 6301f79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions ImperatorToCK3/Source/CK3/Character/CK3Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ void CK3::Character::initializeFromImperator(std::shared_ptr<Imperator::Characte
if (provinceMapper.getCK3ProvinceNumbers(impProvForProvinceMapper).empty() && !imperatorCharacter->getSpouses().empty())
impProvForProvinceMapper = imperatorCharacter->getSpouses().begin()->second->getProvince();

if (provinceMapper.getCK3ProvinceNumbers(impProvForProvinceMapper).empty())
auto ck3ProvinceNumbers = provinceMapper.getCK3ProvinceNumbers(impProvForProvinceMapper);
if (ck3ProvinceNumbers.empty())
ck3Province = 0;
else
ck3Province = provinceMapper.getCK3ProvinceNumbers(impProvForProvinceMapper)[0];
ck3Province = ck3ProvinceNumbers[0];

auto match = religionMapper.match(imperatorCharacter->getReligion(), ck3Province, imperatorCharacter->getProvince());
if (match)
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Source/Imperator/Characters/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const std::string& Imperator::Character::getCulture() const {
if (!culture.empty())
return culture;
if (family.first && !family.second->getCulture().empty())
if (family.first && family.second && !family.second->getCulture().empty())
return family.second->getCulture();
return culture;
}
Expand Down
12 changes: 6 additions & 6 deletions ImperatorToCK3/Source/Imperator/Characters/Characters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ void Imperator::Characters::linkFamilies(const Families& theFamilies) {
}
}

std::string warningString = "Families without definition:";
std::string logString = "Families without definition:";
if (!idsWithoutDefinition.empty()) {
for (auto id : idsWithoutDefinition) {
warningString += " ";
warningString += std::to_string(id);
warningString += ",";
logString += " ";
logString += std::to_string(id);
logString += ",";
}
warningString = warningString.substr(0, warningString.size() - 1); //remove last comma
Log(LogLevel::Warning) << warningString;
logString = logString.substr(0, logString.size() - 1); // remove last comma
Log(LogLevel::Info) << logString;
}

Log(LogLevel::Info) << "<> " << counter << " families linked to characters.";
Expand Down

0 comments on commit 6301f79

Please sign in to comment.