Skip to content

Commit 782b29b

Browse files
authored
Fix float value being read as integer (#220) #patch
* Update Fronter * Fix float value being read as integer * Minor ReSharper tweaks * Update commonItems
1 parent 8470228 commit 782b29b

File tree

12 files changed

+25
-14
lines changed

12 files changed

+25
-14
lines changed

Fronter

ImperatorToCK3/Source/CK3/CK3World.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "ConverterVersion.h"
1313
#include <filesystem>
1414
#include <ranges>
15-
#include <math.h>
15+
#include <cmath>
1616

1717

1818

ImperatorToCK3/Source/Imperator/Characters/Characters.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ Imperator::Characters::Characters(std::istream& theStream, const std::shared_ptr
1818
}
1919

2020

21+
Imperator::Characters& Imperator::Characters::operator=(const Characters& other) {
22+
if (this != &other) {
23+
this->characters = other.characters;
24+
}
25+
return *this;
26+
}
27+
28+
2129
void Imperator::Characters::registerKeys() {
2230
registerRegex(commonItems::integerRegex, [this](const std::string& charID, std::istream& theStream) {
2331
std::shared_ptr<Character> newCharacter = characterFactory.getCharacter(theStream, charID, genes);

ImperatorToCK3/Source/Imperator/Characters/Characters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Characters: commonItems::parser {
1616
Characters() = default;
1717
Characters(std::istream& theStream, const std::shared_ptr<GenesDB>& genesDB);
1818

19-
Characters& operator= (const Characters& obj) { this->characters = obj.characters; return *this; }
19+
Characters& operator=(const Characters& other);
2020

2121
[[nodiscard]] const auto& getCharacters() const { return characters; }
2222

ImperatorToCK3/Source/Imperator/Provinces/Province.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Province {
4444
std::string religion;
4545
std::pair<unsigned long long, std::shared_ptr<Country>> ownerCountry{ 0, nullptr };
4646
unsigned long long controller = 0;
47-
unsigned int civilizationValue = 0;
47+
double civilizationValue = 0;
4848
ProvinceRank provinceRank = ProvinceRank::settlement;
4949
bool fort = false;
5050
bool holySite = false;

ImperatorToCK3/Source/Imperator/Provinces/ProvinceFactory.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ Imperator::Province::Factory::Factory() {
2727
province->pops.emplace(commonItems::getULlong(theStream), nullptr);
2828
});
2929
registerKeyword("civilization_value", [this](std::istream& theStream) {
30-
const auto valStr = commonItems::getString(theStream);
31-
province->civilizationValue = commonItems::stringToInteger<unsigned int>(valStr);
30+
province->civilizationValue = commonItems::getDouble(theStream);
3231
});
3332
registerKeyword("province_rank", [this](std::istream& theStream) {
3433
const auto provinceRankStr = commonItems::getString(theStream);

ImperatorToCK3/Source/ImperatorToCK3Converter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212

1313
void logGameVersions(const std::string& imperatorPath, const std::string& ck3Path) {
14-
nlohmann::json impLauncherSettings, ck3LauncherSettings;
15-
1614
try {
15+
nlohmann::json impLauncherSettings;
1716
std::ifstream impSettingsFile(imperatorPath + "/launcher/launcher-settings.json");
1817
impSettingsFile >> impLauncherSettings;
1918
impSettingsFile.close();
@@ -24,6 +23,7 @@ void logGameVersions(const std::string& imperatorPath, const std::string& ck3Pat
2423
}
2524

2625
try {
26+
nlohmann::json ck3LauncherSettings;
2727
std::ifstream ck3SettingsFile(ck3Path + "/launcher/launcher-settings.json");
2828
ck3SettingsFile >> ck3LauncherSettings;
2929
ck3SettingsFile.close();

ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ std::optional<mappers::LocBlock> mappers::LocalizationMapper::getLocBlockForKey(
124124
}
125125

126126

127-
void mappers::LocBlock::modifyForEveryLanguage(const LocBlock& otherLocBlock, std::function<void(std::string&, const std::string&)> modifyingFunction) {
127+
void mappers::LocBlock::modifyForEveryLanguage(const LocBlock& otherLocBlock, const std::function<void(std::string&, const std::string&)>& modifyingFunction) {
128128
modifyingFunction(english, otherLocBlock.english);
129129
modifyingFunction(french, otherLocBlock.french);
130130
modifyingFunction(german, otherLocBlock.german);

ImperatorToCK3/Source/Mappers/LocalizationMapper/LocalizationMapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef struct LocBlock {
2121
std::string russian;
2222
std::string simp_chinese;
2323
std::string spanish;
24-
void modifyForEveryLanguage(const LocBlock& otherLocBlock, std::function<void(std::string&, const std::string&)> modifyingFunction);
24+
void modifyForEveryLanguage(const LocBlock& otherLocBlock, const std::function<void(std::string&, const std::string&)>& modifyingFunction);
2525
} LocBlock;
2626

2727
class LocalizationMapper {

ImperatorToCK3/Source/Mappers/ReligionMapper/ReligionMapper.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ void mappers::ReligionMapper::registerKeys() {
3232
void mappers::ReligionMapper::loadRegionMappers(std::shared_ptr<ImperatorRegionMapper> impRegionMapper, std::shared_ptr<CK3RegionMapper> _ck3RegionMapper) {
3333
const auto imperatorRegionMapper = std::move(impRegionMapper);
3434
const auto ck3RegionMapper = std::move(_ck3RegionMapper);
35-
if (!imperatorRegionMapper)
35+
if (!imperatorRegionMapper) {
3636
throw std::runtime_error("Religion Mapper: Imperator Region Mapper is unloaded!");
37-
if (!ck3RegionMapper)
37+
}
38+
if (!ck3RegionMapper) {
3839
throw std::runtime_error("Religion Mapper: CK3 Region Mapper is unloaded!");
40+
}
3941
for (auto& mapping : religionMappings) {
4042
mapping.insertImperatorRegionMapper(imperatorRegionMapper);
4143
mapping.insertCK3RegionMapper(ck3RegionMapper);
@@ -46,8 +48,9 @@ void mappers::ReligionMapper::loadRegionMappers(std::shared_ptr<ImperatorRegionM
4648
std::optional<std::string> mappers::ReligionMapper::match(const std::string& impReligion, const unsigned long long ck3ProvinceID, const unsigned long long impProvinceID) const {
4749
for (const auto& religionMapping : religionMappings) {
4850
const auto& possibleMatch = religionMapping.match(impReligion, ck3ProvinceID, impProvinceID);
49-
if (possibleMatch)
51+
if (possibleMatch) {
5052
return *possibleMatch;
53+
}
5154
}
5255
return std::nullopt;
5356
}

0 commit comments

Comments
 (0)