Added filtering system to prepare_metric_for_sending. (#3139)

This commit is contained in:
gir489 2024-05-18 18:04:12 -04:00 committed by GitHub
parent 00f5c34e2a
commit 254f64f1af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 62 additions and 45 deletions

View File

@ -94,7 +94,7 @@ namespace big
{
struct logs
{
bool metric_logs{};
int metric_logs{};
int packet_logs{};
bool script_hook_logs{};
@ -170,7 +170,9 @@ namespace big
pair out_of_allowed_range_sync_type{};
pair invalid_sync{};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(notifications, gta_thread_kill, gta_thread_start, network_player_mgr_init, network_player_mgr_shutdown, player_join, player_leave, send_net_info_to_lobby, transaction_rate_limit, mismatch_sync_type, out_of_allowed_range_sync_type, invalid_sync)
bool warn_metric = false;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(notifications, gta_thread_kill, gta_thread_start, network_player_mgr_init, network_player_mgr_shutdown, player_join, player_leave, send_net_info_to_lobby, transaction_rate_limit, mismatch_sync_type, out_of_allowed_range_sync_type, invalid_sync, warn_metric)
} notifications{};
struct reactions

View File

@ -4,21 +4,18 @@
namespace big
{
const auto bad_metrics = std::unordered_set<std::string_view>({
const auto warn_bad_metrics = std::unordered_set<std::string_view>({
"REPORTER",
"REPORT_INVALIDMODEL",
"MEM_NEW",
"DEBUGGER_ATTACH",
"DIG",
"XP_LOSS",
"AWARD_XP",
"CF",
"CC",
"CNR",
"SCRIPT",
"CHEAT",
"AUX_DEUX",
"WEATHER",
"HARDWARE_OS",
"HARDWARE_GPU",
"HARDWARE_MOBO",
@ -27,26 +24,31 @@ namespace big
"PCSETTINGS",
"CASH_CREATED",
"DR_PS",
"UVC",
"W_L",
"ESVCS",
"IDLEKICK",
"GSCB",
"GSINV",
"GSCW",
"GSINT",
"EARN",
"GARAGE_TAMPER",
"DUPE_DETECT",
"LAST_VEH",
"FAIL_SERV",
"CCF_UPDATE",
"CODE_CRC",
"COLLECTIBLE",
"FIRST_VEH",
"MM",
"RDEV",
"RQA",
});
const auto filtered_bad_metrics = std::unordered_set<std::string_view>({
"DIG",
"AWARD_XP",
"WEATHER",
"UVC",
"W_L",
"ESVCS",
"EARN",
"COLLECTIBLE",
"FIRST_VEH",
"RANK_UP",
});
@ -87,11 +89,23 @@ namespace big
char metric_json_buffer [256] {};
rage::json_serializer yim_serializer(metric_json_buffer, sizeof(metric_json_buffer));
metric->serialize(&yim_serializer);
const bool is_bad_metric = bad_metrics.contains(metric->get_name());
auto metric_name = metric->get_name();
auto is_warn_bad_metrics = warn_bad_metrics.contains(metric_name);
auto is_filtered_bad_metrics = filtered_bad_metrics.contains(metric_name);
auto is_bad_metric = is_warn_bad_metrics || is_filtered_bad_metrics;
if (is_bad_metric)
{
LOG(WARNING) << "BAD METRIC: " << metric->get_name() << "; DATA: " << yim_serializer.get_string();
if(strcmp(metric->get_name(), "MM") == 0)
if (g.debug.logs.metric_logs || is_warn_bad_metrics)
{
LOG(WARNING) << "BAD METRIC: " << metric_name << "; DATA: " << yim_serializer.get_string();
}
if (g.notifications.warn_metric && is_warn_bad_metrics)
{
g_notification_service.push_warning("METRIC"_T.data(),
std::format("{} {}", "METRIC_WARNING_MESSAGE"_T, metric_name).c_str());
}
if (!strcmp(metric_name, "MM"))
{
std::string data = std::string(reinterpret_cast<char*>(metric) + 0x18);
char module_name[MAX_PATH];
@ -105,10 +119,9 @@ namespace big
}
return false;
}
if (!is_bad_metric && g.debug.logs.metric_logs)
else if (g.debug.logs.metric_logs == 1)
{
LOG(INFO) << "METRIC: " << metric->get_name() << "; DATA: " << yim_serializer.get_string();
LOG(INFO) << "METRIC: " << metric_name << "; DATA: " << yim_serializer.get_string();
}
return g_hooking->get_original<prepare_metric_for_sending>()(serializer, unk, time, metric);

View File

@ -8,8 +8,8 @@ namespace big
{
if (ImGui::BeginTabItem("DEBUG_TABS_LOGS"_T.data()))
{
ImGui::Checkbox("DEBUG_LOG_METRICS"_T.data(), &g.debug.logs.metric_logs);
static const char* options[]{"OFF"_T.data(), "ALL"_T.data(), "FILTERS"_T.data()};
ImGui::Combo("DEBUG_LOG_METRICS"_T.data(), (int*)&g.debug.logs.metric_logs, options, IM_ARRAYSIZE(options));
ImGui::Combo("VIEW_DEBUG_LOGS_LOG_PACKETS"_T.data(), (int*)&g.debug.logs.packet_logs, options, IM_ARRAYSIZE(options));
ImGui::Checkbox("DEBUG_LOG_NATIVE_SCRIPT_HOOKS"_T.data(), &g.debug.logs.script_hook_logs);

View File

@ -60,6 +60,8 @@ namespace big
ImGui::EndGroup();
ImGui::Checkbox("VIEW_GUI_FORMAT_MONEY"_T.data(), &g.window.gui.format_money);
ImGui::SameLine();
ImGui::Checkbox("METRIC_WARNING"_T.data(), &g.notifications.warn_metric);
if (g.window.ingame_overlay.show_indicators)
{