From 782b29bbbbd483f2b4de59837e234cba04bf62e2 Mon Sep 17 00:00:00 2001 From: IhateTrains Date: Fri, 7 May 2021 04:36:03 +0200 Subject: [PATCH] Fix float value being read as integer (#220) #patch * Update Fronter * Fix float value being read as integer * Minor ReSharper tweaks * Update commonItems --- Fronter | 2 +- ImperatorToCK3/Source/CK3/CK3World.cpp | 2 +- .../Source/Imperator/Characters/Characters.cpp | 8 ++++++++ ImperatorToCK3/Source/Imperator/Characters/Characters.h | 2 +- ImperatorToCK3/Source/Imperator/Provinces/Province.h | 2 +- .../Source/Imperator/Provinces/ProvinceFactory.cpp | 3 +-- ImperatorToCK3/Source/ImperatorToCK3Converter.cpp | 4 ++-- .../Mappers/LocalizationMapper/LocalizationMapper.cpp | 2 +- .../Mappers/LocalizationMapper/LocalizationMapper.h | 2 +- .../Source/Mappers/ReligionMapper/ReligionMapper.cpp | 9 ++++++--- .../Source/Mappers/TagTitleMapper/TagTitleMapper.cpp | 1 + commonItems | 2 +- 12 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Fronter b/Fronter index 98cfc07d6..d25d1d2bf 160000 --- a/Fronter +++ b/Fronter @@ -1 +1 @@ -Subproject commit 98cfc07d625bd2f856af733b222a19e1d88f6fb4 +Subproject commit d25d1d2bf450af9c779835e5abab06f0c238627e diff --git a/ImperatorToCK3/Source/CK3/CK3World.cpp b/ImperatorToCK3/Source/CK3/CK3World.cpp index 522d1741b..fffaa6b47 100644 --- a/ImperatorToCK3/Source/CK3/CK3World.cpp +++ b/ImperatorToCK3/Source/CK3/CK3World.cpp @@ -12,7 +12,7 @@ #include "ConverterVersion.h" #include #include -#include +#include diff --git a/ImperatorToCK3/Source/Imperator/Characters/Characters.cpp b/ImperatorToCK3/Source/Imperator/Characters/Characters.cpp index 54e77b168..a7f213bf7 100644 --- a/ImperatorToCK3/Source/Imperator/Characters/Characters.cpp +++ b/ImperatorToCK3/Source/Imperator/Characters/Characters.cpp @@ -18,6 +18,14 @@ Imperator::Characters::Characters(std::istream& theStream, const std::shared_ptr } +Imperator::Characters& Imperator::Characters::operator=(const Characters& other) { + if (this != &other) { + this->characters = other.characters; + } + return *this; +} + + void Imperator::Characters::registerKeys() { registerRegex(commonItems::integerRegex, [this](const std::string& charID, std::istream& theStream) { std::shared_ptr newCharacter = characterFactory.getCharacter(theStream, charID, genes); diff --git a/ImperatorToCK3/Source/Imperator/Characters/Characters.h b/ImperatorToCK3/Source/Imperator/Characters/Characters.h index 9dec368c6..7e7c10b3c 100644 --- a/ImperatorToCK3/Source/Imperator/Characters/Characters.h +++ b/ImperatorToCK3/Source/Imperator/Characters/Characters.h @@ -16,7 +16,7 @@ class Characters: commonItems::parser { Characters() = default; Characters(std::istream& theStream, const std::shared_ptr& genesDB); - Characters& operator= (const Characters& obj) { this->characters = obj.characters; return *this; } + Characters& operator=(const Characters& other); [[nodiscard]] const auto& getCharacters() const { return characters; } diff --git a/ImperatorToCK3/Source/Imperator/Provinces/Province.h b/ImperatorToCK3/Source/Imperator/Provinces/Province.h index 2427e33d4..e9ca38612 100644 --- a/ImperatorToCK3/Source/Imperator/Provinces/Province.h +++ b/ImperatorToCK3/Source/Imperator/Provinces/Province.h @@ -44,7 +44,7 @@ class Province { std::string religion; std::pair> ownerCountry{ 0, nullptr }; unsigned long long controller = 0; - unsigned int civilizationValue = 0; + double civilizationValue = 0; ProvinceRank provinceRank = ProvinceRank::settlement; bool fort = false; bool holySite = false; diff --git a/ImperatorToCK3/Source/Imperator/Provinces/ProvinceFactory.cpp b/ImperatorToCK3/Source/Imperator/Provinces/ProvinceFactory.cpp index e2e1ba7eb..77e910afa 100644 --- a/ImperatorToCK3/Source/Imperator/Provinces/ProvinceFactory.cpp +++ b/ImperatorToCK3/Source/Imperator/Provinces/ProvinceFactory.cpp @@ -27,8 +27,7 @@ Imperator::Province::Factory::Factory() { province->pops.emplace(commonItems::getULlong(theStream), nullptr); }); registerKeyword("civilization_value", [this](std::istream& theStream) { - const auto valStr = commonItems::getString(theStream); - province->civilizationValue = commonItems::stringToInteger(valStr); + province->civilizationValue = commonItems::getDouble(theStream); }); registerKeyword("province_rank", [this](std::istream& theStream) { const auto provinceRankStr = commonItems::getString(theStream); diff --git a/ImperatorToCK3/Source/ImperatorToCK3Converter.cpp b/ImperatorToCK3/Source/ImperatorToCK3Converter.cpp index 899d932ee..9d914b132 100644 --- a/ImperatorToCK3/Source/ImperatorToCK3Converter.cpp +++ b/ImperatorToCK3/Source/ImperatorToCK3Converter.cpp @@ -11,9 +11,8 @@ void logGameVersions(const std::string& imperatorPath, const std::string& ck3Path) { - nlohmann::json impLauncherSettings, ck3LauncherSettings; - try { + nlohmann::json impLauncherSettings; std::ifstream impSettingsFile(imperatorPath + "/launcher/launcher-settings.json"); impSettingsFile >> impLauncherSettings; impSettingsFile.close(); @@ -24,6 +23,7 @@ void logGameVersions(const std::string& imperatorPath, const std::string& ck3Pat } try { + nlohmann::json ck3LauncherSettings; std::ifstream ck3SettingsFile(ck3Path + "/launcher/launcher-settings.json"); ck3SettingsFile >> ck3LauncherSettings; ck3SettingsFile.close(); diff --git a/ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.cpp b/ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.cpp index 5238e33b0..f8253bcdf 100644 --- a/ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.cpp +++ b/ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.cpp @@ -124,7 +124,7 @@ std::optional mappers::LocalizationMapper::getLocBlockForKey( } -void mappers::LocBlock::modifyForEveryLanguage(const LocBlock& otherLocBlock, std::function modifyingFunction) { +void mappers::LocBlock::modifyForEveryLanguage(const LocBlock& otherLocBlock, const std::function& modifyingFunction) { modifyingFunction(english, otherLocBlock.english); modifyingFunction(french, otherLocBlock.french); modifyingFunction(german, otherLocBlock.german); diff --git a/ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.h b/ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.h index efe82e68f..7b7cedbae 100644 --- a/ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.h +++ b/ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.h @@ -21,7 +21,7 @@ typedef struct LocBlock { std::string russian; std::string simp_chinese; std::string spanish; - void modifyForEveryLanguage(const LocBlock& otherLocBlock, std::function modifyingFunction); + void modifyForEveryLanguage(const LocBlock& otherLocBlock, const std::function& modifyingFunction); } LocBlock; class LocalizationMapper { diff --git a/ImperatorToCK3/Source/Mappers/ReligionMapper/ReligionMapper.cpp b/ImperatorToCK3/Source/Mappers/ReligionMapper/ReligionMapper.cpp index 9a7bca2ed..982ae511a 100644 --- a/ImperatorToCK3/Source/Mappers/ReligionMapper/ReligionMapper.cpp +++ b/ImperatorToCK3/Source/Mappers/ReligionMapper/ReligionMapper.cpp @@ -32,10 +32,12 @@ void mappers::ReligionMapper::registerKeys() { void mappers::ReligionMapper::loadRegionMappers(std::shared_ptr impRegionMapper, std::shared_ptr _ck3RegionMapper) { const auto imperatorRegionMapper = std::move(impRegionMapper); const auto ck3RegionMapper = std::move(_ck3RegionMapper); - if (!imperatorRegionMapper) + if (!imperatorRegionMapper) { throw std::runtime_error("Religion Mapper: Imperator Region Mapper is unloaded!"); - if (!ck3RegionMapper) + } + if (!ck3RegionMapper) { throw std::runtime_error("Religion Mapper: CK3 Region Mapper is unloaded!"); + } for (auto& mapping : religionMappings) { mapping.insertImperatorRegionMapper(imperatorRegionMapper); mapping.insertCK3RegionMapper(ck3RegionMapper); @@ -46,8 +48,9 @@ void mappers::ReligionMapper::loadRegionMappers(std::shared_ptr mappers::ReligionMapper::match(const std::string& impReligion, const unsigned long long ck3ProvinceID, const unsigned long long impProvinceID) const { for (const auto& religionMapping : religionMappings) { const auto& possibleMatch = religionMapping.match(impReligion, ck3ProvinceID, impProvinceID); - if (possibleMatch) + if (possibleMatch) { return *possibleMatch; + } } return std::nullopt; } \ No newline at end of file diff --git a/ImperatorToCK3/Source/Mappers/TagTitleMapper/TagTitleMapper.cpp b/ImperatorToCK3/Source/Mappers/TagTitleMapper/TagTitleMapper.cpp index 37afd732e..855c9e224 100644 --- a/ImperatorToCK3/Source/Mappers/TagTitleMapper/TagTitleMapper.cpp +++ b/ImperatorToCK3/Source/Mappers/TagTitleMapper/TagTitleMapper.cpp @@ -35,6 +35,7 @@ std::string mappers::TagTitleMapper::getCK3TitleRank(const Imperator::countryRan case Imperator::countryRankEnum::regionalPower: return "k"; case Imperator::countryRankEnum::majorPower: return "k"; case Imperator::countryRankEnum::greatPower: return "e"; + default: return "d"; } } diff --git a/commonItems b/commonItems index 0c8535ad3..e905578bc 160000 --- a/commonItems +++ b/commonItems @@ -1 +1 @@ -Subproject commit 0c8535ad39c2aa150afa155c1df16540c1340448 +Subproject commit e905578bc6c17f79e55f0acea45f693ababd9459