Skip to content

Commit

Permalink
monumentsmapper cleanup (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo Elezović authored Oct 28, 2021
1 parent f28971f commit 449ac58
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 64 deletions.
6 changes: 3 additions & 3 deletions CK2ToEU4/CK2ToEU4.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@
<ClInclude Include="Source\Mappers\GovernmentsMapper\GovernmentsMapping.h" />
<ClInclude Include="Source\Mappers\IAmHreMapper\IAmHreMapper.h" />
<ClInclude Include="Source\Mappers\LocalizationMapper\LocalizationMapper.h" />
<ClCompile Include="Source\Mappers\MonumentsMapper\BuildTriggerBuilder.h" />
<ClInclude Include="Source\Mappers\MonumentsMapper\BuildTriggerBuilder.h" />
<ClInclude Include="Source\Mappers\MonumentsMapper\InternalModifiers.h" />
<ClCompile Include="Source\Mappers\MonumentsMapper\MonumentsMapper.h" />
<ClCompile Include="Source\Mappers\MonumentsMapper\MonumentsMapping.h" />
<ClInclude Include="Source\Mappers\MonumentsMapper\MonumentsMapper.h" />
<ClInclude Include="Source\Mappers\MonumentsMapper\MonumentsMapping.h" />
<ClInclude Include="Source\Mappers\PersonalityScraper\PersonalityScraper.h" />
<ClInclude Include="Source\Mappers\PrimaryTagMapper\PrimaryTagCultureGroup.h" />
<ClInclude Include="Source\Mappers\PrimaryTagMapper\PrimaryTagMapper.h" />
Expand Down
18 changes: 9 additions & 9 deletions CK2ToEU4/CK2ToEU4.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,9 @@
<ClCompile Include="Source\Mappers\MonumentsMapper\MonumentsMapper.cpp">
<Filter>Mappers\MonumentsMapper</Filter>
</ClCompile>
<ClCompile Include="Source\Mappers\MonumentsMapper\MonumentsMapper.h">
<Filter>Mappers\MonumentsMapper</Filter>
</ClCompile>
<ClCompile Include="Source\Mappers\MonumentsMapper\MonumentsMapping.cpp">
<Filter>Mappers\MonumentsMapper</Filter>
</ClCompile>
<ClCompile Include="Source\Mappers\MonumentsMapper\MonumentsMapping.h">
<Filter>Mappers\MonumentsMapper</Filter>
</ClCompile>
<ClCompile Include="Source\EU4World\Output\outMonument.cpp">
<Filter>EU4World\Output</Filter>
</ClCompile>
Expand All @@ -276,9 +270,6 @@
<ClCompile Include="Source\Mappers\MonumentsMapper\BuildTriggerBuilder.cpp">
<Filter>Mappers\MonumentsMapper</Filter>
</ClCompile>
<ClCompile Include="Source\Mappers\MonumentsMapper\BuildTriggerBuilder.h">
<Filter>Mappers\MonumentsMapper</Filter>
</ClCompile>
<ClCompile Include="..\commonItems\ConverterVersion.cpp">
<Filter>CommonItems</Filter>
</ClCompile>
Expand Down Expand Up @@ -570,6 +561,15 @@
<ClInclude Include="Source\Mappers\AfricanPassesMapper\AfricanPassesMapping.h">
<Filter>Mappers\AfricanPassesMapper</Filter>
</ClInclude>
<ClInclude Include="Source\Mappers\MonumentsMapper\BuildTriggerBuilder.h">
<Filter>Mappers\MonumentsMapper</Filter>
</ClInclude>
<ClInclude Include="Source\Mappers\MonumentsMapper\MonumentsMapper.h">
<Filter>Mappers\MonumentsMapper</Filter>
</ClInclude>
<ClInclude Include="Source\Mappers\MonumentsMapper\MonumentsMapping.h">
<Filter>Mappers\MonumentsMapper</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="EU4World">
Expand Down
2 changes: 1 addition & 1 deletion CK2ToEU4/Source/CK2World/Titles/Title.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Title: commonItems::parser
void setPreviousHolders(const std::map<int, std::shared_ptr<Character>>& thePreviousHolders) { previousHolders = thePreviousHolders; }
void overrideLiege() { liege = deJureLiege; }
void overrideLiege(const std::pair<std::string, std::shared_ptr<Liege>>& theLiege) { liege = theLiege; }
void registerGeneratedLiege(const std::pair<std::string, std::shared_ptr<Title>>& liege) { generatedLiege = liege; }
void registerGeneratedLiege(const std::pair<std::string, std::shared_ptr<Title>>& theLiege) { generatedLiege = theLiege; }
void registerVassal(const std::pair<std::string, std::shared_ptr<Title>>& theVassal) { vassals.insert(theVassal); }
void registerGeneratedVassal(const std::pair<std::string, std::shared_ptr<Title>>& theVassal);
void registerDeJureVassal(const std::pair<std::string, std::shared_ptr<Title>>& theVassal) { deJureVassals.insert(theVassal); }
Expand Down
1 change: 0 additions & 1 deletion CK2ToEU4/Source/CK2World/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ void CK2::World::splitVassals(const Configuration& theConfiguration)
{
const auto& liege = newIndep.second->getLiege().second->getTitle();
liege.second->registerGeneratedVassal(newIndep);
newIndep.second->clearLiege();
newIndep.second->registerGeneratedLiege(liege);
independentTitles.insert(newIndep);
}
Expand Down
33 changes: 11 additions & 22 deletions CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#include "BuildTriggerBuilder.h"
#include "CommonRegexes.h"
#include "ParserHelpers.h"
#include <iomanip>

mappers::BuildTriggerBuilder::BuildTriggerBuilder()
{
registerKeys();
clearRegisteredKeywords();
}

mappers::BuildTriggerBuilder::BuildTriggerBuilder(std::istream& theStream)
{
Expand All @@ -19,27 +12,23 @@ mappers::BuildTriggerBuilder::BuildTriggerBuilder(std::istream& theStream)

void mappers::BuildTriggerBuilder::registerKeys()
{
registerKeyword("religious_groups", [this](const std::string& mods, std::istream& theStream) {
const auto& groups = commonItems::stringList(theStream).getStrings();
registerKeyword("religious_groups", [this](std::istream& theStream) {
const auto& groups = commonItems::getStrings(theStream);
for (auto& group: groups)
{
buildTrigger += ("AND = {\n\t\t\t\treligion_group = " + group + "\n\t\t\t\thas_owner_religion = yes\n\t\t\t}\n\t\t");
}
buildTrigger += "AND = {\n\t\t\t\treligion_group = " + group + "\n\t\t\t\thas_owner_religion = yes\n\t\t\t}\n\t\t";
});
registerKeyword("cultural_groups", [this](const std::string& mods, std::istream& theStream) {
const auto& groups = commonItems::stringList(theStream).getStrings();
registerKeyword("cultural_groups", [this](std::istream& theStream) {
const auto& groups = commonItems::getStrings(theStream);
for (auto& group: groups)
{
buildTrigger += ("AND = {\n\t\t\t\tculture_group = " + group + "\n\t\t\t\thas_owner_culture = yes\n\t\t\t}\n\t\t");
}
buildTrigger += "AND = {\n\t\t\t\tculture_group = " + group + "\n\t\t\t\thas_owner_culture = yes\n\t\t\t}\n\t\t";
});
registerKeyword("cultural", [this](const std::string& mods, std::istream& theStream) {
cultural = commonItems::getString(theStream).find("yes") != std::string::npos;
registerKeyword("cultural", [this](std::istream& theStream) {
cultural = commonItems::getString(theStream) == "yes";
});
registerKeyword("religious", [this](const std::string& mods, std::istream& theStream) {
religious = commonItems::getString(theStream).find("yes") != std::string::npos;
registerKeyword("religious", [this](std::istream& theStream) {
religious = commonItems::getString(theStream) == "yes";
});
registerKeyword("other", [this](const std::string& mods, std::istream& theStream) {
registerKeyword("other", [this](std::istream& theStream) {
auto tempInput = commonItems::stringOfItem(theStream).getString();
tempInput = tempInput.substr(tempInput.find('{') + 1, tempInput.length());
tempInput = tempInput.substr(0, tempInput.find_last_of('}'));
Expand Down
4 changes: 2 additions & 2 deletions CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace mappers
class BuildTriggerBuilder: commonItems::parser
{
public:
BuildTriggerBuilder();
BuildTriggerBuilder(std::istream& theStream);
BuildTriggerBuilder() = default;
explicit BuildTriggerBuilder(std::istream& theStream);

[[nodiscard]] const auto& getBuildTrigger() const { return buildTrigger; }
[[nodiscard]] auto getCultural() const { return cultural; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ mappers::InternalModifiers::InternalModifiers(std::istream& theStream)
void mappers::InternalModifiers::registerKeys()
{
registerRegex(commonItems::catchallRegex, [this](const std::string& mod, std::istream& theStream) {
modifierMap.emplace(mod, commonItems::doubleList(theStream).getDoubles());
modifierMap.emplace(mod, commonItems::getDoubles(theStream));
});
}
29 changes: 14 additions & 15 deletions CK2ToEU4/Source/Mappers/MonumentsMapper/MonumentsMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "CommonRegexes.h"
#include "InternalModifiers.h"
#include "ParserHelpers.h"
#include <iomanip>

mappers::MonumentsMapping::MonumentsMapping(std::istream& theStream)
{
Expand All @@ -14,28 +13,28 @@ mappers::MonumentsMapping::MonumentsMapping(std::istream& theStream)

void mappers::MonumentsMapping::registerKeys()
{
registerKeyword("properties", [this](const std::string& mods, std::istream& theStream) {
registerKeyword("properties", [this](std::istream& theStream) {
isBase = true; // Only the wonder bases have properties
auto movedStr = commonItems::stringOfItem(theStream).getString();
canBeMoved = (movedStr.find("can_be_moved = yes") != std::string::npos);
canBeMoved = movedStr.find("can_be_moved = yes") != std::string::npos;
});
registerKeyword("build_trigger", [this](const std::string& mods, std::istream& theStream) {
registerKeyword("build_trigger", [this](std::istream& theStream) {
const BuildTriggerBuilder builder(theStream);
buildTrigger = "OR = {\n\t\t\t";
BuildTriggerBuilder builder(theStream);
buildTrigger += builder.getBuildTrigger();
cultural = builder.getCultural();
religious = builder.getReligious();
});
registerKeyword("province_modifiers", [this](const std::string& mods, std::istream& theStream) {
registerKeyword("province_modifiers", [this](std::istream& theStream) {
AddProvinceSet(theStream);
});
registerKeyword("area_modifiers", [this](const std::string& mods, std::istream& theStream) {
registerKeyword("area_modifiers", [this](std::istream& theStream) {
AddAreaSet(theStream);
});
registerKeyword("country_modifiers", [this](const std::string& mods, std::istream& theStream) {
registerKeyword("country_modifiers", [this](std::istream& theStream) {
AddCountrySet(theStream);
});
registerKeyword("on_upgraded", [this](const std::string& mods, std::istream& theStream) {
registerKeyword("on_upgraded", [this](std::istream& theStream) {
auto tempInput = commonItems::stringOfItem(theStream).getString();
tempInput = tempInput.substr(tempInput.find('{') + 1, tempInput.length());
tempInput = tempInput.substr(0, tempInput.find('}'));
Expand All @@ -46,22 +45,22 @@ void mappers::MonumentsMapping::registerKeys()

void mappers::MonumentsMapping::AddProvinceSet(std::istream& theStream)
{
InternalModifiers mods(theStream);
for (auto tempMod: mods.getModifierMap())
const InternalModifiers mods(theStream);
for (const auto& tempMod: mods.getModifierMap())
if (!provinceModifiers.contains(tempMod.first))
provinceModifiers.emplace(tempMod.first, tempMod.second);
}
void mappers::MonumentsMapping::AddAreaSet(std::istream& theStream)
{
InternalModifiers mods(theStream);
for (auto tempMod: mods.getModifierMap())
const InternalModifiers mods(theStream);
for (const auto& tempMod: mods.getModifierMap())
if (!areaModifiers.contains(tempMod.first))
areaModifiers.emplace(tempMod.first, tempMod.second);
}
void mappers::MonumentsMapping::AddCountrySet(std::istream& theStream)
{
InternalModifiers mods(theStream);
for (auto tempMod: mods.getModifierMap())
const InternalModifiers mods(theStream);
for (const auto& tempMod: mods.getModifierMap())
if (!countryModifiers.contains(tempMod.first))
countryModifiers.emplace(tempMod.first, tempMod.second);
}
20 changes: 10 additions & 10 deletions CK2ToEU4/Source/Mappers/MonumentsMapper/MonumentsMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ class MonumentsMapping: commonItems::parser
{
public:
MonumentsMapping() = default;
MonumentsMapping(std::istream& theStream);
explicit MonumentsMapping(std::istream& theStream);

void AddProvinceSet(std::istream& theStream);
void AddAreaSet(std::istream& theStream);
void AddCountrySet(std::istream& theStream);

[[nodiscard]] auto getIsBase() { return isBase; }
[[nodiscard]] auto getProvinceModifiers() { return provinceModifiers; }
[[nodiscard]] auto getAreaModifiers() { return areaModifiers; }
[[nodiscard]] auto getCountryModifiers() { return countryModifiers; }
[[nodiscard]] auto getOnUpgraded() { return onUpgraded; }
[[nodiscard]] auto isOfBuilderCulture() { return cultural; }
[[nodiscard]] auto isOfBuilderReligion() { return religious; }
[[nodiscard]] auto getBuildTrigger() { return buildTrigger; }
[[nodiscard]] auto getCanBeMoved() { return canBeMoved; }
[[nodiscard]] auto getIsBase() const { return isBase; }
[[nodiscard]] auto getProvinceModifiers() const { return provinceModifiers; }
[[nodiscard]] auto getAreaModifiers() const { return areaModifiers; }
[[nodiscard]] auto getCountryModifiers() const { return countryModifiers; }
[[nodiscard]] auto getOnUpgraded() const { return onUpgraded; }
[[nodiscard]] auto isOfBuilderCulture() const { return cultural; }
[[nodiscard]] auto isOfBuilderReligion() const { return religious; }
[[nodiscard]] auto getBuildTrigger() const { return buildTrigger; }
[[nodiscard]] auto getCanBeMoved() const { return canBeMoved; }


private:
Expand Down

0 comments on commit 449ac58

Please sign in to comment.