Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Notexe committed Mar 22, 2022
0 parents commit 51b0592
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 0 deletions.
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
HashStringListParser
Copyright (c) 2020+, REDACTED
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# HashListStringParser
## Usage
`HashListStringParser.exe hashlist_filename.txt`

This will create a `duplicates.txt` and `master_hash_to_string_list.txt` file.

`duplicates.txt` will contain something like this:
```
00B6993D9DBF2147.ALOC, has duplicate: 00B6993D9DBF2147.ALOC,[assembly:/_pro/environment/geometry/props/furniture/shelving_unit_wooden_modern_a.wl2?/wall_japanese_modern_a.prim].pc_coll
```

`master_hash_to_string_list.txt` will be a copy of the hash list with your newely merged hashes.
31 changes: 31 additions & 0 deletions hashstringlistparser.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hashstringlistparser", "hashstringlistparser\hashstringlistparser.vcxproj", "{245D1145-FD18-4B2A-B483-25B9D79B136D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{245D1145-FD18-4B2A-B483-25B9D79B136D}.Debug|x64.ActiveCfg = Debug|x64
{245D1145-FD18-4B2A-B483-25B9D79B136D}.Debug|x64.Build.0 = Debug|x64
{245D1145-FD18-4B2A-B483-25B9D79B136D}.Debug|x86.ActiveCfg = Debug|Win32
{245D1145-FD18-4B2A-B483-25B9D79B136D}.Debug|x86.Build.0 = Debug|Win32
{245D1145-FD18-4B2A-B483-25B9D79B136D}.Release|x64.ActiveCfg = Release|x64
{245D1145-FD18-4B2A-B483-25B9D79B136D}.Release|x64.Build.0 = Release|x64
{245D1145-FD18-4B2A-B483-25B9D79B136D}.Release|x86.ActiveCfg = Release|Win32
{245D1145-FD18-4B2A-B483-25B9D79B136D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C7D80F0C-E5FB-4443-828F-3210635A2B63}
EndGlobalSection
EndGlobal
144 changes: 144 additions & 0 deletions hashstringlistparser/hashstringlistparser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <stdint.h>
#include <vector>

std::string to_lower_case(std::string s)
{
for (uint64_t i = 0; i < s.length(); i++)
{
s[i] = std::tolower(s[i]);
}

return s;
}

int main(int argc, char* argv[])
{
std::ifstream hash_to_string_list_file = std::ifstream(argv[1], std::ifstream::binary);

if (!hash_to_string_list_file.good())
{
std::cout << "Error: " + std::string(argv[1]) + " could not be read." << std::endl;
}

hash_to_string_list_file.seekg(0, hash_to_string_list_file.end);

uint64_t file_size = hash_to_string_list_file.tellg();

hash_to_string_list_file.seekg(0, hash_to_string_list_file.beg);

std::ofstream duplicates_file = std::ofstream("duplicates.txt", std::ofstream::binary);

if (!duplicates_file.good())
{
std::cout << "Error: duplicates.txt could not be read." << std::endl;
}

std::map<uint64_t, uint64_t> hash_map;
std::vector<std::string> hash_map_strings;
std::vector<std::string> hash_strings;
std::vector<std::string> hash_resource_type_strings;

std::string line = "";

while (std::getline(hash_to_string_list_file, line))
{
if (line.length() > 4)
{
std::string hash_string = line.substr(0, 16);
std::string hash_resource_type = line.substr(17, 4);
std::string ioi_string = line.substr(22, line.length() - 22);

size_t pos = ioi_string.find_last_of('\r');

if (pos != std::string::npos)
{
ioi_string.erase(pos, 1);
}

bool legal_line = false;

std::string legal_chars = "0123456789ABCDEF";

bool is_a_hash = false;

if (hash_string.length() == 16)
{
is_a_hash = true;

for (int i = 0; i < 16; i++)
{
bool is_legal = false;

for (int j = 0; j < 16; j++)
{
if (hash_string[i] == legal_chars[j])
{
is_legal = true;
}
}

if (!is_legal)
{
is_a_hash = false;
}
}
}

if (is_a_hash)
{
legal_line = true;
}

if (legal_line)
{
ioi_string = to_lower_case(ioi_string);

uint64_t hash = std::strtoull(hash_string.c_str(), nullptr, 16);

std::map<uint64_t, uint64_t>::iterator it = hash_map.find(hash);

if (it != hash_map.end())
{
std::string duplicate = hash_string + "." + hash_resource_type + "," + ioi_string + " has duplicate: " + hash_string + "." + hash_resource_type + "," + hash_map_strings.at(it->second) + "\n";

//if (ioi_string != hash_map_strings.at(it->second))
duplicates_file.write(duplicate.c_str(), duplicate.length());
}
else
{
hash_strings.push_back(hash_string);

hash_map_strings.push_back(ioi_string);

hash_resource_type_strings.push_back(hash_resource_type);

hash_map[hash] = hash_map_strings.size() - 1;
}
}
else
{
std::cout << "Not a legal line: " << line << std::endl;
}
}
}

std::ofstream master_hash_to_string_list_file = std::ofstream("master_hash_to_string_list.txt", std::ofstream::binary);

if (!master_hash_to_string_list_file.good())
{
std::cout << "Error: master_hash_to_string_list.txt could not be read." << std::endl;
}

for (int i = 0; i < hash_strings.size(); i++)
{
std::string output = hash_strings.at(i) + "." + hash_resource_type_strings.at(i) + "," + hash_map_strings.at(i) + "\n";

master_hash_to_string_list_file.write(output.c_str(), output.length());
}

return 0;
}
147 changes: 147 additions & 0 deletions hashstringlistparser/hashstringlistparser.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?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>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{245d1145-fd18-4b2a-b483-25b9d79b136d}</ProjectGuid>
<RootNamespace>hashstringlistparser</RootNamespace>
<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>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</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)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="hashstringlistparser.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
22 changes: 22 additions & 0 deletions hashstringlistparser/hashstringlistparser.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="hashstringlistparser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

0 comments on commit 51b0592

Please sign in to comment.