41 lines
1.0 KiB
C++
Raw Normal View History

2018-11-03 23:26:27 -04:00
#include "../extension.h"
void RemoveRepeatedChars(std::wstring& sentence)
{
2018-09-22 15:45:54 -04:00
int repeatNumber = 0;
wchar_t prevChar = sentence[0];
2018-10-30 21:21:21 -04:00
for (auto c : sentence)
if (c == prevChar) repeatNumber++;
else break;
if (repeatNumber == 1) return;
for (int i = 0; i < sentence.size(); i += repeatNumber)
for (int j = i; j < sentence.size(); ++j)
if (sentence[j] != sentence[i])
if ((j - i) % repeatNumber != 0) return;
else break;
2018-09-13 02:50:03 -04:00
std::wstring newSentence = L"";
for (int i = 0; i < sentence.size(); i += repeatNumber) newSentence.push_back(sentence[i]);
2018-09-13 02:50:03 -04:00
sentence = newSentence;
}
void RemoveCyclicRepeats(std::wstring& sentence)
{
2018-11-15 00:06:49 -05:00
remove:
2018-11-27 16:54:19 -05:00
for (std::wstring junk = sentence; junk.size() > 4; junk.pop_back())
2018-11-15 00:06:49 -05:00
if (sentence.rfind(junk) > 0)
{
sentence.erase(0, junk.size());
goto remove;
}
}
2018-09-22 15:08:31 -04:00
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
{
2018-09-22 15:08:31 -04:00
if (sentenceInfo["hook address"] == -1) return false;
RemoveRepeatedChars(sentence);
RemoveCyclicRepeats(sentence);
return true;
}