Skip to content

Commit

Permalink
Fix float value being read as integer (#220) #patch
Browse files Browse the repository at this point in the history
* Update Fronter

* Fix float value being read as integer

* Minor ReSharper tweaks

* Update commonItems
  • Loading branch information
IhateTrains authored May 7, 2021
1 parent 8470228 commit 782b29b
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Fronter
2 changes: 1 addition & 1 deletion ImperatorToCK3/Source/CK3/CK3World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "ConverterVersion.h"
#include <filesystem>
#include <ranges>
#include <math.h>
#include <cmath>



Expand Down
8 changes: 8 additions & 0 deletions ImperatorToCK3/Source/Imperator/Characters/Characters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Character> newCharacter = characterFactory.getCharacter(theStream, charID, genes);
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Source/Imperator/Characters/Characters.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Characters: commonItems::parser {
Characters() = default;
Characters(std::istream& theStream, const std::shared_ptr<GenesDB>& genesDB);

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

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

Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Source/Imperator/Provinces/Province.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Province {
std::string religion;
std::pair<unsigned long long, std::shared_ptr<Country>> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int>(valStr);
province->civilizationValue = commonItems::getDouble(theStream);
});
registerKeyword("province_rank", [this](std::istream& theStream) {
const auto provinceRankStr = commonItems::getString(theStream);
Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3/Source/ImperatorToCK3Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ std::optional<mappers::LocBlock> mappers::LocalizationMapper::getLocBlockForKey(
}


void mappers::LocBlock::modifyForEveryLanguage(const LocBlock& otherLocBlock, std::function<void(std::string&, const std::string&)> modifyingFunction) {
void mappers::LocBlock::modifyForEveryLanguage(const LocBlock& otherLocBlock, const std::function<void(std::string&, const std::string&)>& modifyingFunction) {
modifyingFunction(english, otherLocBlock.english);
modifyingFunction(french, otherLocBlock.french);
modifyingFunction(german, otherLocBlock.german);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct LocBlock {
std::string russian;
std::string simp_chinese;
std::string spanish;
void modifyForEveryLanguage(const LocBlock& otherLocBlock, std::function<void(std::string&, const std::string&)> modifyingFunction);
void modifyForEveryLanguage(const LocBlock& otherLocBlock, const std::function<void(std::string&, const std::string&)>& modifyingFunction);
} LocBlock;

class LocalizationMapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ void mappers::ReligionMapper::registerKeys() {
void mappers::ReligionMapper::loadRegionMappers(std::shared_ptr<ImperatorRegionMapper> impRegionMapper, std::shared_ptr<CK3RegionMapper> _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);
Expand All @@ -46,8 +48,9 @@ void mappers::ReligionMapper::loadRegionMappers(std::shared_ptr<ImperatorRegionM
std::optional<std::string> 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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

Expand Down
2 changes: 1 addition & 1 deletion commonItems
Submodule commonItems updated 1 files
+9 −7 CommonRegexes.h

0 comments on commit 782b29b

Please sign in to comment.