Update SortRdb code and add it to project

This commit is contained in:
zilmar 2022-10-24 21:00:51 +10:30
parent 6c9237f603
commit edeaf14471
3 changed files with 47 additions and 65 deletions

View File

@ -68,6 +68,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "discord-rpc", "Source\3rdPa
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project64-input", "Source\Project64-input\Project64-input.vcxproj", "{D3F979CE-8FA7-48C9-A2B3-A33594B48536}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project64-input", "Source\Project64-input\Project64-input.vcxproj", "{D3F979CE-8FA7-48C9-A2B3-A33594B48536}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SortRdb", "Source\SortRdb\SortRdb.vcxproj", "{5788717F-E3D4-40CF-9637-3A2AEE85BB81}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
@ -235,6 +237,12 @@ Global
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|Win32.Build.0 = Release|Win32 {D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|Win32.Build.0 = Release|Win32
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|x64.ActiveCfg = Release|x64 {D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|x64.ActiveCfg = Release|x64
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|x64.Build.0 = Release|x64 {D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|x64.Build.0 = Release|x64
{5788717F-E3D4-40CF-9637-3A2AEE85BB81}.Debug|Win32.ActiveCfg = Debug|Win32
{5788717F-E3D4-40CF-9637-3A2AEE85BB81}.Debug|Win32.Build.0 = Debug|Win32
{5788717F-E3D4-40CF-9637-3A2AEE85BB81}.Debug|x64.ActiveCfg = Debug|Win32
{5788717F-E3D4-40CF-9637-3A2AEE85BB81}.Release|Win32.ActiveCfg = Release|Win32
{5788717F-E3D4-40CF-9637-3A2AEE85BB81}.Release|Win32.Build.0 = Release|Win32
{5788717F-E3D4-40CF-9637-3A2AEE85BB81}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -13,42 +13,17 @@
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{5788717F-E3D4-40CF-9637-3A2AEE85BB81}</ProjectGuid> <ProjectGuid>{5788717F-E3D4-40CF-9637-3A2AEE85BB81}</ProjectGuid>
<RootNamespace>SortRdb</RootNamespace> <RootNamespace>SortRdb</RootNamespace>
<Keyword>Win32Proj</Keyword> </PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ImportGroup Label="PropertySheets">
<ConfigurationType>Application</ConfigurationType> <Import Project="$(SolutionDir)PropertySheets\Platform.$(Configuration).props" />
<PlatformToolset>v120</PlatformToolset> </ImportGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</ImportGroup> <ItemDefinitionGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)PropertySheets/Win32.Release.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)PropertySheets/Win32.Debug.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.21005.1</_ProjectFileVersion>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader />
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<PrecompiledHeader /> <PrecompiledHeader />
</ClCompile> </ClCompile>
@ -65,7 +40,4 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> </Project>

View File

@ -1,5 +1,6 @@
#include <windows.h> #include <windows.h>
#include <common/IniFileClass.h> #include <Common/IniFile.h>
#include <Common/StdString.h>
#include <set> #include <set>
int main (int argc, char *argv[]) int main (int argc, char *argv[])
@ -232,27 +233,28 @@ int main (int argc, char *argv[])
PDNames.insert("Yoshi's Story BootEmu (PD)"); PDNames.insert("Yoshi's Story BootEmu (PD)");
strmap GoodNameSections, PDNameSections; strmap GoodNameSections, PDNameSections;
for (size_t i = 0, n = Sections.size(); i < n; i++) for (CIniFile::SectionList::const_iterator SectionItr = Sections.begin(); SectionItr != Sections.end(); SectionItr++)
{ {
const char * Section = SectionItr->c_str();
stdstr GoodName; stdstr GoodName;
if (!RomIniFile.GetString(Sections[i].c_str(),"Good Name","",GoodName)) if (!RomIniFile.GetString(Section,"Good Name","",GoodName))
{ {
continue; continue;
} }
std::vector<std::string> items; std::vector<std::string> items;
items.push_back(Sections[i]); items.push_back(Section);
if (PDNames.find(GoodName) == PDNames.end()) if (PDNames.find(GoodName) == PDNames.end())
{ {
strmap::_Pairib res = GoodNameSections.insert(strmap::value_type(GoodName,items)); strmap::_Pairib res = GoodNameSections.insert(strmap::value_type(GoodName,items));
if (!res.second) if (!res.second)
{ {
res.first->second.push_back(Sections[i]); res.first->second.push_back(Section);
} }
} else { } else {
strmap::_Pairib res = PDNameSections.insert(strmap::value_type(GoodName,items)); strmap::_Pairib res = PDNameSections.insert(strmap::value_type(GoodName,items));
if (!res.second) if (!res.second)
{ {
res.first->second.push_back(Sections[i]); res.first->second.push_back(Section);
} }
} }
} }
@ -273,12 +275,12 @@ int main (int argc, char *argv[])
for (size_t i = 0, n = itr->second.size(); i < n; i++) for (size_t i = 0, n = itr->second.size(); i < n; i++)
{ {
std::string & SectionName = itr->second[i]; std::string & SectionName = itr->second[i];
strlist KeyList; CIniFileBase::strlist KeyList;
RomIniFile.GetKeyList(SectionName.c_str(),KeyList); RomIniFile.GetKeyList(SectionName.c_str(),KeyList);
std::set<stdstr> SortedKeyList; std::set<stdstr> SortedKeyList;
for (strlist::iterator itr = KeyList.begin(); itr != KeyList.end(); itr++) for (CIniFileBase::strlist::iterator KeyListItr = KeyList.begin(); KeyListItr != KeyList.end(); KeyListItr++)
{ {
SortedKeyList.insert(*itr); SortedKeyList.insert(*KeyListItr);
} }
if (LastGoodName.length() == 0 || LastGoodName[0] != GoodName[0]) if (LastGoodName.length() == 0 || LastGoodName[0] != GoodName[0])
@ -297,29 +299,29 @@ int main (int argc, char *argv[])
} }
LastGoodName = GoodName; LastGoodName = GoodName;
fprintf(fp,"[%s]\n",SectionName.c_str()); fprintf(fp,"[%s]\n",SectionName.c_str());
for (strlist::iterator itr = NonSortedArray.begin(); itr != NonSortedArray.end(); itr++) for (strlist::iterator NonSortedItr = NonSortedArray.begin(); NonSortedItr != NonSortedArray.end(); NonSortedItr++)
{ {
std::set<stdstr>::iterator find_itr = SortedKeyList.find(itr->c_str()); std::set<stdstr>::iterator find_itr = SortedKeyList.find(NonSortedItr->c_str());
if (find_itr != SortedKeyList.end()) if (find_itr != SortedKeyList.end())
{ {
stdstr Value; stdstr Value;
if (RomIniFile.GetString(SectionName.c_str(),itr->c_str(),"",Value)) if (RomIniFile.GetString(SectionName.c_str(), NonSortedItr->c_str(),"",Value))
{ {
fprintf(fp,"%s=%s\n",itr->c_str(), Value.c_str()); fprintf(fp,"%s=%s\n", NonSortedItr->c_str(), Value.c_str());
} }
SortedKeyList.erase(find_itr); SortedKeyList.erase(find_itr);
} }
} }
for (std::set<stdstr>::iterator itr = SortedKeyList.begin(); itr != SortedKeyList.end(); itr++) for (std::set<stdstr>::iterator SortedKeyListItr = SortedKeyList.begin(); SortedKeyListItr != SortedKeyList.end(); SortedKeyListItr++)
{ {
stdstr Value; stdstr Value;
if (RomIniFile.GetString(SectionName.c_str(),itr->c_str(),"",Value)) if (RomIniFile.GetString(SectionName.c_str(), SortedKeyListItr->c_str(),"",Value))
{ {
fprintf(fp,"%s=%s\n",itr->c_str(), Value.c_str()); fprintf(fp,"%s=%s\n", SortedKeyListItr->c_str(), Value.c_str());
} }
} }
fprintf(fp,"\n",SectionName.c_str()); fprintf(fp,"\n");
} }
} }
@ -333,38 +335,38 @@ int main (int argc, char *argv[])
for (size_t i = 0, n = itr->second.size(); i < n; i++) for (size_t i = 0, n = itr->second.size(); i < n; i++)
{ {
std::string & SectionName = itr->second[i]; std::string & SectionName = itr->second[i];
strlist KeyList; CIniFileBase::strlist KeyList;
RomIniFile.GetKeyList(SectionName.c_str(),KeyList); RomIniFile.GetKeyList(SectionName.c_str(),KeyList);
std::set<stdstr> SortedKeyList; std::set<stdstr> SortedKeyList;
for (strlist::iterator itr = KeyList.begin(); itr != KeyList.end(); itr++) for (CIniFileBase::strlist::iterator KeyListItr = KeyList.begin(); KeyListItr != KeyList.end(); KeyListItr++)
{ {
SortedKeyList.insert(*itr); SortedKeyList.insert(*KeyListItr);
} }
fprintf(fp,"[%s]\n",SectionName.c_str()); fprintf(fp,"[%s]\n",SectionName.c_str());
for (strlist::iterator itr = NonSortedArray.begin(); itr != NonSortedArray.end(); itr++) for (strlist::iterator NonSortedItr = NonSortedArray.begin(); NonSortedItr != NonSortedArray.end(); NonSortedItr++)
{ {
std::set<stdstr>::iterator find_itr = SortedKeyList.find(itr->c_str()); std::set<stdstr>::iterator find_itr = SortedKeyList.find(NonSortedItr->c_str());
if (find_itr != SortedKeyList.end()) if (find_itr != SortedKeyList.end())
{ {
stdstr Value; stdstr Value;
if (RomIniFile.GetString(SectionName.c_str(),itr->c_str(),"",Value)) if (RomIniFile.GetString(SectionName.c_str(), NonSortedItr->c_str(),"",Value))
{ {
fprintf(fp,"%s=%s\n",itr->c_str(), Value.c_str()); fprintf(fp,"%s=%s\n", NonSortedItr->c_str(), Value.c_str());
} }
SortedKeyList.erase(find_itr); SortedKeyList.erase(find_itr);
} }
} }
for (std::set<stdstr>::iterator itr = SortedKeyList.begin(); itr != SortedKeyList.end(); itr++) for (std::set<stdstr>::iterator SortedKeyItr = SortedKeyList.begin(); SortedKeyItr != SortedKeyList.end(); SortedKeyItr++)
{ {
stdstr Value; stdstr Value;
if (RomIniFile.GetString(SectionName.c_str(),itr->c_str(),"",Value)) if (RomIniFile.GetString(SectionName.c_str(), SortedKeyItr->c_str(),"",Value))
{ {
fprintf(fp,"%s=%s\n",itr->c_str(), Value.c_str()); fprintf(fp,"%s=%s\n", SortedKeyItr->c_str(), Value.c_str());
} }
} }
fprintf(fp,"\n",SectionName.c_str()); fprintf(fp,"\n");
} }
} }
} }