Skip to content

Commit

Permalink
Update SortRdb code and add it to project
Browse files Browse the repository at this point in the history
  • Loading branch information
project64 committed Oct 24, 2022
1 parent 6c9237f commit edeaf14
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 64 deletions.
8 changes: 8 additions & 0 deletions Project64.sln
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "discord-rpc", "Source\3rdPa
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project64-input", "Source\Project64-input\Project64-input.vcxproj", "{D3F979CE-8FA7-48C9-A2B3-A33594B48536}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SortRdb", "Source\SortRdb\SortRdb.vcxproj", "{5788717F-E3D4-40CF-9637-3A2AEE85BB81}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -235,6 +237,12 @@ Global
{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.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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
42 changes: 7 additions & 35 deletions Source/SortRdb/SortRdb.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,17 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{5788717F-E3D4-40CF-9637-3A2AEE85BB81}</ProjectGuid>
<RootNamespace>SortRdb</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<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" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)PropertySheets\Platform.$(Configuration).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'">
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader />
</ClCompile>
Expand All @@ -65,7 +40,4 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
60 changes: 31 additions & 29 deletions Source/SortRdb/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <windows.h>
#include <common/IniFileClass.h>
#include <Common/IniFile.h>
#include <Common/StdString.h>
#include <set>

int main (int argc, char *argv[])
Expand Down Expand Up @@ -232,27 +233,28 @@ int main (int argc, char *argv[])
PDNames.insert("Yoshi's Story BootEmu (PD)");

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;
if (!RomIniFile.GetString(Sections[i].c_str(),"Good Name","",GoodName))
if (!RomIniFile.GetString(Section,"Good Name","",GoodName))
{
continue;
}
std::vector<std::string> items;
items.push_back(Sections[i]);
items.push_back(Section);
if (PDNames.find(GoodName) == PDNames.end())
{
strmap::_Pairib res = GoodNameSections.insert(strmap::value_type(GoodName,items));
if (!res.second)
{
res.first->second.push_back(Sections[i]);
res.first->second.push_back(Section);
}
} else {
strmap::_Pairib res = PDNameSections.insert(strmap::value_type(GoodName,items));
if (!res.second)
{
res.first->second.push_back(Sections[i]);
res.first->second.push_back(Section);
}
}
}
Expand All @@ -273,12 +275,12 @@ int main (int argc, char *argv[])
for (size_t i = 0, n = itr->second.size(); i < n; i++)
{
std::string & SectionName = itr->second[i];
strlist KeyList;
CIniFileBase::strlist KeyList;
RomIniFile.GetKeyList(SectionName.c_str(),KeyList);
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])
Expand All @@ -297,29 +299,29 @@ int main (int argc, char *argv[])
}
LastGoodName = GoodName;
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())
{
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);
}
}

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;
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");
}
}

Expand All @@ -333,38 +335,38 @@ int main (int argc, char *argv[])
for (size_t i = 0, n = itr->second.size(); i < n; i++)
{
std::string & SectionName = itr->second[i];
strlist KeyList;
CIniFileBase::strlist KeyList;
RomIniFile.GetKeyList(SectionName.c_str(),KeyList);
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());
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())
{
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);
}
}

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;
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");
}
}
}
Expand Down

0 comments on commit edeaf14

Please sign in to comment.