prevent log spam

This commit is contained in:
dynamoNg 2024-08-01 15:18:42 +05:30
parent c27b150297
commit 6c40a08232

View File

@ -1,3 +1,4 @@
#include "core/data/bullet_impact_types.hpp"
#include "fiber_pool.hpp" #include "fiber_pool.hpp"
#include "gta/enums.hpp" #include "gta/enums.hpp"
#include "gta/net_game_event.hpp" #include "gta/net_game_event.hpp"
@ -7,7 +8,6 @@
#include "util/mobile.hpp" #include "util/mobile.hpp"
#include "util/notify.hpp" #include "util/notify.hpp"
#include "util/toxic.hpp" #include "util/toxic.hpp"
#include "core/data/bullet_impact_types.hpp"
#include <base/CObject.hpp> #include <base/CObject.hpp>
#include <network/CNetGamePlayer.hpp> #include <network/CNetGamePlayer.hpp>
@ -389,6 +389,13 @@ namespace big
// logs all type of explosion including owned one, fire, water hydrant etc, one without damage but camerashake, npcs shooting explosive ammo from planes from source client etc // logs all type of explosion including owned one, fire, water hydrant etc, one without damage but camerashake, npcs shooting explosive ammo from planes from source client etc
if (g.debug.logs.explosion_event && plyr) if (g.debug.logs.explosion_event && plyr)
{
static player_ptr last_exp_player = nullptr;
static eExplosionTag last_exp_type = eExplosionTag::DONTCARE;
std::chrono::system_clock::time_point last_exp_time{};
auto time_now = std::chrono::system_clock::now();
if (last_exp_player != plyr || last_exp_type != explosionType || (time_now - last_exp_time < 1s))
{ {
auto exp_type_itr = BULLET_IMPACTS.find(explosionType); auto exp_type_itr = BULLET_IMPACTS.find(explosionType);
LOGF(WARNING, LOGF(WARNING,
@ -398,6 +405,11 @@ namespace big
exp_type_itr != BULLET_IMPACTS.end() ? exp_type_itr->second : "?"); exp_type_itr != BULLET_IMPACTS.end() ? exp_type_itr->second : "?");
} }
last_exp_player = plyr;
last_exp_type = explosionType;
last_exp_time = time_now;
}
if (g.session.explosion_karma && g_local_player if (g.session.explosion_karma && g_local_player
&& math::distance_between_vectors({posX, posY, posZ}, *g_local_player->m_navigation->get_position()) < 3.0f) && math::distance_between_vectors({posX, posY, posZ}, *g_local_player->m_navigation->get_position()) < 3.0f)
{ {