Skip to content

Commit

Permalink
Use getHolderID() instead of getHolder()->ID (#225) #patch
Browse files Browse the repository at this point in the history
* Update commonItems

* Fix tests

* Update ImperatorToCK3.vcxproj

* Update googletest

* Update ImperatorToCK3Tests.vcxproj

* Update ImperatorToCK3Tests.vcxproj.filters
  • Loading branch information
IhateTrains authored May 19, 2021
1 parent 728eedf commit 0602d81
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 173 deletions.
85 changes: 0 additions & 85 deletions ImperatorToCK3/ImperatorToCK3.vcxproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
Expand All @@ -25,19 +17,6 @@
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
Expand All @@ -58,12 +37,6 @@
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
Expand Down Expand Up @@ -97,38 +70,6 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ExecutablePath>$(ExecutablePath)</ExecutablePath>
<OutDir>$(ProjectDir)\..\$(Configuration)\ImperatorToCK3\</OutDir>
<IntDir>$(SolutionDir)\ReleaseIntermediate\</IntDir>
<TargetName>ImperatorToCK3Converter</TargetName>
<IncludePath>$(UniversalCRT_IncludePath);$(IncludePath)</IncludePath>
<ReferencePath>$(ReferencePath)</ReferencePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<LibraryWPath>$(LibraryWPath)</LibraryWPath>
<SourcePath>$(SourcePath)</SourcePath>
<ExcludePath>$(ExcludePath)</ExcludePath>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(ProjectDir)\..\$(Configuration)\ImperatorToCK3\</OutDir>
<IntDir>$(SolutionDir)\ReleaseIntermediate\</IntDir>
<TargetName>ImperatorToCK3Converter</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>..\commonItems;..\ZipLib;$(WindowsSDK_IncludePath)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_UNICODE;UNICODE;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
Expand Down Expand Up @@ -156,32 +97,6 @@
</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>..\commonItems;..\commonItems\compile-time-regular-expressions\single-header;..\cpp-base64;..\ZipLib;$(WindowsSDK_IncludePath)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_UNICODE;UNICODE;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>Copy_Files.bat</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copying Data Files</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
Expand Down
11 changes: 5 additions & 6 deletions ImperatorToCK3/Source/CK3/CK3World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,13 @@ void CK3::World::overWriteCountiesHistory() {
title->setHolder(holderItr->second);
}
title->setDeFactoLiege(nullptr);
countyHoldersCache.emplace(title->getHolder()->ID);
countyHoldersCache.emplace(title->getHolderID());
}
}
}
else { // county is probably outside of Imperator map
const auto& titleHolderID = title->getHolder()->ID;
if (!titleHolderID.empty() && titleHolderID != "0")
countyHoldersCache.emplace(titleHolderID);
if (!title->getHolderID().empty() && title->getHolderID() != "0")
countyHoldersCache.emplace(title->getHolderID());
}
}
}
Expand All @@ -328,7 +327,7 @@ void CK3::World::removeInvalidLandlessTitles() {
for (const auto& [name, title] : getTitles()) {
//important check: if duchy/kingdom/empire title holder holds no county (is landless), remove the title
// this also removes landless titles initialized from Imperator
if (title->getRank()!=TitleRank::county && title->getRank()!=TitleRank::barony && !countyHoldersCache.contains(title->getHolder()->ID)) {
if (title->getRank()!=TitleRank::county && title->getRank()!=TitleRank::barony && !countyHoldersCache.contains(title->getHolderID())) {
if (!getTitles().find(name)->second->isLandless()) { // does not have landless attribute set to true
if (title->isImportedOrUpdatedFromImperator() && name.find("IMPTOCK3") != string::npos) {
removedGeneratedTitles.emplace(name);
Expand Down Expand Up @@ -373,7 +372,7 @@ void CK3::World::purgeLandlessVanillaCharacters() {
}

for (const auto& titlePtr : getTitles() | std::views::values) {
farewellIDs.erase(titlePtr->getHolder()->ID);
farewellIDs.erase(titlePtr->getHolderID());
}
for (const auto& characterId : farewellIDs) {
characters[characterId]->breakAllLinks();
Expand Down
3 changes: 2 additions & 1 deletion ImperatorToCK3/Source/CK3/Titles/Title.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class Title: commonItems::parser, public std::enable_shared_from_this<Title> {
[[nodiscard]] auto getRank() const { return rank; }
[[nodiscard]] auto isLandless() const { return landless; }
[[nodiscard]] auto hasDefiniteForm() const { return definiteForm; }
[[nodiscard]] const auto& getHolder() const { return holderPtr; }
[[nodiscard]] const auto& getHolderID() const { return history.holder; }
[[nodiscard]] const auto& getHolderPtr() const { return holderPtr; }
[[nodiscard]] const auto& getGovernment() const { return history.government; }
[[nodiscard]] const auto& getDevelopmentLevel() const { return history.developmentLevel; }
[[nodiscard]] std::optional<int> getOwnOrInheritedDevelopmentLevel() const;
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Source/CK3Outputter/outTitles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void CK3::outputTitleHistory(const shared_ptr<Title>& title, ofstream& outputStr
if (deFactoLiege)
outputStream << "\t\tliege = " << deFactoLiege->getName() << "\n";

outputStream << "\t\tholder = " << title->getHolder() << "\n";
outputStream << "\t\tholder = " << title->getHolderID() << "\n";

const auto& govOpt = title->getGovernment();
if (govOpt)
Expand Down
13 changes: 10 additions & 3 deletions ImperatorToCK3Tests/CK3WorldTests/Titles/TitleTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,18 @@ TEST(CK3World_TitleTests, membersDefaultToBlank) {
ASSERT_FALSE(theTitle.getCapitalCounty());
}

TEST(CK3World_TitleTests, holderDefaultsTo0String) {
TEST(CK3World_TitleTests, holderIdDefaultsTo0String) {
std::stringstream input;
const CK3::Title theTitle;

ASSERT_EQ("0", theTitle.getHolder()->ID);
ASSERT_EQ("0", theTitle.getHolderID());
}

TEST(CK3World_TitleTests, holderPtrDefaultsToNullptr) {
std::stringstream input;
const CK3::Title theTitle;

ASSERT_EQ(nullptr, theTitle.getHolderPtr());
}

TEST(CK3World_TitleTests, capitalBaronyDefaultsToNullopt) {
Expand All @@ -78,7 +85,7 @@ TEST(CK3World_TitleTests, historyCanBeAdded) {
CK3::Title title;
title.addHistory(CK3::LandedTitles{}, history);

ASSERT_EQ("420", title.getHolder()->ID);
ASSERT_EQ("420", title.getHolderID());
ASSERT_EQ(20, *title.getDevelopmentLevel());
}

Expand Down
77 changes: 2 additions & 75 deletions ImperatorToCK3Tests/ImperatorToCK3Tests.vcxproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
Expand All @@ -25,19 +17,6 @@
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
Expand All @@ -56,28 +35,13 @@
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>..\commonItems;..\googletest\googlemock\include;..\googletest\googlemock;..\googletest\googletest\include;..\googletest\googletest;..\googletest;$(IncludePath)</IncludePath>
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\commonItems;..\googletest\googlemock\include;..\googletest\googlemock;..\googletest\googletest\include;..\googletest\googletest;..\googletest;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\</IntDir>
Expand All @@ -90,45 +54,6 @@
<IntDir>$(Configuration)\</IntDir>
<IncludePath>..\commonItems;..\googletest\googlemock\include;..\googletest\googlemock;..\googletest\googletest\include;..\googletest\googletest;..\googletest;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>..\cpp-base64;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>$(ProjectDir)$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>$(ProjectDir)$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
Expand Down Expand Up @@ -173,6 +98,8 @@
<ClCompile Include="..\commonItems\OSCommonLayer.cpp" />
<ClCompile Include="..\commonItems\StringUtils.cpp" />
<ClCompile Include="..\cpp-base64\base64.cpp" />
<ClCompile Include="..\ImperatorToCK3\Source\CK3Outputter\outCharacter.cpp" />
<ClCompile Include="..\ImperatorToCK3\Source\CK3\Character\CK3Character.cpp" />
<ClCompile Include="..\ImperatorToCK3\Source\CK3\Dynasties\Dynasty.cpp" />
<ClCompile Include="..\ImperatorToCK3\Source\CK3\Province\CK3Province.cpp" />
<ClCompile Include="..\ImperatorToCK3\Source\CK3\Province\CK3ProvinceMappings.cpp" />
Expand Down
12 changes: 12 additions & 0 deletions ImperatorToCK3Tests/ImperatorToCK3Tests.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
<Filter Include="MapperTests\DeathReasonMapper">
<UniqueIdentifier>{019b65d3-db9b-416f-a670-fecff54b6fb6}</UniqueIdentifier>
</Filter>
<Filter Include="Sources\CK3\Characters">
<UniqueIdentifier>{56431e02-d0c3-4092-b36e-c00fc3af9a79}</UniqueIdentifier>
</Filter>
<Filter Include="Sources\CK3Outputter">
<UniqueIdentifier>{4db30bce-7d0e-4982-bab0-82d11150afad}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ImperatorWorldTests\Families\FamilyTests.cpp">
Expand Down Expand Up @@ -531,6 +537,12 @@
<ClCompile Include="..\ImperatorToCK3\Source\CommonUtilities\ContainerField.cpp">
<Filter>Sources\CommonUtilities</Filter>
</ClCompile>
<ClCompile Include="..\ImperatorToCK3\Source\CK3\Character\CK3Character.cpp">
<Filter>Sources\CK3\Characters</Filter>
</ClCompile>
<ClCompile Include="..\ImperatorToCK3\Source\CK3Outputter\outCharacter.cpp">
<Filter>Sources\CK3Outputter</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\ImperatorToCK3\Source\Imperator\Provinces\Province.h">
Expand Down
2 changes: 1 addition & 1 deletion commonItems
Submodule commonItems updated 3 files
+6 −0 ParserHelpers.cpp
+1 −0 ParserHelpers.h
+36 −0 tests/ParserHelperTests.cpp

0 comments on commit 0602d81

Please sign in to comment.