optimization

This commit is contained in:
BenCat07 2018-02-17 14:24:53 +01:00 committed by GitHub
parent d9c60ce057
commit 7377183f9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -692,7 +692,7 @@ bool DispatchUserMessage_hook(void *_this, int type, bf_read &buf)
message.push_back(c); message.push_back(c);
} }
} }
if (chat_filter_enabled) if (chat_filter_enabled && data[0] != LOCAL_E->m_IDX)
{ {
if (!strcmp(chat_filter.GetString(), "")) if (!strcmp(chat_filter.GetString(), ""))
{ {
@ -700,43 +700,49 @@ bool DispatchUserMessage_hook(void *_this, int type, bf_read &buf)
int iii = 0; int iii = 0;
player_info_s info; player_info_s info;
g_IEngine->GetPlayerInfo(LOCAL_E->m_IDX, &info); g_IEngine->GetPlayerInfo(LOCAL_E->m_IDX, &info);
std::string name2 = info.name; std::string name1 = info.name;
std::vector<std::string> name2{};
std::string claz = {}; std::string claz = {};
switch (g_pLocalPlayer->clazz) { switch (g_pLocalPlayer->clazz)
case tf_scout:
claz = "scout";
break;
case tf_soldier:
claz = "soldier";
break;
case tf_pyro:
claz = "pyro";
break;
case tf_demoman:
claz = "demo";
break;
case tf_engineer:
claz = "engi";
break;
case tf_heavy:
claz = "heavy";
break;
case tf_medic:
claz = "med";
break;
case tf_sniper:
claz = "sniper";
break;
case tf_spy:
claz = "spy";
break;
}
for (char i : name2)
{ {
if (iii == 3) case tf_scout:
claz = "scout";
break;
case tf_soldier:
claz = "soldier";
break;
case tf_pyro:
claz = "pyro";
break;
case tf_demoman:
claz = "demo";
break;
case tf_engineer:
claz = "engi";
break;
case tf_heavy:
claz = "heavy";
break;
case tf_medic:
claz = "med";
break;
case tf_sniper:
claz = "sniper";
break;
case tf_spy:
claz = "spy";
break;
default:
break;
}
for (char i : name1)
{
if (iii == 2)
{ {
iii++; iii = 0;
continue; tmp += i;
name2.push_back(tmp);
tmp = "";
} }
else if (iii < 2) else if (iii < 2)
{ {
@ -744,114 +750,63 @@ bool DispatchUserMessage_hook(void *_this, int type, bf_read &buf)
tmp += i; tmp += i;
} }
} }
i = 0; if (tmp.size() > 2)
name2 = tmp; name2.push_back(tmp);
std::vector<std::string> res = { "skid", "script", "cheat", "hak", "hac", "f1", "hax","vac", iii = 0;
"ban", "lmao", "bot", std::vector<std::string> res = { "skid", "script", "cheat",
"cat", "kick", name2, claz }; "hak", "hac", "f1", "hax",
std::string message2 = message; "vac", "ban", "lmao",
std::transform(message2.begin(), message2.end(), "bot", "report"
message2.begin(), ::tolower); "cat",
std::string temp; "kick", claz };
for (char i : message2) for (auto i : name2)
{ {
if (i == '4') boost::to_lower(i);
temp += "a"; res.push_back(i);
else if (i == '3')
temp += "e";
else if (i == '0')
temp += "o";
else if (i == '6')
temp += "g";
else if (i == '5')
temp += "s";
else if (i == '7')
temp += "t";
else
temp += i;
} }
message2 = temp; std::string message2 = message;
temp = ""; boost::to_lower(message2);
boost::replace_all(message2, "4", "a");
boost::replace_all(message2, "3", "e");
boost::replace_all(message2, "0", "o");
boost::replace_all(message2, "6", "g");
boost::replace_all(message2, "5", "s");
boost::replace_all(message2, "7", "t");
logging::Info("message2: %s", message2.c_str());
for (auto filter : res) for (auto filter : res)
{ {
if (boost::contains(message2,filter)) logging::Info("res: %s", filter.c_str());
if (boost::contains(message2, filter))
{ {
logging::Info("gay"); logging::Info("k");
std::string blanks(". " chat_stack::Say(". "
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n "); "\n ",
chat_stack::Say(blanks,
true); true);
} }
} }
} }
else else if (data[0] != LOCAL_E->m_IDX)
{ {
std::string input = chat_filter.GetString(); std::string input = chat_filter.GetString();
std::transform(input.begin(), input.end(), input.begin(), boost::to_lower(input);
::tolower); std::string message2 = message;
std::string message2;
std::vector<std::string> result{}; std::vector<std::string> result{};
std::string temp{};
int prevj = 0;
int previ;
boost::split(result, input, boost::is_any_of(",")); boost::split(result, input, boost::is_any_of(","));
for (int ii = 0; ii < result.size() - 1; i++) boost::replace_all(message2, "4", "a");
{ boost::replace_all(message2, "3", "e");
std::string i = result[ii]; boost::replace_all(message2, "0", "o");
for (int j = 0; j < i.size() - 1; j++) boost::replace_all(message2, "6", "g");
{ boost::replace_all(message2, "5", "s");
char c = i[j]; boost::replace_all(message2, "7", "t");
if (prevj < j)
{
prevj++;
result[i[j]] = temp;
temp = "";
}
if (c == '4')
temp += "a";
else if (c == '3')
temp += "e";
else if (c == '0')
temp += "o";
else if (c == '6')
temp += "g";
else if (c == '5')
temp += "s";
else if (c == '7')
temp += "t";
else
temp += c;
}
}
for (char i : message2)
{
if (i == '4')
temp += "a";
else if (i == '3')
temp += "e";
else if (i == '0')
temp += "o";
else if (i == '6')
temp += "g";
else if (i == '5')
temp += 's';
else if (i == '7')
temp += 't';
else
temp += i;
}
temp = "";
for (auto filter : result) for (auto filter : result)
{ {
if (boost::contains(message2, filter)) if (boost::contains(message2, filter))
{ {
std::string blanks( chat_stack::Say(
". \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "); ". \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ",
chat_stack::Say(blanks, true); true);
PrintChat("Cleared Chat");
} }
} }
} }