Skip to content

Instantly share code, notes, and snippets.

@womblee
Created January 15, 2024 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save womblee/11b38c9c349407cb04eaa9cf9ce6990b to your computer and use it in GitHub Desktop.
Save womblee/11b38c9c349407cb04eaa9cf9ce6990b to your computer and use it in GitHub Desktop.
Prototype of disabling everything that was installed ACTUALLY BY MY DL MOD DOWNLOADER
for (auto const& it : ini)
{
// mINI has everything in lowercase, first tried CustomPak, wasted my time...
if (it.first == "custompak")
{
//;[DONT_EDIT_THIS_LINE]satan_reborn.pak=1,colorful_night_stars.pak=1
// Prime example of what we will try to parse
// Create a file dummy
std::ifstream file(dide_direct);
// To indicate a success of finding what we need
bool success = false;
// Open
if (file.is_open())
{
std::string line;
// Find the start position of the relevant part
bool found = false;
while (std::getline(file, line))
{
size_t start_pos = line.find(";[DONT_TOUCH_THIS_LINE]");
if (start_pos != std::string::npos)
{
// Erase the prefix
line.erase(0, start_pos + strlen(";[DONT_TOUCH_THIS_LINE]"));
found = true;
break; // Stop reading after finding the section indicator
}
}
if (found)
{
std::vector<std::string> keys;
// Tokenize the remaining string using commas
std::istringstream token_s(line);
std::string token;
while (std::getline(token_s, token, ','))
{
// Extract the key (before the equals sign)
size_t equals = token.find('=');
if (equals != std::string::npos)
keys.push_back(token.substr(0, equals));
}
// Add the extracted keys
for (const auto& key : keys)
{
for (auto const& it2 : it.second)
{
if (it2.first.find(key) != std::string::npos)
ini[it.first][it2.first] = "0";
}
}
// Congrats
success = true;
}
}
// Close the file
file.close();
if (!success)
{
for (auto const& it2 : it.second)
ini[it.first][it2.first] = "0";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment